Skip to main content

SDK Code Generation

Synced from the repository

This page mirrors sdk/gentool/README.md in the posemesh repo (branch main). The repository is the source of truth.

JSON documentation

Root JSON options

NameRequiredTypeDescription
namestringName of the class in Camel_Snake_Case naming convention. The different naming conventions are automatically derived from this one, however they can be manually specified with options such as name.style.lowerCase, name.style.upperCase and such. Furthermore, different language binding names are taken from the generated naming conventions, but they can also be manually specified with options such as name.lang.cPlusPlus, name.lang.c and such.
staticbooleanDetermine whether the class will be static or not. Default is false.
finalbooleanDetermine whether the class will be final or not. Inferred from static option.
aliasesAlias[]Alternative names of the class. No aliases by default. See definition.
headerGuardNamestringName of the class in UPPER_CASE naming convention used for C++ and C header guards. Derived from name option.
propertiesProperty[]Properties of the class. No properties by default. See definition.
copyablebooleanDetermine whether the class is copyable or not. Inferred from static option.
movablebooleanDetermine whether the class is movable or not. Inferred from static option.
parameterlessConstructorParameterlessConstructorOptions for the parameterless constructor. See definition.
copyConstructorCopyConstructorOptions for the copy constructor and operator. See definition.
moveConstructorMoveConstructorOptions for the move constructor and operator. See definition.
destructorDestructorOptions for the destructor. See definition.
equalityOperatorEqualityOperatorOptions for the equality (and inequality) operator. See definition.
hashOperatorHashOperatorOptions for the hash operator. See definition.
toStringOperatorToStringOperatorOptions for the to-string operator. See definition.
c.generateFuncAliasDefinesbooleanDetermine whether the C header will contain the macro defines for all class functions with the first part of the function replaced with names for all class aliases or not. Default is true.
constructorsConstructor[]Custom constructors of the class. No custom constructors by default. See definition.
methodsMethod[]Custom methods of the class. No custom methods by default. See definition.

Alias JSON options

NameRequiredTypeDescription
namestringAlternative name of the class in Camel_Snake_Case naming convention. Same naming convention and language specializations possible as in class name option.

Property JSON options

NameRequiredTypeDescription
namestringName of the property in Camel_Snake_Case naming convention. Same naming convention and language specializations possible as in class name option.
typestringType of the property. See list of valid types.
staticbooleanDetermine whether the property will be static or not. Inferred from class static option.
hasGetterbooleanDetermine whether the property will have a getter or not. Default is true.
getterConstbooleanDetermine whether the property getter will have a const modifier or not. Inferred from class static option.
getterNoexceptbooleanDetermine whether the property getter will have a noexcept modifier or not. Inferred from type option.
getterNamestringName of the property getter in Camel_Snake_Case naming convention. Derived from name option. Same naming convention and language specializations possible as in class name option.
getterModeMethodModeMethod mode of the property getter. See possible method modes. Default is regular.
getterCustombooleanDetermine whether the property getter will be have a custom implementation or not. Inferred from getterMode option.
getterVisibilityVisibilityVisibility of the property getter. See possible visibilities. Default is public.
hasSetterbooleanDetermine whether the property will have a setter or not. Default is true.
setterConstbooleanDetermine whether the property setter will have a const modifier or not. Inferred from class static option.
setterNoexceptbooleanDetermine whether the property setter will have a noexcept modifier or not. Inferred from type option.
setterNamestringName of the property setter in Camel_Snake_Case naming convention. Derived from name option. Same naming convention and language specializations possible as in class name option.
setterArgNamestringName of the property setter argument in Camel_Snake_Case naming convention. Derived from name option. Same naming convention and language specializations possible as in class name option.
setterModeMethodModeMethod mode of the property setter. See possible method modes. Default is regular.
setterCustombooleanDetermine whether the property setter will be have a custom implementation or not. Inferred from setterMode option.
setterVisibilityVisibilityVisibility of the property setter. See possible visibilities. Default is public.
hasMemberVarbooleanDetermine whether the property will have a member variable or not. Inferred from getterCustom and setterCustom options.
defaultValuestringDefault member variable initialized value either set via a constructor or via a static member initialization if the class is static. Default is empty string.
partOfIdentitybooleanDetermine whether the property is considered to be a part of identity of the class instance or not. If set to true the property will be used in the equality, inequality and hash operators. Inferred from static option.

