Defining a data type via IDL

Supported IDL types

Be aware that Safe DDS-Gen is not case sensitive as it is specified in the IDL specification.

Safe DDS Usage

Unsupported types will abort the file generation, leaving a static assert to alert the user.

Primitive types

The following table shows the basic IDL types supported by Safe DDS-Gen and how they are mapped to C++11.

IDL

C++11

char

char

octet

uint8_t

short

int16_t

unsigned short

uint16_t

long

int32_t

unsigned long

uint32_t

long long

int64_t

unsigned long long

uint64_t

float

float

double

double

boolean

bool

string

std::string

Arrays

Safe DDS-Gen supports single and multidimensional arrays. Arrays are always mapped to C arrays. The following table shows the array types supported and their mapping.

IDL

C++11

char a[5]

char a[5]

octet a[5]

uint8_t a[5]

short a[5]

int16_t a[5]

unsigned short a[5]

uint16_t a[5]

long a[5]

int32_t a[5]

unsigned long a[5]

uint32_t a[5]

long long a[5]

int64_t a[5]

unsigned long long a[5]

uint64_t a[5]

float a[5]

float a[5]

double a[5]

double a[5]

Sequences

Safe DDS-Gen supports bounded sequences. Sequences are always mapped to C++11 std::vector. The following table shows the sequence types supported and their mapping.

IDL

C++11

sequence<char, 5>

std::vector<char>

sequence<octet, 5>

std::vector<uint8_t>

sequence<short, 5>

std::vector<int16_t>

sequence<unsigned short, 5>

std::vector<uint16_t>

sequence<long, 5>

std::vector<int32_t>

sequence<unsigned long, 5>

std::vector<uint32_t>

sequence<long long, 5>

std::vector<int64_t>

sequence<unsigned long long, 5>

std::vector<uint64_t>

sequence<float, 5>

std::vector<float>

sequence<double, 5>

std::vector<double>

Structures

It is possible to define an IDL structure with a set of members with multiple types, which will be converted into a C struct.

The following IDL structure:

struct Structure
{
    octet octet_value;
    long long_value;
    octet octet_array[5];
};

Would be converted to:

struct Structure
{
    /// Member octet_value
    uint8_t octet_value;

    /// Member long_value
    int32_t long_value;

    /// Member octet_array
    uint8_t octet_array[5];
};

Structures can inherit from other structures, extending their member set.

struct ParentStruct
{
    octet parent_member;
};

struct ChildStruct : ParentStruct
{
    long child_member;
};

In this case, the resulting C++ code will be:

struct ParentStruct
{
    /// Member parent_member
    uint8_t parent_member;
};

struct ChildStruct : public ParentStruct
{
    /// Member child_member
    int32_t child_member;
};

Including other IDL files

Other IDL files can be included in addition to the current IDL file. Safe DDS-Gen uses a C/C++ preprocessor for this purpose, and #include directive can be used to include an IDL file.

 #include "OtherFile.idl"
 #include <AnotherFile.idl>

If Safe DDS-Gen does not find a C/C++ preprocessor in default system paths, the preprocessor path can be specified using parameter --preprocessor <path>. The parameter --no-preprocessor can be used to disable the usage of the C/C++ preprocessor.