This directive applies to data members of type string as well as to containers, such as structures, classes, and exceptions. It changes the default mapping for strings from
std::string to
std::wstring. (See
Section 6.6.1.)
This directive applies to classes. If the directive is present and a class has base classes, the generated C++ class derives virtually from its bases; without this directive,
slice2cpp generates the class so it derives non-virtually from its bases.
This directive is useful if you use Slice classes as servants and want to inherit the implementation of operations in the base class in the derived class. For example:
The metadata directive causes slice2cpp to generate the class definition for
Derived using virtual inheritance:
This allows you to reuse the implementation of baseOp in the servant for
Derived using ladder inheritance:
Note that, if you have data member in classes and use virtual inheritance, you need to take care to correctly call base class constructors if you implement your own one-shot constructor. For example:
If you derive your own class from Derived and add a one-shot constructor to your class, you must explicitly call the constructor of all the base classes, including
Base. Failure to call the
Base constructor will result in
Base being default-constructed instead of getting a defined value. For example:
This code correctly initializes the baseInt member of the
Base part of the class. Note that the following does
not work as intended and leaves the
Base part default-constructed (meaning that
baseInt is not initialized):