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

Encodes and writes protocol message fields. More...

Inheritance diagram for Google.Protobuf.CodedOutputStream:

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ CodedOutputStream() [1/5]

Google.Protobuf.CodedOutputStream.CodedOutputStream ( byte []  flatArray)
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.

◆ CodedOutputStream() [2/5]

Google.Protobuf.CodedOutputStream.CodedOutputStream ( Stream  output)
inline

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

Parameters
outputThe stream to write to. It will be disposed when the returned CodedOutputStream is disposed.

◆ CodedOutputStream() [3/5]

Google.Protobuf.CodedOutputStream.CodedOutputStream ( Stream  output,
int  bufferSize 
)
inline

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

Parameters
outputThe stream to write to. It will be disposed when the returned CodedOutputStream is disposed.
bufferSizeThe size of buffer to use internally.

◆ CodedOutputStream() [4/5]

Google.Protobuf.CodedOutputStream.CodedOutputStream ( Stream  output,
bool  leaveOpen 
)
inline

Creates a new CodedOutputStream which write to the given stream.

Parameters
outputThe stream to write to.
leaveOpenIf true, output is left open when the returned CodedOutputStream is disposed; if false, the provided stream is disposed as well.

◆ CodedOutputStream() [5/5]

Google.Protobuf.CodedOutputStream.CodedOutputStream ( Stream  output,
int  bufferSize,
bool  leaveOpen 
)
inline

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

Parameters
outputThe stream to write to.
bufferSizeThe size of buffer to use internally.
leaveOpenIf true, output is left open when the returned CodedOutputStream is disposed; if false, the provided stream is disposed as well.

Member Function Documentation

◆ CheckNoSpaceLeft()

void Google.Protobuf.CodedOutputStream.CheckNoSpaceLeft ( )
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.

◆ ComputeBoolSize()

static int Google.Protobuf.CodedOutputStream.ComputeBoolSize ( bool  value)
inlinestatic

Computes the number of bytes that would be needed to encode a bool field, including the tag.

◆ ComputeBytesSize()

static int Google.Protobuf.CodedOutputStream.ComputeBytesSize ( ByteString  value)
inlinestatic

Computes the number of bytes that would be needed to encode a bytes field, including the tag.

◆ ComputeDoubleSize()

static int Google.Protobuf.CodedOutputStream.ComputeDoubleSize ( double  value)
inlinestatic

Computes the number of bytes that would be needed to encode a double field, including the tag.

◆ ComputeEnumSize()

static int Google.Protobuf.CodedOutputStream.ComputeEnumSize ( int  value)
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.

◆ ComputeFixed32Size()

static int Google.Protobuf.CodedOutputStream.ComputeFixed32Size ( uint  value)
inlinestatic

Computes the number of bytes that would be needed to encode a fixed32 field, including the tag.

◆ ComputeFixed64Size()

static int Google.Protobuf.CodedOutputStream.ComputeFixed64Size ( ulong  value)
inlinestatic

Computes the number of bytes that would be needed to encode a fixed64 field, including the tag.

◆ ComputeFloatSize()

static int Google.Protobuf.CodedOutputStream.ComputeFloatSize ( float  value)
inlinestatic

Computes the number of bytes that would be needed to encode a float field, including the tag.

◆ ComputeGroupSize()

static int Google.Protobuf.CodedOutputStream.ComputeGroupSize ( IMessage  value)
inlinestatic

Computes the number of bytes that would be needed to encode a group field, including the tag.

◆ ComputeInt32Size()

static int Google.Protobuf.CodedOutputStream.ComputeInt32Size ( int  value)
inlinestatic

Computes the number of bytes that would be needed to encode an int32 field, including the tag.

◆ ComputeInt64Size()

static int Google.Protobuf.CodedOutputStream.ComputeInt64Size ( long  value)
inlinestatic

Computes the number of bytes that would be needed to encode an int64 field, including the tag.

◆ ComputeLengthSize()

static int Google.Protobuf.CodedOutputStream.ComputeLengthSize ( int  length)
inlinestatic

