Class CMacro#

Class Documentation#

class CMacro#

Macro processing class.

Public Functions

CMacro(const char *szName, const std::vector<std::string> *pvecParams, const char *szValue)#

Constructor.

Parameters:
  • szName[in] The name of the macro.

  • pvecParams[in] Pointer to the list of zero or more param definitions or NULL when the macro doesn’t have param definitions.

  • szValue[in] Zero terminated string to the value or NULL when the macro doesn’t have a value.

CMacro(const CMacro &rMacro)#

Copy constructor.

Parameters:

rMacro[in] Reference to the macro to copy from.

CMacro(CMacro &&rMacro) noexcept#

Move constructor.

Parameters:

rMacro[in] Reference to the macro to copy from.

CMacro &operator=(const CMacro &rMacro)#

Assignment operator.

Parameters:

rMacro[in] Reference to the macro to copy from.

Returns:

Reference to this macro.

CMacro &operator=(CMacro &&rMacro) noexcept#

Move operator.

Parameters:

rMacro[in] Reference to the macro to copy from.

Returns:

Reference to this macro.

bool operator==(const CMacro &rMacro)#

Equality operator.

Parameters:

rMacro[in] Reference to the macro to copy from.

Returns:

Returns true if the macros are identical; otherwise returns false.

bool operator!=(const CMacro &rMacro)#

Inequality operator.

Parameters:

rMacro[in] Reference to the macro to copy from.

Returns:

Returns true if the macros are not identical; otherwise returns false.

const std::string &GetName() const#

Get the name of the macro.

Returns:

Reference to the string containing the macro name.

bool ExpectParameters() const#

Returns whether the macro expects zero or more parameters (uses parenthesis for its parameters).

Attention

A macro could return ‘true’ even when it expects zero parameters. In that case, it uses at least parenthesis. If no parenthesis is defined for this macro, it would returns false.

Returns:

Returns ‘true’ when the macro expects parameters; false when not.

std::string Expand(const CIdlCompilerEnvironment &renv, const CToken &rtoken, const std::vector<std::string> &rvecParams, CUsedMacroSet &rsetUsedMacros) const#

Expand the macro with the provided parameters. Returns the value string of the macro with the filled in parameters.

Parameters:
  • renv[in] Reference to the current environment needed to expand parameters.

  • rtoken[in] Token of the parameters in the code. Used for throwing errors.

  • rvecParams[in] Vector with the parameters.

  • rsetUsedMacros[inout] Reference to the set of previously expanded macros, preventing circular expansion. This set will be extended if macros

Returns:

Returns the macro string with the resolved parameters.