C# Class ProtoBuf.ProtoWriter

Represents an output stream for writing protobuf data. Why is the API backwards (static methods with writer arguments)? See: http://marcgravell.blogspot.com/2010/03/last-will-be-first-and-first-will-be.html
Inheritance: IDisposable
Afficher le fichier Open project: egametang/Egametang Class Usage Examples

Private Properties

Свойство Type Description
CheckDepthFlushlock void
CheckRecursionStackAndPush void
CopyRawFromStream void
CreateException System.Exception
DemandSpace void
Dispose void
EndSubItem void
Flush void
GetPosition int
GetTypeKey int
IDisposable void
IncrementedAndReset void
PopRecursionStack void
SerializeType string
StartSubItem ProtoBuf.SubItemToken
WriteHeaderCore void
WriteInt32ToBuffer void
WriteObject void
WriteUInt32Variant void
WriteUInt64Variant void
Zig uint
Zig ulong

Méthodes publiques

Méthode Description
AppendExtensionData ( IExtensible instance, ProtoWriter writer ) : void

Copies any extension data stored for the instance to the underlying stream

Close ( ) : void

Flushes data to the underlying stream, and releases any resources. The underlying stream is *not* disposed by this operation.

EndSubItem ( ProtoBuf.SubItemToken token, ProtoWriter writer ) : void

Indicates the end of a nested record.

ProtoWriter ( Stream dest, ProtoBuf.Meta.TypeModel model, ProtoBuf.SerializationContext context ) : System

Creates a new writer against a stream

SetPackedField ( int fieldNumber, ProtoWriter writer ) : void

Used for packed encoding; indicates that the next field should be skipped rather than a field header written. Note that the field number must match, else an exception is thrown when the attempt is made to write the (incorrect) field. The wire-type is taken from the subsequent call to WriteFieldHeader. Only primitive types can be packed.

SetRootObject ( object value ) : void

Specifies a known root object to use during reference-tracked serialization

StartSubItem ( object instance, ProtoWriter writer ) : ProtoBuf.SubItemToken

Indicates the start of a nested record.

ThrowEnumException ( ProtoWriter writer, object enumValue ) : void

Throws an exception indicating that the given enum cannot be mapped to a serialized value.

WriteBoolean ( bool value, ProtoWriter writer ) : void

Writes a boolean to the stream; supported wire-types: Variant, Fixed32, Fixed64

WriteByte ( byte value, ProtoWriter writer ) : void

Writes an unsigned 8-bit integer to the stream; supported wire-types: Variant, Fixed32, Fixed64

WriteBytes ( byte data, ProtoWriter writer ) : void

Writes a byte-array to the stream; supported wire-types: String

WriteBytes ( byte data, int offset, int length, ProtoWriter writer ) : void

Writes a byte-array to the stream; supported wire-types: String

WriteDouble ( double value, ProtoWriter writer ) : void

Writes a double-precision number to the stream; supported wire-types: Fixed32, Fixed64

WriteFieldHeader ( int fieldNumber, WireType wireType, ProtoWriter writer ) : void

Writes a field-header, indicating the format of the next data we plan to write.

WriteInt16 ( short value, ProtoWriter writer ) : void

Writes a signed 16-bit integer to the stream; supported wire-types: Variant, Fixed32, Fixed64, SignedVariant

WriteInt32 ( int value, ProtoWriter writer ) : void

Writes a signed 32-bit integer to the stream; supported wire-types: Variant, Fixed32, Fixed64, SignedVariant

WriteInt64 ( long value, ProtoWriter writer ) : void

Writes a signed 64-bit integer to the stream; supported wire-types: Variant, Fixed32, Fixed64, SignedVariant

WriteObject ( object value, int key, ProtoWriter writer ) : void

Write an encapsulated sub-object, using the supplied unique key (reprasenting a type).

WriteRecursionSafeObject ( object value, int key, ProtoWriter writer ) : void

Write an encapsulated sub-object, using the supplied unique key (reprasenting a type) - but the caller is asserting that this relationship is non-recursive; no recursion check will be performed.

WriteSByte ( sbyte value, ProtoWriter writer ) : void

Writes a signed 8-bit integer to the stream; supported wire-types: Variant, Fixed32, Fixed64, SignedVariant

WriteSingle ( float value, ProtoWriter writer ) : void
WriteString ( string value, ProtoWriter writer ) : void

Writes a string to the stream; supported wire-types: String

WriteType ( System value, ProtoWriter writer ) : void

Writes a Type to the stream, using the model's DynamicTypeFormatting if appropriate; supported wire-types: String

