C# 클래스 Google.Protobuf.CodedOutputStream

Encodes and writes protocol message fields.

This class is generally used by generated code to write appropriate primitives to the stream. It effectively encapsulates the lowest levels of protocol buffer format. Unlike some other implementations, this does not include combined "write tag and value" methods. Generated code knows the exact byte representations of the tags they're going to write, so there's no need to re-encode them each time. Manually-written code calling this class should just call one of the WriteTag overloads before each value.

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

파일 보기 프로젝트 열기: Arctium-Emulation/Project-WoW 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
DefaultBufferSize int

공개 메소드들

메소드 설명
CheckNoSpaceLeft ( ) : void

Verifies that SpaceLeft returns zero. It's common to create a byte array that is exactly big enough to hold a message, then write to it with a CodedOutputStream. Calling CheckNoSpaceLeft after writing verifies that the message was actually as big as expected, which can help bugs.

CodedOutputStream ( Stream output ) : System

Creates a new CodedOutputStream which write to the given stream, and disposes of that stream when the returned CodedOutputStream is disposed.

CodedOutputStream ( Stream output, bool leaveOpen ) : System

Creates a new CodedOutputStream which write to the given stream.

CodedOutputStream ( Stream output, int bufferSize ) : System

Creates a new CodedOutputStream which write to the given stream and uses the specified buffer size.

CodedOutputStream ( Stream output, int bufferSize, bool leaveOpen ) : System

Creates a new CodedOutputStream which write to the given stream and uses the specified buffer size.

CodedOutputStream ( byte flatArray ) : System

Creates a new CodedOutputStream that writes directly to the given byte array. If more bytes are written than fit in the array, OutOfSpaceException will be thrown.

Dispose ( ) : void

Flushes any buffered data and optionally closes the underlying stream, if any.

By default, any underlying stream is closed by this method. To configure this behaviour, use a constructor overload with a leaveOpen parameter. If this instance does not have an underlying stream, this method does nothing.

For the sake of efficiency, calling this method does not prevent future write calls - but if a later write ends up writing to a stream which has been disposed, that is likely to fail. It is recommend that you not call any other methods after this.

Flush ( ) : void

Flushes any buffered data to the underlying stream (if there is one).

WriteBool ( bool value ) : void

Writes a bool field value, without a tag, to the stream.

WriteBytes ( ByteString value ) : void

Write a byte string, without a tag, to the stream. The data is length-prefixed.

WriteDouble ( double value ) : void

Writes a double field value, without a tag, to the stream.

WriteEnum ( int value ) : void

Writes an enum value, without a tag, to the stream.

WriteFixed32 ( uint value ) : void

Writes a fixed32 field value, without a tag, to the stream.

WriteFixed64 ( ulong value ) : void

Writes a fixed64 field value, without a tag, to the stream.

WriteFloat ( float value ) : void

Writes a float field value, without a tag, to the stream.

WriteInt32 ( int value ) : void

Writes an int32 field value, without a tag, to the stream.

WriteInt64 ( long value ) : void

Writes an int64 field value, without a tag, to the stream.

WriteLength ( int length ) : void

Writes a length (in bytes) for length-delimited data.

This method simply writes a rawint, but exists for clarity in calling code.

WriteMessage ( IMessage value ) : void

Writes a message, without a tag, to the stream. The data is length-prefixed.

WriteRawTag ( byte b1 ) : void

Writes the given single-byte tag directly to the stream.

WriteRawTag ( byte b1, byte b2 ) : void

Writes the given two-byte tag directly to the stream.

WriteRawTag ( byte b1, byte b2, byte b3 ) : void

Writes the given three-byte tag directly to the stream.

WriteRawTag ( byte b1, byte b2, byte b3, byte b4 ) : void

Writes the given four-byte tag directly to the stream.

WriteRawTag ( byte b1, byte b2, byte b3, byte b4, byte b5 ) : void

Writes the given five-byte tag directly to the stream.

WriteSFixed32 ( int value ) : void

Writes an sfixed32 value, without a tag, to the stream.

WriteSFixed64 ( long value ) : void

Writes an sfixed64 value, without a tag, to the stream.

WriteSInt32 ( int value ) : void

Writes an sint32 value, without a tag, to the stream.

WriteSInt64 ( long value ) : void

Writes an sint64 value, without a tag, to the stream.

WriteString ( string value ) : void

Writes a string field value, without a tag, to the stream. The data is length-prefixed.

WriteTag ( int fieldNumber, WireFormat type ) : void

Encodes and writes a tag.

WriteTag ( uint tag ) : void

Writes an already-encoded tag.

WriteUInt32 ( uint value ) : void

Writes a uint32 value, without a tag, to the stream.

WriteUInt64 ( ulong value ) : void

Writes a uint64 field value, without a tag, to the stream.

