-
Notifications
You must be signed in to change notification settings - Fork 10
Mark entities for parsing
Julien SOYSOUVANH edited this page Aug 6, 2021
·
3 revisions
C++ entities (namespaces, enums, enum values, variables, functions, classes/structs, fields, and methods) contained in parsed files are not detected by default by the FileParser. You have 2 ways to handle that:
- Set the ParsingSettings::shouldParseAllEntities setting to true, in which case all the entities contained in parsed files will be added to the result structure;
- Mark each entity individually for parsing, using the macros defined in ParsingSettings;
For the second method, note that there are a few rules to follow:
- You must include the file "EntityMacros.h" generated by the CodeGenManager to use the different macros. The file will be generated in the output directory specified in the CodeGenUnit settings.
- If you mark an entity for parsing, you must make sure that its outer entity (if any) is also marked, or it won't be parsed, like in the following example:
#include "Generated/EntityMacros.h"
class ExampleClass
{
//NestedClass is marked for parsing with the macro Class, but its outer entity (ExampleClass)
//is not marked for parsing, hence NestedClass won't be parsed
class Class() NestedClass {};
};
namespace ExampleNamespace Namespace() //The macro comes AFTER the namespace name
{
}
Variable()
int exampleVariable = 0;
Function()
void exampleFunction();
//Can also be written inline
Variable() int exampleVariable2 = 0;
Function() void exampleFunction2();
class Class() ExampleClass
{
Field()
int _exampleField;
Method()
int exampleMethod();
};
enum class Enum() ExampleEnum
{
Value1 EnumValue(Property1) = 0,
Value2
};
Note: All enum values contained in a tagged enum are parsed by default even when the macro is not used. You can still use the macro to add properties to enum values.