The C++ code reverse is a plug-out directly written in C++, as the C++ generator.
Note that the C++ code reverse cannot be used as a C++ code round trip and doesn't allows to update already defined classes having at least one member. Furthermore the preprocessing phase is not made by the C++ code reverse whose ignore all the preprocessor forms, but some substitutions may be asked, see at the end of this chapter.
The C++ code reverse plug-out may be applied only on packages.
When you start the C++ code reverse, it asks you for directories (enter the directories then choose cancel to start the reverse), then it reads all the sources placed under the selected directories and sub-directories. The sources read by the C++ code reverse are the ones having the extension specified in the generation settings. The tree formed by the directories and sub-directories produce an equivalent tree of sub-packages, on whose the needed class view and artifact view are made to support the classes and artifacts. When a type is referenced but not defined in the reverse files, a class having the same name is defined under an additional package named unknown.
The reverse/roundtrip setting dialog of the modeler allows to specify through regular expression the files and / or directories whose must not be taken into account during a reverse and roundtrip, for instance to bypass test programs.
Obviously the C++ code reverse tries to produce the definitions made in BOUML at the artifact / class / operation / relation / attribute levels. When it is possible it creates a relation rather than an attribute.
Except for the special case of the templates class definition like vector<bool>, a artifact is created for each type definition, then a future C++ code generation may not produce a list of files similar to the reversed ones.
A C function cannot be specified in UML, the C++ code reverse loses them (generating a warning) except the ones declared friend in a class.
The C++ code reverse works in two steps, during the first step it scans all the files to establish the list of defined types, then the second step may reverse the files. The first phase tries to replace the missing #include management, but it is not enough because the files whose are not under the selected directory (for instance the standard headers files !) are never taken into account and the synonym types are confusing.
When the C++ code reverse has a problem, for instance when it reads a C function definition, it produces a warning in the trace window. The trace window is automatically opened by BOUML, it may also be manually opened through the Tools menu.
To do simple substitution on the read files : edit the project (top level package) to add a user property (through the tab 'Properties') with the key #file and the value must be the absolute pathname of a file. Each line of the specified file must contain :
just an identifier : in this case this identifier will be ignored during reverse. This is like #define identifier
a form identifier=value : in this case the identifier will replaced by the value during reverse. The value must a token, for instance an other identifier, a float, a string etc. This is like #define identifier value.
Warning : the lines must not contains spaces or tabs.
Previous : C++ generator
Next : C++ roundtrip