class EpsCopyInputStream

Defined at line 96 of file ../../third_party/protobuf/src/google/protobuf/parse_context.h

The basic abstraction the parser is designed for is a slight modification

of the ZeroCopyInputStream (ZCIS) abstraction. A ZCIS presents a serialized

stream as a series of buffers that concatenate to the full stream.

Pictorially a ZCIS presents a stream in chunks like so

[---------------------------------------------------------------]

[---------------------] chunk 1

[----------------------------] chunk 2

chunk 3 [--------------]

Where the '-' represent the bytes which are vertically lined up with the

bytes of the stream. The proto parser requires its input to be presented

similarly with the extra

property that each chunk has kSlopBytes past its end that overlaps with the

first kSlopBytes of the next chunk, or if there is no next chunk at least its

still valid to read those bytes. Again, pictorially, we now have

[---------------------------------------------------------------]

[-------------------....] chunk 1

[------------------------....] chunk 2

chunk 3 [------------------..**]

chunk 4 [--****]

Here '-' mean the bytes of the stream or chunk and '.' means bytes past the

chunk that match up with the start of the next chunk. Above each chunk has

4 '.' after the chunk. In the case these 'overflow' bytes represents bytes

past the stream, indicated by '*' above, their values are unspecified. It is

still legal to read them (ie. should not segfault). Reading past the

end should be detected by the user and indicated as an error.

The reason for this, admittedly, unconventional invariant is to ruthlessly

optimize the protobuf parser. Having an overlap helps in two important ways.

Firstly it alleviates having to performing bounds checks if a piece of code

is guaranteed to not read more than kSlopBytes. Secondly, and more

importantly, the protobuf wireformat is such that reading a key/value pair is

always less than 16 bytes. This removes the need to change to next buffer in

the middle of reading primitive values. Hence there is no need to store and

load the current position.

Public Methods

void EpsCopyInputStream (bool enable_aliasing)

Defined at line 99 of file ../../third_party/protobuf/src/google/protobuf/parse_context.h

void BackUp (const char * ptr)

Defined at line 102 of file ../../third_party/protobuf/src/google/protobuf/parse_context.h

LimitToken PushLimit (const char * ptr, int limit)

If return value is negative it's an error

Defined at line 150 of file ../../third_party/protobuf/src/google/protobuf/parse_context.h

bool PopLimit (LimitToken delta)

Defined at line 161 of file ../../third_party/protobuf/src/google/protobuf/parse_context.h

const char * Skip (const char * ptr, int size)

Defined at line 172 of file ../../third_party/protobuf/src/google/protobuf/parse_context.h

const char * ReadString (const char * ptr, int size, std::string * s)

Defined at line 178 of file ../../third_party/protobuf/src/google/protobuf/parse_context.h

const char * AppendString (const char * ptr, int size, std::string * s)

Defined at line 192 of file ../../third_party/protobuf/src/google/protobuf/parse_context.h

const char * ReadCord (const char * ptr, int size, ::absl::Cord * cord)

Defined at line 205 of file ../../third_party/protobuf/src/google/protobuf/parse_context.h

template <typename Add>
const char * ReadPackedVarint (const char * ptr, Add add)

Defined at line 225 of file ../../third_party/protobuf/src/google/protobuf/parse_context.h

uint32_t LastTag ()

Defined at line 232 of file ../../third_party/protobuf/src/google/protobuf/parse_context.h

bool ConsumeEndGroup (uint32_t start_tag)

Defined at line 233 of file ../../third_party/protobuf/src/google/protobuf/parse_context.h

bool EndedAtLimit ()

Defined at line 238 of file ../../third_party/protobuf/src/google/protobuf/parse_context.h

bool EndedAtEndOfStream ()

Defined at line 239 of file ../../third_party/protobuf/src/google/protobuf/parse_context.h

const char * ReadArenaString (const char * ptr, ArenaStringPtr * s, Arena * arena)

Implemented in arenastring.cc

void SetLastTag (uint32_t tag)

Defined at line 240 of file ../../third_party/protobuf/src/google/protobuf/parse_context.h

void SetEndOfStream ()

Defined at line 241 of file ../../third_party/protobuf/src/google/protobuf/parse_context.h

bool IsExceedingLimit (const char * ptr)

Defined at line 242 of file ../../third_party/protobuf/src/google/protobuf/parse_context.h

bool AliasingEnabled ()

Defined at line 246 of file ../../third_party/protobuf/src/google/protobuf/parse_context.h

int BytesUntilLimit (const char * ptr)

Defined at line 247 of file ../../third_party/protobuf/src/google/protobuf/parse_context.h

int MaximumReadSize (const char * ptr)

Maximum number of sequential bytes that can be read starting from `ptr`.

Defined at line 251 of file ../../third_party/protobuf/src/google/protobuf/parse_context.h

bool DataAvailable (const char * ptr)

Returns true if more data is available, if false is returned one has to

call Done for further checks.

Defined at line 256 of file ../../third_party/protobuf/src/google/protobuf/parse_context.h

template <typename Tag, typename T>
const char * ReadRepeatedFixed (const char * ptr, Tag expected_tag, RepeatedField<T> * out)

Defined at line 1136 of file ../../third_party/protobuf/src/google/protobuf/parse_context.h

template <typename T>
const char * ReadPackedFixed (const char * ptr, int size, RepeatedField<T> * out)

Defined at line 1160 of file ../../third_party/protobuf/src/google/protobuf/parse_context.h

template <typename Add, typename SizeCb>
const char * ReadPackedVarint (const char * ptr, Add add, SizeCb size_callback)

Defined at line 1212 of file ../../third_party/protobuf/src/google/protobuf/parse_context.h

Protected Methods

bool DoneWithCheck (const char ** ptr, int d)

Returns true if limit (either an explicit limit or end of stream) is

reached. It aligns *ptr across buffer seams.

If limit is exceeded, it returns true and ptr is set to null.

Defined at line 262 of file ../../third_party/protobuf/src/google/protobuf/parse_context.h

const char * InitFrom (absl::string_view flat)

Defined at line 279 of file ../../third_party/protobuf/src/google/protobuf/parse_context.h

const char * InitFrom (io::ZeroCopyInputStream * zcis)
const char * InitFrom (io::ZeroCopyInputStream * zcis, int limit)

Defined at line 304 of file ../../third_party/protobuf/src/google/protobuf/parse_context.h

Enumerations

enum 
Name Value
kMaxCordBytesToCopy 512

Defined at line 98 of file ../../third_party/protobuf/src/google/protobuf/parse_context.h

Records

Friends

pair EpsCopyInputStream (const char * p, uint32_t res)
class ImplicitWeakMessage