ParameterlessConstructor JSON options

NameRequiredTypeDescription
initializedPropertiesInitializedProperty[]Initialized properties in the constructor. Inferred from class properties option. See definition.
codeFrontstring[]Constructor code lines placed before the autogenerated constructor body lines. Default is an empty array.
codeBackstring[]Constructor code lines placed after the autogenerated constructor body lines. Default is an empty array.
definitionConstructorDefinitionDetermine which constructor definition mode to use. See possible options. Inferred from class static option and constructor context.
visibilityVisibilityVisibility of the constructor. See possible visibilities. Inferred from class static option.
noexceptbooleanDetermine whether the constructor will have the noexcept modifier or not. Inferred from constructor context and definition option.
custombooleanDetermine whether the constructor will have a custom implementation or not. Default is false.

CopyConstructor JSON options

NameRequiredTypeDescription
mainArgNamestringName of the constructor main argument in Camel_Snake_Case naming convention. Derived from class name option. Same naming convention and language specializations possible as in class name option.
initializedPropertiesInitializedProperty[]Initialized properties in the constructor. Inferred from class properties option. See definition.
codeFrontstring[]Constructor code lines placed before the autogenerated constructor body lines. Default is an empty array.
codeBackstring[]Constructor code lines placed after the autogenerated constructor body lines. Default is an empty array.
operatorCodeFrontstring[]Copy assignment operator code lines placed before the autogenerated copy assignment operator body lines. Inferred from codeFront option.
operatorCodeBackstring[]Copy assignment operator code lines placed after the autogenerated copy assignment operator body lines. Inferred from codeBack option.
definitionConstructorDefinitionDetermine which constructor and copy assignment operator definition mode to use. See possible options. Inferred from class static and copyable options as well as constructor context.
visibilityVisibilityVisibility of the constructor and copy assignment operator. See possible visibilities. Default is public.
noexceptbooleanDetermine whether the constructor and copy assignment operator will have the noexcept modifier or not. Inferred from constructor context and definition option.
custombooleanDetermine whether the constructor will have a custom implementation or not. Default is false.
customOperatorbooleanDetermine whether the copy assignment operator will have a custom implementation or not. Inferred from custom option.

MoveConstructor JSON options

NameRequiredTypeDescription
mainArgNamestringName of the constructor main argument in Camel_Snake_Case naming convention. Derived from class name option. Same naming convention and language specializations possible as in class name option.
initializedPropertiesInitializedProperty[]Initialized properties in the constructor. Inferred from class properties option. See definition.
codeFrontstring[]Constructor code lines placed before the autogenerated constructor body lines. Default is an empty array.
codeBackstring[]Constructor code lines placed after the autogenerated constructor body lines. Default is an empty array.
operatorCodeFrontstring[]Move assignment operator code lines placed before the autogenerated move assignment operator body lines. Inferred from codeFront option.
operatorCodeBackstring[]Move assignment operator code lines placed after the autogenerated move assignment operator body lines. Inferred from codeBack option.
definitionConstructorDefinitionDetermine which constructor and move assignment operator definition mode to use. See possible options. Inferred from class static and movable options as well as constructor context.
visibilityVisibilityVisibility of the constructor and move assignment operator. See possible visibilities. Default is public.
noexceptbooleanDetermine whether the constructor and copy assignment operator will have the noexcept modifier or not. Inferred from constructor context and definition option.
custombooleanDetermine whether the constructor will have a custom implementation or not. Default is false.
customOperatorbooleanDetermine whether the move assignment operator will have a custom implementation or not. Inferred from custom option.

InitializedProperty JSON options

