#include <CommandSyntax.h>
The command syntax class. This class describes the parameter syntax of a given command. Using this syntax the command manager can automatically perform syntax error checking when executing a command.
◆ EParamType
The parameter type.
Enumerator |
---|
PARAMTYPE_STRING | The parameter value is a string.
|
PARAMTYPE_BOOLEAN | The parameter value is a boolean.
|
PARAMTYPE_CHAR | The parameter value is a character.
|
PARAMTYPE_INT | The parameter value is an integer.
|
PARAMTYPE_FLOAT | The parameter value is a float.
|
PARAMTYPE_VECTOR3 | The parameter value is a three component vector.
|
PARAMTYPE_VECTOR4 | The parameter value is a four component vector.
|
◆ CommandSyntax()
MCore::CommandSyntax::CommandSyntax |
( |
size_t |
numParamsToReserve = 5 | ) |
|
The constructor.
- Parameters
-
numParamsToReserve | The amount of parameters to pre-allocate memory for. This can reduce the number of reallocs needed when registering new paramters. |
◆ ~CommandSyntax()
MCore::CommandSyntax::~CommandSyntax |
( |
| ) |
|
◆ AddParameter()
void MCore::CommandSyntax::AddParameter |
( |
const char * |
name, |
|
|
const char * |
description, |
|
|
EParamType |
paramType, |
|
|
const char * |
defaultValue |
|
) |
| |
Add a new optional parameter to this syntax. The order in which you add parameters isn't really important.
- Parameters
-
name | The parameter name. |
description | The description of the parameter. |
paramType | The type of the parameter. |
defaultValue | The default value of the parameter. |
◆ AddRequiredParameter()
void MCore::CommandSyntax::AddRequiredParameter |
( |
const char * |
name, |
|
|
const char * |
description, |
|
|
EParamType |
paramType |
|
) |
| |
Add a required parameter to the syntax.
- Parameters
-
name | The name of the parameter. |
description | The description of the parameter. |
paramType | The parameter type. |
◆ CheckIfHasParameter()
bool MCore::CommandSyntax::CheckIfHasParameter |
( |
const char * |
parameter | ) |
const |
Check if we already registered a parameter with a given name. This is non-case-sensitive.
- Parameters
-
parameter | The name of the parameter. |
- Returns
- Returns true when the parameter has already been registered to this syntax, otherwise false is returned.
◆ CheckIfIsValid() [1/2]
bool MCore::CommandSyntax::CheckIfIsValid |
( |
const char * |
parameterList, |
|
|
AZStd::string & |
outResult |
|
) |
| const |
Check if a given parameter list would be valid with this syntax. The parameter list will look like: "-numItems 10 -enableMixing true".
- Parameters
-
parameterList | The parameter string to validate with this syntax. |
outResult | The string that will receive the result of the validation. This will contain the errors in case it's invalid. |
- Returns
- Returns false when the parameter list is invalid, otherwise true is returned.
◆ CheckIfIsValid() [2/2]
bool MCore::CommandSyntax::CheckIfIsValid |
( |
const CommandLine & |
commandLine, |
|
|
AZStd::string & |
outResult |
|
) |
| const |
Check if a given command line is valid in combination with this syntax.
- Parameters
-
commandLine | The command line to check. |
outResult | The string that will receive the result of the validation. This will contain the errors in case it's invalid. |
- Returns
- Returns false when the command line is invalid, otherwise true is returned.
◆ FindParameterIndex()
size_t MCore::CommandSyntax::FindParameterIndex |
( |
const char * |
parameter | ) |
const |
Find the parameter number of the parameter with a specified name.
- Parameters
-
parameter | The name of the parameter, non-case-sensitive. |
- Returns
- Returns the index of the parameter, in range of [0..GetNumParameters()-1], or MCORE_INVALIDINDEX32 in case it hasn't been found.
◆ GetDefaultValue() [1/3]
const AZStd::string& MCore::CommandSyntax::GetDefaultValue |
( |
const char * |
paramName | ) |
const |
Get the default value for a parameter with a given name.
- Parameters
-
paramName | The parameter name to check for. |
- Returns
- The string that will receive the default value.
◆ GetDefaultValue() [2/3]
bool MCore::CommandSyntax::GetDefaultValue |
( |
const char * |
paramName, |
|
|
AZStd::string & |
outDefaultValue |
|
) |
| const |
Get the default value for a parameter with a given name.
- Parameters
-
paramName | The parameter name to check for. |
outDefaultValue | The string that will receive the default value. |
- Returns
- Returns true when the parameter default value has been looked up successfully, otherwise false is returned (no parameter with such name found).
◆ GetDefaultValue() [3/3]
const AZStd::string& MCore::CommandSyntax::GetDefaultValue |
( |
size_t |
index | ) |
const |
Get the default value for a given parameter.
- Parameters
-
index | The parameter number to get the default value from. |
- Returns
- The string containing the default value.
◆ GetNumParameters()
MCORE_INLINE size_t MCore::CommandSyntax::GetNumParameters |
( |
| ) |
const |
|
inline |
Get the number of parameters registered to this syntax.
- Returns
- The number of added/registered parameters.
◆ GetParamDescription()
const char* MCore::CommandSyntax::GetParamDescription |
( |
size_t |
index | ) |
const |
Get the description of a given parameter.
- Parameters
-
index | The parameter number to get the description for. |
- Returns
- A string containing the description of the parameter.
◆ GetParamName()
const char* MCore::CommandSyntax::GetParamName |
( |
size_t |
index | ) |
const |
Get the name of a given parameter.
- Parameters
-
index | The parameter number to get the name for. |
- Returns
- The string containing the name of the parameter.
◆ GetParamRequired()
bool MCore::CommandSyntax::GetParamRequired |
( |
size_t |
index | ) |
const |
Check if a given parameter is required or not.
- Parameters
-
index | The parameter number to check. |
- Returns
- Returns true when the parameter is required, or false when it is optional.
◆ GetParamType()
EParamType MCore::CommandSyntax::GetParamType |
( |
size_t |
index | ) |
const |
Get the value type of a given parameter.
- Parameters
-
index | The parameter number to get the value type from. |
- Returns
- The type of the parameter value.
◆ GetParamTypeString()
const char* MCore::CommandSyntax::GetParamTypeString |
( |
size_t |
index | ) |
const |
Get the parameter type string of a given parameter. This returns a human readable string of the parameter type, for example "STRING" or "FLOAT".
- Parameters
-
index | The parameter number to get the type string for. |
- Returns
- The parameter type string.
◆ LogSyntax()
void MCore::CommandSyntax::LogSyntax |
( |
| ) |
|
Log the currently registered syntax using MCore::LogInfo(...).
◆ ReserveParameters()
void MCore::CommandSyntax::ReserveParameters |
( |
size_t |
numParamsToReserve | ) |
|
Reserve space for a given number of parameters, to prevent memory reallocs when adding new parameters.
- Parameters
-
numParamsToReserve | The number of parameters to reserve space for. |
The documentation for this class was generated from the following file:
- Gems/EMotionFX/Code/MCore/Source/CommandSyntax.h