IDL Syntax¶
Eclipse Cyclone DDS follows the OMG IDL 4.2 specification for its IDL syntax.
Including Other IDLs¶
You can include other IDL files using the #include directive. This allows you to reuse type definitions across multiple IDL files.
#include "OtherFile.idl"
Primitive Types¶
The table below shows the primitive types supported by the IDL compiler for both C/C++ and Python. Some aliases are defined, but only for primitive types
IDL Type |
Aliases |
C/C++11 Types |
Description |
---|---|---|---|
|
|
|
Boolean type, true or false |
|
|
|
8-bit character |
|
|
|
8-bit unsigned integer |
|
|
|
16-bit unsigned integer |
|
|
|
16-bit unsigned integer |
|
|
|
32-bit signed integer |
|
|
|
32-bit unsigned integer |
|
|
|
64-bit signed integer |
|
|
|
64-bit unsigned integer |
|
|
|
32-bit floating point number |
|
|
|
64-bit floating point number |
|
|
|
UTF-8 encoded string |
Arrays¶
Arrays in IDL are defined using the syntax type name[size], where type is the element type, name is the name of the variable, and size is the number of elements. For dynamically sized arrarys, see Sequences.
IDL Type |
C/C++11 Types |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Sequences¶
Sequences in IDL are mapped to an std::vector like structure. They can grow and shrink dynamically, and their size is not fixed at compile time.
IDL Type |
C/C++11 Types |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Maps¶
Maps in IDL are defined using the map<key_type, value_type> syntax, where key_type is the type of the keys and value_type is the type of the values. They are typically implemented as a std::map in C++.
IDL Type |
C/C++11 Types |
---|---|
|
|
Enumerations¶
Enumerations are typically used to define a set of named constants. In IDL, it is defined using the enum keyword followed by the name and a list of enumerators, and is mapped directly to a C++ enum.
The following IDL definition:
enum Color
{
RED,
YELLOW,
@value(3)
BLUE
};
Would be converted to the following C++ code:
enum class Color
{
RED,
YELLOW,
BLUE = 3
};
Bitmasks¶
Bitmasks in IDL are a special kind of enumeration defined using the bitmask keyword followed by the name and the underlying type. They are typically used to represent a set of flags in binary form.
For example, the following IDL definition:
@bit_bound(8)
bitmask MyFlags : unsigned long
{
FLAG_ONE = 0x1,
FLAG_TWO = 0x2,
FLAG_THREE = 0x4
};
Would be converted to the following C++ code:
enum class MyFlags : uint32_t
{
FLAG_ONE = 0x1,
FLAG_TWO = 0x2,
FLAG_THREE = 0x4
};
Comment Syntax¶
IDL supports single-line and multi-line comments in a similar fashion to C/C++.
Single-line comments start with // and continue to the end of the line.
Multi-line comments are enclosed in /* and */.