| protozero 1.8.0
    Minimalistic protocol buffer decoder and encoder in C++. | 
#include <basic_pbf_writer.hpp>

| Public Member Functions | |
| 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 () | 
| Scalar field writer functions | |
| 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) | 
| Repeated packed field writer functions | |
| 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_writer is used to write PBF formatted messages into a buffer.
This uses TBuffer as the type for the underlaying buffer. In typical uses this is std::string, but you can use a different type that must support the right interface. Please see the documentation for details.
Almost all methods in this class can throw an std::bad_alloc exception if the underlying buffer class wants to resize.
| 
 | inlineexplicitnoexcept | 
Create a writer using the specified buffer as a data store. The basic_pbf_writer stores a pointer to that buffer and adds all data to it. The buffer doesn't have to be empty. The basic_pbf_writer will just append data.
| 
 | defaultnoexcept | 
Create a writer without a data store. In this form the writer can not be used!
| 
 | inline | 
Construct a basic_pbf_writer for a submessage from the basic_pbf_writer of the parent message.
| parent_writer | The basic_pbf_writer | 
| tag | Tag (field number) of the field that will be written | 
| size | Optional size of the submessage in bytes (use 0 for unknown). Setting this allows some optimizations but is only possible in a few very specific cases. | 
| 
 | inlinenoexcept | 
A basic_pbf_writer object can be moved. After this the other basic_pbf_writer will be invalid.
| 
 | inline | 
Add "bool" field to data.
| tag | Tag (field number) of the field | 
| value | Value to be written | 
| 
 | inline | 
Add "bytes" field to data. Bytes from the value are written until a null byte is encountered. The null byte is not added.
| tag | Tag (field number) of the field | 
| value | Pointer to zero-delimited value to be written | 
| 
 | inline | 
Add "bytes" field to data.
| tag | Tag (field number) of the field | 
| value | Pointer to value to be written | 
| size | Number of bytes to be written | 
| 
 | inline | 
Add "bytes" field to data.
| tag | Tag (field number) of the field | 
| value | Value to be written | 
| 
 | inline | 
Add "bytes" field to data.
| tag | Tag (field number) of the field | 
| value | Value to be written | 
| 
 | inline | 
Add "bytes" field to data using vectored input. All the data in the 2nd and further arguments is "concatenated" with only a single copy into the final buffer.
This will work with objects of any type supporting the data() and size() methods like std::string or protozero::data_view.
Example:
| Ts | List of types supporting data() and size() methods. | 
| tag | Tag (field number) of the field | 
| values | List of objects of types Ts with data to be appended. | 
| 
 | inline | 
Add "double" field to data.
| tag | Tag (field number) of the field | 
| value | Value to be written | 
| 
 | inline | 
Add "enum" field to data.
| tag | Tag (field number) of the field | 
| value | Value to be written | 
| 
 | inline | 
Add "fixed32" field to data.
| tag | Tag (field number) of the field | 
| value | Value to be written | 
| 
 | inline | 
Add "fixed64" field to data.
| tag | Tag (field number) of the field | 
| value | Value to be written | 
| 
 | inline | 
Add "float" field to data.
| tag | Tag (field number) of the field | 
| value | Value to be written | 
| 
 | inline | 
Add "int32" field to data.
| tag | Tag (field number) of the field | 
| value | Value to be written | 
| 
 | inline | 
Add "int64" field to data.
| tag | Tag (field number) of the field | 
| value | Value to be written | 
| 
 | inline | 
Add "message" field to data.
| tag | Tag (field number) of the field | 
| value | Pointer to message to be written | 
| size | Length of the message | 
| 
 | inline | 
Add "message" field to data.
| tag | Tag (field number) of the field | 
| value | Value to be written. The value must be a complete message. | 
| 
 | inline | 
Add "message" field to data.
| tag | Tag (field number) of the field | 
| value | Value to be written. The value must be a complete message. | 
| 
 | inline | 
Add "repeated packed bool" field to data.
| InputIterator | A type satisfying the InputIterator concept. Dereferencing the iterator must yield a type assignable to bool. | 
| tag | Tag (field number) of the field | 
| first | Iterator pointing to the beginning of the data | 
| last | Iterator pointing one past the end of data | 
| 
 | inline | 
Add "repeated packed double" field to data.
| InputIterator | A type satisfying the InputIterator concept. Dereferencing the iterator must yield a type assignable to double. | 
| tag | Tag (field number) of the field | 
| first | Iterator pointing to the beginning of the data | 
| last | Iterator pointing one past the end of data | 
| 
 | inline | 
Add "repeated packed enum" field to data.
| InputIterator | A type satisfying the InputIterator concept. Dereferencing the iterator must yield a type assignable to int32_t. | 
| tag | Tag (field number) of the field | 
| first | Iterator pointing to the beginning of the data | 
| last | Iterator pointing one past the end of data | 
| 
 | inline | 
Add a "repeated packed" fixed-size field to data. The following fixed-size fields are available:
uint32_t -> repeated packed fixed32 int32_t -> repeated packed sfixed32 uint64_t -> repeated packed fixed64 int64_t -> repeated packed sfixed64 double -> repeated packed double float -> repeated packed float
| ValueType | One of the following types: (u)int32/64_t, double, float. | 
| InputIterator | A type satisfying the InputIterator concept. | 
| tag | Tag (field number) of the field | 
| first | Iterator pointing to the beginning of the data | 
| last | Iterator pointing one past the end of data | 
| 
 | inline | 
Add "repeated packed fixed32" field to data.
| InputIterator | A type satisfying the InputIterator concept. Dereferencing the iterator must yield a type assignable to uint32_t. | 
| tag | Tag (field number) of the field | 
| first | Iterator pointing to the beginning of the data | 
| last | Iterator pointing one past the end of data | 
| 
 | inline | 
