webkit
2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
|
Encodes and writes protocol message fields. More...
Classes | |
class | OutOfSpaceException |
Indicates that a CodedOutputStream wrapping a flat byte array ran out of space. More... | |
Public Member Functions | |
CodedOutputStream (byte[] flatArray) | |
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. More... | |
CodedOutputStream (Stream output) | |
Creates a new CodedOutputStream which write to the given stream, and disposes of that stream when the returned CodedOutputStream is disposed. More... | |
CodedOutputStream (Stream output, int bufferSize) | |
Creates a new CodedOutputStream which write to the given stream and uses the specified buffer size. More... | |
CodedOutputStream (Stream output, bool leaveOpen) | |
Creates a new CodedOutputStream which write to the given stream. More... | |
CodedOutputStream (Stream output, int bufferSize, bool leaveOpen) | |
Creates a new CodedOutputStream which write to the given stream and uses the specified buffer size. More... | |
void | WriteDouble (double value) |
Writes a double field value, without a tag, to the stream. More... | |
void | WriteFloat (float value) |
Writes a float field value, without a tag, to the stream. More... | |
void | WriteUInt64 (ulong value) |
Writes a uint64 field value, without a tag, to the stream. More... | |
void | WriteInt64 (long value) |
Writes an int64 field value, without a tag, to the stream. More... | |
void | WriteInt32 (int value) |
Writes an int32 field value, without a tag, to the stream. More... | |
void | WriteFixed64 (ulong value) |
Writes a fixed64 field value, without a tag, to the stream. More... | |
void | WriteFixed32 (uint value) |
Writes a fixed32 field value, without a tag, to the stream. More... | |
void | WriteBool (bool value) |
Writes a bool field value, without a tag, to the stream. More... | |
void | WriteString (string value) |
Writes a string field value, without a tag, to the stream. The data is length-prefixed. More... | |
void | WriteMessage (IMessage value) |
Writes a message, without a tag, to the stream. The data is length-prefixed. More... | |
void | WriteBytes (ByteString value) |
Write a byte string, without a tag, to the stream. The data is length-prefixed. More... | |
void | WriteUInt32 (uint value) |
Writes a uint32 value, without a tag, to the stream. More... | |
void | WriteEnum (int value) |
Writes an enum value, without a tag, to the stream. More... | |
void | WriteSFixed32 (int value) |
Writes an sfixed32 value, without a tag, to the stream. More... | |
void | WriteSFixed64 (long value) |
Writes an sfixed64 value, without a tag, to the stream. More... | |
void | WriteSInt32 (int value) |
Writes an sint32 value, without a tag, to the stream. More... | |
void | WriteSInt64 (long value) |
Writes an sint64 value, without a tag, to the stream. More... | |
void | WriteLength (int length) |
Writes a length (in bytes) for length-delimited data. More... | |
void | WriteTag (int fieldNumber, WireFormat.WireType type) |
Encodes and writes a tag. More... | |
void | WriteTag (uint tag) |
Writes an already-encoded tag. More... | |
void | WriteRawTag (byte b1) |
Writes the given single-byte tag directly to the stream. More... | |
void | WriteRawTag (byte b1, byte b2) |
Writes the given two-byte tag directly to the stream. More... | |
void | WriteRawTag (byte b1, byte b2, byte b3) |
Writes the given three-byte tag directly to the stream. More... | |
void | WriteRawTag (byte b1, byte b2, byte b3, byte b4) |
Writes the given four-byte tag directly to the stream. More... | |
void | WriteRawTag (byte b1, byte b2, byte b3, byte b4, byte b5) |
Writes the given five-byte tag directly to the stream. More... | |
void | Dispose () |
Flushes any buffered data and optionally closes the underlying stream, if any. More... | |
void | Flush () |
Flushes any buffered data to the underlying stream (if there is one). More... | |
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. More... | |
Static Public Member Functions | |
static int | ComputeDoubleSize (double value) |
Computes the number of bytes that would be needed to encode a double field, including the tag. More... | |
static int | ComputeFloatSize (float value) |
Computes the number of bytes that would be needed to encode a float field, including the tag. More... | |
static int | ComputeUInt64Size (ulong value) |
Computes the number of bytes that would be needed to encode a uint64 field, including the tag. More... | |
static int | ComputeInt64Size (long value) |
Computes the number of bytes that would be needed to encode an int64 field, including the tag. More... | |
static int | ComputeInt32Size (int value) |
Computes the number of bytes that would be needed to encode an int32 field, including the tag. More... | |
static int | ComputeFixed64Size (ulong value) |
Computes the number of bytes that would be needed to encode a fixed64 field, including the tag. More... | |
static int | ComputeFixed32Size (uint value) |
Computes the number of bytes that would be needed to encode a fixed32 field, including the tag. More... | |
static int | ComputeBoolSize (bool value) |
Computes the number of bytes that would be needed to encode a bool field, including the tag. More... | |
static int | ComputeStringSize (String value) |
Computes the number of bytes that would be needed to encode a string field, including the tag. More... | |
static int | ComputeGroupSize (IMessage value) |
Computes the number of bytes that would be needed to encode a group field, including the tag. More... | |
static int | ComputeMessageSize (IMessage value) |
Computes the number of bytes that would be needed to encode an embedded message field, including the tag. More... | |
static int | ComputeBytesSize (ByteString value) |
Computes the number of bytes that would be needed to encode a bytes field, including the tag. More... | |
static int | ComputeUInt32Size (uint value) |
Computes the number of bytes that would be needed to encode a uint32 field, including the tag. More... | |
static int | ComputeEnumSize (int value) |
Computes the number of bytes that would be needed to encode a enum field, including the tag. The caller is responsible for converting the enum value to its numeric value. More... | |
static int | ComputeSFixed32Size (int value) |
Computes the number of bytes that would be needed to encode an sfixed32 field, including the tag. More... | |
static int | ComputeSFixed64Size (long value) |
Computes the number of bytes that would be needed to encode an sfixed64 field, including the tag. More... | |
static int | ComputeSInt32Size (int value) |
Computes the number of bytes that would be needed to encode an sint32 field, including the tag. More... | |
static int | ComputeSInt64Size (long value) |
Computes the number of bytes that would be needed to encode an sint64 field, including the tag. More... | |
static int | ComputeLengthSize (int length) |
Computes the number of bytes that would be needed to encode a length, as written by WriteLength. More... | |
static int | ComputeRawVarint32Size (uint value) |
Computes the number of bytes that would be needed to encode a varint. More... | |
static int | ComputeRawVarint64Size (ulong value) |
Computes the number of bytes that would be needed to encode a varint. More... | |
static int | ComputeTagSize (int fieldNumber) |
Computes the number of bytes that would be needed to encode a tag. More... | |
Static Public Attributes | |
static readonly int | DefaultBufferSize = 4096 |
The buffer size used by CreateInstance(Stream). More... | |
Properties | |
long | Position [get] |
Returns the current position in the stream, or the position in the output buffer More... | |
int | SpaceLeft [get] |
If writing to a flat array, returns the space left in the array. Otherwise, throws an InvalidOperationException. More... | |
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.
|
inline |
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.
|
inline |
Creates a new CodedOutputStream which write to the given stream, and disposes of that stream when the returned CodedOutputStream
is disposed.
output | The stream to write to. It will be disposed when the returned CodedOutputStream is disposed. |
|
inline |
Creates a new CodedOutputStream which write to the given stream and uses the specified buffer size.
output | The stream to write to. It will be disposed when the returned CodedOutputStream is disposed. |
bufferSize | The size of buffer to use internally. |
|
inline |
Creates a new CodedOutputStream which write to the given stream.
output | The stream to write to. |
leaveOpen | If true , output is left open when the returned CodedOutputStream is disposed; if false , the provided stream is disposed as well. |
|
inline |
Creates a new CodedOutputStream which write to the given stream and uses the specified buffer size.
output | The stream to write to. |
bufferSize | The size of buffer to use internally. |
leaveOpen | If true , output is left open when the returned CodedOutputStream is disposed; if false , the provided stream is disposed as well. |
|
inline |
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.
|
inlinestatic |
Computes the number of bytes that would be needed to encode a bool field, including the tag.
|
inlinestatic |
Computes the number of bytes that would be needed to encode a bytes field, including the tag.
|
inlinestatic |
Computes the number of bytes that would be needed to encode a double field, including the tag.
|
inlinestatic |
Computes the number of bytes that would be needed to encode a enum field, including the tag. The caller is responsible for converting the enum value to its numeric value.
|
inlinestatic |
Computes the number of bytes that would be needed to encode a fixed32 field, including the tag.
|
inlinestatic |
Computes the number of bytes that would be needed to encode a fixed64 field, including the tag.
|
inlinestatic |
Computes the number of bytes that would be needed to encode a float field, including the tag.
|
inlinestatic |
Computes the number of bytes that would be needed to encode a group field, including the tag.
|
inlinestatic |
Computes the number of bytes that would be needed to encode an int32 field, including the tag.
|
inlinestatic |
Computes the number of bytes that would be needed to encode an int64 field, including the tag.
|
inlinestatic |
Computes the number of bytes that would be needed to encode a length, as written by WriteLength.
|
inlinestatic |
Computes the number of bytes that would be needed to encode an embedded message field, including the tag.
|
inlinestatic |
Computes the number of bytes that would be needed to encode a varint.
|
inlinestatic |
Computes the number of bytes that would be needed to encode a varint.
|
inlinestatic |
Computes the number of bytes that would be needed to encode an sfixed32 field, including the tag.
|
inlinestatic |
Computes the number of bytes that would be needed to encode an sfixed64 field, including the tag.
|
inlinestatic |
Computes the number of bytes that would be needed to encode an sint32 field, including the tag.
|
inlinestatic |
Computes the number of bytes that would be needed to encode an sint64 field, including the tag.
|
inlinestatic |
Computes the number of bytes that would be needed to encode a string field, including the tag.
|
inlinestatic |
Computes the number of bytes that would be needed to encode a tag.
|
inlinestatic |
Computes the number of bytes that would be needed to encode a uint32 field, including the tag.
|
inlinestatic |
Computes the number of bytes that would be needed to encode a uint64 field, including the tag.
|
inline |
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.
|
inline |
Flushes any buffered data to the underlying stream (if there is one).
|
inline |
Writes a bool field value, without a tag, to the stream.
value | The value to write |
|
inline |
|
inline |
Writes a double field value, without a tag, to the stream.
value | The value to write |
|
inline |
Writes an enum value, without a tag, to the stream.
value | The value to write |
Writes a fixed32 field value, without a tag, to the stream.
value | The value to write |
Writes a fixed64 field value, without a tag, to the stream.
value | The value to write |
|
inline |
Writes a float field value, without a tag, to the stream.
value | The value to write |
|
inline |
Writes an int32 field value, without a tag, to the stream.
value | The value to write |
|
inline |
Writes an int64 field value, without a tag, to the stream.
value | The value to write |
|
inline |
Writes a length (in bytes) for length-delimited data.
This method simply writes a rawint, but exists for clarity in calling code.
length | Length value, in bytes. |
|
inline |
Writes the given single-byte tag directly to the stream.
b1 | The encoded tag |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Writes an sfixed32 value, without a tag, to the stream.
value | The value to write. |
|
inline |
Writes an sfixed64 value, without a tag, to the stream.
value | The value to write |
|
inline |
Writes an sint32 value, without a tag, to the stream.
value | The value to write |
|
inline |
Writes an sint64 value, without a tag, to the stream.
value | The value to write |
|
inline |
Writes an already-encoded tag.
tag | The encoded tag |
Writes a uint32 value, without a tag, to the stream.
value | The value to write |
Writes a uint64 field value, without a tag, to the stream.
value | The value to write |
|
static |
The buffer size used by CreateInstance(Stream).
|
get |
Returns the current position in the stream, or the position in the output buffer
|
get |
If writing to a flat array, returns the space left in the array. Otherwise, throws an InvalidOperationException.