RTI Connext Modern C++ API  Version 5.3.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Topic-type serialization and deserialization

Provides functions to serialize and deserialize user data types to and from CDR format. More...

Functions

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.
 
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<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.
 

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
TopicTypeA valid topic-type. Valid types are IDL-generated types, the built-in types and dds::core::xtypes::DynamicData.
Parameters
sampleThe destination (see precondition)
bufferThe 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
TopicTypeA valid topic-type. Valid types are IDL-generated types, the built-in types and dds::core::xtypes::DynamicData.
Parameters
bufferThe CDR buffer to desrialize
Returns
The deserialized sample
See Also
from_cdr_buffer_no_alloc()
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.

Template Parameters
TopicTypeA valid topic-type. Valid types are IDL-generated types, the built-in types and dds::core::xtypes::DynamicData.
Parameters
bufferThe destination buffer. It will be resized to fit the serialized sample
sampleThe sample to serialize
Examples:
Foo.hpp.

RTI Connext Modern C++ API Version 5.3.1 Copyright © Mon Feb 19 2018 Real-Time Innovations, Inc