ISerializer

Description

interface Tinman.Core.IO.Serialization.ISerializer

Derived from

IBinaryReader
IBinaryWriter

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:

Public / Methods

Begin


public method Begin → (1)

flags in : SerializerFlags

The serializer flags to use. The initial value is SerializerFlags.None.

Begins a new block with the given flags in.

For each call to Begin, the End method must be called once.

End


public method End → ()

Ends the current block and restores the SerializerFlags.

Read​Length


public method ReadLength → ()

returns → int32

The read length value or -1 for the null list.

Reads the length for the subsequent data token list.

IOException

If an I/O error has occurred.

Read​Object


[OwnerReturn]
public method ReadObject → (1)

allowNull opt : bool = true

Allow null to be returned?

returns → ISerializable

The data token value.

Returns a data token of the object being deserialized.

IOException

If an I/O error has occurred.

Read​String


public method ReadString → ()

returns → string

The data token value.

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.

Write​Length


public method WriteLength → (1)

length in : int32

The length of the value list or -1 for null.

Writes the length of the subsequent value list.

IOException

If an I/O error has occurred.

Write​Object


public method WriteObject → (1)

value in : ISerializable

The data token value.

Writes the value of a data token of the object being serialized.

IOException

If an I/O error has occurred.

Write​String


public method WriteString → (1)

value in : string

The data token value.

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

Read​Array

2 overloads


[OwnerReturn]
public static method ReadArray1 → ()
<T ref : ISerializable>

returns → T [ ]

The read array.

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.


public static method ReadArray2 → (2)<T val>

serializer in : ITypeSerializer<T>

[not-null]
The value serializer to use.

delta opt : bool = false

Use component-wise delta encoding, if supported?

returns → T [ ]

The deserialized value.

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.

Read​Bool​Array


public static method ReadBoolArray → ()

returns → bool [ ]

The data token value.

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.

Read​Char​Array


public static method ReadCharArray → ()

returns → char [ ]

The data token value.

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.

Read​Collection

2 overloads


public static method ReadCollection1 → (1)
<T ref : ISerializable>

collection in : IBag<T>

[not-null]
The output collection.

returns → bool

true if zero or more objects have been added to collection in,
false if the serialized collection is null.

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.


public static method ReadCollection2 → (3)<T val>

values in : IBag<T>

[not-null]
Output for deserialized struct values.

serializer in : ITypeSerializer<T>

[not-null]
The value serializer to use.

delta opt : bool = false

Use component-wise delta encoding, if supported?

returns → bool

true if zero or more objects have been added to values in,
false if the serialized collection is null.

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.

Read​Enum

2 overloads


public static method ReadEnum1 → ()
<T val : Enum>

returns → T

The enumerated value.

Reads an enumerated value.

The given enumeration type should have the SemanticEnum attribute.

IOException

If an I/O error has occurred.


public static method ReadEnum2 → (1)
<T val : Enum>

values in : T [ ]

[not-null]
The array to use for mapping enumerated values to invariant ordinals.

returns → T

The enumerated value.

Reads an enumerated value.

IOException

If an I/O error has occurred.

Read​Enum​Flags

2 overloads


public static method ReadEnumFlags1 → ()
<T val : Enum>

returns → T

The set of enumerated values.

Reads a set of enumerated values.

The given enumeration type should have the SemanticEnum attribute.

IOException

If an I/O error has occurred.


public static method ReadEnumFlags2 → (1)
<T val : Enum>

values in : T [ ]

[not-null]
The array to use for mapping enumerated values to invariant bit indices. The maximum array length is 64.

returns → T

The set of enumerated values.

Reads a set of enumerated values.

The given enumeration type should have the SemanticEnum attribute.

IOException

If an I/O error has occurred.

Read​Float32​Array


public static method ReadFloat32Array → ()

returns → float32 [ ]

The data token value.

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.

Read​Float64​Array


public static method ReadFloat64Array → ()

returns → float64 [ ]

The data token value.

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.

Read​Int16​Array


public static method ReadInt16Array → ()

returns → int16 [ ]

The data token value.

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.

Read​Int32​Array


public static method ReadInt32Array → ()

returns → int32 [ ]

The data token value.

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.

Read​Int64​Array


public static method ReadInt64Array → ()

returns → int64 [ ]

The data token value.

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.

Read​Int8​Array


public static method ReadInt8Array → ()

returns → int8 [ ]

The data token value.

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.

Read​Object​As


[OwnerReturn]
public static method ReadObjectAs → (1)
<T ref : ISerializable>

allowNull opt : bool = true

Allow null to be returned?

returns → T

The data token value.

Returns a data token of the object being deserialized.

IOException

If an I/O error has occurred.

Read​Value


public static method ReadValue → (1)<T val>

format in : ITypeSerializer<T>

[not-null]
The value format to use.

returns → T

The read value.

Reads a value by delegating to ITypeSerializer.ReadValue.

IOException

If an I/O error has occurred.

Write​Array

3 overloads


public static method WriteArray1 → (1)
<T ref : ISerializable>

values in : T [ ]

The object array or null.

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.


public static method WriteArray2 → (3)<T val>

