webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
Public Member Functions | Static Public Member Functions | Properties | List of all members
Google.Protobuf.CodedInputStream Class Reference

Reads and decodes protocol message fields. More...

Inheritance diagram for Google.Protobuf.CodedInputStream:

Public Member Functions

 CodedInputStream (byte[] buffer)
 Creates a new CodedInputStream reading data from the given byte array. More...
 
 CodedInputStream (byte[] buffer, int offset, int length)
 Creates a new CodedInputStream that reads from the given byte array slice. More...
 
 CodedInputStream (Stream input)
 Creates a new CodedInputStream reading data from the given stream, which will be disposed when the returned object is disposed. More...
 
 CodedInputStream (Stream input, bool leaveOpen)
 Creates a new CodedInputStream reading data from the given stream. More...
 
void Dispose ()
 Disposes of this instance, potentially closing any underlying stream. More...
 
uint PeekTag ()
 Peeks at the next field tag. This is like calling ReadTag, but the tag is not consumed. (So a subsequent call to ReadTag will return the same value.) More...
 
uint ReadTag ()
 Reads a field tag, returning the tag of 0 for "end of stream". More...
 
void SkipLastField ()
 Skips the data for the field with the tag we've just read. This should be called directly after ReadTag, when the caller wishes to skip an unknown field. More...
 
double ReadDouble ()
 Reads a double field from the stream. More...
 
float ReadFloat ()
 Reads a float field from the stream. More...
 
ulong ReadUInt64 ()
 Reads a uint64 field from the stream. More...
 
long ReadInt64 ()
 Reads an int64 field from the stream. More...
 
int ReadInt32 ()
 Reads an int32 field from the stream. More...
 
ulong ReadFixed64 ()
 Reads a fixed64 field from the stream. More...
 
uint ReadFixed32 ()
 Reads a fixed32 field from the stream. More...
 
bool ReadBool ()
 Reads a bool field from the stream. More...
 
string ReadString ()
 Reads a string field from the stream. More...
 
void ReadMessage (IMessage builder)
 Reads an embedded message field value from the stream. More...
 
ByteString ReadBytes ()
 Reads a bytes field value from the stream. More...
 
uint ReadUInt32 ()
 Reads a uint32 field value from the stream. More...
 
int ReadEnum ()
 Reads an enum field value from the stream. If the enum is valid for type T, then the ref value is set and it returns true. Otherwise the unknown output value is set and this method returns false. More...
 
int ReadSFixed32 ()
 Reads an sfixed32 field value from the stream. More...
 
long ReadSFixed64 ()
 Reads an sfixed64 field value from the stream. More...
 
int ReadSInt32 ()
 Reads an sint32 field value from the stream. More...
 
long ReadSInt64 ()
 Reads an sint64 field value from the stream. More...
 
int ReadLength ()
 Reads a length for length-delimited data. More...
 
bool MaybeConsumeTag (uint tag)
 Peeks at the next tag in the stream. If it matches tag , the tag is consumed and the method returns true; otherwise, the stream is left in the original position and the method returns false. More...
 

Static Public Member Functions

static CodedInputStream CreateWithLimits (Stream input, int sizeLimit, int recursionLimit)
 Creates a CodedInputStream with the specified size and recursion limits, reading from an input stream. More...
 

Properties

long Position [get]
 Returns the current position in the input stream, or the position in the input buffer More...
 
int SizeLimit [get]
 Returns the size limit for this stream. More...
 
int RecursionLimit [get]
 Returns the recursion limit for this stream. This limit is applied whilst reading messages, to avoid maliciously-recursive data. More...
 
bool IsAtEnd [get]
 Returns true if the stream has reached the end of the input. This is the case if either the end of the underlying input source has been reached or the stream has reached a limit created using PushLimit. More...
 

Detailed Description

Reads and decodes protocol message fields.

