protozero 1.7.1
Minimalistic protocol buffer decoder and encoder in C++.
|
#include <pbf_message.hpp>
Public Types | |
using | enum_type = T |
The type of messages this class will read. | |
![]() | |
using | const_bool_iterator = const_varint_iterator< int32_t > |
Forward iterator for iterating over bool (int32 varint) values. | |
using | const_enum_iterator = const_varint_iterator< int32_t > |
Forward iterator for iterating over enum (int32 varint) values. | |
using | const_int32_iterator = const_varint_iterator< int32_t > |
Forward iterator for iterating over int32 (varint) values. | |
using | const_sint32_iterator = const_svarint_iterator< int32_t > |
Forward iterator for iterating over sint32 (varint) values. | |
using | const_uint32_iterator = const_varint_iterator< uint32_t > |
Forward iterator for iterating over uint32 (varint) values. | |
using | const_int64_iterator = const_varint_iterator< int64_t > |
Forward iterator for iterating over int64 (varint) values. | |
using | const_sint64_iterator = const_svarint_iterator< int64_t > |
Forward iterator for iterating over sint64 (varint) values. | |
using | const_uint64_iterator = const_varint_iterator< uint64_t > |
Forward iterator for iterating over uint64 (varint) values. | |
using | const_fixed32_iterator = const_fixed_iterator< uint32_t > |
Forward iterator for iterating over fixed32 values. | |
using | const_sfixed32_iterator = const_fixed_iterator< int32_t > |
Forward iterator for iterating over sfixed32 values. | |
using | const_fixed64_iterator = const_fixed_iterator< uint64_t > |
Forward iterator for iterating over fixed64 values. | |
using | const_sfixed64_iterator = const_fixed_iterator< int64_t > |
Forward iterator for iterating over sfixed64 values. | |
using | const_float_iterator = const_fixed_iterator< float > |
Forward iterator for iterating over float values. | |
using | const_double_iterator = const_fixed_iterator< double > |
Forward iterator for iterating over double values. | |
This class represents a protobuf message. Either a top-level message or a nested sub-message. Top-level messages can be created from any buffer with a pointer and length:
Sub-messages are created using get_message():
All methods of the pbf_message class except get_bytes() and get_string() provide the strong exception guarantee, ie they either succeed or do not change the pbf_message object they are called on. Use the get_data() method instead of get_bytes() or get_string(), if you need this guarantee.
This template class is based on the pbf_reader class and has all the same methods. The difference is that whereever the pbf_reader class takes an integer tag, this template class takes a tag of the template type T.
Read the tutorial to understand how this class is used.
|
inlinenoexcept |
Construct a pbf_message. All arguments are forwarded to the pbf_reader parent class.
|
inline |
Set next field in the message as the current field. This is usually called in a while loop:
true
if there is a next field, false
if not. true
there is a current field now.
|
inline |
Set next field with given tag in the message as the current field. Fields with other tags are skipped. This is usually called in a while loop for repeated fields:
or you can call it just once to get the one field with this tag:
Note that this will not check the wire type. The two-argument version of this function will also check the wire type.
true
if there is a next field with this tag. true
there is a current field now with the given tag.
|
inline |
Set next field with given tag and wire type in the message as the current field. Fields with other tags are skipped. This is usually called in a while loop for repeated fields:
or you can call it just once to get the one field with this tag:
Note that this will also check the wire type. The one-argument version of this function will not check the wire type.
true
if there is a next field with this tag. true
there is a current field now with the given tag.
|
inlinenoexcept |