Space Engineers
|
A stateful reader, used to read a protobuf stream. Typical usage would be (sequentially) to call ReadFieldHeader and (after matching the field) an appropriate Read* method. More...
Public Member Functions | |
ProtoReader (Stream source, TypeModel model, SerializationContext context) | |
Creates a new reader against a stream More... | |
ProtoReader (Stream source, TypeModel model, SerializationContext context, int length) | |
Creates a new reader against a stream More... | |
void | Dispose () |
Releases resources used by the reader, but importantly does not Dispose the underlying stream; in many typical use-cases the stream is used for different processes, so it is assumed that the consumer will Dispose their stream separately. More... | |
uint | ReadUInt32 () |
Reads an unsigned 32-bit integer from the stream; supported wire-types: Variant, Fixed32, Fixed64 More... | |
short | ReadInt16 () |
Reads a signed 16-bit integer from the stream: Variant, Fixed32, Fixed64, SignedVariant More... | |
ushort | ReadUInt16 () |
Reads an unsigned 16-bit integer from the stream; supported wire-types: Variant, Fixed32, Fixed64 More... | |
byte | ReadByte () |
Reads an unsigned 8-bit integer from the stream; supported wire-types: Variant, Fixed32, Fixed64 More... | |
sbyte | ReadSByte () |
Reads a signed 8-bit integer from the stream; supported wire-types: Variant, Fixed32, Fixed64, SignedVariant More... | |
int | ReadInt32 () |
Reads a signed 32-bit integer from the stream; supported wire-types: Variant, Fixed32, Fixed64, SignedVariant More... | |
long | ReadInt64 () |
Reads a signed 64-bit integer from the stream; supported wire-types: Variant, Fixed32, Fixed64, SignedVariant More... | |
string | ReadString () |
Reads a string from the stream (using UTF8); supported wire-types: String More... | |
void | ThrowEnumException (System.Type type, int value) |
Throws an exception indication that the given value cannot be mapped to an enum. More... | |
unsafe double | ReadDouble () |
Reads a double-precision number from the stream; supported wire-types: Fixed32, Fixed64 More... | |
int | ReadFieldHeader () |
Reads a field header from the stream, setting the wire-type and retuning the field number. If no more fields are available, then 0 is returned. This methods respects sub-messages. More... | |
bool | TryReadFieldHeader (int field) |
Looks ahead to see whether the next field in the stream is what we expect (typically; what we've just finished reading - for example ot read successive list items) More... | |
void | Hint (WireType wireType) |
Compares the streams current wire-type to the hinted wire-type, updating the reader if necessary; for example, a Variant may be updated to SignedVariant. If the hinted wire-type is unrelated then no change is made. More... | |
void | Assert (WireType wireType) |
Verifies that the stream's current wire-type is as expected, or a specialized sub-type (for example, SignedVariant) - in which case the current wire-type is updated. Otherwise an exception is thrown. More... | |
void | SkipField () |
Discards the data for the current field. More... | |
ulong | ReadUInt64 () |
Reads an unsigned 64-bit integer from the stream; supported wire-types: Variant, Fixed32, Fixed64 More... | |
unsafe float | ReadSingle () |
Reads a single-precision number from the stream; supported wire-types: Fixed32, Fixed64 More... | |
bool | ReadBoolean () |
Reads a boolean value from the stream; supported wire-types: Variant, Fixed32, Fixed64 More... | |
void | AppendExtensionData (IExtensible instance) |
Copies the current field into the instance as extension data More... | |
System.Type | ReadType () |
Reads a Type from the stream, using the model's DynamicTypeFormatting if appropriate; supported wire-types: String More... | |
Static Public Member Functions | |
static object | ReadObject (object value, int key, ProtoReader reader) |
Reads (merges) a sub-message from the stream, internally calling StartSubItem and EndSubItem, and (in between) parsing the message in accordance with the model associated with the reader More... | |
static void | EndSubItem (SubItemToken token, ProtoReader reader) |
Makes the end of consuming a nested message in the stream; the stream must be either at the correct EndGroup marker, or all fields of the sub-message must have been consumed (in either case, this means ReadFieldHeader should return zero) More... | |
static SubItemToken | StartSubItem (ProtoReader reader) |
Begins consuming a nested message in the stream; supported wire-types: StartGroup, String More... | |
static byte[] | AppendBytes (byte[] value, ProtoReader reader) |
Reads a byte-sequence from the stream, appending them to an existing byte-sequence (which can be null); supported wire-types: String More... | |
static int | ReadLengthPrefix (Stream source, bool expectHeader, PrefixStyle style, out int fieldNumber) |
Reads the length-prefix of a message from a stream without buffering additional data, allowing a fixed-length reader to be created. More... | |
static int | DirectReadLittleEndianInt32 (Stream source) |
Reads a little-endian encoded integer. An exception is thrown if the data is not all available. More... | |
static int | DirectReadBigEndianInt32 (Stream source) |
Reads a big-endian encoded integer. An exception is thrown if the data is not all available. More... | |
static int | DirectReadVarintInt32 (Stream source) |
Reads a varint encoded integer. An exception is thrown if the data is not all available. More... | |
static void | DirectReadBytes (Stream source, byte[] buffer, int offset, int count) |
Reads a string (of a given lenth, in bytes) directly from the source into a pre-existing buffer. An exception is thrown if the data is not all available. More... | |
static byte[] | DirectReadBytes (Stream source, int count) |
Reads a given number of bytes directly from the source. An exception is thrown if the data is not all available. More... | |
static string | DirectReadString (Stream source, int length) |
Reads a string (of a given lenth, in bytes) directly from the source. An exception is thrown if the data is not all available. More... | |
static int | ReadLengthPrefix (Stream source, bool expectHeader, PrefixStyle style, out int fieldNumber, out int bytesRead) |
Reads the length-prefix of a message from a stream without buffering additional data, allowing a fixed-length reader to be created. More... | |
static bool | HasSubValue (ProtoBuf.WireType wireType, ProtoReader source) |
Indicates whether the reader still has data remaining in the current sub-item, additionally setting the wire-type for the next field if there is more data. This is used when decoding packed data. More... | |
static void | NoteObject (object value, ProtoReader reader) |
Utility method, not intended for public use; this helps maintain the root object is complex scenarios More... | |
static object | Merge (ProtoReader parent, object from, object to) |
Merge two objects using the details from the current reader; this is used to change the type of objects when an inheritance relationship is discovered later than usual during deserilazation. More... | |
Properties | |
int | FieldNumber [get] |
Gets the number of the field being processed. More... | |
WireType | WireType [get] |
Indicates the underlying proto serialization format on the wire. More... | |
bool | InternStrings [get, set] |
Gets / sets a flag indicating whether strings should be checked for repetition; if true, any repeated UTF-8 byte sequence will result in the same String instance, rather than a second instance of the same string. Enabled by default. Note that this uses a custom interner - the system-wide string interner is not used. More... | |
SerializationContext | Context [get] |
Addition information about this deserialization operation. More... | |
int | Position [get] |
Returns the position of the current reader (note that this is not necessarily the same as the position in the underlying stream, if multiple readers are used on the same stream) More... | |
TypeModel | Model [get] |
Get the TypeModel associated with this reader More... | |
A stateful reader, used to read a protobuf stream. Typical usage would be (sequentially) to call ReadFieldHeader and (after matching the field) an appropriate Read* method.
Definition at line 24 of file ProtoReader.cs.
|
inline |
Creates a new reader against a stream
source | The source stream |
model | The model to use for serialization; this can be null, but this will impair the ability to deserialize sub-objects |
context | Additional context about this serialization operation |
Definition at line 47 of file ProtoReader.cs.
|
inline |
Creates a new reader against a stream
source | The source stream |
model | The model to use for serialization; this can be null, but this will impair the ability to deserialize sub-objects |
context | Additional context about this serialization operation |
length | The number of bytes to read, or -1 to read until the end of the stream |
Definition at line 71 of file ProtoReader.cs.
|
inlinestatic |
Reads a byte-sequence from the stream, appending them to an existing byte-sequence (which can be null); supported wire-types: String
Definition at line 861 of file ProtoReader.cs.
|
inline |
Copies the current field into the instance as extension data
Definition at line 1174 of file ProtoReader.cs.
|
inline |
Verifies that the stream's current wire-type is as expected, or a specialized sub-type (for example, SignedVariant) - in which case the current wire-type is updated. Otherwise an exception is thrown.
Definition at line 704 of file ProtoReader.cs.
|
inlinestatic |
Reads a big-endian encoded integer. An exception is thrown if the data is not all available.
Definition at line 953 of file ProtoReader.cs.
|
inlinestatic |
Reads a string (of a given lenth, in bytes) directly from the source into a pre-existing buffer. An exception is thrown if the data is not all available.
Definition at line 973 of file ProtoReader.cs.
|
inlinestatic |
Reads a given number of bytes directly from the source. An exception is thrown if the data is not all available.
Definition at line 986 of file ProtoReader.cs.
|
inlinestatic |
Reads a little-endian encoded integer. An exception is thrown if the data is not all available.
Definition at line 943 of file ProtoReader.cs.
|
inlinestatic |
Reads a string (of a given lenth, in bytes) directly from the source. An exception is thrown if the data is not all available.
Definition at line 995 of file ProtoReader.cs.
|
inlinestatic |
Reads a varint encoded integer. An exception is thrown if the data is not all available.
Definition at line 963 of file ProtoReader.cs.
|
inline |
Releases resources used by the reader, but importantly does not Dispose the underlying stream; in many typical use-cases the stream is used for different processes, so it is assumed that the consumer will Dispose their stream separately.
Definition at line 96 of file ProtoReader.cs.
|
inlinestatic |
Makes the end of consuming a nested message in the stream; the stream must be either at the correct EndGroup marker, or all fields of the sub-message must have been consumed (in either case, this means ReadFieldHeader should return zero)
Definition at line 577 of file ProtoReader.cs.
|
inlinestatic |
Indicates whether the reader still has data remaining in the current sub-item, additionally setting the wire-type for the next field if there is more data. This is used when decoding packed data.
Definition at line 1229 of file ProtoReader.cs.
|
inline |
Compares the streams current wire-type to the hinted wire-type, updating the reader if necessary; for example, a Variant may be updated to SignedVariant. If the hinted wire-type is unrelated then no change is made.
Definition at line 690 of file ProtoReader.cs.
|
inlinestatic |
Merge two objects using the details from the current reader; this is used to change the type of objects when an inheritance relationship is discovered later than usual during deserilazation.
Definition at line 1307 of file ProtoReader.cs.
|
inlinestatic |
Utility method, not intended for public use; this helps maintain the root object is complex scenarios
Definition at line 1268 of file ProtoReader.cs.
|
inline |
Reads a boolean value from the stream; supported wire-types: Variant, Fixed32, Fixed64
Definition at line 847 of file ProtoReader.cs.
|
inline |
Reads an unsigned 8-bit integer from the stream; supported wire-types: Variant, Fixed32, Fixed64
Definition at line 257 of file ProtoReader.cs.
|
inline |
Reads a double-precision number from the stream; supported wire-types: Fixed32, Fixed64
Definition at line 517 of file ProtoReader.cs.
|
inline |
Reads a field header from the stream, setting the wire-type and retuning the field number. If no more fields are available, then 0 is returned. This methods respects sub-messages.
Definition at line 632 of file ProtoReader.cs.
|
inline |
Reads a signed 16-bit integer from the stream: Variant, Fixed32, Fixed64, SignedVariant
Definition at line 242 of file ProtoReader.cs.
|
inline |
Reads a signed 32-bit integer from the stream; supported wire-types: Variant, Fixed32, Fixed64, SignedVariant
Definition at line 273 of file ProtoReader.cs.
|
inline |
Reads a signed 64-bit integer from the stream; supported wire-types: Variant, Fixed32, Fixed64, SignedVariant
Definition at line 312 of file ProtoReader.cs.
|
inlinestatic |
Reads the length-prefix of a message from a stream without buffering additional data, allowing a fixed-length reader to be created.
Definition at line 935 of file ProtoReader.cs.
|
inlinestatic |
Reads the length-prefix of a message from a stream without buffering additional data, allowing a fixed-length reader to be created.
Definition at line 1006 of file ProtoReader.cs.
|
inlinestatic |
Reads (merges) a sub-message from the stream, internally calling StartSubItem and EndSubItem, and (in between) parsing the message in accordance with the model associated with the reader
Definition at line 539 of file ProtoReader.cs.
|
inline |
Reads a signed 8-bit integer from the stream; supported wire-types: Variant, Fixed32, Fixed64, SignedVariant
Definition at line 265 of file ProtoReader.cs.
|
inline |
Reads a single-precision number from the stream; supported wire-types: Fixed32, Fixed64
Definition at line 814 of file ProtoReader.cs.
|
inline |
Reads a string from the stream (using UTF8); supported wire-types: String
Definition at line 466 of file ProtoReader.cs.
|
inline |
Reads a Type from the stream, using the model's DynamicTypeFormatting if appropriate; supported wire-types: String
Definition at line 1280 of file ProtoReader.cs.
|
inline |
Reads an unsigned 16-bit integer from the stream; supported wire-types: Variant, Fixed32, Fixed64
Definition at line 249 of file ProtoReader.cs.
|
inline |
Reads an unsigned 32-bit integer from the stream; supported wire-types: Variant, Fixed32, Fixed64
Definition at line 177 of file ProtoReader.cs.
|
inline |
Reads an unsigned 64-bit integer from the stream; supported wire-types: Variant, Fixed32, Fixed64
Definition at line 782 of file ProtoReader.cs.
|
inline |
Discards the data for the current field.
Definition at line 720 of file ProtoReader.cs.
|
inlinestatic |
Begins consuming a nested message in the stream; supported wire-types: StartGroup, String
The token returned must be help and used when callining EndSubItem
Definition at line 607 of file ProtoReader.cs.
|
inline |
Throws an exception indication that the given value cannot be mapped to an enum.
Definition at line 497 of file ProtoReader.cs.
|
inline |
Looks ahead to see whether the next field in the stream is what we expect (typically; what we've just finished reading - for example ot read successive list items)
Definition at line 661 of file ProtoReader.cs.
|
get |
Addition information about this deserialization operation.
Definition at line 90 of file ProtoReader.cs.
|
get |
Gets the number of the field being processed.
Definition at line 35 of file ProtoReader.cs.
|
getset |
Gets / sets a flag indicating whether strings should be checked for repetition; if true, any repeated UTF-8 byte sequence will result in the same String instance, rather than a second instance of the same string. Enabled by default. Note that this uses a custom interner - the system-wide string interner is not used.
Definition at line 62 of file ProtoReader.cs.
|
get |
Get the TypeModel associated with this reader
Definition at line 684 of file ProtoReader.cs.
|
get |
Returns the position of the current reader (note that this is not necessarily the same as the position in the underlying stream, if multiple readers are used on the same stream)
Definition at line 203 of file ProtoReader.cs.
|
get |
Indicates the underlying proto serialization format on the wire.
Definition at line 39 of file ProtoReader.cs.