Custom Containers¶
IDLCXX enables users to supply their own container classes, replacing the default containers
used for IDL sequences (bounded and unbounded), strings (bounded and unbounded), arrays and
unions. All custom containers templates are set through the -f command line option, followed
by the option to be set, an equals sign and the value to set it to. Each template can have a
varying number of tags, which are indicated by the following strings:
{TYPE}: will replace type names in sequences and arrays{BOUND}: will replace maximum size values in bounded sequences and strings{DIMENSION}: will replace size in arrays
For example, to set a custom container for the bounded sequence, you must add the following
to the command line options of idlc:
-f bounded-sequence-template="company_name::special_bounded_sequence_impl<{TYPE}, {BOUND}>"
Supplying this command line option converts the following IDL code from:
sequence<long,255>
to the following C++ code:
company_name::special_bounded_sequence_impl<uint32_t, 255>
For each template, the ordering of the tags is not important, the generator will replace based on tags, not positions, all other text is inserted into the generated code verbatim. This enables custom allocators to also be added.
For more information on all command line options, run idlc with the -h option, while loading
the idlcxx library. For example:
idlc -l libdidlcxx.so -h
Sequences¶
The default container for both bounded and unbounded IDL sequences is std::vector.
The custom containers for bounded and unbounded sequences can be defined independently.
Any user-supplied container class that replaces std::vector must comply
with the following interface (with the same effect as these functions in std::vector):
sizeresizedataoperator==operator[]copy assignment operatorcopy constructor
The command line options for custom sequence containers are:
bounded-sequence-templatetemplate used for bounded sequences instead of
std::vectorreplaced tags:
{TYPE},{BOUND}
bounded-sequence-includeheader to include if
bounded-sequence-templateis used
sequence-templatetemplate used for sequences instead of
std::vectorreplaced tags:
{TYPE}
sequence-includeheader to include if
sequence-templateis used
Strings¶
The default container used for both bounded and unbounded IDL strings is std::string.
The custom containers for bounded and unbounded strings can be defined independently.
Any user-supplied container class that replaces std::string must comply
with the following interface (with the same effect as these functions in std::string):
lengthassignthe variant taking an input pointer and a length
operator==copy assignment operatorcopy constructor
The command line options for custom string containers are:
bounded-string-templatetemplate to use for strings instead of
std::stringreplaced tags:
{BOUND}
bounded-string-includeheader to include if
bounded-string-templateis used
string-templatetemplate to use for strings instead of
std::stringreplaced tags: none
string-includeheader to include if
string-templateis used
Arrays¶
The default container used for IDL arrays is std::array.
Any user-supplied container class that replaces std::array must comply
with the following interface (with the same effect as these functions in std::array):
support auto-range for loops
having begin() and end() functions returning iterators to the begin and end of the array
the function data()
The command line options for custom array containers are:
array-templatetemplate to use for arrays instead of
std::arrayreplaced tags:
{TYPE},{DIMENSION}
array-includeheader to include if template for
array-templateis used
Unions¶
IDL unions use the std::variant class by default as the container for the union values.
The only function needed from the custom union container is the templated getter function:
template<typename T>T get(variant& var)
The command line options for custom variant containers are:
union-getter-templatetemplate to use for reading the value of a variant, copied verbatim
union-templatetemplate to use for unions instead of
std::variant, copied verbatim
union-includeheader to include if template for union-template is used