Open 3D Engine EMotionFX Gem API Reference  24.09
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
MCore::CommandSyntax Class Reference

#include <CommandSyntax.h>

Public Types

enum  EParamType {
  PARAMTYPE_STRING = 0 , PARAMTYPE_BOOLEAN = 1 , PARAMTYPE_CHAR = 2 , PARAMTYPE_INT = 3 ,
  PARAMTYPE_FLOAT = 4 , PARAMTYPE_VECTOR3 = 5 , PARAMTYPE_VECTOR4 = 6
}
 

Public Member Functions

 CommandSyntax (size_t numParamsToReserve=5)
 
 ~CommandSyntax ()
 
void ReserveParameters (size_t numParamsToReserve)
 
void AddParameter (const char *name, const char *description, EParamType paramType, const char *defaultValue)
 
void AddRequiredParameter (const char *name, const char *description, EParamType paramType)
 
bool GetParamRequired (size_t index) const
 
const char * GetParamName (size_t index) const
 
const char * GetParamDescription (size_t index) const
 
const AZStd::string & GetDefaultValue (size_t index) const
 
const AZStd::string & GetDefaultValue (const char *paramName) const
 
bool GetDefaultValue (const char *paramName, AZStd::string &outDefaultValue) const
 
MCORE_INLINE size_t GetNumParameters () const
 
const char * GetParamTypeString (size_t index) const
 
const char * GetParamTypeString (const Parameter &parameter) const
 
EParamType GetParamType (size_t index) const
 
bool CheckIfIsValid (const char *parameterList, AZStd::string &outResult) const
 
bool CheckIfIsValid (const CommandLine &commandLine, AZStd::string &outResult) const
 
bool CheckIfHasParameter (const char *parameter) const
 
size_t FindParameterIndex (const char *parameter) const
 
void LogSyntax ()
 

Detailed Description

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.

Member Enumeration Documentation

◆ 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.

Constructor & Destructor Documentation

◆ CommandSyntax()

MCore::CommandSyntax::CommandSyntax ( size_t  numParamsToReserve = 5)

The constructor.

Parameters
numParamsToReserveThe amount of parameters to pre-allocate memory for. This can reduce the number of reallocs needed when registering new paramters.

◆ ~CommandSyntax()

MCore::CommandSyntax::~CommandSyntax ( )

The destructor.

Member Function Documentation

◆ 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
nameThe parameter name.
descriptionThe description of the parameter.
paramTypeThe type of the parameter.
defaultValueThe 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
nameThe name of the parameter.
descriptionThe description of the parameter.
paramTypeThe 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
parameterThe 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
parameterListThe parameter string to validate with this syntax.
outResultThe 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
commandLineThe command line to check.
outResultThe 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
parameterThe 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
paramNameThe 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
paramNameThe parameter name to check for.
outDefaultValueThe 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
indexThe 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
indexThe 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
indexThe 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
indexThe 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
indexThe 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
indexThe 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
numParamsToReserveThe number of parameters to reserve space for.

The documentation for this class was generated from the following file: