On this page:
General Metadata Directives
This directive applies to interfaces, classes, and individual operations. It enables code generation for asynchronous method dispatch. (See the relevant language mapping chapter for details.)
This directive allows you to emit a deprecation warning for Slice constructs.
This directive defines the encoding format used for any classes or exceptions marshaled as the arguments or results of an operation. The tag can be applied to an interface, which affects all of its operations, or to individual operations. Legal values for the tag are
format:default. A tag specified for an operation overrides any setting applied to its enclosing interface. The
Ice.Default.SlicedFormat property defines the behavior when no tag is present.
This directive applies to classes and exceptions, allowing an intermediary to forward an instance of the annotated type, or any of its subtypes, with all of its slices intact. Operations that transfer such types must be annotated with
format:sliced. It is not necessary to repeat the
preserve-slice tag on derived types, but you may wish to do so for documentation purposes.
This directive applies to data members of classes and changes code generation to make these members protected. See class mapping of the relevant language mapping chapter for more information.
This directive applies only to operations on local interfaces. The metadata directive indicates that the operation can throw any user exception, regardless of its specific definition. (This directive is used for the
finished operations on servant locators, which can throw any user exception.)
Metadata Directives for C++
These directives apply to sequences. They direct the code generator to create zero-copy APIs for passing sequences as parameters.
This directive applies to structures. It directs the code generator to create a C++ class (instead of a C++ structure) to represent a Slice structure.
This directive applies to structures. It directs the code generator to generate comparison operators for a structure regardless of whether it qualifies as a legal dictionary key type.
This directive applies to operations. It directs the code generator to create a
const pure virtual member function for the skeleton class.
This global directive allows you to use a file extension for C++ header files other than the default
This directive applies to exceptions. It directs the code generator to declare (but not implement) an
ice_print member function that overrides the
ice_print virtual function in
Ice::Exception. The application must provide the implementation of this
This global directive allows you inject additional #include directives into the generated code. This is useful for custom types.
These directives apply to data members of type string as well as to containers, such as structures, classes, exceptions, and modules. String members map by default to
std::string. You can use the
cpp:type:wstring metadata to cause a string data member (or all string data members in a structure, class or exception) to map to
std::wstring instead. Use the
cpp:type:string metadata to force string members to use the default mapping regardless of any enclosing metadata.
This directive applies to string, sequence and dictionary parameters. It directs the code generator to map this parameter to the provided C++ type when this parameter does not need to hold any memory, for example when mapping an in-parameter to a proxy function.
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:
The generated one-shot constructor for
Derived initializes both
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):
Metadata Directives for Java
This directive applies to sequences of certain primitive types. It directs the translator to map the sequence to a subclass of
This directive applies to data members and structures, classes, and exceptions. It adds accessor and modifier methods (JavaBean methods) for data members.
This directive forces optional output parameters to use the optional mapping instead of the default required mapping in servants.
This global directive instructs the code generator to place the generated classes into a specific package.
This directive allows you to use Ice to transmit serializable Java classes as native objects, without having to define corresponding Slice definitions for these classes.
This directive overrides the default (generated) value of
serialVersionUID for a Slice type.
This directive allows you to use custom types for sequences and dictionaries.
Metadata Directives for C#
Note that C# (and other Common Language Runtime languages) are also affected by metadata with a
clr: prefix. (See Metadata Directives for .NET.)
This directive can be used both as a global directive and as directive for specific Slice constructs. It injects C# attribute definitions into the generated code. (See .Slice Metadata Directives v3.6.)
Metadata Directives for .NET
This directive applies to Slice structures. It directs the code generator to emit a C# class instead of a structure.
These directives apply to sequences and map them to the specified sequence type.
This directive applies to dictionaries and maps them to
This directive applies to sequences and allows you map them to custom types.
This directive adds the specified base type to the generated code for a Slice structure, class or interface. For example, Ice defines the
Communicator interface as shown below:
Consequently, the generated C# interface
This directive applies to Slice structures and classes. It directs the code generator to create C# property definitions for data members.
This directive allows you to use Ice to transmit serializable CLR classes as native objects, without having to define corresponding Slice definitions for these classes.
Metadata Directives for Objective-C
This directive applies to modules and changes the default mapping for modules to use a specified prefix.
Metadata Directives for Python
This global directive instructs the code generator to place the generated code into a specified Python package.
These directives allow you to change the mapping for Slice sequences.
Metadata Directives for Freeze
These directives inform a Freeze evictor whether an operation updates the state of an object, so the evictor knows whether it must save an object before evicting it.