protozero
1.7.0
Minimalistic protocol buffer decoder and encoder in C++.
|
#include <basic_pbf_builder.hpp>
Public Types | |
using | enum_type = T |
The type of messages this class will build. | |
Public Member Functions | |
basic_pbf_builder (TBuffer &data) noexcept | |
![]() | |
basic_pbf_writer (TBuffer &buffer) noexcept | |
basic_pbf_writer () noexcept=default | |
basic_pbf_writer (basic_pbf_writer &parent_writer, pbf_tag_type tag, std::size_t size=0) | |
basic_pbf_writer (const basic_pbf_writer &)=delete | |
A basic_pbf_writer object can not be copied. | |
basic_pbf_writer & | operator= (const basic_pbf_writer &)=delete |
A basic_pbf_writer object can not be copied. | |
basic_pbf_writer (basic_pbf_writer &&other) noexcept | |
basic_pbf_writer & | operator= (basic_pbf_writer &&other) noexcept |
bool | valid () const noexcept |
void | swap (basic_pbf_writer &other) noexcept |
void | reserve (std::size_t size) |
void | commit () |
void | rollback () |
void | add_bool (pbf_tag_type tag, bool value) |
void | add_enum (pbf_tag_type tag, int32_t value) |
void | add_int32 (pbf_tag_type tag, int32_t value) |
void | add_sint32 (pbf_tag_type tag, int32_t value) |
void | add_uint32 (pbf_tag_type tag, uint32_t value) |
void | add_int64 (pbf_tag_type tag, int64_t value) |
void | add_sint64 (pbf_tag_type tag, int64_t value) |
void | add_uint64 (pbf_tag_type tag, uint64_t value) |
void | add_fixed32 (pbf_tag_type tag, uint32_t value) |
void | add_sfixed32 (pbf_tag_type tag, int32_t value) |
void | add_fixed64 (pbf_tag_type tag, uint64_t value) |
void | add_sfixed64 (pbf_tag_type tag, int64_t value) |
void | add_float (pbf_tag_type tag, float value) |
void | add_double (pbf_tag_type tag, double value) |
void | add_bytes (pbf_tag_type tag, const char *value, std::size_t size) |
void | add_bytes (pbf_tag_type tag, const data_view &value) |
void | add_bytes (pbf_tag_type tag, const std::string &value) |
void | add_bytes (pbf_tag_type tag, const char *value) |
template<typename... Ts> | |
void | add_bytes_vectored (pbf_tag_type tag, Ts &&...values) |
void | add_string (pbf_tag_type tag, const char *value, std::size_t size) |
void | add_string (pbf_tag_type tag, const data_view &value) |
void | add_string (pbf_tag_type tag, const std::string &value) |
void | add_string (pbf_tag_type tag, const char *value) |
void | add_message (pbf_tag_type tag, const char *value, std::size_t size) |
void | add_message (pbf_tag_type tag, const data_view &value) |
void | add_message (pbf_tag_type tag, const std::string &value) |
template<typename InputIterator > | |
void | add_packed_bool (pbf_tag_type tag, InputIterator first, InputIterator last) |
template<typename InputIterator > | |
void | add_packed_enum (pbf_tag_type tag, InputIterator first, InputIterator last) |
template<typename InputIterator > | |
void | add_packed_int32 (pbf_tag_type tag, InputIterator first, InputIterator last) |
template<typename InputIterator > | |
void | add_packed_sint32 (pbf_tag_type tag, InputIterator first, InputIterator last) |
template<typename InputIterator > | |
void | add_packed_uint32 (pbf_tag_type tag, InputIterator first, InputIterator last) |
template<typename InputIterator > | |
void | add_packed_int64 (pbf_tag_type tag, InputIterator first, InputIterator last) |
template<typename InputIterator > | |
void | add_packed_sint64 (pbf_tag_type tag, InputIterator first, InputIterator last) |
template<typename InputIterator > | |
void | add_packed_uint64 (pbf_tag_type tag, InputIterator first, InputIterator last) |
template<typename ValueType , typename InputIterator > | |
void | add_packed_fixed (pbf_tag_type tag, InputIterator first, InputIterator last) |
template<typename InputIterator > | |
void | add_packed_fixed32 (pbf_tag_type tag, InputIterator first, InputIterator last) |
template<typename InputIterator > | |
void | add_packed_sfixed32 (pbf_tag_type tag, InputIterator first, InputIterator last) |
template<typename InputIterator > | |
void | add_packed_fixed64 (pbf_tag_type tag, InputIterator first, InputIterator last) |
template<typename InputIterator > | |
void | add_packed_sfixed64 (pbf_tag_type tag, InputIterator first, InputIterator last) |
template<typename InputIterator > | |
void | add_packed_float (pbf_tag_type tag, InputIterator first, InputIterator last) |
template<typename InputIterator > | |
void | add_packed_double (pbf_tag_type tag, InputIterator first, InputIterator last) |
The basic_pbf_builder is used to write PBF formatted messages into a buffer. It is based on the basic_pbf_writer class and has all the same methods. The difference is that while the pbf_writer class takes an integer tag, this template class takes a tag of the template type T. The idea is that T will be an enumeration value and this helps reduce the possibility of programming errors.
Almost all methods in this class can throw an std::bad_alloc exception if the underlying buffer class wants to resize.
Read the tutorial to understand how this class is used. In most cases you want to use the pbf_builder class which uses a std::string as buffer type.
|
inlineexplicitnoexcept |
Create a builder using the given string as a data store. The object stores a reference to that string and adds all data to it. The string doesn't have to be empty. The pbf_message object will just append data.