The class KeywordList provides conversion functionality between keyword strings and their respective enumeration values.
Keyword strings are used in the NANDRAD project files as identifier. In the code we use the enumeration values. You can obtain a keyword for a given enumeration value with the static function Keyword(). The corresponding enumeration value can be obtained with Enumeration(), as shown in the example below.
Remember to pass the correct and full enumeration type as first argument to Keyword.
- Note
- Instead of overloading the Keyword() function for different types in the current implementation we use a generic form in order to avoid adding compilation dependencies for all CPP files in the project that include the keyword list.
Definition at line 53 of file NANDRAD_KeywordList.h.
#include <NANDRAD_KeywordList.h>
|
static const char * | Keyword (const char *const enumtype, int t) |
| Returns a keyword for an enum value t of type enumtype. More...
|
|
static const char * | Description (const char *const enumtype, int t, bool *no_description=nullptr) |
| Returns a description for an enum value t of type enumtype. More...
|
|
static const char * | Unit (const char *const enumtype, int t) |
| Returns a default unit for an enum value t of type enumtype. More...
|
|
static const char * | Color (const char *const enumtype, int t) |
| Returns a color string for an enum value t of type enumtype. More...
|
|
static double | DefaultValue (const char *const enumtype, int t) |
| Returns a default value for an enum value t of type enumtype. More...
|
|
static int | Enumeration (const char *const enumtype, const std::string &kw, bool *deprecated=nullptr) |
| Returns an enumeration value for a given keyword kw of type enumtype. More...
|
|
static int | MaxIndex (const char *const enumtype) |
| Returns the maximum index for entries of a category in the keyword list. More...
|
|
static unsigned int | Count (const char *const enumtype) |
| Returns the number of keywords in this category. More...
|
|
static bool | KeywordExists (const char *const enumtype, const std::string &kw) |
| Checks whether a keyword exists in the enumeration of type enumtype. More...
|
|
static bool | CategoryExists (const char *const enumtype) |
| Checks whether a category of type enumtype exists. More...
|
|
static void | setParameter (IBK::Parameter para[], const char *const enumtype, int n, const double &val) |
| Convenience function to set an IBK::Parameter inside a static C-array of IBK::Parameters with correct name, value and unit. More...
|
|
static void | setIntPara (IBK::IntPara para[], const char *const enumtype, int n, const int &val) |
| As setParameter(), but for IBK::IntPara. More...
|
|
◆ Keyword()
static const char* NANDRAD::KeywordList::Keyword |
( |
const char *const |
enumtype, |
|
|
int |
t |
|
) |
| |
|
static |
Returns a keyword for an enum value t of type enumtype.
◆ Description()
static const char* NANDRAD::KeywordList::Description |
( |
const char *const |
enumtype, |
|
|
int |
t, |
|
|
bool * |
no_description = nullptr |
|
) |
| |
|
static |
Returns a description for an enum value t of type enumtype.
This function throws an exception if the enumeration type is invalid or unknown. If no descrption is given, the keyword itself is returned.
- Parameters
-
enumtype | The full enumeration type including the class name. |
t | The enumeration type cast in an int. |
no_description | The optional argument is set to true, if there was no description for this keyword, otherwise to false. |
◆ Unit()
static const char* NANDRAD::KeywordList::Unit |
( |
const char *const |
enumtype, |
|
|
int |
t |
|
) |
| |
|
static |
Returns a default unit for an enum value t of type enumtype.
This function throws an exception if the enumeration type is invalid or unknown. Returns an empty string if no default unit was specified.
- Parameters
-
enumtype | The full enumeration type including the class name. |
t | The enumeration type cast in an int. |
◆ Color()
static const char* NANDRAD::KeywordList::Color |
( |
const char *const |
enumtype, |
|
|
int |
t |
|
) |
| |
|
static |
Returns a color string for an enum value t of type enumtype.
This function throws an exception if the enumeration type is invalid or unknown. Returns the color code for 'white' if no color value was specified.
- Parameters
-
enumtype | The full enumeration type including the class name. |
t | The enumeration type cast in an int. |
◆ DefaultValue()
static double NANDRAD::KeywordList::DefaultValue |
( |
const char *const |
enumtype, |
|
|
int |
t |
|
) |
| |
|
static |
Returns a default value for an enum value t of type enumtype.
This function throws an exception if the enumeration type is invalid or unknown. Returns an nan if no default value was specified.
- Parameters
-
enumtype | The full enumeration type including the class name. |
t | The enumeration type cast in an int. |
◆ Enumeration()
static int NANDRAD::KeywordList::Enumeration |
( |
const char *const |
enumtype, |
|
|
const std::string & |
kw, |
|
|
bool * |
deprecated = nullptr |
|
) |
| |
|
static |
Returns an enumeration value for a given keyword kw of type enumtype.
This function throws an exception if the keyword or the enumeration type is invalid or unknown.
- Parameters
-
enumtype | The full enumeration type including the class name. |
kw | The keyword string. |
deprecated | The optional argument is set the true if the keyword kw is deprecated. |
◆ MaxIndex()
static int NANDRAD::KeywordList::MaxIndex |
( |
const char *const |
enumtype | ) |
|
|
static |
Returns the maximum index for entries of a category in the keyword list.
This function throws an exception if the enumeration type is invalid or unknown.
- Parameters
-
enumtype | The full enumeration type including the class name. |
◆ Count()
static unsigned int NANDRAD::KeywordList::Count |
( |
const char *const |
enumtype | ) |
|
|
static |
Returns the number of keywords in this category.
This function throws an exception if the enumeration type is invalid or unknown.
- Parameters
-
enumtype | The full enumeration type including the class name. |
◆ KeywordExists()
static bool NANDRAD::KeywordList::KeywordExists |
( |
const char *const |
enumtype, |
|
|
const std::string & |
kw |
|
) |
| |
|
static |
Checks whether a keyword exists in the enumeration of type enumtype.
- Returns
- Returns true if the keyword is valid, otherwise false.
◆ CategoryExists()
static bool NANDRAD::KeywordList::CategoryExists |
( |
const char *const |
enumtype | ) |
|
|
static |
Checks whether a category of type enumtype exists.
- Returns
- Returns true if the category/enum type exists, otherwise false.
◆ setParameter()
static void NANDRAD::KeywordList::setParameter |
( |
IBK::Parameter |
para[], |
|
|
const char *const |
enumtype, |
|
|
int |
n, |
|
|
const double & |
val |
|
) |
| |
|
static |
Convenience function to set an IBK::Parameter inside a static C-array of IBK::Parameters with correct name, value and unit.
enum MyParameters {
MP_Temperature,
MP_Mass,
NUM_MP
};
IBK::Parameter m_para[NUM_MP];
NANDRAD::setParameter(m_para, "MyClass::MyParameters", MP_Temperature, 23.5);
NANDRAD::setParameter(m_para, "MyClass::MyParameters", MP_Mass, 1500);
- Parameters
-
para | Pointer to begin of array with IBK::Parameters |
enumtype | The enumeration type (class::enumtypename) |
n | Enumeration value (which parameter to set) |
val | The value (given in the unit specified for the parameter; requires a unit to be given) |
◆ setIntPara()
static void NANDRAD::KeywordList::setIntPara |
( |
IBK::IntPara |
para[], |
|
|
const char *const |
enumtype, |
|
|
int |
n, |
|
|
const int & |
val |
|
) |
| |
|
static |
The documentation for this class was generated from the following file: