FASTDDS IDL
-
IDL为接口定义语言,支持的类型有:
-
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
long double long double
boolean bool
string std::string
-
支持一维和多维数组。
IDL C++11 char a[5] std::array<char,5> a
octet a[5] std::array<uint8_t,5> a
short a[5] std::array<int16_t,5> a
unsigned short a[5] std::array<uint16_t,5> a
long a[5] std::array<int32_t,5> a
unsigned long a[5] std::array<uint32_t,5> a
long long a[5] std::array<int64_t,5> a
unsigned long long a[5] std::array<uint64_t,5> a
float a[5] std::array<float,5> a
double a[5] std::array<double,5> a
-
支持动态数组,对应C++中的std::vector
IDL C++11 sequence std::vector<char>
sequence std::vector<uint8_t>
sequence std::vector<int16_t>
sequence std::vector<uint16_t>
sequence std::vector<int32_t>
sequence std::vector<uint32_t>
sequence std::vector<int64_t>
sequence std::vector<uint64_t>
sequence std::vector<float>
sequence std::vector<double>
-
支持容器,对应C++中的std::map
IDL C++11 map<char, unsigned long long> std::map<char, uint64_T>
-
将多种类型的变量定义在一个结构体,最后每个结构体将被转换成为一个类,为类中的每个变量定义set和get方法
struct Structure { octet octet_value; long long_value; string string_value; };
class Structure { public: Structure(); ~Structure(); Structure(const Structure &x); Structure(Structure &&x); Structure& operator=(const Structure &x); Structure& operator=(Structure &&x); void octet_value(uint8_t _octet_value); uint8_t octet_value() const; uint8_t& octet_value(); void long_value(int64_t _long_value); int64_t long_value() const; int64_t& long_value(); void string_value(const std::string &_string_value); void string_value(std::string &&_string_value); const std::string& string_value() const; std::string& string_value(); private: uint8_t m_octet_value; int64_t m_long_value; std::string m_string_value; };
结构体可以继承
struct ParentStruct { octet parent_member; }; struct ChildStruct : ParentStruct { long child_member; };
-
union Union switch(long) { case 1: octet octet_value; case 2: long long_value; case 3: string string_value; };
-
bitset MyBitset { bitfield<3> a; bitfield<10> b; bitfield<12, long> c; };
共25bits(3+10+12)
-
enum Enumeration { RED, GREEN, BLUE };
-
@bit_bound(8) bitmask MyBitMask { @position(0) flag0, @position(1) flag1, @position(4) flag4, @position(6) flag6, flag7 };
转换后
enum MyBitMask : uint8_t { flag0 = 0x01 << 0, flag1 = 0x01 << 1, flag4 = 0x01 << 4, flag6 = 0x01 << 6, flag7 = 0x01 << 7 };
bit_bound设置范围1-64,不设置默认为32bits,使用position定义flag,如果不定义,position将从最后一次flag自动递增,从0开始。
-
struct MyType { @Key long id; @Key string type; long positionX; long positionY; };
IDL可以包含别的IDL文件
#include "OtherFile.idl" #include <AnotherFile.idl>
-