Skip to content

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:

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 {};
};

Namespaces

namespace ExampleNamespace Namespace()  //The macro comes AFTER the namespace name
{
}

Variables/Functions

Variable()
int exampleVariable = 0;

Function()
void exampleFunction();

//Can also be written inline
Variable() int exampleVariable2 = 0;
Function() void exampleFunction2();

Classes/Structs

class Class() ExampleClass
{
    Field()
    int _exampleField;

    Method()
    int exampleMethod();
};

Enums

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.