3.1. RareTs: Generic Macros - TheNitesWhoSay/RareCpp GitHub Wiki

NOTE(targetIdentifier, notesValues...)

  • targetIdentifier: the name of the class or class member you wish to annotate
  • noteValues: the compile-time values you wish to associate with the given target

The NOTE macro is used to associate compile-time information with the reflected member or reflected struct/class given by "targetIdentifier". NOTE expands to a (static inline constexpr) tuple named targetIdentifier_note, e.g. NOTE(a, 0) becomes "static inline constexpr auto a_note { std::tuple { 1 } };" in the namespace or class-scope you placed it in.

Further information about notes and how to use them can be found at Notes.


REFLECT(objectName, memberNames...)

  • objectName: the name of the class or struct which you're reflecting
  • memberNames: between zero and 125 members you wish to reflect

The REFLECT macro is used to generate reflection information about the struct/class named "objectName".

Further information about the REFLECT macro and how to use it can be found at REFLECT Macro


REFLECT_NOTED(objectName, memberNames...)

  • objectName: the name of the class or struct which you're reflecting
  • memberNames: between zero and 125 members you wish to reflect

The REFLECT_NOTED macro is used to generate reflection information about the struct/class named "objectName". REFLECT_NOTED is exactly the same as REFLECT except it captures the NOTE on the given "objectName".

Further information about the REFLECT/REFLECT_NOTED macro and how to use it can be found at REFLECT Macro


REFLECT_PRIVATE(objectName, memberNames...)

  • objectName: the name of the class or struct which you're reflecting
  • memberNames: between zero and 125 members you wish to reflect

The REFLECT_PRIVATE macro is used to generate reflection information about the struct/class named "objectName".

Further information about the REFLECT_PRIVATE macro and how to use it can be found at REFLECT Macro.


REFLECT_PRIVATE_EMPTY(objectName, noteValues...)

  • objectName: the name of the class or struct you're reflecting
  • noteValues: the compile-time values you wish to associate with the given object

The REFLECT_PRIVATE_EMPTY macro is used to associate notes with the struct/class named "objectName" when there are no members being reflected.

Further information about the REFLECT_PRIVATE_EMPTY macro and how to use it can be found at REFLECT Macro.


REFLECT_PRIVATE_NOTED((objectName) (objectNoteValues...), (firstMemberName) (firstMemberNoteValues...), ...(nthMemberName) (nthMemberNoteValues...)...)

  • objectName: the name of the class or struct you're reflecting
  • objectNoteValues: the compile-time values you wish to associate with the given object type (may be done/empty parenthesis)
  • firstMemberName: the name of the first member being reflected
  • firstMemberNoteValues...: the compile-time values you wish to associate with the first member
  • nthMemberName: the name of the nth member (up to 125) being reflected
  • nthMemberNoteValues...: the compile-time values you wish to associate with the nth member The REFLECT_PRIVATE_NOTED macro is used to generate reflection information about the struct/class named "objectName" and associate notes with at least one of the members or the struct/class type itself.

Further information about the REFLECT_PRIVATE_NOTED macro and how to use it can be found at REFLECT Macro.


SET_DEFAULT_OBJECT_MAPPING(object, objectDefaultMapping)

  • object: the name of the object for which you wish to set a default mapping
  • objectDefaultMapping: the name of the type to which something should be mapped prior to operations like serializations, or should be mapped from prior to operations like deserialization

The SET_DEFAULT_OBJECT_MAPPING macro must be placed in the global scope and creates an association between a type which can be used by components to determine to what something should be mapped using RareMapper prior to output/input. For more information, see RareMapper: Annotations


RARE_COUNT_ARGUMENTS(args...)

  • args: the arguments to count

The RARE_COUNT_ARGUMENTS macro expands to a number representing the count of arguments passed to it. This macro can count 0 arguments, but cannot count parenthesized arguments.


RARE_COUNT_POSITIVE_ARGUMENTS(args...)

  • args: the arguments to count (must not be 0 arguments)

The RARE_COUNT_POSITIVE_ARGUMENTS macro expands to a number representing the count of arguments passed to it. This macro cannot count 0 arguments, but can count parenthesized arguments.


RARE_FOR_EACH(function, args...)

  • function: the function-like macro to call for each argument
  • args: the arguments, each of which will be passed individually to the function-like macro "function"

The RARE_FOR_EACH macro "calls" the function-like macro "function" for each argument present in "args".


RARE_FOR_EACH_POSITIVE(function, args...)

  • function: the function-like macro to call for each argument
  • args: the arguments, which may be parenthesized, each of which will be passed individually to the function-like macro "function"

The RARE_FOR_EACH_POSITIVE macro "calls" the function-like macro "function" for each argument present in "args"; unlike RARE_FOR_EACH the arguments may be parenthesized and there cannot be zero arguments.


LHS(x)

  • x: an argument in the form (lhs)(rhs) Takes an argument in the form "(lhs)(rhs)" and expands to lhs.

RHS(x)

  • x: an argument in the form (lhs)(rhs) Takes an argument in the form "(lhs)(rhs)" and expands to rhs.