The class containing some helper function for configuration parameters. More...
Static Public Member Functions | |
static bool | getBool (ConfigurationParameters ¶ms, QString paramPath, bool def=false) |
Return the value of parameter as boolean, if the parameter has not been setted or the value is not a boolean, it will return the defaul value specified The valid value converted in boolean are: | |
static QVector< bool > | getBoolVector (ConfigurationParameters ¶ms, QString paramPath, QString def=QString()) |
Returns a vector of booleans from the specified parameter. | |
static QStringList | getDescribedParameterNames (QString type, QString prefix=QString()) |
return the list of all parameter's type described in Factory::getTypeDescriptions() | |
static QStringList | getDescribedSubgroupNames (QString type, QString prefix=QString()) |
return the list of all subgroup's type described in Factory::getTypeDescriptions() | |
static double | getDouble (ConfigurationParameters ¶ms, QString paramPath, double def=0) |
Return the value of parameter as double, if the parameter has not been setted or the value is not an double, it will return the defaul value specified. | |
static int | getInt (ConfigurationParameters ¶ms, QString paramPath, int def=0) |
Return the value of parameter as integer, if the parameter has not been setted or the value is not an integer, it will return the defaul value specified. | |
static QVector< int > | getIntegerVector (ConfigurationParameters ¶ms, QString paramPath, QString def=QString()) |
Returns a vector of integers from the specified parameter. | |
static QStringList | getParameterEnumValues (QString type, QString paramName) |
return the possible enum values as QStringList for the parameter | |
static QString | getParameterTypeName (QString type, QString paramName) |
return the type of the parameter as declared in Factory::getTypeDescriptions() | |
static QString | getString (ConfigurationParameters ¶ms, QString paramPath, QString def=QString()) |
Return the value of parameter as QString, if the parameter has not been setted, it will return the default value specified. | |
static QStringList | getStringList (ConfigurationParameters ¶ms, QString paramPath, QString delimiter=QString(" ")) |
Return the value of parameter as QStringList, if the parameter has not been setted, it will return an empty QStringList. | |
static unsigned int | getUnsignedInt (ConfigurationParameters ¶ms, QString paramPath, unsigned int def=0) |
Return the value of parameter as unsigned integer, if the parameter has not been setted or the value is not an unsigned integer, it will return the defaul value specified. | |
static QVector< unsigned int > | getUnsignedIntegerVector (ConfigurationParameters ¶ms, QString paramPath, QString def=QString()) |
Returns a vector of unsigned integers from the specified parameter. | |
static QVector< double > | getVector (ConfigurationParameters ¶ms, QString paramPath, QString def=QString()) |
Return a QVector of double from the parameters specified It helps on parsing parameters like: | |
static bool | hasGroup (ConfigurationParameters ¶ms, QString group) |
Return true if the group exists. | |
static bool | hasParameter (ConfigurationParameters ¶ms, QString group, QString paramName) |
Return true if the parameter exist and is not empty into the group. | |
static bool | isRuntimeParameter (QString type, QString paramName) |
Returns true if the parameter can be modified at runtime using ParameterSettable::setRuntimeParameter. | |
static bool | parameterIsDouble (QString type, QString paramName) |
return true if the real parameter is double, otherwise return false | |
static void | throwUserConfigError (QString paramName, QString paramValue, QString description) |
A utility function to ease throwing the exception UserDefinedCheckFailureException. | |
static void | throwUserMissingResourceError (QString resourceName, QString description) |
A utility function to ease throwing the exception UserRequiredResourceMissingException. | |
Detailed Description
The class containing some helper function for configuration parameters.
Definition at line 34 of file configurationhelper.h.
Member Function Documentation
|
static |
Return the value of parameter as boolean, if the parameter has not been setted or the value is not a boolean, it will return the defaul value specified The valid value converted in boolean are:
Any other values are not accepted.
- Parameters
-
paramPath is the full path to the parameter; i.e. prefix + "paramName" in a typical use of configure method def is the default value returned if the conversion fails
Definition at line 59 of file configurationhelper.cpp.
References ConfigurationParameters::getValue().
Referenced by ConfigurationHelper::isRuntimeParameter().
|
static |
Returns a vector of booleans from the specified parameter.
This transforms the string value of the parameter to a vector of booleans with true corresponding to ones in the string and false to zeros. The string must be made up only of "0" and "1"
- Parameters
-
params the configuration parameters object paramPath a string with only 0 and 1 def the string to use if the parameter is not present
- Returns
- a vector of bools. If the string contains characters other than 0 or 1 returns an empty vector
Definition at line 136 of file configurationhelper.cpp.
References ConfigurationParameters::getValue().
|
static |
return the list of all parameter's type described in Factory::getTypeDescriptions()
This function return the name of all parameter's type described in the Factory::getTypeDescriptions() corresponding to the type specified
- Parameters
-
type the type name of the object (or the full path where the type description is) prefix is the subgroup prefix to get the parameters described in a subgroup
- Returns
- a list of parameter's name
Definition at line 181 of file configurationhelper.cpp.
References ParameterSettable::fullSubgroupDescriptionPath(), ConfigurationParameters::getGroupsList(), and Factory::getTypeDescriptions().
|
static |
return the list of all subgroup's type described in Factory::getTypeDescriptions()
This function return the name of all subgroup's type described in the Factory::getTypeDescriptions() corresponding to the type specified
- Parameters
-
type the type name of the object (or the full path where the type description is) prefix is the subgroup prefix to get the subgroups described into another subgroup
- Returns
- a list of subgroup's name
Definition at line 186 of file configurationhelper.cpp.
References ParameterSettable::fullSubgroupDescriptionPath(), ConfigurationParameters::getGroupsList(), and Factory::getTypeDescriptions().
|
static |
Return the value of parameter as double, if the parameter has not been setted or the value is not an double, it will return the defaul value specified.
- Parameters
-
paramPath is the full path to the parameter; i.e. prefix + "paramName" in a typical use of configure method def is the default value returned if the conversion fails
Definition at line 48 of file configurationhelper.cpp.
References ConfigurationParameters::getValue().
|
static |
Return the value of parameter as integer, if the parameter has not been setted or the value is not an integer, it will return the defaul value specified.
- Parameters
-
paramPath is the full path to the parameter; i.e. prefix + "paramName" in a typical use of configure method def is the default value returned if the conversion fails
Definition at line 26 of file configurationhelper.cpp.
References ConfigurationParameters::getValue().
|
static |
Returns a vector of integers from the specified parameter.
This function helps parsing parameters like:
The value of the parameter should be a space-separated list of integers
- Parameters
-
params the configuration parameters object paramPath the name of the parameter to parse def the string to use if the parameter is not present
- Returns
- a vector of integers. If the parameter contains some non-numeric string, a 0 is returned in the corresponding position
Definition at line 98 of file configurationhelper.cpp.
References ConfigurationParameters::getValue().
|
static |
return the possible enum values as QStringList for the parameter
- Parameters
-
type the type name of the object (or the full path where the type description is) paramName is the name of the parameter
- Warning
- it return an empty QStringList if the parameter is not an enum type
Definition at line 213 of file configurationhelper.cpp.
References ParameterSettable::fullParameterDescriptionPath(), ConfigurationHelper::getStringList(), and Factory::getTypeDescriptions().
|
static |
return the type of the parameter as declared in Factory::getTypeDescriptions()
- Parameters
-
type the type name of the object (or the full path where the type description is) paramName is the name of the parameter
- Returns
- the type name; the possible values are (case-sensitive):
string
int
real
bool
enum
object
missing
- Note
- the value 'missing' is returned when the type is not specified in the parameter's description
Definition at line 191 of file configurationhelper.cpp.
References ParameterSettable::fullParameterDescriptionPath(), ConfigurationHelper::getString(), and Factory::getTypeDescriptions().
|
static |
Return the value of parameter as QString, if the parameter has not been setted, it will return the default value specified.
- Parameters
-
paramPath is the full path to the parameter; i.e. prefix + "paramName" in a typical use of configure method def is the default value returned if the parameters does not exists
- Note
- If this method is called with def equal to QString(), then it behaves exactly as ConfigurationParameters::getValue
Definition at line 71 of file configurationhelper.cpp.
References ConfigurationParameters::getValue().
Referenced by RuntimeParameterSetter::get(), ConfigurationHelper::getParameterTypeName(), ConfigurationHelper::parameterIsDouble(), and RuntimeParameterSetter::set().
|
static |
Return the value of parameter as QStringList, if the parameter has not been setted, it will return an empty QStringList.
- Parameters
-
paramPath is the full path to the parameter; i.e. prefix + "paramName" in a typical use of configure method delimiter is the string that delimits the elements of the QStringList
Definition at line 79 of file configurationhelper.cpp.
References ConfigurationParameters::getValue().
Referenced by ConfigurationHelper::getParameterEnumValues().
|
static |
Return the value of parameter as unsigned integer, if the parameter has not been setted or the value is not an unsigned integer, it will return the defaul value specified.
- Parameters
-
paramPath is the full path to the parameter; i.e. prefix + "paramName" in a typical use of configure method def is the default value returned if the conversion fails
Definition at line 37 of file configurationhelper.cpp.
References ConfigurationParameters::getValue().
|
static |
Returns a vector of unsigned integers from the specified parameter.
This function helps parsing parameters like:
The value of the parameter should be a space-separated list of unsigned integers
- Parameters
-
params the configuration parameters object paramPath the name of the parameter to parse def the string to use if the parameter is not present
- Returns
- a vector of unsigned integers. If the parameter contains some non-numeric string, a 0 is returned in the corresponding position
Definition at line 117 of file configurationhelper.cpp.
References ConfigurationParameters::getValue().
|
static |
Return a QVector of double from the parameters specified It helps on parsing parameters like:
and it returns a QVector containing the values
- Parameters
-
paramPath is the full path to the parameter; i.e. prefix + "paramName" in a typical use of configure method def the string to use if the parameter is not present
- Note
- if the list of values in the parameter contains some non-numeric strings then in the corresponding position a zero will be placed into the vector: getVector will return: { 10 3.2 0.0 4 23 12 }[GROUP]param = 10 3.2 garbage 4 23 12
Definition at line 83 of file configurationhelper.cpp.
References ConfigurationParameters::getValue().
|
static |
Return true if the group exists.
- Parameters
-
group is the full path of the group to search; i.e: /parentGroup1/parentGroup2/groupToCheck
Definition at line 154 of file configurationhelper.cpp.
References ConfigurationParameters::getGroupsList(), and ConfigurationParameters::isCaseSensitive().
|
static |
Return true if the parameter exist and is not empty into the group.
- Parameters
-
group is the full path of the group containing the parameter paramName is the name of the parameter to check
- Returns
- true if the parameter exists and its value is not empty, otherwise return false
Definition at line 167 of file configurationhelper.cpp.
References ConfigurationParameters::getValue().
|
static |
Returns true if the parameter can be modified at runtime using ParameterSettable::setRuntimeParameter.
- Parameters
-
type the type name of the object (or the full path where the type description is) paramName is the name of the parameter
Definition at line 198 of file configurationhelper.cpp.
References ParameterSettable::fullParameterDescriptionPath(), ConfigurationHelper::getBool(), and Factory::getTypeDescriptions().
|
static |
return true if the real parameter is double, otherwise return false
- Parameters
-
type the type name of the object (or the full path where the type description is) paramName is the name of the parameter
- Warning
- in the description the precision is present only for runtime parameter with real type
Definition at line 205 of file configurationhelper.cpp.
References ParameterSettable::fullParameterDescriptionPath(), ConfigurationHelper::getString(), and Factory::getTypeDescriptions().
|
static |
A utility function to ease throwing the exception UserDefinedCheckFailureException.
This function accepts QStrings instead of const char* to allow easier formatting of the error messages. This does never return as the exception is always thrown
- Parameters
-
paramName the name of the parameter on which the check failed paramValue the value of the parameter that caused the check to fail description a description of the error
Definition at line 171 of file configurationhelper.cpp.
|
static |
A utility function to ease throwing the exception UserRequiredResourceMissingException.
This function accepts QStrings instead of const char* to allow easier formatting of the error messages. This does never return as the exception is always thrown
- Parameters
-
resourceName the name of the missing resource description a description of the error
Definition at line 176 of file configurationhelper.cpp.
The documentation for this class was generated from the following files:
- configuration/include/configurationhelper.h
- configuration/src/configurationhelper.cpp