This class is generally used by generated code to read appropriate primitives from the stream. It effectively encapsulates the lowest levels of protocol buffer format.

Repeated fields and map fields are not handled by this class; use RepeatedField<T> and MapField<TKey, TValue> to serialize such fields.

Constructor & Destructor Documentation

◆ CodedInputStream() [1/4]

Google.Protobuf.CodedInputStream.CodedInputStream ( byte []  buffer)
inline

Creates a new CodedInputStream reading data from the given byte array.

◆ CodedInputStream() [2/4]

Google.Protobuf.CodedInputStream.CodedInputStream ( byte []  buffer,
int  offset,
int  length 
)
inline

Creates a new CodedInputStream that reads from the given byte array slice.

◆ CodedInputStream() [3/4]

Google.Protobuf.CodedInputStream.CodedInputStream ( Stream  input)
inline

Creates a new CodedInputStream reading data from the given stream, which will be disposed when the returned object is disposed.

Parameters
inputThe stream to read from.

◆ CodedInputStream() [4/4]

Google.Protobuf.CodedInputStream.CodedInputStream ( Stream  input,
bool  leaveOpen 
)
inline

Creates a new CodedInputStream reading data from the given stream.

Parameters
inputThe stream to read from.
leaveOpentrue to leave input open when the returned is disposed; false to dispose of the given stream when the returned object is disposed.

Member Function Documentation

◆ CreateWithLimits()

static CodedInputStream Google.Protobuf.CodedInputStream.CreateWithLimits ( Stream  input,
int  sizeLimit,
int  recursionLimit 
)
inlinestatic

Creates a CodedInputStream with the specified size and recursion limits, reading from an input stream.

This method exists separately from the constructor to reduce the number of constructor overloads. It is likely to be used considerably less frequently than the constructors, as the default limits are suitable for most use cases.

Parameters
inputThe input stream to read from
sizeLimitThe total limit of data to read from the stream.
recursionLimitThe maximum recursion depth to allow while reading.
Returns
A CodedInputStream reading from input with the specified size and recursion limits.

◆ Dispose()

void Google.Protobuf.CodedInputStream.Dispose ( )
inline

Disposes of this instance, potentially closing any underlying stream.

As there is no flushing to perform here, disposing of a CodedInputStream which was constructed with the leaveOpen option parameter set to true (or one which was constructed to read from a byte array) has no effect.

◆ MaybeConsumeTag()

bool Google.Protobuf.CodedInputStream.MaybeConsumeTag ( uint  tag)
inline

Peeks at the next tag in the stream. If it matches tag , the tag is consumed and the method returns true; otherwise, the stream is left in the original position and the method returns false.

◆ PeekTag()

uint Google.Protobuf.CodedInputStream.PeekTag ( )
inline

Peeks at the next field tag. This is like calling ReadTag, but the tag is not consumed. (So a subsequent call to ReadTag will return the same value.)

◆ ReadBool()

bool Google.Protobuf.CodedInputStream.ReadBool ( )
inline

Reads a bool field from the stream.

◆ ReadBytes()

ByteString Google.Protobuf.CodedInputStream.ReadBytes ( )
inline

Reads a bytes field value from the stream.

◆ ReadDouble()

double Google.Protobuf.CodedInputStream.ReadDouble ( )
inline

Reads a double field from the stream.

◆ ReadEnum()

int Google.Protobuf.CodedInputStream.ReadEnum ( )
inline

Reads an enum field value from the stream. If the enum is valid for type T, then the ref value is set and it returns true. Otherwise the unknown output value is set and this method returns false.

◆ ReadFixed32()

uint Google.Protobuf.CodedInputStream.ReadFixed32 ( )
inline

Reads a fixed32 field from the stream.

◆ ReadFixed64()

ulong Google.Protobuf.CodedInputStream.ReadFixed64 ( )
inline

Reads a fixed64 field from the stream.

◆ ReadFloat()

