Provides functions to serialize and deserialize user data types to and from CDR format.
More...
Detailed Description
Provides functions to serialize and deserialize user data types to and from CDR format.
DDS serializes topic-types into bytes in CDR format to transmit them between DataWriters and DataReaders. The functions rti::topic::to_cdr() and rti::topic::from_cdr() expose this functionality so applications can take advantage of this capability.
Function Documentation
template<typename TopicType >
void rti::topic::from_cdr_buffer_no_alloc |
( |
TopicType & |
sample, |
|
|
const std::vector< char > & |
buffer |
|
) |
| |
Deserializes a sample from a buffer of bytes in CDR format.
- Precondition
- sample must have been created by a previous call to from_cdr_buffer() or default-constructed and then initialized with
dds::topic::topic_type_support<TopicType>::initialize_sample()
. This precondition doesn't apply if TopicType
is dds::core::xtypes::DynamicData
This function does the same as from_cdr_buffer() but it doesn't create a new sample. When deserializing multiple samples this operation will be more efficient.
- Template Parameters
-
- Parameters
-
sample | The destination (see precondition) |
buffer | The CDR buffer to deserialize |
template<typename TopicType >
TopicType rti::topic::from_cdr_buffer |
( |
const std::vector< char > & |
buffer | ) |
|
Creates a sample by deserializing a buffer of bytes in CDR format.
- Template Parameters
-
- Parameters
-
buffer | The CDR buffer to desrialize |
- Returns
- The deserialized sample
- See Also
- from_cdr_buffer_no_alloc()
- Examples:
- Foo.hpp.
template<typename TopicType >
Serializes a sample into a buffer of octets in CDR format.
- Template Parameters
-
- Parameters
-
buffer | The destination buffer. It will be resized to fit the serialized sample |
sample | The sample to serialize |
representation | The representation to serialize the data into |
- Examples:
- Foo.hpp.
template<typename TopicType >
std::vector<char>& rti::topic::to_cdr_buffer |
( |
std::vector< char > & |
buffer, |
|
|
const TopicType & |
sample |
|
) |
| |
Serializes a sample into a buffer of octets in CDR format.
This overload uses dds::core::policy::DataRepresentationId::auto_id() as the data representation.