Computes the number of bytes that would be needed to encode a length, as written by WriteLength.

◆ ComputeMessageSize()

static int Google.Protobuf.CodedOutputStream.ComputeMessageSize ( IMessage  value)
inlinestatic

Computes the number of bytes that would be needed to encode an embedded message field, including the tag.

◆ ComputeRawVarint32Size()

static int Google.Protobuf.CodedOutputStream.ComputeRawVarint32Size ( uint  value)
inlinestatic

Computes the number of bytes that would be needed to encode a varint.

◆ ComputeRawVarint64Size()

static int Google.Protobuf.CodedOutputStream.ComputeRawVarint64Size ( ulong  value)
inlinestatic

Computes the number of bytes that would be needed to encode a varint.

◆ ComputeSFixed32Size()

static int Google.Protobuf.CodedOutputStream.ComputeSFixed32Size ( int  value)
inlinestatic

Computes the number of bytes that would be needed to encode an sfixed32 field, including the tag.

◆ ComputeSFixed64Size()

static int Google.Protobuf.CodedOutputStream.ComputeSFixed64Size ( long  value)
inlinestatic

Computes the number of bytes that would be needed to encode an sfixed64 field, including the tag.

◆ ComputeSInt32Size()

static int Google.Protobuf.CodedOutputStream.ComputeSInt32Size ( int  value)
inlinestatic

Computes the number of bytes that would be needed to encode an sint32 field, including the tag.

◆ ComputeSInt64Size()

static int Google.Protobuf.CodedOutputStream.ComputeSInt64Size ( long  value)
inlinestatic

Computes the number of bytes that would be needed to encode an sint64 field, including the tag.

◆ ComputeStringSize()

static int Google.Protobuf.CodedOutputStream.ComputeStringSize ( String  value)
inlinestatic

Computes the number of bytes that would be needed to encode a string field, including the tag.

◆ ComputeTagSize()

static int Google.Protobuf.CodedOutputStream.ComputeTagSize ( int  fieldNumber)
inlinestatic

Computes the number of bytes that would be needed to encode a tag.

◆ ComputeUInt32Size()

static int Google.Protobuf.CodedOutputStream.ComputeUInt32Size ( uint  value)
inlinestatic

Computes the number of bytes that would be needed to encode a uint32 field, including the tag.

◆ ComputeUInt64Size()

static int Google.Protobuf.CodedOutputStream.ComputeUInt64Size ( ulong  value)
inlinestatic

Computes the number of bytes that would be needed to encode a uint64 field, including the tag.

◆ Dispose()

void Google.Protobuf.CodedOutputStream.Dispose ( )
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.

◆ Flush()

void Google.Protobuf.CodedOutputStream.Flush ( )
inline

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

◆ WriteBool()

void Google.Protobuf.CodedOutputStream.WriteBool ( bool  value)
inline

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

Parameters
valueThe value to write

◆ WriteBytes()

void Google.Protobuf.CodedOutputStream.WriteBytes ( ByteString  value)
inline

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

Parameters
valueThe value to write

◆ WriteDouble()

void Google.Protobuf.CodedOutputStream.WriteDouble ( double  value)
inline

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

Parameters
valueThe value to write

◆ WriteEnum()

void Google.Protobuf.CodedOutputStream.WriteEnum ( int  value)
inline

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

Parameters
valueThe value to write

◆ WriteFixed32()

void Google.Protobuf.CodedOutputStream.WriteFixed32 ( uint  value)
inline

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

Parameters
valueThe value to write

◆ WriteFixed64()

void Google.Protobuf.CodedOutputStream.WriteFixed64 ( ulong  value)
inline

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

Parameters
valueThe value to write

◆ WriteFloat()

void Google.Protobuf.CodedOutputStream.WriteFloat ( float  value)
inline

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

Parameters
valueThe value to write

◆ WriteInt32()

void Google.Protobuf.CodedOutputStream.WriteInt32 ( int  value)
inline

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

Parameters
valueThe value to write

◆ WriteInt64()