비공개 메소드들

메소드 설명
CodedOutputStream ( Stream output, byte buffer, bool leaveOpen ) : System
CodedOutputStream ( byte buffer, int offset, int length ) : System

Creates a new CodedOutputStream that writes directly to the given byte array slice. If more bytes are written than fit in the array, OutOfSpaceException will be thrown.

EncodeZigZag32 ( int n ) : uint

Encode a 32-bit value with ZigZag encoding.

ZigZag encodes signed integers into values that can be efficiently encoded with varint. (Otherwise, negative values must be sign-extended to 64 bits to be varint encoded, thus always taking 10 bytes on the wire.)

EncodeZigZag64 ( long n ) : ulong

Encode a 64-bit value with ZigZag encoding.

ZigZag encodes signed integers into values that can be efficiently encoded with varint. (Otherwise, negative values must be sign-extended to 64 bits to be varint encoded, thus always taking 10 bytes on the wire.)

RefreshBuffer ( ) : void
WriteRawByte ( byte value ) : void
WriteRawByte ( uint value ) : void
WriteRawBytes ( byte value ) : void

Writes out an array of bytes.

WriteRawBytes ( byte value, int offset, int length ) : void

Writes out part of an array of bytes.

WriteRawLittleEndian32 ( uint value ) : void
WriteRawLittleEndian64 ( ulong value ) : void
WriteRawVarint32 ( uint value ) : void

Writes a 32 bit value as a varint. The fast route is taken when there's enough buffer space left to whizz through without checking for each byte; otherwise, we resort to calling WriteRawByte each time.

WriteRawVarint64 ( ulong value ) : void

메소드 상세

CheckNoSpaceLeft() 공개 메소드

Verifies that SpaceLeft returns zero. It's common to create a byte array that is exactly big enough to hold a message, then write to it with a CodedOutputStream. Calling CheckNoSpaceLeft after writing verifies that the message was actually as big as expected, which can help bugs.
public CheckNoSpaceLeft ( ) : void
리턴 void

CodedOutputStream() 공개 메소드

Creates a new CodedOutputStream which write to the given stream, and disposes of that stream when the returned CodedOutputStream is disposed.
public CodedOutputStream ( Stream output ) : System
output Stream The stream to write to. It will be disposed when the returned CodedOutputStream is disposed.
리턴 System

CodedOutputStream() 공개 메소드

Creates a new CodedOutputStream which write to the given stream.
public CodedOutputStream ( Stream output, bool leaveOpen ) : System
output Stream The stream to write to.
leaveOpen bool If true, is left open when the returned CodedOutputStream is disposed; /// if false, the provided stream is disposed as well.
리턴 System

CodedOutputStream() 공개 메소드

Creates a new CodedOutputStream which write to the given stream and uses the specified buffer size.
public CodedOutputStream ( Stream output, int bufferSize ) : System
output Stream The stream to write to. It will be disposed when the returned CodedOutputStream is disposed.
bufferSize int The size of buffer to use internally.
리턴 System

CodedOutputStream() 공개 메소드

Creates a new CodedOutputStream which write to the given stream and uses the specified buffer size.
public CodedOutputStream ( Stream output, int bufferSize, bool leaveOpen ) : System
output Stream The stream to write to.
bufferSize int The size of buffer to use internally.
leaveOpen bool If true, is left open when the returned CodedOutputStream is disposed; /// if false, the provided stream is disposed as well.
리턴 System

CodedOutputStream() 공개 메소드

Creates a new CodedOutputStream that writes directly to the given byte array. If more bytes are written than fit in the array, OutOfSpaceException will be thrown.
public CodedOutputStream ( byte flatArray ) : System
flatArray byte
리턴 System

Dispose() 공개 메소드

Flushes any buffered data and optionally closes the underlying stream, if any.

By default, any underlying stream is closed by this method. To configure this behaviour, use a constructor overload with a leaveOpen parameter. If this instance does not have an underlying stream, this method does nothing.

For the sake of efficiency, calling this method does not prevent future write calls - but if a later write ends up writing to a stream which has been disposed, that is likely to fail. It is recommend that you not call any other methods after this.

public Dispose ( ) : void
리턴 void

Flush() 공개 메소드

Flushes any buffered data to the underlying stream (if there is one).
public Flush ( ) : void
리턴 void

WriteBool() 공개 메소드

Writes a bool field value, without a tag, to the stream.
public WriteBool ( bool value ) : void
value bool The value to write
리턴 void

WriteBytes() 공개 메소드

Write a byte string, without a tag, to the stream. The data is length-prefixed.
public WriteBytes ( ByteString value ) : void
value ByteString The value to write
리턴 void

WriteDouble() 공개 메소드

Writes a double field value, without a tag, to the stream.
public WriteDouble ( double value ) : void
value double The value to write
리턴 void