values in : T [ ]

The struct values to serialize.

serializer in : ITypeSerializer<T>

[not-null]
The value serializer to use.

delta opt : bool = false

Use component-wise delta encoding, if supported?

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.


public static method WriteArray3 → (5)<T val>

values in : T [ ]

The struct values to serialize.

first in : int32

[>=0]
Index of first array element to write.

count in : int32

[>=0]
Number array elements to write.

serializer in : ITypeSerializer<T>

[not-null]
The value serializer to use.

delta opt : bool = false

Use component-wise delta encoding, if supported?

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.

Write​Bool​Array

2 overloads


public static method WriteBoolArray1 → (1)

value in : bool [ ]

The data token value.

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.


public static method WriteBoolArray2 → (3)

value in : bool [ ]

The data token value.

first in : int32

[>=0]
Index of first array element to write.

count in : int32

[>=0]
Number array elements to write.

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.

Write​Char​Array

2 overloads


public static method WriteCharArray1 → (1)

value in : char [ ]

The data token value.

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.


public static method WriteCharArray2 → (3)

value in : char [ ]

The data token value.

first in : int32

[>=0]
Index of first array element to write.

count in : int32

[>=0]
Number array elements to write.

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.

Write​Collection

2 overloads


public static method WriteCollection1 → (1)
<T ref : ISerializable>

values in : IBagConst<T>

The object collection or null.

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.


public static method WriteCollection2 → (3)<T val>

values in : IBagConst<T>

The struct values to serialize.

serializer in : ITypeSerializer<T>

[not-null]
The value serializer to use.

delta opt : bool = false

Use component-wise delta encoding, if supported?

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.

Write​Enum

2 overloads


[Pure]
public static method WriteEnum1 → (1)
<T val : Enum>

value in : T

The enumerated value.

Writes an enumerated value.

The given enumeration type resp. enumeration item should have the SemanticEnum attribute.

IOException

If an I/O error has occurred.


[Pure]
public static method WriteEnum2 → (2)
<T val : Enum>

value in : T

The enumerated value.

values in : T [ ]

[not-null]
The array to use for mapping enumerated values to invariant ordinals.

Writes an enumerated value.

IOException

If an I/O error has occurred.

Write​Enum​Flags

2 overloads


[Pure]
public static method WriteEnumFlags1 → (1)
<T val : Enum>

value in : T

The set of enumerated values.

Writes a set of enumerated values.

The given enumeration type should have the SemanticEnum attribute.

IOException

If an I/O error has occurred.


[Pure]
public static method WriteEnumFlags2 → (2)
<T val : Enum>

value in : T

The set of enumerated values.

values in : T [ ]

[not-null]
The array to use for mapping enumerated values to invariant bit indices. The maximum array length is 64.

Writes a set of enumerated values.

IOException

If an I/O error has occurred.

Write​Float32​Array

2 overloads


public static method WriteFloat32Array1 → (1)

value in : float32 [ ]

The data token value.

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.


public static method WriteFloat32Array2 → (3)

value in : float32 [ ]

The data token value.

first in : int32

[>=0]
Index of first array element to write.

count in : int32

[>=0]
Number array elements to write.

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.

Write​Float64​Array

2 overloads


public static method WriteFloat64Array1 → (1)

value in : float64 [ ]

The data token value.

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.


public static method WriteFloat64Array2 → (3)

value in : float64 [ ]

The data token value.

first in : int32

[>=0]
Index of first array element to write.

count in : int32

[>=0]
Number array elements to write.

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.

Write​Int16​Array

2 overloads


public static method WriteInt16Array1 → (1)

value in : int16 [ ]

The data token value.

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.


public static method WriteInt16Array2 → (3)

value in : int16 [ ]

The data token value.

first in : int32

[>=0]
Index of first array element to write.

count in : int32

[>=0]
Number array elements to write.

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.

Write​Int32​Array

2 overloads


public static method WriteInt32Array1 → (1)

value in : int32 [ ]

The data token value.

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.


public static method WriteInt32Array2 → (3)

value in : int32 [ ]

The data token value.

first in : int32

[>=0]
Index of first array element to write.

count in : int32

[>=0]
Number array elements to write.

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.

Write​Int64​Array

2 overloads


public static method WriteInt64Array1 → (1)

value in : int64 [ ]

The data token value.

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.


public static method WriteInt64Array2 → (3)

value in : int64 [ ]

The data token value.

first in : int32

[>=0]
Index of first array element to write.

count in : int32

[>=0]
Number array elements to write.

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.

Write​Int8​Array

2 overloads


public static method WriteInt8Array1 → (1)

value in : int8 [ ]

The data token value.

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.


public static method WriteInt8Array2 → (3)

value in : int8 [ ]

The data token value.

first in : int32

[>=0]
Index of first array element to write.

count in : int32

[>=0]
Number array elements to write.

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.

Write​Value


public static method WriteValue → (2)<T val>

value in : T

The value to write.

format in : ITypeSerializer<T>

[not-null]
The value format to use.

Writes a value by delegating to ITypeSerializer.WriteValue.

IOException

If an I/O error has occurred.