CPACSGen (short for CPACS generator) creates source code for classes and enums from the types defined in a CPACS XML schema file for the TiGL library.
CPACSGen is hosted on Github: https://github.com/RISCSoftware/cpacs_tigl_gen
The following components are required to build and run CPACSGen
Given an input directory, CPACSGen searches for the following input files:
These files are typically part of the TiGL distribution and do not have to be created. Altering these files influences CPACSGen’s output and may require further adaption of the TiGL code depending on the generated code.
In addition to these files, three more files have existed with are now compiled into CPACSGen and inside Tables.cpp:
Furthermore, in addition to the discussed input files, subdirectories may be present containing the same input files as listed above. For each subdirectory, CPACSGen runs an additional pass, putting the generated files into an equally named subfolder in the output directory and generating an equally named additional namespace in the generated code.
The CPACSGen executable takes the following positional command line options:
CustomTypes.txt
Types which will be sub-classed in TIGL, e.g. for implementing additional behavior or fixing issues with the generated code.
Types for which a custom type has been specified will never be instantiated by the generated code.
Instead, their customized derived classes are instantiated.
Customized types are still outputted.
e.g. tigl\::generated\::CPACSFuselage -> tigl::CCPACSFuselage
ParentPointer.txt
e.g. CPACSWing, CPACSFuselageSegment
List of types which should hold a pointer to their parent element in CPACS.
Causes all parent classes to pass themselves to their child classes on child instantiation.
PruneList.txt
List of CPACS types which (including their child types in the CPACS schema tree) should be removed from the type system built by CPACSGen.
Pruned types are not outputted.
A graphical representation of the type system after pruning can be obtained using the optional Graphviz file command line argument.
TypeSubstitution.txt
e.g. stringUIDBaseType -> std::string, integerBaseType -> int
Types of the CPACS schema which should simply be replaced without further logic.
Replaced types are not outputted.
FundamentalTypes.txt
std::string, double, bool, int, time_t
Fundamental data types for which XML element and attribute IO functions exist in the TIXI wrapper.
ReservedNames.txt
e.g. int, inline, break, false
List of identifiers which are reserved in C++.
Members of generated enums are checked against this table and altered.
XsdTypes.txt
e.g. xsd:unsignedLong -> uint64_t
Same functionality as TypeSubstitution.txt. Maps XSD to C++ types.
The classes generated by CPACSGen depend upon the following helper files, which are part of CPACSGen and will be written to the output directory when CPACSGen is invoked:
TixiHelper.h
Wrappers over TIXI functions providing a C++ friendly interface (references, std::string, exceptions, ...).
Is used by the ReadCPACS and WriteCPACS implementation.
UniquePtr.hpp
Contains tigl\::unique_ptr\