WriteUInt16 ( ushort value, ProtoWriter writer ) : void

Writes an unsigned 16-bit integer to the stream; supported wire-types: Variant, Fixed32, Fixed64

WriteUInt32 ( uint value, ProtoWriter writer ) : void

Writes an unsigned 16-bit integer to the stream; supported wire-types: Variant, Fixed32, Fixed64

WriteUInt64 ( ulong value, ProtoWriter writer ) : void

Writes an unsigned 64-bit integer to the stream; supported wire-types: Variant, Fixed32, Fixed64

Private Methods

Méthode Description
CheckDepthFlushlock ( ) : void
CheckRecursionStackAndPush ( object instance ) : void
CopyRawFromStream ( Stream source, ProtoWriter writer ) : void
CreateException ( ProtoWriter writer ) : Exception
DemandSpace ( int required, ProtoWriter writer ) : void
Dispose ( ) : void
EndSubItem ( ProtoBuf.SubItemToken token, ProtoWriter writer, PrefixStyle style ) : void
Flush ( ProtoWriter writer ) : void

Writes any buffered data (if possible) to the underlying stream.

It is not always possible to fully flush, since some sequences may require values to be back-filled into the byte-stream.

GetPosition ( ProtoWriter writer ) : int
GetTypeKey ( IKVM.Reflection.Type &type ) : int
IDisposable ( ) : void
IncrementedAndReset ( int length, ProtoWriter writer ) : void
PopRecursionStack ( ) : void
SerializeType ( System type ) : string
StartSubItem ( object instance, ProtoWriter writer, bool allowFixed ) : ProtoBuf.SubItemToken
WriteHeaderCore ( int fieldNumber, WireType wireType, ProtoWriter writer ) : void
WriteInt32ToBuffer ( int value, byte buffer, int index ) : void
WriteObject ( object value, int key, ProtoWriter writer, PrefixStyle style, int fieldNumber ) : void
WriteUInt32Variant ( uint value, ProtoWriter writer ) : void

Writes an unsigned 32-bit integer to the stream; supported wire-types: Variant, Fixed32, Fixed64

WriteUInt64Variant ( ulong value, ProtoWriter writer ) : void
Zig ( int value ) : uint
Zig ( long value ) : ulong

Method Details

AppendExtensionData() public static méthode

Copies any extension data stored for the instance to the underlying stream
public static AppendExtensionData ( IExtensible instance, ProtoWriter writer ) : void
instance IExtensible
writer ProtoWriter
Résultat void

Close() public méthode

Flushes data to the underlying stream, and releases any resources. The underlying stream is *not* disposed by this operation.
public Close ( ) : void
Résultat void

EndSubItem() public static méthode

Indicates the end of a nested record.
public static EndSubItem ( ProtoBuf.SubItemToken token, ProtoWriter writer ) : void
token ProtoBuf.SubItemToken The token obtained from StartubItem.
writer ProtoWriter The destination.
Résultat void

ProtoWriter() public méthode

Creates a new writer against a stream
public ProtoWriter ( Stream dest, ProtoBuf.Meta.TypeModel model, ProtoBuf.SerializationContext context ) : System
dest Stream The destination stream
model ProtoBuf.Meta.TypeModel The model to use for serialization; this can be null, but this will impair the ability to serialize sub-objects
context ProtoBuf.SerializationContext Additional context about this serialization operation
Résultat System

SetPackedField() public static méthode

Used for packed encoding; indicates that the next field should be skipped rather than a field header written. Note that the field number must match, else an exception is thrown when the attempt is made to write the (incorrect) field. The wire-type is taken from the subsequent call to WriteFieldHeader. Only primitive types can be packed.
public static SetPackedField ( int fieldNumber, ProtoWriter writer ) : void
fieldNumber int
writer ProtoWriter
Résultat void

SetRootObject() public méthode

Specifies a known root object to use during reference-tracked serialization
public SetRootObject ( object value ) : void
value object
Résultat void

StartSubItem() public static méthode

Indicates the start of a nested record.
public static StartSubItem ( object instance, ProtoWriter writer ) : ProtoBuf.SubItemToken
instance object The instance to write.
writer ProtoWriter The destination.
Résultat ProtoBuf.SubItemToken

ThrowEnumException() public static méthode

Throws an exception indicating that the given enum cannot be mapped to a serialized value.
public static ThrowEnumException ( ProtoWriter writer, object enumValue ) : void
writer ProtoWriter
enumValue object
Résultat void

WriteBoolean() public static méthode