WriteEnum() 공개 메소드

Writes an enum value, without a tag, to the stream.
public WriteEnum ( int value ) : void
value int The value to write
리턴 void

WriteFixed32() 공개 메소드

Writes a fixed32 field value, without a tag, to the stream.
public WriteFixed32 ( uint value ) : void
value uint The value to write
리턴 void

WriteFixed64() 공개 메소드

Writes a fixed64 field value, without a tag, to the stream.
public WriteFixed64 ( ulong value ) : void
value ulong The value to write
리턴 void

WriteFloat() 공개 메소드

Writes a float field value, without a tag, to the stream.
public WriteFloat ( float value ) : void
value float The value to write
리턴 void

WriteInt32() 공개 메소드

Writes an int32 field value, without a tag, to the stream.
public WriteInt32 ( int value ) : void
value int The value to write
리턴 void

WriteInt64() 공개 메소드

Writes an int64 field value, without a tag, to the stream.
public WriteInt64 ( long value ) : void
value long The value to write
리턴 void

WriteLength() 공개 메소드

Writes a length (in bytes) for length-delimited data.
This method simply writes a rawint, but exists for clarity in calling code.
public WriteLength ( int length ) : void
length int Length value, in bytes.
리턴 void

WriteMessage() 공개 메소드

Writes a message, without a tag, to the stream. The data is length-prefixed.
public WriteMessage ( IMessage value ) : void
value IMessage The value to write
리턴 void

WriteRawTag() 공개 메소드

Writes the given single-byte tag directly to the stream.
public WriteRawTag ( byte b1 ) : void
b1 byte The encoded tag
리턴 void

WriteRawTag() 공개 메소드

Writes the given two-byte tag directly to the stream.
public WriteRawTag ( byte b1, byte b2 ) : void
b1 byte The first byte of the encoded tag
b2 byte The second byte of the encoded tag
리턴 void

WriteRawTag() 공개 메소드

Writes the given three-byte tag directly to the stream.
public WriteRawTag ( byte b1, byte b2, byte b3 ) : void
b1 byte The first byte of the encoded tag
b2 byte The second byte of the encoded tag
b3 byte The third byte of the encoded tag
리턴 void

WriteRawTag() 공개 메소드

Writes the given four-byte tag directly to the stream.
public WriteRawTag ( byte b1, byte b2, byte b3, byte b4 ) : void
b1 byte The first byte of the encoded tag
b2 byte The second byte of the encoded tag
b3 byte The third byte of the encoded tag
b4 byte The fourth byte of the encoded tag
리턴 void

WriteRawTag() 공개 메소드

Writes the given five-byte tag directly to the stream.
public WriteRawTag ( byte b1, byte b2, byte b3, byte b4, byte b5 ) : void
b1 byte The first byte of the encoded tag
b2 byte The second byte of the encoded tag
b3 byte The third byte of the encoded tag
b4 byte The fourth byte of the encoded tag
b5 byte The fifth byte of the encoded tag
리턴 void

WriteSFixed32() 공개 메소드

Writes an sfixed32 value, without a tag, to the stream.
public WriteSFixed32 ( int value ) : void
value int The value to write.
리턴 void

WriteSFixed64() 공개 메소드

Writes an sfixed64 value, without a tag, to the stream.
public WriteSFixed64 ( long value ) : void
value long The value to write
리턴 void

WriteSInt32() 공개 메소드

Writes an sint32 value, without a tag, to the stream.
public WriteSInt32 ( int value ) : void
value int The value to write
리턴 void

WriteSInt64() 공개 메소드

Writes an sint64 value, without a tag, to the stream.
public WriteSInt64 ( long value ) : void
value long The value to write
리턴 void

WriteString() 공개 메소드

Writes a string field value, without a tag, to the stream. The data is length-prefixed.
public WriteString ( string value ) : void
value string The value to write
리턴 void

WriteTag() 공개 메소드

Encodes and writes a tag.
public WriteTag ( int fieldNumber, WireFormat type ) : void
fieldNumber int The number of the field to write the tag for
type WireFormat The wire format type of the tag to write
리턴 void

WriteTag() 공개 메소드

Writes an already-encoded tag.
public WriteTag ( uint tag ) : void
tag uint The encoded tag
리턴 void

WriteUInt32() 공개 메소드

Writes a uint32 value, without a tag, to the stream.
public WriteUInt32 ( uint value ) : void
value uint The value to write
리턴 void

WriteUInt64() 공개 메소드

Writes a uint64 field value, without a tag, to the stream.
public WriteUInt64 ( ulong value ) : void
value ulong The value to write
리턴 void

프로퍼티 상세

DefaultBufferSize 공개적으로 정적으로 프로퍼티

The buffer size used by CreateInstance(Stream).
public static int DefaultBufferSize
리턴 int