C# 클래스 Google.ProtocolBuffers.CodedInputStream

Readings and decodes protocol message fields.
This class contains two kinds of methods: methods that read specific protocol message constructs and field types (e.g. ReadTag and ReadInt32) and methods that read low-level values (e.g. ReadRawVarint32 and ReadRawBytes). If you are reading encoded protocol messages, you should use the former methods, but if you are reading some other format of your own design, use the latter. The names of the former methods are taken from the protocol buffer type names, not .NET types. (Hence ReadFloat instead of ReadSingle, and ReadBool instead of ReadBoolean.) TODO(jonskeet): Consider whether recursion and size limits shouldn't be readonly, set at construction time.
파일 보기 프로젝트 열기: ayende/dotnet-protobufs 1 사용 예제들

공개 메소드들

메소드 설명
CreateInstance ( Stream input ) : CodedInputStream

Creates a new CodedInputStream reading data from the given stream.

CreateInstance ( byte buf ) : CodedInputStream

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

PopLimit ( int oldLimit ) : void

Discards the current limit, returning the previous limit.

PushLimit ( int byteLimit ) : int

Sets currentLimit to (current position) + byteLimit. This is called when descending into a length-delimited embedded message. The previous limit is returned.

ReadBool ( ) : bool

Read a bool field from the stream.

ReadBytes ( ) : ByteString

Reads a bytes field value from the stream.

ReadDouble ( ) : double

Read a double field from the stream.

ReadEnum ( ) : int

Reads an enum field value from the stream. The caller is responsible for converting the numeric value to an actual enum.

ReadFloat ( ) : float

Read a float field from the stream.

ReadGroup ( int fieldNumber, IBuilder builder, ExtensionRegistry extensionRegistry ) : void

Reads a group field value from the stream.

ReadInt32 ( ) : int

Read an int32 field from the stream.

ReadInt64 ( ) : long

Read an int64 field from the stream.

ReadMessage ( IBuilder builder, ExtensionRegistry extensionRegistry ) : void

Reads an embedded message field value from the stream.

ReadPrimitiveField ( FieldType fieldType ) : object

Reads a field of any primitive type. Enums, groups and embedded messages are not handled by this method.

ReadRawByte ( ) : byte

Read one byte from the input.

ReadRawBytes ( int size ) : System.ByteBuffer

Read a fixed size of bytes from the input.

ReadSFixed32 ( ) : int

Reads an sfixed32 field value from the stream.

ReadSFixed64 ( ) : long

Reads an sfixed64 field value from the stream.

ReadSInt32 ( ) : int

Reads an sint32 field value from the stream.

ReadSInt64 ( ) : long

Reads an sint64 field value from the stream.

ReadString ( ) : String

Reads a string field from the stream.

ReadUnknownGroup ( int fieldNumber, Google.ProtocolBuffers.UnknownFieldSet builder ) : void

Reads a group field value from the stream and merges it into the given UnknownFieldSet.

ResetSizeCounter ( ) : void

Resets the current size counter to zero (see SetSizeLimit).

SetRecursionLimit ( int limit ) : int

Set the maximum message recursion depth.

In order to prevent malicious messages from causing stack overflows, CodedInputStream limits how deeply messages may be nested. The default limit is 64.

SetSizeLimit ( int limit ) : int

Set the maximum message size.

In order to prevent malicious messages from exhausting memory or causing integer overflows, CodedInputStream limits how large a message may be. The default limit is 64MB. You should set this limit as small as you can without harming your app's functionality. Note that size limits only apply when reading from an InputStream, not when constructed around a raw byte array (nor with ByteString.NewCodedInput). If you want to read several messages from a single CodedInputStream, you can call ResetSizeCounter() after each message to avoid hitting the size limit.

SkipMessage ( ) : void

Reads and discards an entire message. This will read either until EOF or until an endgroup tag, whichever comes first.

SkipRawBytes ( int size ) : void

Reads and discards size bytes.

비공개 메소드들

메소드 설명
CheckLastTagWas ( uint value ) : void
CodedInputStream ( Stream input ) : System
CodedInputStream ( byte buffer ) : System
DecodeZigZag32 ( uint n ) : int
DecodeZigZag64 ( ulong n ) : long
ReadFixed32 ( ) : uint
ReadFixed64 ( ) : ulong
ReadRawLittleEndian32 ( ) : uint
ReadRawLittleEndian64 ( ) : ulong
ReadRawVarint32 ( ) : uint
ReadRawVarint32 ( Stream input ) : uint

Reads a varint from the input one byte at a time, so that it does not read any bytes after the end of the varint. If you simply wrapped the stream in a CodedInputStream and used ReadRawVarint32(Stream)} then you would probably end up reading past the end of the varint since CodedInputStream buffers its input.

ReadRawVarint64 ( ) : ulong
ReadTag ( ) : uint
ReadUInt32 ( ) : uint
ReadUInt64 ( ) : ulong
RecomputeBufferSizeAfterLimit ( ) : void
RefillBuffer ( bool mustSucceed ) : bool

Called when buffer is empty to read more bytes from the input. If mustSucceed is true, RefillBuffer() gurantees that either there will be at least one byte in the buffer when it returns or it will throw an exception. If mustSucceed is false, RefillBuffer() returns false if no more bytes were available.

SkipField ( uint tag ) : bool
SkipImpl ( int amountToSkip ) : void

Abstraction of skipping to cope with streams which can't really skip.

