ConfigurationHelper Class Reference

The class containing some helper function for configuration parameters. More...

List of all members.

Static Public Member Functions

static bool getBool (ConfigurationParameters &params, 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 double getDouble (ConfigurationParameters &params, 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 &params, 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 QString getString (ConfigurationParameters &params, 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 &params, 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 &params, 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< double > getVector (ConfigurationParameters &params, QString paramPath)
 Return a QVector of double from the parameters specified It helps on parsing parameters like:
static bool hasGroup (ConfigurationParameters &params, QString group)
 Return true if the group exists.
static bool hasParameter (ConfigurationParameters &params, QString group, QString paramName)
 Return true if the parameter exist and is not empty into the group.
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 35 of file configurationhelper.h.


Member Function Documentation

bool getBool ( ConfigurationParameters params,
QString  paramPath,
bool  def = false 
) [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:

  param = true
  param = false
  param = T  ; <- converted as TRUE
  param = F  ; <- converted as FALSE
  ; any case of the above values are correctly converted
  param = 1  ; <- converted as TRUE
  param = 0  ; <- converted as FALSE

Any other values are not accepted.

Parameters:
paramPathis the full path to the parameter; i.e. prefix + "paramName" in a typical use of configure method
defis the default value returned if the conversion fails

Definition at line 59 of file configurationhelper.cpp.

References ConfigurationParameters::getValue().

double getDouble ( ConfigurationParameters params,
QString  paramPath,
double  def = 0 
) [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:
paramPathis the full path to the parameter; i.e. prefix + "paramName" in a typical use of configure method
defis the default value returned if the conversion fails

Definition at line 48 of file configurationhelper.cpp.

References ConfigurationParameters::getValue().

int getInt ( ConfigurationParameters params,
QString  paramPath,
int  def = 0 
) [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:
paramPathis the full path to the parameter; i.e. prefix + "paramName" in a typical use of configure method
defis the default value returned if the conversion fails

Definition at line 26 of file configurationhelper.cpp.

References ConfigurationParameters::getValue().

QString getString ( ConfigurationParameters params,
QString  paramPath,
QString  def = QString() 
) [static]

Return the value of parameter as QString, if the parameter has not been setted, it will return the default value specified.

Parameters:
paramPathis the full path to the parameter; i.e. prefix + "paramName" in a typical use of configure method
defis 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().

QStringList getStringList ( ConfigurationParameters params,
QString  paramPath,
QString  delimiter = QString(" ") 
) [static]

Return the value of parameter as QStringList, if the parameter has not been setted, it will return an empty QStringList.

Parameters:
paramPathis the full path to the parameter; i.e. prefix + "paramName" in a typical use of configure method
delimiteris the string that delimits the elements of the QStringList

Definition at line 79 of file configurationhelper.cpp.

References ConfigurationParameters::getValue().

unsigned int getUnsignedInt ( ConfigurationParameters params,
QString  paramPath,
unsigned int  def = 0 
) [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:
paramPathis the full path to the parameter; i.e. prefix + "paramName" in a typical use of configure method
defis the default value returned if the conversion fails

Definition at line 37 of file configurationhelper.cpp.

References ConfigurationParameters::getValue().

QVector< double > getVector ( ConfigurationParameters params,
QString  paramPath 
) [static]

Return a QVector of double from the parameters specified It helps on parsing parameters like:

  [GROUP]
  param = 10 3.2 4 23 12

and it returns a QVector containing the values

Parameters:
paramPathis the full path to the parameter; i.e. prefix + "paramName" in a typical use of configure method
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:
  [GROUP]
  param = 10 3.2 garbage 4 23 12
getVector will return: { 10 3.2 0.0 4 23 12 }

Definition at line 83 of file configurationhelper.cpp.

References ConfigurationParameters::getValue().

bool hasGroup ( ConfigurationParameters params,
QString  group 
) [static]

Return true if the group exists.

Parameters:
groupis the full path of the group to search; i.e: /parentGroup1/parentGroup2/groupToCheck

Definition at line 97 of file configurationhelper.cpp.

References ConfigurationParameters::getGroupsList(), and ConfigurationParameters::isCaseSensitive().

bool hasParameter ( ConfigurationParameters params,
QString  group,
QString  paramName 
) [static]

Return true if the parameter exist and is not empty into the group.

Parameters:
groupis the full path of the group containing the parameter
paramNameis 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 110 of file configurationhelper.cpp.

References ConfigurationParameters::getValue().

void throwUserConfigError ( QString  paramName,
QString  paramValue,
QString  description 
) [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:
paramNamethe name of the parameter on which the check failed
paramValuethe value of the parameter that caused the check to fail
descriptiona description of the error

Definition at line 114 of file configurationhelper.cpp.

void throwUserMissingResourceError ( QString  resourceName,
QString  description 
) [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:
resourceNamethe name of the missing resource
descriptiona description of the error

Definition at line 119 of file configurationhelper.cpp.


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