Allows serializing and deserializing IDL types as byte buffers
More...
Inherits IDisposable.
Allows serializing and deserializing IDL types as byte buffers
- Template Parameters
-
T | A type generated from IDL |
To create an ISerializer, use TypeSupport<T>.CreateSerializer.
- Warning
- The ISerializer methods are not thread-safe. To use them in multiple threads, either protect them or create a different ISerializer per thread
This type is IDisposable, but it automatically calls Dispose() in its destructor.
This interface has extension methods, see SerializerExtensions.
- See also
- IDL examples
◆ Deserialize() [1/2]
unsafe T Deserialize |
( |
byte * |
buffer, |
|
|
int |
length |
|
) |
| |
Deserializes a data sample from a byte buffer
- Parameters
-
buffer | A byte buffer containing the serialized data |
length | The length of the byte buffer |
- Returns
- A new data sample created by deserializing the buffer
◆ Deserialize() [2/2]
T Deserialize |
( |
byte[] |
buffer | ) |
|
Deserializes a data sample from a byte array
- Parameters
-
buffer | A byte array containing the serialized data |
- Returns
- A new data sample created by deserializing the buffer
◆ FromDynamicData()
Converts a DynamicData sample into a T sample.
- Parameters
-
sample | The sample to convert |
- Returns
- A copy of sample as an instance of type T
This method requires that sample.Type and TSupport.Instance.DynamicType be equal.
◆ GetSerializedSampleMaxSize()
uint GetSerializedSampleMaxSize |
( |
| ) |
|
Calculates the maximum number of bytes that any data sample of type T
may take in serialized form.
◆ GetSerializedSampleMinSize()
uint GetSerializedSampleMinSize |
( |
| ) |
|
Calculates the minimum number of bytes that any data sample of type T
may take in serialized form.
◆ GetSerializedSampleSize()
uint GetSerializedSampleSize |
( |
T |
sample | ) |
|
Calculates the exact number of bytes that a given data sample takes in serialized form.
- Parameters
-
- Returns
- The number of bytes that the sample needs to be serialized
◆ Serialize() [1/2]
byte [] Serialize |
( |
T |
sample | ) |
|
Serializes a data sample into a byte array
- Parameters
-
- Returns
- A new byte array containing the serialized data
◆ Serialize() [2/2]
unsafe uint Serialize |
( |
T |
sample, |
|
|
byte * |
buffer, |
|
|
int |
length |
|
) |
| |
Serializes a data sample into a byte array
- Parameters
-
sample | A data sample |
buffer | A byte buffer with enough space to contain the serialized data |
length | The available length of the byte buffer. This operation throws DdsException if the data doesn't fit. You can obtain the exact size required for this sample with GetSerializedSampleSize or a size that is guaranteed to suffice for any sample of this type with GetSerializedSampleMaxSize. |
- Returns
- The actual number of bytes that were serialized
◆ ToDynamicData()
Converts a T sample into a DynamicData sample.
- Parameters
-
sample | The sample to convert |
- Returns
- A copy of sample as a DynamicData object