The project includes:
Templates
: folder providing unit/scale definitions and XSLT templates of target structs,Units
: destination folder for generated unit and scale structures (*.h
).CMakeLists.txt
: CMake script that builds library of units and scales (as a header-only library ofUnits/*.h
files) and makes it available for use in parent/dependent projects.
At build time, the CMakeLists.txt
script runs the UnitGenerator
(external) tool, which does the job using packages:
- Definitions : reads, verifies and transforms definitions into an intermediate form,
- Model : translates (using XSLT templates) the verified definitions into target C++ structures.
NOTE:
👉 UnitGenerator is a dotnet tool that MUST be installed separately BEFORE building such a project!
Definitions and XSLT templates of units and scales:
definitions.txt
: definitions of units & scales,math-constants.xslt
: stylesheet to be imported into templates that need mathematical constants (such asPI
,E
, etc.),replace-string.xslt
: stylesheet to be imported into templates that need thereplace
function not available inXSLT 1.0
,report.xslt
: template forgenerator_report.txt
file (a summary of generated units and scales).scale.xslt
: template for a single scale (struct),unit.xslt
: template for a single unit (struct),
This is the folder where units and scales are generated as C++ header files (*.h).
The details
subfolder is a permanent part of the project: it contains the finished C++ code, supplementing the code of the generated units/scales.
On the other hand, the generated *.h files can be safely deleted after build - on the next build they will be automatically restored (albeit at the cost of additional time). Either way, they do not need to be stored in the git
repository.