NameRequiredTypeDescription
namestringName of the property that will be initialized. Must match the property name option.
valuestringValue to which the property member variable will be initialized. For example, this value can be as simple as 123 or a bit more complicated like std::move(@) where @ is the valuePlaceholder option. The placeholder will implicitly be replaced with the constructor context specific value (for parameterless constructors it will use the property defaultValue option, for copy constructor it will use the member variable name and so on). Inferred from constructor context and property type option.
valuePlaceholderstringReplace value placeholder used in value option. Default is @.
initializeInBodybooleanDetermine whether the member variable will be initialized in the constructor body or not. Default is false.

Destructor JSON options

NameRequiredTypeDescription
virtualbooleanDetermine wether the destructor is virtual or not. Default is false.
codestring[]Destructor code lines placed in the destructor body. Default is an empty array.
definitionDestructorDefinitionDetermine which destructor definition mode to use. See possible options. Inferred from code option.
visibilityVisibilityVisibility of the destructor. See possible visibilities. Default is public.
custombooleanDetermine whether the destructor will have a custom implementation or not. Default is false.

EqualityOperator JSON options

NameRequiredTypeDescription
definedbooleanDetermine whether the equality and inequality operators are defined or not. Inferred from class static option.
comparePointersbooleanDetermine whether the equality and inequality operators will just compare the class instance pointer or not. Inferred from class copyable option.
comparedPropertiesComparedProperty[]Compared properties in the equality and inequality operators. Inferred from class properties option. See definition.
custombooleanDetermine whether the equality operator will have a custom implementation or not. Default is false.
customInequalitybooleanDetermine whether the inequality operator will have a custom implementation or not. Default is false.

ComparedProperty JSON options

NameRequiredTypeDescription
namestringName of the property that will be compared. Must match the property name option.
useGetterbooleanDetermine whether to use the property getter method or not. Inferred from property hasMemberVar and hasGetter options.
comparatorstringExpression evaluating to a boolean used to test equality of the property. For example, this comparator can be as simple as true or a bit more complicated like $ == @.$ where @ is the comparatorClassInstancePlaceholder option and $ is the comparatorPropertyPlaceholder option. The @ (comparatorClassInstancePlaceholder) placeholder will implicitly be replaced with the name of the other class instance argument name. The $ (comparatorPropertyPlaceholder) placeholder will implicitly be replaced with either the named access of the property member variable or the property getter method call. Inferred from comparatorClassInstancePlaceholder and comparatorPropertyPlaceholder options as well as property type option.
comparatorClassInstancePlaceholderstringReplace comparator placeholder used in comparator option. Default is @.
comparatorPropertyPlaceholderstringReplace comparator placeholder used in comparator option. Default is $.

HashOperator JSON options

NameRequiredTypeDescription
definedbooleanDetermine whether the hash operator is defined or not. Inferred from equality operator defined option.
usePointerAsHashbooleanDetermine whether the hash operator will just return the class instance pointer or not. Inferred from equality operator comparePointers option.
hashedPropertiesHashedProperty[]Hashed properties in the hash operator. Inferred from equality operator comparedProperties option. See definition.
custombooleanDetermine whether the hash operator will have a custom implementation or not. Inferred from equality operator custom option.

HashedProperty JSON options

NameRequiredTypeDescription
namestringName of the property that will be hashed. Must match the property name option.
useGetterbooleanDetermine whether to use the property getter method or not. Inferred from compared property useGetter option if possible or property hasMemberVar and hasGetter options.
hasherstringExpression evaluating to a hash integer used to hash the property. For example, this hasher can be as simple as 123 or a bit more complicated like hash<float> {}(@) where @ is the hasherPlaceholder option. The placeholder will implicitly be replaced with either the named access of the property member variable or the property getter method call. Inferred from hasherPlaceholder option as well as property type option.
hasherPlaceholderstringReplace hasher placeholder used in hasher option. Default is @.

ToStringOperator JSON options

NameRequiredTypeDescription
definedbooleanDetermine whether the to-string operator is defined or not. Inferred from class static option.
custombooleanDetermine whether the to-string operator will have a custom implementation or not. Default is false.

Constructor JSON options

NameRequiredTypeDescription
parametersConstructorParameter[]List of parameters that the constructor takes. Must contain at least one entry. See definition.
modeMethodModeMethod mode of the constructor. See possible method modes. Default is regular.
visibilityVisibilityVisibility of the constructor. See possible visibilities. Default is public.
noexceptbooleanDetermine whether the constructor will have the noexcept modifier or not. Default is false.

ConstructorParameter JSON options

NameRequiredTypeDescription
namestringName of the constructor parameter in Camel_Snake_Case naming convention. Same naming convention and language specializations possible as in class name option.
typestringType of the constructor parameter. See list of valid types. Note that the type cannot be string_mix, CLASS_MIX:<TYPE>, CLASS_PTR_MIX:<TYPE>, ARRAY_MIX:<TYPE> or ARRAY_PTR_MIX:<TYPE>.
objectiveC.namePrefixstringPrefix of the constructor parameter in Objective-C. Only lowercase letters are allowed here. Use empty string to omit the prefix. If - is used, both the prefix and the name will be omitted. Default is - for the very first parameter and empty string for all other parameters.
swift.namePrefixstringPrefix of the constructor parameter in Swift. Only lowercase letters are allowed here. Use empty string to omit the prefix. If - is used, both the prefix and the name will be omitted. Inferred from objectiveC.namePrefix option.

Method JSON options

NameRequiredTypeDescription
namestringName of the method in Camel_Snake_Case naming convention. Same naming convention and language specializations possible as in class name option.
returnTypestringReturn type of the method. See list of valid types. Note that the type cannot be string_mix, CLASS_MIX:<TYPE>, CLASS_PTR_MIX:<TYPE>, ARRAY_MIX:<TYPE> or ARRAY_PTR_MIX:<TYPE>. Empty string means no return type (void). Default is empty string.
parametersMethodParameter[]List of parameters that the method takes. See definition. Default is an empty array.
staticbooleanDetermine whether the method will be static or not. Inferred from class static option.
modeMethodModeMethod mode of the method. See possible method modes. Default is regular.
visibilityVisibilityVisibility of the method. See possible visibilities. Default is public.
noexceptbooleanDetermine whether the method will have the noexcept modifier or not. Default is false.

MethodParameter JSON options

NameRequiredTypeDescription
namestringName of the method parameter in Camel_Snake_Case naming convention. Same naming convention and language specializations possible as in class name option.
typestringType of the method parameter. See list of valid types. Note that the type cannot be string_mix, CLASS_MIX:<TYPE>, CLASS_PTR_MIX:<TYPE>, ARRAY_MIX:<TYPE> or ARRAY_PTR_MIX:<TYPE>.
objectiveC.namePrefixstringPrefix of the method parameter in Objective-C. Only lowercase letters are allowed here. Use empty string to omit the prefix. If - is used, both the prefix and the name will be omitted. Default is - for the very first parameter and empty string for all other parameters.
swift.namePrefixstringPrefix of the method parameter in Swift. Only lowercase letters are allowed here. Use empty string to omit the prefix. If - is used, both the prefix and the name will be omitted. Inferred from objectiveC.namePrefix option.

Naming conventions

Naming convention keyExample
lowerCasenaming_convention_example
upperCaseNAMING_CONVENTION_EXAMPLE
camelBacknamingConventionExample
camelCaseNamingConventionExample
camelSnakeBacknaming_Convention_Example
camelSnakeCaseNaming_Convention_Example
leadingUpperSnakeCaseNaming_convention_example

Languages

Language keyLanguage
cPlusPlusC++
cC
objectiveCObjective-C
swiftSwift
javaScriptJavaScript

Method modes

Mode keyDescription
regularA plain method.
virtualA virtual method.
pureVirtualA pure virtual method.
overrideA virtual method with an override specifier.

Visibilities

Visibility keyDescription
publicA public item.
protectedA protected item.
privateA private item.

Constructor definitions

Definition keyDescription
definedThe constructor will have an explicit body.
defaultThe constructor is defined as default in the implementation file.
deletedThe constructor is deleted in the header file.
omittedThe constructor is omitted altogether.

Destructor definitions

Definition keyDescription
definedThe destructor will have an explicit body.
defaultThe destructor is defined as default in the implementation file.
omittedThe destructor is omitted altogether.

Valid types

Type keyDescription
int8An 8-bit signed integer. Maps to std::int8_t C++ type. A number type in JavaScript.
int16A 16-bit signed integer. Maps to std::int16_t C++ type. A number type in JavaScript.
int32A 32-bit signed integer. Maps to std::int32_t C++ type. A number type in JavaScript.
int64A 64-bit signed integer. Maps to std::int64_t C++ type. A bigint type in JavaScript.
uint8An 8-bit unsigned integer. Maps to std::uint8_t C++ type. A number type in JavaScript.
uint16A 16-bit unsigned integer. Maps to std::uint16_t C++ type. A number type in JavaScript.
uint32A 32-bit unsigned integer. Maps to std::uint32_t C++ type. A number type in JavaScript.
uint64A 64-bit unsigned integer. Maps to std::uint64_t C++ type. A bigint type in JavaScript.
floatA 32-bit IEEE 754 floating point number. Maps to float C++ type. A number type in JavaScript.
doubleA 64-bit IEEE 754 floating point number. Maps to double C++ type. A number type in JavaScript.
booleanA boolean type. Maps to bool C++ type. A boolean type in JavaScript.
stringA string type. Maps to std::string C++ type (getter and setter use it by value). A string type in JavaScript.
string_refA string type. Maps to std::string C++ type (getter and setter use it by const-ref). A string type in JavaScript.
string_mixA string type. Maps to std::string C++ type (getter uses it by const-ref and setter uses it by value). A string type in JavaScript.
ENUM:<TYPE>A custom generated enum <TYPE> type.
CLASS:<TYPE>A custom generated class <TYPE> type. In C++ getter and setter use it by value.
CLASS_REF:<TYPE>A custom generated class <TYPE> type. In C++ getter and setter use it by const-ref.
CLASS_MIX:<TYPE>A custom generated class <TYPE> type. In C++ getter uses it by const-ref and setter uses it by value.
CLASS_PTR:<TYPE>A custom generated class <TYPE> type wrapped in a std::shared_ptr smart pointer. In C++ getter and setter use it by value.
CLASS_PTR_REF:<TYPE>A custom generated class <TYPE> type wrapped in a std::shared_ptr smart pointer. In C++ getter and setter use it by const-ref.
CLASS_PTR_MIX:<TYPE>A custom generated class <TYPE> type wrapped in a std::shared_ptr smart pointer. In C++ getter uses it by const-ref and setter uses it by value.
ARRAY:<TYPE>An array of a builtin <TYPE> type or a custom generated enum or class <TYPE> type. Maps to std::vector C++ type. In C++ getter and setter use it by value. Valid builtin types are int8, int16, int32, int64, uint8, uint16, uint32, uint64, float, double, boolean and string.
ARRAY_REF:<TYPE>An array of a builtin <TYPE> type or a custom generated enum or class <TYPE> type. Maps to std::vector C++ type. In C++ getter and setter use it by const-ref. Valid builtin types are int8, int16, int32, int64, uint8, uint16, uint32, uint64, float, double, boolean and string.
ARRAY_MIX:<TYPE>An array of a builtin <TYPE> type or a custom generated enum or class <TYPE> type. Maps to std::vector C++ type. In C++ getter uses it by const-ref and setter uses it by value. Valid builtin types are int8, int16, int32, int64, uint8, uint16, uint32, uint64, float, double, boolean and string.
ARRAY_PTR:<TYPE>An array of a custom generated class <TYPE> type wrapped in a std::shared_ptr smart pointer. Maps to std::vector C++ type. In C++ getter and setter use it by value.
ARRAY_PTR_REF:<TYPE>An array of a custom generated class <TYPE> type wrapped in a std::shared_ptr smart pointer. Maps to std::vector C++ type. In C++ getter and setter use it by const-ref.
ARRAY_PTR_MIX:<TYPE>An array of a custom generated class <TYPE> type wrapped in a std::shared_ptr smart pointer. Maps to std::vector C++ type. In C++ getter uses it by const-ref and setter uses it by value.
dataA binary data type.