Generating Reflex Dictionaries

Selecting Types And Members

You can use selection files to tell genreflex what it should generate a dictionary for. If you do not use it, it will generate a dictionary for all types in the files passed at the command line, or when specifying --deep for all types it finds.

The selection file is passed to genreflex with the -s parameters like this: genreflex -s selection.xml header1.h header2.h. It is an XML file with the following structure:

<lcgdict>
[<selection>]
  <class [name="classname"] [pattern="wildname"] 
         [file_name="filename"] [file_pattern="wildname"] 
         [id="xxxx"] [type="vector"]/>
  <class name="classname" >
    <field name="m_transient" transient="true"/>
    <field name="m_anothertransient" transient="true"/>
    <properties prop1="value1" [prop2="value2"]/>
  </class>
  <function [name="funcname"] [pattern="wildname"]
            [proto_name="name(int)"] [proto_pattern="name(int,*)"] />
  <enum [name="enumname"] [patter="wildname"] />
  <variable [name="varname"] [patter="wildname"] />
[</selection>]
<exclusion>
  <class [name="classname"] [pattern="wildname"] />
    <method name="unwanted" />
  </class>
...
</lcgdict>

Genreflex and Templates

The program parsing the header files and providing genreflex with the information what's in them is called GCCXML. It only sees templates if they are instantiated. See the C++ standard on when template instantiation happens. The rule of thumb is: if you design a templated class then it probably does not happen in that templated class's header!

So you need to help GCCXML. There are two common approaches: the struct member, and the "proper" C++ way.

Explicit Template Instantiation

This is the preferred method, but it is not widely used. Suppose you have a templated template class C and a templated function template T A::f(const T&) const;. You can instantiate them (say with template parameter long long) using
#ifdef __GCCXML__
// GCCXML explicit template instantiation block
template class C<long long>;
template long long A::f<long long>(const long long&);
#endif
You can even put this into your regular header file: it is surrounded by an #ifdef __GCCXML__ and will thus be invisible to any other compiler.

Template Instantiation By struct Members

Suppose you have a templated template class C and a templated function template T f(const T&) const; defined in file C.h. You cannot instantiate the templated member function (at least I haven't found a way - do you know one?). For the templated class you can use:

#include "C.h"
#ifdef __GCCXML__
// GCCXML explicit template instantiation block
namespace {
  struct GCCXML_DUMMY_INSTANTIATION {
    C<long long> dummyMember;
  };
}
#endif

Often people put these instantiations into a separate header which in turn #includes the actual header, such that the C++ sources do not see the GCCXML_DUMMY_INSTANTIATION.