ISerializer
Description
- Derived from
- Extended by
-
SerializerBase abstract
Base interface for classes that read and write data during conversion of ISerializable objects to binary data streams.
The following methods read or write canonical multibyte values using the byte order of the underlying data stream (see IDataStream.Endianness, for example):
These methods use different binary layouts, depending on the SerializerFlags of the current block, i.e. the innermost paired call to Begin and End:
To achieve binary compatibility with the Protocol Buffers Wire format (see https://protobuf.dev/programming-guides/encoding), use the following methods:
-
VARINT - int32, int64, sint32, sint64, bool, enum
With flags SerializerFlags.None:
IBinaryReader.ReadVarInt32, IBinaryReader.ReadVarInt64
IBinaryWriter.WriteVarInt32, IBinaryWriter.WriteVarInt64
With flags SerializerFlags.UseVarIntForValues:
IBinaryReader.ReadInt8, IBinaryReader.ReadInt16, IBinaryReader.ReadInt32, IBinaryReader.ReadInt64, IBinaryReader.ReadUInt8, IBinaryReader.ReadUInt16, IBinaryReader.ReadUInt32
IBinaryWriter.WriteInt8, IBinaryWriter.WriteInt16, IBinaryWriter.WriteInt32, IBinaryWriter.WriteInt64 -
VARINT - uint32, uint64, bool
With flags SerializerFlags.None:
IBinaryReader.ReadVarUInt32, IBinaryReader.ReadVarUInt64
IBinaryWriter.WriteVarUInt32, IBinaryWriter.WriteVarUInt64
With flags SerializerFlags.UseVarIntForValues and SerializerFlags.UseUnsignedValues:
IBinaryReader.ReadInt8, IBinaryReader.ReadInt16, IBinaryReader.ReadInt32, IBinaryReader.ReadInt64, IBinaryReader.ReadUInt8, IBinaryReader.ReadUInt16, IBinaryReader.ReadUInt32
IBinaryWriter.WriteInt8, IBinaryWriter.WriteInt16, IBinaryWriter.WriteInt32, IBinaryWriter.WriteInt64 -
I64 - fixed64, sfixed64
With flags SerializerFlags.None:
IBinaryReader.ReadInt64, IBinaryWriter.WriteInt64 -
I64 - double
With flags SerializerFlags.None:
IBinaryReader.ReadFloat64, IBinaryWriter.WriteFloat64 -
I32 - fixed32, sfixed32
With flags SerializerFlags.None:
IBinaryReader.ReadInt32, IBinaryWriter.WriteInt32 -
I32 - float
With flags SerializerFlags.None:
IBinaryReader.ReadFloat32, IBinaryWriter.WriteFloat32 -
LEN - string, bytes, embedded messages, packed repeated fields
With flags SerializerFlags.None:
IBinaryReader.ReadVarUInt32, IBinaryReader.ReadVarUInt64
IBinaryWriter.WriteVarUInt32, IBinaryWriter.WriteVarUInt64
With flags SerializerFlags.UseVarIntForLength and SerializerFlags.UseUnsignedLength:
ReadLength, WriteLength
With flags SerializerFlags.UseVarIntForLength, SerializerFlags.UseUnsignedLength and SerializerFlags.UseUtf8ForString:
ReadString, WriteString
Public / Methods
ReadLength
Reads the length for the subsequent data token list.
- IOException
-
If an I/O error has occurred.
ReadObject
Returns a data token of the object being deserialized.
- IOException
-
If an I/O error has occurred.
ReadString
Returns a data token of the object being deserialized.
The string is read as a length-prefixed (see ReadLength) followed by a sequence of UTF8-, UTF-16 or ISO-8859-1 code units.
- IOException
-
If an I/O error has occurred.
WriteLength
Writes the length of the subsequent value list.
- IOException
-
If an I/O error has occurred.
WriteObject
Writes the value of a data token of the object being serialized.
- IOException
-
If an I/O error has occurred.
WriteString
Writes the value of a data token of the object being serialized.
The given string value in is written as a length-prefixed (see WriteLength) followed by a sequence of UTF8-, UTF-16 or ISO-8859-1 code units.
- IOException
-
If an I/O error has occurred.
Extensions
ReadArray
2 overloads
Reads an array of objects with ReadObjectAs.
The array length is read with ISerializer.ReadLength. If not null
, ReadObjectAs is used to read the array elements.
- IOException
-
If an I/O error has occurred.
- See also
Deserializes a struct value array form the given serialization stream.
The array length is read with ISerializer.ReadLength. If not null
, ITypeSerializer.ReadValue is used to read the array elements.
- IOException
-
If an I/O error has occurred.
ReadBoolArray
Returns a data token of the object being deserialized.
The array length is read with ISerializer.ReadLength. If not null
, IBinaryReader.ReadBools is used to read the array elements.
- IOException
-
If an I/O error has occurred.
- See also
ReadCharArray
Returns a data token of the object being deserialized.
The array length is read with ISerializer.ReadLength. If not null
, IBinaryReader.ReadChars is used to read the array elements.
- IOException
-
If an I/O error has occurred.
ReadCollection
2 overloads
Reads a collection of objects with ReadObjectAs.
The collection length is read with ISerializer.ReadLength. If not null
, ReadObjectAs is used to read the collection elements.
- IOException
-
If an I/O error has occurred.
- See also
Deserializes a struct value collection from the given serialization stream.
The collection length is read with ISerializer.ReadLength. If not null
, ITypeSerializer.ReadValue is used to read the collection elements.
- IOException
-
If an I/O error has occurred.
ReadEnum
2 overloads
Reads an enumerated value.
The given enumeration type should have the SemanticEnum attribute.
- IOException
-
If an I/O error has occurred.
- See also
Reads an enumerated value.
- IOException
-
If an I/O error has occurred.
- See also
ReadEnumFlags
2 overloads
Reads a set of enumerated values.
The given enumeration type should have the SemanticEnum attribute.
- IOException
-
If an I/O error has occurred.
- See also
Reads a set of enumerated values.
The given enumeration type should have the SemanticEnum attribute.
- IOException
-
If an I/O error has occurred.
- See also
ReadFloat32Array
Returns a data token of the object being deserialized.
The array length is read with ISerializer.ReadLength. If not null
, IBinaryReader.ReadFloat32s is used to read the array elements.
- IOException
-
If an I/O error has occurred.
- See also
ReadFloat64Array
Returns a data token of the object being deserialized.
The array length is read with ISerializer.ReadLength. If not null
, IBinaryReader.ReadFloat64s is used to read the array elements.
- IOException
-
If an I/O error has occurred.
- See also
ReadInt16Array
Returns a data token of the object being deserialized.
The array length is read with ISerializer.ReadLength. If not null
, IBinaryReader.ReadInt16s is used to read the array elements.
- IOException
-
If an I/O error has occurred.
ReadInt32Array
Returns a data token of the object being deserialized.
The array length is read with ISerializer.ReadLength. If not null
, IBinaryReader.ReadInt32s is used to read the array elements.
- IOException
-
If an I/O error has occurred.
ReadInt64Array
Returns a data token of the object being deserialized.
The array length is read with ISerializer.ReadLength. If not null
, IBinaryReader.ReadInt64s is used to read the array elements.
- IOException
-
If an I/O error has occurred.
ReadInt8Array
Returns a data token of the object being deserialized.
The array length is read with ISerializer.ReadLength. If not null
, IBinaryReader.ReadInt8s is used to read the array elements.
- IOException
-
If an I/O error has occurred.
- See also
ReadObjectAs
Returns a data token of the object being deserialized.
- IOException
-
If an I/O error has occurred.
- See also
ReadValue
Reads a value by delegating to ITypeSerializer.ReadValue.
- IOException
-
If an I/O error has occurred.
- See also
WriteArray
3 overloads
Serializes an array of objects.
The array length is written with ISerializer.WriteLength. If not null
, ISerializer.WriteObject is used to write the array elements.
- IOException
-
If an I/O error has occurred.
- See also
Serializes the given struct value array to the serialization stream.
The array length is written with ISerializer.WriteLength. If not null
, ITypeSerializer.WriteValue is used to write the array elements.
- IOException
-
If an I/O error has occurred.
Serializes the given struct value array to the serialization stream.
The array length is written with ISerializer.WriteLength. If not null
, ITypeSerializer.WriteValue is used to write the array elements.
- IOException
-
If an I/O error has occurred.
WriteBoolArray
2 overloads
Writes the value of a data token of the object being serialized.
The array length is written with ISerializer.WriteLength. If not null
, IBinaryWriter.WriteBools is used to write the array elements.
- IOException
-
If an I/O error has occurred.
- See also
Writes the value of a data token of the object being serialized.
The array length is written with ISerializer.WriteLength. If not null
, IBinaryWriter.WriteBools is used to write the array elements.
- IOException
-
If an I/O error has occurred.
- See also
WriteCharArray
2 overloads
Writes the value of a data token of the object being serialized.
The array length is written with ISerializer.WriteLength. If not null
, IBinaryWriter.WriteChars is used to write the array elements.
- IOException
-
If an I/O error has occurred.
Writes the value of a data token of the object being serialized.
The array length is written with ISerializer.WriteLength. If not null
, IBinaryWriter.WriteChars is used to write the array elements.
- IOException
-
If an I/O error has occurred.
WriteCollection
2 overloads
Writes a collection of objects.
The collection length is written with ISerializer.WriteLength. If not null
, ISerializer.WriteObject is used to write the array elements.
- IOException
-
If an I/O error has occurred.
- See also
Serializes the given struct value collection to the serialization stream.
The collection length is written with ISerializer.WriteLength. If not null
, ITypeSerializer.WriteValue is used to write the collection elements.
- IOException
-
If an I/O error has occurred.
WriteEnum
2 overloads
Writes an enumerated value.
The given enumeration type resp. enumeration item should have the SemanticEnum attribute.
- IOException
-
If an I/O error has occurred.
- See also
Writes an enumerated value.
- IOException
-
If an I/O error has occurred.
- See also
WriteEnumFlags
2 overloads
Writes a set of enumerated values.
The given enumeration type should have the SemanticEnum attribute.
- IOException
-
If an I/O error has occurred.
- See also
Writes a set of enumerated values.
- IOException
-
If an I/O error has occurred.
- See also
WriteFloat32Array
2 overloads
Writes the value of a data token of the object being serialized.
The array length is written with ISerializer.WriteLength. If not null
, IBinaryWriter.WriteFloat32s is used to write the array elements.
- IOException
-
If an I/O error has occurred.
- See also
Writes the value of a data token of the object being serialized.
The array length is written with ISerializer.WriteLength. If not null
, IBinaryWriter.WriteFloat32s is used to write the array elements.
- IOException
-
If an I/O error has occurred.
- See also
WriteFloat64Array
2 overloads
Writes the value of a data token of the object being serialized.
The array length is written with ISerializer.WriteLength. If not null
, IBinaryWriter.WriteFloat64s is used to write the array elements.
- IOException
-
If an I/O error has occurred.
- See also
Writes the value of a data token of the object being serialized.
The array length is written with ISerializer.WriteLength. If not null
, IBinaryWriter.WriteFloat64s is used to write the array elements.
- IOException
-
If an I/O error has occurred.
- See also
WriteInt16Array
2 overloads
Writes the value of a data token of the object being serialized.
The array length is written with ISerializer.WriteLength. If not null
, IBinaryWriter.WriteInt16s is used to write the array elements.
- IOException
-
If an I/O error has occurred.
Writes the value of a data token of the object being serialized.
The array length is written with ISerializer.WriteLength. If not null
, IBinaryWriter.WriteInt16s is used to write the array elements.
- IOException
-
If an I/O error has occurred.
WriteInt32Array
2 overloads
Writes the value of a data token of the object being serialized.
The array length is written with ISerializer.WriteLength. If not null
, IBinaryWriter.WriteInt32s is used to write the array elements.
- IOException
-
If an I/O error has occurred.
Writes the value of a data token of the object being serialized.
The array length is written with ISerializer.WriteLength. If not null
, IBinaryWriter.WriteInt32s is used to write the array elements.
- IOException
-
If an I/O error has occurred.
WriteInt64Array
2 overloads
Writes the value of a data token of the object being serialized.
The array length is written with ISerializer.WriteLength. If not null
, IBinaryWriter.WriteInt64s is used to write the array elements.
- IOException
-
If an I/O error has occurred.
Writes the value of a data token of the object being serialized.
The array length is written with ISerializer.WriteLength. If not null
, IBinaryWriter.WriteInt64s is used to write the array elements.
- IOException
-
If an I/O error has occurred.
WriteInt8Array
2 overloads
Writes the value of a data token of the object being serialized.
The array length is written with ISerializer.WriteLength. If not null
, IBinaryWriter.WriteInt8s is used to write the array elements.
- IOException
-
If an I/O error has occurred.
- See also
Writes the value of a data token of the object being serialized.
The array length is written with ISerializer.WriteLength. If not null
, IBinaryWriter.WriteInt8s is used to write the array elements.
- IOException
-
If an I/O error has occurred.
- See also
WriteValue
Writes a value by delegating to ITypeSerializer.WriteValue.
- IOException
-
If an I/O error has occurred.
- See also