This application is designed to automatically generate the content used in the header files:
- Inclusions (#include directives)
- Forward declaration types
This content is generated based on information received from the code generator program:
- List of available types from header files
- List of types for which inclusion is a priority
- Two lists of types to be generated
- For inclusions
- For forward declaration
The subsystem returns a string containing a ready block of inclusions and declarations.
The arrangement of C++ types in header files is given:
- File <string> contains the definition of class std::string
- File "my_class.h" contains the definition of class my_class
- File "my_library.h" contains definitions of type my_library::callback - an alias to a pointer to a function which takes a single argument of type std::string and returns a value of type my_class* and of template structure my_library::struct1<T1,T2,T3>
The generation subsystem receives information about available types:
Repository Repository = new Repository();
Repository.AvailableTypes["<string>"].Add(new Class("std::string"));
Repository.AvailableTypes["\"my_class.h\""].Add(new Class("my_class"));
Repository.AvailableTypes["\"my_library.h\""].Add(new Alias("my_library::callback", "my_class", "std::string"));
Repository.AvailableTypes["\"my_library.h\""].Add(new Struct("my_library::struct1<T1,T2,T3>"));
If you want to generate declarations for the alias my_library::callback and the structure my_library::struct1, the Сompiler class initialization looks like this:
Сompiler compiler = new Сompiler(Repository)
{
Declarations = { "my_library::struct1<T1,T2,T3>", "my_library::callback" }
};
Including the <string> file containing the std::string class definition is defined by default because declarations for STL classes have portability issues.
After calling the:
Console.WriteLine(compiler.BuildOutput());
The result will be as follows: