class ProtoDecoder

Defined at line 48 of file ../../third_party/perfetto/include/perfetto/protozero/proto_decoder.h

A generic protobuf decoder. Doesn't require any knowledge about the proto

schema. It tokenizes fields, retrieves their ID and type and exposes

accessors to retrieve its values.

It does NOT recurse in nested submessages, instead it just computes their

boundaries, recursion is left to the caller.

This class is designed to be used in perf-sensitive contexts. It does not

allocate and does not perform any proto semantic checks (e.g. repeated /

required / optional). It's supposedly safe wrt out-of-bounds memory accesses

(see proto_decoder_fuzzer.cc).

This class serves also as a building block for TypedProtoDecoder, used when

the schema is known at compile time.

Protected Members

const uint8_t *const begin_
const uint8_t *const end_
const uint8_t * read_ptr_

Public Methods

void ProtoDecoder (const void * buffer, size_t length)

Creates a ProtoDecoder using the given |buffer| with size |length| bytes.

Defined at line 51 of file ../../third_party/perfetto/include/perfetto/protozero/proto_decoder.h

void ProtoDecoder (const std::string & str)

Defined at line 55 of file ../../third_party/perfetto/include/perfetto/protozero/proto_decoder.h

void ProtoDecoder (const ConstBytes & cb)

Defined at line 56 of file ../../third_party/perfetto/include/perfetto/protozero/proto_decoder.h

Field ReadField ()

Reads the next field from the buffer and advances the read cursor. If a

full field cannot be read, the returned Field will be invalid (i.e.

field.valid() == false).

Field FindField (uint32_t field_id)

Finds the first field with the given id. Doesn't affect the read cursor.

void Reset ()

Resets the read cursor to the start of the buffer.

Defined at line 67 of file ../../third_party/perfetto/include/perfetto/protozero/proto_decoder.h

void Reset (const uint8_t * pos)

Resets the read cursor to the given position (must be within the buffer).

Defined at line 70 of file ../../third_party/perfetto/include/perfetto/protozero/proto_decoder.h

size_t read_offset ()

Returns the position of read cursor, relative to the start of the buffer.

Defined at line 76 of file ../../third_party/perfetto/include/perfetto/protozero/proto_decoder.h

size_t bytes_left ()

Defined at line 78 of file ../../third_party/perfetto/include/perfetto/protozero/proto_decoder.h

const uint8_t * begin ()

Defined at line 83 of file ../../third_party/perfetto/include/perfetto/protozero/proto_decoder.h

const uint8_t * end ()

Defined at line 84 of file ../../third_party/perfetto/include/perfetto/protozero/proto_decoder.h