1 #ifndef PROTOZERO_PBF_BUILDER_HPP 2 #define PROTOZERO_PBF_BUILDER_HPP 19 #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");
59 #define PROTOZERO_WRITER_WRAP_ADD_SCALAR(name, type) \ 60 void add_##name(T tag, type value) { \ 61 pbf_writer::add_##name(pbf_tag_type(tag), value); \ 64 PROTOZERO_WRITER_WRAP_ADD_SCALAR(
bool,
bool)
65 PROTOZERO_WRITER_WRAP_ADD_SCALAR(
enum, int32_t)
66 PROTOZERO_WRITER_WRAP_ADD_SCALAR(int32, int32_t)
67 PROTOZERO_WRITER_WRAP_ADD_SCALAR(sint32, int32_t)
68 PROTOZERO_WRITER_WRAP_ADD_SCALAR(uint32, uint32_t)
69 PROTOZERO_WRITER_WRAP_ADD_SCALAR(int64, int64_t)
70 PROTOZERO_WRITER_WRAP_ADD_SCALAR(sint64, int64_t)
71 PROTOZERO_WRITER_WRAP_ADD_SCALAR(uint64, uint64_t)
72 PROTOZERO_WRITER_WRAP_ADD_SCALAR(fixed32, uint32_t)
73 PROTOZERO_WRITER_WRAP_ADD_SCALAR(sfixed32, int32_t)
74 PROTOZERO_WRITER_WRAP_ADD_SCALAR(fixed64, uint64_t)
75 PROTOZERO_WRITER_WRAP_ADD_SCALAR(sfixed64, int64_t)
76 PROTOZERO_WRITER_WRAP_ADD_SCALAR(
float,
float)
77 PROTOZERO_WRITER_WRAP_ADD_SCALAR(
double,
double)
79 #undef PROTOZERO_WRITER_WRAP_ADD_SCALAR 82 void add_bytes(T tag,
const char* value, std::size_t size) {
86 void add_bytes(T tag,
const std::string& value) {
90 void add_string(T tag,
const char* value, std::size_t size) {
94 void add_string(T tag,
const std::string& value) {
98 void add_string(T tag,
const char* value) {
102 void add_message(T tag,
const char* value, std::size_t size) {
106 void add_message(T tag,
const std::string& value) {
111 #define PROTOZERO_WRITER_WRAP_ADD_PACKED(name) \ 112 template <typename InputIterator> \ 113 void add_packed_##name(T tag, InputIterator first, InputIterator last) { \ 114 pbf_writer::add_packed_##name(pbf_tag_type(tag), first, last); \ 117 PROTOZERO_WRITER_WRAP_ADD_PACKED(
bool)
118 PROTOZERO_WRITER_WRAP_ADD_PACKED(
enum)
119 PROTOZERO_WRITER_WRAP_ADD_PACKED(int32)
120 PROTOZERO_WRITER_WRAP_ADD_PACKED(sint32)
121 PROTOZERO_WRITER_WRAP_ADD_PACKED(uint32)
122 PROTOZERO_WRITER_WRAP_ADD_PACKED(int64)
123 PROTOZERO_WRITER_WRAP_ADD_PACKED(sint64)
124 PROTOZERO_WRITER_WRAP_ADD_PACKED(uint64)
125 PROTOZERO_WRITER_WRAP_ADD_PACKED(fixed32)
126 PROTOZERO_WRITER_WRAP_ADD_PACKED(sfixed32)
127 PROTOZERO_WRITER_WRAP_ADD_PACKED(fixed64)
128 PROTOZERO_WRITER_WRAP_ADD_PACKED(sfixed64)
129 PROTOZERO_WRITER_WRAP_ADD_PACKED(
float)
130 PROTOZERO_WRITER_WRAP_ADD_PACKED(
double)
132 #undef PROTOZERO_WRITER_WRAP_ADD_PACKED 139 #endif // PROTOZERO_PBF_BUILDER_HPP void add_message(pbf_tag_type tag, const char *value, std::size_t size)
Definition: pbf_writer.hpp:559
void add_string(pbf_tag_type tag, const char *value, std::size_t size)
Definition: pbf_writer.hpp:517
Definition: pbf_writer.hpp:51
Contains the declaration of low-level types used in the pbf format.
Definition: pbf_builder.hpp:40
Contains the pbf_writer class.
pbf_writer() noexcept
Definition: pbf_writer.hpp:240
uint32_t pbf_tag_type
Definition: types.hpp:32
void add_bytes(pbf_tag_type tag, const char *value, std::size_t size)
Definition: pbf_writer.hpp:482
All parts of the protozero header-only library are in this namespace.
Definition: byteswap.hpp:24