SlowReadRawVarint32 ( ) : uint

Same code as ReadRawVarint32, but read each byte individually, checking for buffer overflow.

메소드 상세

CreateInstance() 공개 정적인 메소드

Creates a new CodedInputStream reading data from the given stream.
public static CreateInstance ( Stream input ) : CodedInputStream
input Stream
리턴 CodedInputStream

CreateInstance() 공개 정적인 메소드

Creates a new CodedInputStream reading data from the given byte array.
public static CreateInstance ( byte buf ) : CodedInputStream
buf byte
리턴 CodedInputStream

PopLimit() 공개 메소드

Discards the current limit, returning the previous limit.
public PopLimit ( int oldLimit ) : void
oldLimit int
리턴 void

PushLimit() 공개 메소드

Sets currentLimit to (current position) + byteLimit. This is called when descending into a length-delimited embedded message. The previous limit is returned.
public PushLimit ( int byteLimit ) : int
byteLimit int
리턴 int

ReadBool() 공개 메소드

Read a bool field from the stream.
public ReadBool ( ) : bool
리턴 bool

ReadBytes() 공개 메소드

Reads a bytes field value from the stream.
public ReadBytes ( ) : ByteString
리턴 ByteString

ReadDouble() 공개 메소드

Read a double field from the stream.
public ReadDouble ( ) : double
리턴 double

ReadEnum() 공개 메소드

Reads an enum field value from the stream. The caller is responsible for converting the numeric value to an actual enum.
public ReadEnum ( ) : int
리턴 int

ReadFloat() 공개 메소드

Read a float field from the stream.
public ReadFloat ( ) : float
리턴 float

ReadGroup() 공개 메소드

Reads a group field value from the stream.
public ReadGroup ( int fieldNumber, IBuilder builder, ExtensionRegistry extensionRegistry ) : void
fieldNumber int
builder IBuilder
extensionRegistry ExtensionRegistry
리턴 void

ReadInt32() 공개 메소드

Read an int32 field from the stream.
public ReadInt32 ( ) : int
리턴 int

ReadInt64() 공개 메소드

Read an int64 field from the stream.
public ReadInt64 ( ) : long
리턴 long

ReadMessage() 공개 메소드

Reads an embedded message field value from the stream.
public ReadMessage ( IBuilder builder, ExtensionRegistry extensionRegistry ) : void
builder IBuilder
extensionRegistry ExtensionRegistry
리턴 void

ReadPrimitiveField() 공개 메소드

Reads a field of any primitive type. Enums, groups and embedded messages are not handled by this method.
public ReadPrimitiveField ( FieldType fieldType ) : object
fieldType FieldType
리턴 object

ReadRawByte() 공개 메소드

Read one byte from the input.
/// the end of the stream or the current limit was reached ///
public ReadRawByte ( ) : byte
리턴 byte

ReadRawBytes() 공개 메소드

Read a fixed size of bytes from the input.
/// the end of the stream or the current limit was reached ///
public ReadRawBytes ( int size ) : System.ByteBuffer
size int
리턴 System.ByteBuffer

ReadSFixed32() 공개 메소드

Reads an sfixed32 field value from the stream.
public ReadSFixed32 ( ) : int
리턴 int

ReadSFixed64() 공개 메소드

Reads an sfixed64 field value from the stream.
public ReadSFixed64 ( ) : long
리턴 long

ReadSInt32() 공개 메소드

Reads an sint32 field value from the stream.
public ReadSInt32 ( ) : int
리턴 int

ReadSInt64() 공개 메소드

Reads an sint64 field value from the stream.
public ReadSInt64 ( ) : long
리턴 long

ReadString() 공개 메소드

Reads a string field from the stream.
public ReadString ( ) : String
리턴 String

ReadUnknownGroup() 공개 메소드

Reads a group field value from the stream and merges it into the given UnknownFieldSet.
public ReadUnknownGroup ( int fieldNumber, Google.ProtocolBuffers.UnknownFieldSet builder ) : void
fieldNumber int
builder Google.ProtocolBuffers.UnknownFieldSet
리턴 void

ResetSizeCounter() 공개 메소드

Resets the current size counter to zero (see SetSizeLimit).
public ResetSizeCounter ( ) : void
리턴 void

SetRecursionLimit() 공개 메소드

Set the maximum message recursion depth.
In order to prevent malicious messages from causing stack overflows, CodedInputStream limits how deeply messages may be nested. The default limit is 64.
public SetRecursionLimit ( int limit ) : int
limit int
리턴 int

SetSizeLimit() 공개 메소드

Set the maximum message size.
In order to prevent malicious messages from exhausting memory or causing integer overflows, CodedInputStream limits how large a message may be. The default limit is 64MB. You should set this limit as small as you can without harming your app's functionality. Note that size limits only apply when reading from an InputStream, not when constructed around a raw byte array (nor with ByteString.NewCodedInput). If you want to read several messages from a single CodedInputStream, you can call ResetSizeCounter() after each message to avoid hitting the size limit.
public SetSizeLimit ( int limit ) : int
limit int
리턴 int

SkipMessage() 공개 메소드

Reads and discards an entire message. This will read either until EOF or until an endgroup tag, whichever comes first.
public SkipMessage ( ) : void
리턴 void

SkipRawBytes() 공개 메소드

Reads and discards size bytes.
the end of the stream /// or the current limit was reached
public SkipRawBytes ( int size ) : void
size int
리턴 void