float Google.Protobuf.CodedInputStream.ReadFloat ( )
inline

Reads a float field from the stream.

◆ ReadInt32()

int Google.Protobuf.CodedInputStream.ReadInt32 ( )
inline

Reads an int32 field from the stream.

◆ ReadInt64()

long Google.Protobuf.CodedInputStream.ReadInt64 ( )
inline

Reads an int64 field from the stream.

◆ ReadLength()

int Google.Protobuf.CodedInputStream.ReadLength ( )
inline

Reads a length for length-delimited data.

This is internally just reading a varint, but this method exists to make the calling code clearer.

◆ ReadMessage()

void Google.Protobuf.CodedInputStream.ReadMessage ( IMessage  builder)
inline

Reads an embedded message field value from the stream.

◆ ReadSFixed32()

int Google.Protobuf.CodedInputStream.ReadSFixed32 ( )
inline

Reads an sfixed32 field value from the stream.

◆ ReadSFixed64()

long Google.Protobuf.CodedInputStream.ReadSFixed64 ( )
inline

Reads an sfixed64 field value from the stream.

◆ ReadSInt32()

int Google.Protobuf.CodedInputStream.ReadSInt32 ( )
inline

Reads an sint32 field value from the stream.

◆ ReadSInt64()

long Google.Protobuf.CodedInputStream.ReadSInt64 ( )
inline

Reads an sint64 field value from the stream.

◆ ReadString()

string Google.Protobuf.CodedInputStream.ReadString ( )
inline

Reads a string field from the stream.

◆ ReadTag()

uint Google.Protobuf.CodedInputStream.ReadTag ( )
inline

Reads a field tag, returning the tag of 0 for "end of stream".

If this method returns 0, it doesn't necessarily mean the end of all the data in this CodedInputStream; it may be the end of the logical stream for an embedded message, for example.

Returns
The next field tag, or 0 for end of stream. (0 is never a valid tag.)

◆ ReadUInt32()

uint Google.Protobuf.CodedInputStream.ReadUInt32 ( )
inline

Reads a uint32 field value from the stream.

◆ ReadUInt64()

ulong Google.Protobuf.CodedInputStream.ReadUInt64 ( )
inline

Reads a uint64 field from the stream.

◆ SkipLastField()

void Google.Protobuf.CodedInputStream.SkipLastField ( )
inline

Skips the data for the field with the tag we've just read. This should be called directly after ReadTag, when the caller wishes to skip an unknown field.

This method throws InvalidProtocolBufferException if the last-read tag was an end-group tag. If a caller wishes to skip a group, they should skip the whole group, by calling this method after reading the start-group tag. This behavior allows callers to call this method on any field they don't understand, correctly resulting in an error if an end-group tag has not been paired with an earlier start-group tag.

Exceptions
InvalidProtocolBufferExceptionThe last tag was an end-group tag
InvalidOperationExceptionThe last read operation read to the end of the logical stream

Property Documentation

◆ IsAtEnd

bool Google.Protobuf.CodedInputStream.IsAtEnd
get

Returns true if the stream has reached the end of the input. This is the case if either the end of the underlying input source has been reached or the stream has reached a limit created using PushLimit.

◆ Position

long Google.Protobuf.CodedInputStream.Position
get

Returns the current position in the input stream, or the position in the input buffer

◆ RecursionLimit

int Google.Protobuf.CodedInputStream.RecursionLimit
get

Returns the recursion limit for this stream. This limit is applied whilst reading messages, to avoid maliciously-recursive data.

The default limit is 64.

The recursion limit for this stream.

◆ SizeLimit

int Google.Protobuf.CodedInputStream.SizeLimit
get

Returns the size limit for this stream.

This limit is applied when reading from the underlying stream, as a sanity check. It is not applied when reading from a byte array data source without an underlying stream. The default value is 64MB.

The size limit.


The documentation for this class was generated from the following file: