|
RTI Connext Modern C++ API
Version 5.2.3
|
How IDL types map to C++ classes. More...
Classes | |
| class | Foo |
| A hypothetical topic-type. More... | |
How IDL types map to C++ classes.
The following IDL code defines the types we will use in these examples.
To generate C++ code for these types see Create user data types using rtiddsgen
C++ types generated from IDL have value semantics and provide a default constructor, a copy constructor, a move constructor <<C++11>>, a constructor with parameters to set all the type's members, a destructor, a copy-assignment operator, and a move-assignment operator <<C++11>>. Types also include equality operators, the operator << to std::ostream <<extension>> and a namespace-level swap function.
In addition to that, a number of traits provide additional information and utilities for IDL-generated types.
Setters and getters allow accessing the type members.
The following table summarizes how different IDL types map to C++:
| IDL type | C++ type |
|---|---|
string | dds::core::string |
sequence<T> | dds::core::vector<T> |
array (T member[N]) | dds::core::array<T, N> |
optional annotation (T member; //@Optional) | dds::core::optional<T> |
The types dds::core::string and dds::core::vector provide a similar behavior to std::string and std::vector. They also provide conversions to and from their std counterparts.
The type dds::core::array is just an alias of std::array if supported by the compiler, or an alias of boost::array otherwise.
The following example shows how to use getters and setters and work with different IDL types.