class TypedProtoDecoderBase
Defined at line 332 of file ../../third_party/perfetto/include/perfetto/protozero/proto_decoder.h
This decoder loads all fields upfront, without recursing in nested messages.
It is used as a base class for typed decoders generated by the pbzero plugin.
The split between TypedProtoDecoderBase and TypedProtoDecoder
<
> is to have
unique definition of functions like ParseAllFields() and ExpandHeapStorage().
The storage (either on-stack or on-heap) for this class is organized as
follows:
|-------------------------- fields_ ----------------------|
[ field 0 (invalid) ] [ fields 1 .. N ] [ repeated fields ]
^ ^
num_fields_ size_
Note that if a message has high field numbers, upon creation |size_| can be
<
|num_fields_| (until a heap expansion is hit while inserting).
Protected Members
unique_ptr heap_storage_
Field * fields_
uint32_t num_fields_
uint32_t size_
uint32_t capacity_
Public Methods
const Field & Get (uint32_t id)
If the field |id| is known at compile time, prefer the templated
specialization at
<kFieldNumber
>().
Defined at line 336 of file ../../third_party/perfetto/include/perfetto/protozero/proto_decoder.h
template <typename T>
RepeatedFieldIterator<T> GetRepeated (uint32_t field_id)
Returns an object that allows to iterate over all instances of a repeated
field given its id. Example usage:
for (auto it = decoder.GetRepeated
<int32
_t>(N); it; ++it) { ... }
Defined at line 351 of file ../../third_party/perfetto/include/perfetto/protozero/proto_decoder.h
template <proto_utils::ProtoWireType wire_type, typename cpp_type>
PackedRepeatedFieldIterator<wire_type, cpp_type> GetPackedRepeated (uint32_t field_id, bool * parse_error_location)
Returns an objects that allows to iterate over all entries of a packed
repeated field given its id and type. The |wire_type| is necessary for
decoding the packed field, the |cpp_type| is for convenience
&
stronger
typing.
The caller must also supply a pointer to a bool that is set to true if the
packed buffer is found to be malformed while iterating (so you need to
exhaust the iterator if you want to check the full extent of the buffer).
Note that unlike standard protobuf parsers, protozero does not allow
treating of packed repeated fields as non-packed and vice-versa (therefore
not making the packed option forwards and backwards compatible). So
the caller needs to use the right accessor for correct results.
Defined at line 389 of file ../../third_party/perfetto/include/perfetto/protozero/proto_decoder.h
template <proto_utils::ProtoWireType wire_type, typename cpp_type>
UnifiedRepeatedFieldIterator<wire_type, cpp_type> GetUnifiedRepeated (uint32_t field_id, bool * parse_error_location)
Returns a unified iterator that automatically dispatches between packed and
non-packed repeated field iteration based on the wire format. This allows
parsers to handle both formats without knowing ahead of time which one is
used.
Example usage:
bool parse_error = false;
for (auto it = decoder.GetUnifiedRepeated
<wire
_type, int32_t>(N,
&parse
_error);
it; ++it) { ... }
Defined at line 413 of file ../../third_party/perfetto/include/perfetto/protozero/proto_decoder.h
Protected Methods
void ParseAllFields ()
void ExpandHeapStorage ()
Called when the default on-stack storage is exhausted and new repeated
fields need to be pushed.
void TypedProtoDecoderBase (Field * storage, uint32_t num_fields, uint32_t capacity, const uint8_t * buffer, size_t length)
Defined at line 429 of file ../../third_party/perfetto/include/perfetto/protozero/proto_decoder.h