void Google.Protobuf.CodedOutputStream.WriteInt64 ( long  value)
inline

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

Parameters
valueThe value to write

◆ WriteLength()

void Google.Protobuf.CodedOutputStream.WriteLength ( int  length)
inline

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

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

Parameters
lengthLength value, in bytes.

◆ WriteMessage()

void Google.Protobuf.CodedOutputStream.WriteMessage ( IMessage  value)
inline

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

Parameters
valueThe value to write

◆ WriteRawTag() [1/5]

void Google.Protobuf.CodedOutputStream.WriteRawTag ( byte  b1)
inline

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

Parameters
b1The encoded tag

◆ WriteRawTag() [2/5]

void Google.Protobuf.CodedOutputStream.WriteRawTag ( byte  b1,
byte  b2 
)
inline

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

Parameters
b1The first byte of the encoded tag
b2The second byte of the encoded tag

◆ WriteRawTag() [3/5]

void Google.Protobuf.CodedOutputStream.WriteRawTag ( byte  b1,
byte  b2,
byte  b3 
)
inline

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

Parameters
b1The first byte of the encoded tag
b2The second byte of the encoded tag
b3The third byte of the encoded tag

◆ WriteRawTag() [4/5]

void Google.Protobuf.CodedOutputStream.WriteRawTag ( byte  b1,
byte  b2,
byte  b3,
byte  b4 
)
inline

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

Parameters
b1The first byte of the encoded tag
b2The second byte of the encoded tag
b3The third byte of the encoded tag
b4The fourth byte of the encoded tag

◆ WriteRawTag() [5/5]

void Google.Protobuf.CodedOutputStream.WriteRawTag ( byte  b1,
byte  b2,
byte  b3,
byte  b4,
byte  b5 
)
inline

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

Parameters
b1The first byte of the encoded tag
b2The second byte of the encoded tag
b3The third byte of the encoded tag
b4The fourth byte of the encoded tag
b5The fifth byte of the encoded tag

◆ WriteSFixed32()

void Google.Protobuf.CodedOutputStream.WriteSFixed32 ( int  value)
inline

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

Parameters
valueThe value to write.

◆ WriteSFixed64()

void Google.Protobuf.CodedOutputStream.WriteSFixed64 ( long  value)
inline

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

Parameters
valueThe value to write

◆ WriteSInt32()

void Google.Protobuf.CodedOutputStream.WriteSInt32 ( int  value)
inline

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

Parameters
valueThe value to write

◆ WriteSInt64()

void Google.Protobuf.CodedOutputStream.WriteSInt64 ( long  value)
inline

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

Parameters
valueThe value to write

◆ WriteString()

void Google.Protobuf.CodedOutputStream.WriteString ( string  value)
inline

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

Parameters
valueThe value to write

◆ WriteTag() [1/2]

void Google.Protobuf.CodedOutputStream.WriteTag ( int  fieldNumber,
WireFormat.WireType  type 
)
inline

Encodes and writes a tag.

Parameters
fieldNumberThe number of the field to write the tag for
typeThe wire format type of the tag to write

◆ WriteTag() [2/2]

void Google.Protobuf.CodedOutputStream.WriteTag ( uint  tag)
inline

Writes an already-encoded tag.

Parameters
tagThe encoded tag

◆ WriteUInt32()

void Google.Protobuf.CodedOutputStream.WriteUInt32 ( uint  value)
inline

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

Parameters
valueThe value to write

◆ WriteUInt64()

void Google.Protobuf.CodedOutputStream.WriteUInt64 ( ulong  value)
inline

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

Parameters
valueThe value to write

Member Data Documentation

◆ DefaultBufferSize

readonly int Google.Protobuf.CodedOutputStream.DefaultBufferSize = 4096
static

The buffer size used by CreateInstance(Stream).

Property Documentation

◆ Position

long Google.Protobuf.CodedOutputStream.Position
get

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

◆ SpaceLeft

int Google.Protobuf.CodedOutputStream.SpaceLeft
get

If writing to a flat array, returns the space left in the array. Otherwise, throws an InvalidOperationException.


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