C++11 mapping for IDL constants

OMG IDL constants are mapped directly to a C++ constant definition.

// IDL
const string name = "testing";

interface A {
  const long n = 5;
};

// C++
static constexpr std::string name = "testing";
class A {
public:
  static constextr int32_t n = 5;
};

The mappings for wide character and wide string constants is identical to character and string constants, except that IDL literals are preceded by L in C++. For example, IDL constant:

const wstring ws = “Hello World”;

would map to

static constexpr std::wstring ws = L”Hello World”;

in C++.

Your rating: None Average: 5 (1 vote)

example

An example for constants in IDL has been published on OSportal