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 (for SerializerFlags.None) using the byte order of the underlying data stream (see IByteEndianness.Endianness):
These methods use different binary layouts, depending on the SerializerFlags of the current block, i.e. the result of 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 inherited methods of the IProtonizer interface or the following ones while IByteEndianness.Endianness is set to ByteOrder.LittleEndian (for multibyte values):
-
VARINT - bool
IByteReader.ReadBool, IByteWriter.WriteBool -
VARINT - sint32, sint64
IByteReader.ReadVarInt32, IByteWriter.WriteVarInt32
With shortcut == false:
IByteReader.ReadVarInt64, IByteWriter.WriteVarInt64
With flags SerializerFlags.UseVarIntForValues:
IByteReader.ReadInt8, IBinaryReader.ReadInt16, IBinaryReader.ReadInt32
IByteWriter.WriteInt8, IBinaryWriter.WriteInt16, IBinaryWriter.WriteInt32
With flags SerializerFlags.UseVarIntForValues and SerializerFlags.UseNoShortcutCode:
IBinaryReader.ReadInt64, IBinaryWriter.WriteInt64 -
VARINT - int32, int64, uint32, uint64, bool, enum
IByteReader.ReadVarUInt32, IByteWriter.WriteVarUInt32
With shortcut == false:
IByteReader.ReadVarUInt64, IByteWriter.WriteVarUInt64
With flags SerializerFlags.UseVarIntForValues and SerializerFlags.UseUnsignedValues:
IByteReader.ReadInt8, IBinaryReader.ReadInt16, IBinaryReader.ReadInt32
IByteWriter.WriteInt8, IBinaryWriter.WriteInt16, IBinaryWriter.WriteInt32
With flags SerializerFlags.UseVarIntForValues, SerializerFlags.UseUnsignedValues and SerializerFlags.UseNoShortcutCode:
IBinaryReader.ReadInt64, IBinaryWriter.WriteInt64 -
I32 - fixed32, sfixed32
Without flag SerializerFlags.UseVarIntForValues:
IBinaryReader.ReadInt32, IBinaryWriter.WriteInt32 -
I32 - float
IBinaryReader.ReadFloat32, IBinaryWriter.WriteFloat32 -
I64 - fixed64, sfixed64
Without flag SerializerFlags.UseVarIntForValues:
IBinaryReader.ReadInt64, IBinaryWriter.WriteInt64 -
I64 - double
IBinaryReader.ReadFloat64, IBinaryWriter.WriteFloat64 -
LEN - string, bytes, embedded messages, packed repeated fields
With flags SerializerFlags.None:
IByteReader.ReadVarUInt32, IByteWriter.WriteVarUInt32
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.
The object payload is length-prefixed (see ReadLength).
- 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) 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.
The object payload is length-prefixed (see WriteLength).
- 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) 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
, IByteReader.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 with IByteReader.ReadVarUInt64, using shortcut coding.
The given enumeration type should have the SemanticEnum attribute.
- IOException
-
If an I/O error has occurred.
- See also
Reads an enumerated value with IByteReader.ReadVarUInt32.
- IOException
-
If an I/O error has occurred.
- See also
ReadEnumFlags
2 overloads
Reads a set of enumerated values with IByteReader.ReadVarUInt64, using shortcut coding.
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 with IByteReader.ReadVarUInt64, using shortcut coding.
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
, IByteReader.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.
This method delegates to ISerializer.ReadObject and then tries to cast the resulting object to the given target type.
- 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
, IByteWriter.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
, IByteWriter.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 with IByteWriter.WriteVarUInt64, using shortcut coding.
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 with IByteWriter.WriteVarUInt32.
- IOException
-
If an I/O error has occurred.
- See also
WriteEnumFlags
2 overloads
Writes a set of enumerated values with IByteWriter.WriteVarUInt64, using shortcut coding.
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 with IByteWriter.WriteVarUInt64, using shortcut coding.
- 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
, IByteWriter.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
, IByteWriter.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