RTI Connext Modern C++ API Version 7.3.0
Topic traits and data-type support

Traits and operations associated to topic-types. More...

Modules

 Topic-type serialization and deserialization
 Provides functions to serialize and deserialize user data types to and from Common Data Representation (CDR) format.
 

Classes

struct  dds::topic::is_topic_type< T >
 Trait that indicates if a type is suitable to be the type of a dds::topic::Topic. More...
 
struct  dds::topic::topic_type_support< T >
 Provides convenience operations for a topic-type. More...
 
struct  dds::topic::topic_type_name< T >
 Provides the name of a topic-type. More...
 
struct  rti::topic::PrintFormatKind_def
 The definition of the dds::core::safe_enum PrintFormatKind. More...
 
class  rti::topic::PrintFormatProperty
 <<extension>> <<value-type>> A collection of attributes used to configure how data samples will be formatted when converted to a string. More...
 
struct  rti::topic::extensibility< TopicType >
 <<extension>> Indicates the extensibility kind of a topic-type More...
 
struct  rti::topic::topic_type_disabled_copy< TopicType >
 <<extension>> Indicates whether a TopicType is uncopyable More...
 
struct  rti::topic::topic_type_has_external_members< TopicType >
 <<extension>> Indicates if a topic type contains directly or indirectly IDL external members. More...
 
struct  rti::topic::dynamic_type< TopicType >
 Provides a DynamicType that represents an IDL-generated type. More...
 

Typedefs

typedef dds::core::safe_enum< PrintFormatKind_defrti::topic::PrintFormatKind
 Safe Enumeration of PrintFormatKind_def Format kinds available when converting data samples to string representations. More...
 

Functions

template<typename TopicType >
std::ostream & rti::topic::to_string (std::ostream &out, const TopicType &sample, const PrintFormatProperty &print_format=PrintFormatProperty::Default())
 Prints a data sample to an output stream. More...
 
template<typename TopicType >
std::string rti::topic::to_string (const TopicType &sample, const PrintFormatProperty &print_format=PrintFormatProperty::Default())
 Tranforms a data sample into a human-readable string format. More...
 
template<typename TopicType >
TopicType rti::topic::from_string (RTI_STRING_IN str, PrintFormatKind format_kind=PrintFormatKind::JSON)
 Creates a data sample from a JSON string representation. More...
 

Detailed Description

Traits and operations associated to topic-types.

Typedef Documentation

◆ PrintFormatKind

Safe Enumeration of PrintFormatKind_def Format kinds available when converting data samples to string representations.

See also
PrintFormatKind_def

Function Documentation

◆ to_string() [1/2]

template<typename TopicType >
std::ostream & rti::topic::to_string ( std::ostream &  out,
const TopicType &  sample,
const PrintFormatProperty print_format = PrintFormatProperty::Default() 
)

Prints a data sample to an output stream.

#include <rti/topic/to_string.hpp>
Template Parameters
TopicTypeA valid topic-type. Valid types are IDL-generated types that were generated with typecodes enabled, the built-in types and dds::core::xtypes::DynamicData.
Parameters
outThe output stream to print to
sampleThe sample to print to the output stream
print_formatProperties describing the format with which to print the sample. For example, a sample may be printed in a default format, JSON format or XML format.

Referenced by dds::topic::qos::TopicQos::operator>>().

◆ to_string() [2/2]

template<typename TopicType >
std::string rti::topic::to_string ( const TopicType &  sample,
const PrintFormatProperty print_format = PrintFormatProperty::Default() 
)

Tranforms a data sample into a human-readable string format.

#include <rti/topic/to_string.hpp>
Template Parameters
TopicTypeA valid topic-type. Valid types are IDL-generated types that were generated with typecodes enabled, the built-in types and dds::core::xtypes::DynamicData.
Parameters
sampleThe sample to get the string representation of
print_formatProperties describing the format with which to print the sample. For example, a sample may be printed in a default format, JSON format or XML format.

◆ from_string()

template<typename TopicType >
TopicType rti::topic::from_string ( RTI_STRING_IN  str,
PrintFormatKind  format_kind = PrintFormatKind::JSON 
)

Creates a data sample from a JSON string representation.

#include <rti/topic/to_string.hpp>
Template Parameters
TopicTypeAn IDL-generated type, generated with typecodes enabled.

For example:

Point p = rti::core::xtypes::from_string<Point>("{ \"x\": 1, \"y\": 2 }");
Parameters
strThe JSON string to convert to a sample
format_kindThe only supported value is PrintFormatKind::JSON
Returns
The sample created from the JSON string
See also
dds::core::xtypes::DynamicData::from_string

References dds::core::xtypes::DynamicData::from_string().