1 #ifndef PROTOZERO_PBF_BUILDER_HPP 2 #define PROTOZERO_PBF_BUILDER_HPP 22 #include <type_traits> 42 static_assert(std::is_same<
pbf_tag_type,
typename std::underlying_type<T>::type>::value,
43 "T must be enum with underlying type protozero::pbf_tag_type");
74 #define PROTOZERO_WRITER_WRAP_ADD_SCALAR(name, type) \ 75 void add_##name(T tag, type value) { \ 76 pbf_writer::add_##name(pbf_tag_type(tag), value); \ 79 PROTOZERO_WRITER_WRAP_ADD_SCALAR(
bool,
bool)
80 PROTOZERO_WRITER_WRAP_ADD_SCALAR(
enum, int32_t)
81 PROTOZERO_WRITER_WRAP_ADD_SCALAR(int32, int32_t)
82 PROTOZERO_WRITER_WRAP_ADD_SCALAR(sint32, int32_t)
83 PROTOZERO_WRITER_WRAP_ADD_SCALAR(uint32, uint32_t)
84 PROTOZERO_WRITER_WRAP_ADD_SCALAR(int64, int64_t)
85 PROTOZERO_WRITER_WRAP_ADD_SCALAR(sint64, int64_t)
86 PROTOZERO_WRITER_WRAP_ADD_SCALAR(uint64, uint64_t)
87 PROTOZERO_WRITER_WRAP_ADD_SCALAR(fixed32, uint32_t)
88 PROTOZERO_WRITER_WRAP_ADD_SCALAR(sfixed32, int32_t)
89 PROTOZERO_WRITER_WRAP_ADD_SCALAR(fixed64, uint64_t)
90 PROTOZERO_WRITER_WRAP_ADD_SCALAR(sfixed64, int64_t)
91 PROTOZERO_WRITER_WRAP_ADD_SCALAR(
float,
float)
92 PROTOZERO_WRITER_WRAP_ADD_SCALAR(
double,
double)
94 #undef PROTOZERO_WRITER_WRAP_ADD_SCALAR 104 void add_bytes(T tag,
const char* value, std::size_t size) {
158 template <
typename... Ts>
170 void add_string(T tag,
const char* value, std::size_t size) {
237 #define PROTOZERO_WRITER_WRAP_ADD_PACKED(name) \ 238 template <typename InputIterator> \ 239 void add_packed_##name(T tag, InputIterator first, InputIterator last) { \ 240 pbf_writer::add_packed_##name(pbf_tag_type(tag), first, last); \ 243 PROTOZERO_WRITER_WRAP_ADD_PACKED(
bool)
244 PROTOZERO_WRITER_WRAP_ADD_PACKED(
enum)
245 PROTOZERO_WRITER_WRAP_ADD_PACKED(int32)
246 PROTOZERO_WRITER_WRAP_ADD_PACKED(sint32)
247 PROTOZERO_WRITER_WRAP_ADD_PACKED(uint32)
248 PROTOZERO_WRITER_WRAP_ADD_PACKED(int64)
249 PROTOZERO_WRITER_WRAP_ADD_PACKED(sint64)
250 PROTOZERO_WRITER_WRAP_ADD_PACKED(uint64)
251 PROTOZERO_WRITER_WRAP_ADD_PACKED(fixed32)
252 PROTOZERO_WRITER_WRAP_ADD_PACKED(sfixed32)
253 PROTOZERO_WRITER_WRAP_ADD_PACKED(fixed64)
254 PROTOZERO_WRITER_WRAP_ADD_PACKED(sfixed64)
255 PROTOZERO_WRITER_WRAP_ADD_PACKED(
float)
256 PROTOZERO_WRITER_WRAP_ADD_PACKED(
double)
258 #undef PROTOZERO_WRITER_WRAP_ADD_PACKED 265 #endif // PROTOZERO_PBF_BUILDER_HPP void add_bytes(T tag, const char *value, std::size_t size)
Definition: pbf_builder.hpp:104
void add_message(pbf_tag_type tag, const char *value, std::size_t size)
Definition: pbf_writer.hpp:645
void add_string(pbf_tag_type tag, const char *value, std::size_t size)
Definition: pbf_writer.hpp:603
void add_message(T tag, const data_view &value)
Definition: pbf_builder.hpp:222
Definition: pbf_writer.hpp:53
Contains the declaration of low-level types used in the pbf format.
pbf_builder(std::string &data) noexcept
Definition: pbf_builder.hpp:57
void add_string(T tag, const char *value)
Definition: pbf_builder.hpp:201
void add_string(T tag, const data_view &value)
Definition: pbf_builder.hpp:180
void add_bytes_vectored(T tag, Ts &&... values)
Definition: pbf_builder.hpp:159
T enum_type
The type of messages this class will build.
Definition: pbf_builder.hpp:48
void add_message(T tag, const std::string &value)
Definition: pbf_builder.hpp:232
void add_bytes(T tag, const std::string &value)
Definition: pbf_builder.hpp:124
Definition: pbf_builder.hpp:40
Contains the pbf_writer class.
void add_bytes_vectored(pbf_tag_type tag, Ts &&... values)
Definition: pbf_writer.hpp:585
void add_message(T tag, const char *value, std::size_t size)
Definition: pbf_builder.hpp:212
void add_string(T tag, const char *value, std::size_t size)
Definition: pbf_builder.hpp:170
uint32_t pbf_tag_type
Definition: types.hpp:33
Definition: data_view.hpp:39
void add_string(T tag, const std::string &value)
Definition: pbf_builder.hpp:190
void add_bytes(T tag, const char *value)
Definition: pbf_builder.hpp:135
void add_bytes(T tag, const data_view &value)
Definition: pbf_builder.hpp:114
pbf_builder(pbf_writer &parent_writer, P tag) noexcept
Definition: pbf_builder.hpp:69
void add_bytes(pbf_tag_type tag, const char *value, std::size_t size)
Definition: pbf_writer.hpp:526
All parts of the protozero header-only library are in this namespace.
Definition: byteswap.hpp:23
pbf_writer() noexcept=default