protozero
Minimalistic protocol buffer decoder and encoder in C++.
|
#include <pbf_builder.hpp>
Public Types | |
using | enum_type = T |
Public Member Functions | |
pbf_builder (std::string &data) noexcept | |
template<typename P > | |
pbf_builder (pbf_writer &parent_writer, P tag) noexcept | |
void | add_bytes (T tag, const char *value, std::size_t size) |
void | add_bytes (T tag, const std::string &value) |
void | add_string (T tag, const char *value, std::size_t size) |
void | add_string (T tag, const std::string &value) |
void | add_string (T tag, const char *value) |
void | add_message (T tag, const char *value, std::size_t size) |
void | add_message (T tag, const std::string &value) |
![]() | |
pbf_writer (std::string &data) noexcept | |
pbf_writer () noexcept | |
pbf_writer (pbf_writer &parent_writer, pbf_tag_type tag, std::size_t size=0) | |
pbf_writer (const pbf_writer &) noexcept=default | |
A pbf_writer object can be copied. | |
pbf_writer & | operator= (const pbf_writer &) noexcept=default |
A pbf_writer object can be copied. | |
pbf_writer (pbf_writer &&) noexcept=default | |
A pbf_writer object can be moved. | |
pbf_writer & | operator= (pbf_writer &&) noexcept=default |
A pbf_writer object can be moved. | |
void | swap (pbf_writer &other) noexcept |
void | reserve (std::size_t size) |
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_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 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 pbf_builder is used to write PBF formatted messages into a buffer. It is based on the 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 std::string used as a buffer wants to resize.
Read the tutorial to understand how this class is used.