Add "repeated packed fixed64" field to data.
| InputIterator | A type satisfying the InputIterator concept. Dereferencing the iterator must yield a type assignable to uint64_t. | 
| tag | Tag (field number) of the field | 
| first | Iterator pointing to the beginning of the data | 
| last | Iterator pointing one past the end of data | 
| 
 | inline | 
Add "repeated packed float" field to data.
| InputIterator | A type satisfying the InputIterator concept. Dereferencing the iterator must yield a type assignable to float. | 
| tag | Tag (field number) of the field | 
| first | Iterator pointing to the beginning of the data | 
| last | Iterator pointing one past the end of data | 
| 
 | inline | 
Add "repeated packed int32" field to data.
| InputIterator | A type satisfying the InputIterator concept. Dereferencing the iterator must yield a type assignable to int32_t. | 
| tag | Tag (field number) of the field | 
| first | Iterator pointing to the beginning of the data | 
| last | Iterator pointing one past the end of data | 
| 
 | inline | 
Add "repeated packed int64" field to data.
| InputIterator | A type satisfying the InputIterator concept. Dereferencing the iterator must yield a type assignable to int64_t. | 
| tag | Tag (field number) of the field | 
| first | Iterator pointing to the beginning of the data | 
| last | Iterator pointing one past the end of data | 
| 
 | inline | 
Add "repeated packed sfixed32" field to data.
| InputIterator | A type satisfying the InputIterator concept. Dereferencing the iterator must yield a type assignable to int32_t. | 
| tag | Tag (field number) of the field | 
| first | Iterator pointing to the beginning of the data | 
| last | Iterator pointing one past the end of data | 
| 
 | inline | 
Add "repeated packed sfixed64" field to data.
| InputIterator | A type satisfying the InputIterator concept. Dereferencing the iterator must yield a type assignable to int64_t. | 
| tag | Tag (field number) of the field | 
| first | Iterator pointing to the beginning of the data | 
| last | Iterator pointing one past the end of data | 
| 
 | inline | 
Add "repeated packed sint32" field to data.
| InputIterator | A type satisfying the InputIterator concept. Dereferencing the iterator must yield a type assignable to int32_t. | 
| tag | Tag (field number) of the field | 
| first | Iterator pointing to the beginning of the data | 
| last | Iterator pointing one past the end of data | 
| 
 | inline | 
Add "repeated packed sint64" field to data.
| InputIterator | A type satisfying the InputIterator concept. Dereferencing the iterator must yield a type assignable to int64_t. | 
| tag | Tag (field number) of the field | 
| first | Iterator pointing to the beginning of the data | 
| last | Iterator pointing one past the end of data | 
| 
 | inline | 
Add "repeated packed uint32" field to data.
| InputIterator | A type satisfying the InputIterator concept. Dereferencing the iterator must yield a type assignable to uint32_t. | 
| tag | Tag (field number) of the field | 
| first | Iterator pointing to the beginning of the data | 
| last | Iterator pointing one past the end of data | 
| 
 | inline | 
Add "repeated packed uint64" field to data.
| InputIterator | A type satisfying the InputIterator concept. Dereferencing the iterator must yield a type assignable to uint64_t. | 
| tag | Tag (field number) of the field | 
| first | Iterator pointing to the beginning of the data | 
| last | Iterator pointing one past the end of data | 
| 
 | inline | 
Add "sfixed32" field to data.
| tag | Tag (field number) of the field | 
| value | Value to be written | 
| 
 | inline | 
Add "sfixed64" field to data.
| tag | Tag (field number) of the field | 
| value | Value to be written | 
| 
 | inline | 
Add "sint32" field to data.
| tag | Tag (field number) of the field | 
| value | Value to be written | 
| 
 | inline | 
Add "sint64" field to data.
| tag | Tag (field number) of the field | 
| value | Value to be written | 
| 
 | inline | 
Add "string" field to data. Bytes from the value are written until a null byte is encountered. The null byte is not added.
| tag | Tag (field number) of the field | 
| value | Pointer to value to be written | 
| 
 | inline | 
Add "string" field to data.
| tag | Tag (field number) of the field | 
| value | Pointer to value to be written | 
| size | Number of bytes to be written | 
| 
 | inline | 
Add "string" field to data.
| tag | Tag (field number) of the field | 
| value | Value to be written | 
| 
 | inline | 
Add "string" field to data.
| tag | Tag (field number) of the field | 
| value | Value to be written | 
| 
 | inline | 
Add "uint32" field to data.
| tag | Tag (field number) of the field | 
| value | Value to be written | 
| 
 | inline | 
Add "uint64" field to data.
| tag | Tag (field number) of the field | 
| value | Value to be written | 
| 
 | inline | 
Commit this submessage. This does the same as when the basic_pbf_writer goes out of scope and is destructed.
| 
 | inlinenoexcept | 
A basic_pbf_writer object can be moved. After this the other basic_pbf_writer will be invalid.
| 
 | inline | 
Reserve size bytes in the underlying message store in addition to whatever the message store already holds. So unlike the std::string::reserve() method this is not an absolute size, but additional memory that should be reserved.
| size | Number of bytes to reserve in underlying message store. | 
| 
 | inline | 
Cancel writing of this submessage. The complete submessage will be removed as if it was never created and no fields were added.
| 
 | inlinenoexcept | 
Swap the contents of this object with the other.
| other | Other object to swap data with. | 
| 
 | inlinenoexcept | 
Check if this writer is valid. A writer is invalid if it was default constructed, moved from, or if commit() has been called on it. Otherwise it is valid.