Writes a boolean to the stream; supported wire-types: Variant, Fixed32, Fixed64
public static WriteBoolean ( bool value, ProtoWriter writer ) : void
value bool
writer ProtoWriter
Résultat void

WriteByte() public static méthode

Writes an unsigned 8-bit integer to the stream; supported wire-types: Variant, Fixed32, Fixed64
public static WriteByte ( byte value, ProtoWriter writer ) : void
value byte
writer ProtoWriter
Résultat void

WriteBytes() public static méthode

Writes a byte-array to the stream; supported wire-types: String
public static WriteBytes ( byte data, ProtoWriter writer ) : void
data byte
writer ProtoWriter
Résultat void

WriteBytes() public static méthode

Writes a byte-array to the stream; supported wire-types: String
public static WriteBytes ( byte data, int offset, int length, ProtoWriter writer ) : void
data byte
offset int
length int
writer ProtoWriter
Résultat void

WriteDouble() public static méthode

Writes a double-precision number to the stream; supported wire-types: Fixed32, Fixed64
public static WriteDouble ( double value, ProtoWriter writer ) : void
value double
writer ProtoWriter
Résultat void

WriteFieldHeader() public static méthode

Writes a field-header, indicating the format of the next data we plan to write.
public static WriteFieldHeader ( int fieldNumber, WireType wireType, ProtoWriter writer ) : void
fieldNumber int
wireType WireType
writer ProtoWriter
Résultat void

WriteInt16() public static méthode

Writes a signed 16-bit integer to the stream; supported wire-types: Variant, Fixed32, Fixed64, SignedVariant
public static WriteInt16 ( short value, ProtoWriter writer ) : void
value short
writer ProtoWriter
Résultat void

WriteInt32() public static méthode

Writes a signed 32-bit integer to the stream; supported wire-types: Variant, Fixed32, Fixed64, SignedVariant
public static WriteInt32 ( int value, ProtoWriter writer ) : void
value int
writer ProtoWriter
Résultat void

WriteInt64() public static méthode

Writes a signed 64-bit integer to the stream; supported wire-types: Variant, Fixed32, Fixed64, SignedVariant
public static WriteInt64 ( long value, ProtoWriter writer ) : void
value long
writer ProtoWriter
Résultat void

WriteObject() public static méthode

Write an encapsulated sub-object, using the supplied unique key (reprasenting a type).
public static WriteObject ( object value, int key, ProtoWriter writer ) : void
value object The object to write.
key int The key that uniquely identifies the type within the model.
writer ProtoWriter The destination.
Résultat void

WriteRecursionSafeObject() public static méthode

Write an encapsulated sub-object, using the supplied unique key (reprasenting a type) - but the caller is asserting that this relationship is non-recursive; no recursion check will be performed.
public static WriteRecursionSafeObject ( object value, int key, ProtoWriter writer ) : void
value object The object to write.
key int The key that uniquely identifies the type within the model.
writer ProtoWriter The destination.
Résultat void

WriteSByte() public static méthode

Writes a signed 8-bit integer to the stream; supported wire-types: Variant, Fixed32, Fixed64, SignedVariant
public static WriteSByte ( sbyte value, ProtoWriter writer ) : void
value sbyte
writer ProtoWriter
Résultat void

WriteSingle() public static méthode

public static WriteSingle ( float value, ProtoWriter writer ) : void
value float
writer ProtoWriter
Résultat void

WriteString() public static méthode

Writes a string to the stream; supported wire-types: String
public static WriteString ( string value, ProtoWriter writer ) : void
value string
writer ProtoWriter
Résultat void

WriteType() public static méthode

Writes a Type to the stream, using the model's DynamicTypeFormatting if appropriate; supported wire-types: String
public static WriteType ( System value, ProtoWriter writer ) : void
value System
writer ProtoWriter
Résultat void

WriteUInt16() public static méthode

Writes an unsigned 16-bit integer to the stream; supported wire-types: Variant, Fixed32, Fixed64
public static WriteUInt16 ( ushort value, ProtoWriter writer ) : void
value ushort
writer ProtoWriter
Résultat void

WriteUInt32() public static méthode

Writes an unsigned 16-bit integer to the stream; supported wire-types: Variant, Fixed32, Fixed64
public static WriteUInt32 ( uint value, ProtoWriter writer ) : void
value uint
writer ProtoWriter
Résultat void

WriteUInt64() public static méthode

Writes an unsigned 64-bit integer to the stream; supported wire-types: Variant, Fixed32, Fixed64
public static WriteUInt64 ( ulong value, ProtoWriter writer ) : void
value ulong
writer ProtoWriter
Résultat void