A single variant. More...
#include <Radiant/ConfigReader.hpp>
Public Member Functions | |
| const QString & | documentation () const |
| Returns the documentation. More... | |
| void | dump (std::ostream &os) const |
| Prints the value to given stream. More... | |
| double | getDouble (double def=0.0f) const |
| Returns the value as a double. More... | |
| int | getDoubles (double *target, int n) |
| Reads an array of doubles from the value. More... | |
| float | getFloat (float def=0.f) const |
| Returns the value as a float. More... | |
| int | getFloats (float *target, int n) |
| Reads an array of floats from the value. More... | |
| uint64_t | getFromHex64 (uint64_t def=0) const |
| Returns the value as unsigned 64 bit integer (interpreted as hexadecimal) More... | |
| int | getInt (int def=0) const |
| Returns the value as int. More... | |
| int | getInts (int *target, int n) |
| Reads an array of integers from the value. More... | |
| const QString & | getString (const QString &def) const |
| Returns the value as string or the given default value if the value has not been set. More... | |
| const QString & | getString () const |
| Returns the value as string. More... | |
| bool | hasDocumentation () const |
| Returns true if the variable has been documented. More... | |
| bool | isEmpty () const |
| Returns true if the value has not been set. More... | |
| operator const QString & () const | |
| Returns the value as string. More... | |
| operator double () const | |
| Returns the value as double. More... | |
| operator int () const | |
| Returns the value as integer. More... | |
| void | set (const QString &s) |
| Sets the value. More... | |
| Variant () | |
| Constructor. | |
| Variant (const QString &a, const char *doc=0) | |
| Constructs a new variable and sets it value. More... | |
| Variant (const char *str, const char *doc=0) | |
| Constructs a new variable and sets it value. More... | |
| Variant (int v, const char *doc=0) | |
| Constructs a new int variable. More... | |
| Variant (unsigned v, const char *doc=0) | |
| Constructs a new unsigned int variable. More... | |
| Variant (double v, const char *doc=0) | |
| Constructs a double variable. More... | |
| Variant (const float *arr, int n, const char *doc=0) | |
| Constructs an array of floating point numbers. More... | |
| Variant (const int *arr, int n, const char *doc=0) | |
| Constructs an array of integers. More... | |
| ~Variant () | |
| Destructor. | |
A single variant.
All variants are stored as text strings. This class provides methods to convert the string to the most simple variable types including integers, doubles and float vectors.
In addition to the actual variable information, a variant may contain a documentation string.
| Radiant::Variant::Variant | ( | const QString & | a, |
| const char * | doc = 0 |
||
| ) |
Constructs a new variable and sets it value.
| a | Value as a string |
| doc | Documentation of the variable |
| Radiant::Variant::Variant | ( | const char * | str, |
| const char * | doc = 0 |
||
| ) |
Constructs a new variable and sets it value.
| str | Value as a string |
| doc | Documentation of the variable |
| Radiant::Variant::Variant | ( | int | v, |
| const char * | doc = 0 |
||
| ) |
Constructs a new int variable.
| v | Value to represent |
| doc | Documentation of the variable |
| Radiant::Variant::Variant | ( | unsigned | v, |
| const char * | doc = 0 |
||
| ) |
Constructs a new unsigned int variable.
| v | Value to represent |
| doc | Documentation of the variable |
| Radiant::Variant::Variant | ( | double | v, |
| const char * | doc = 0 |
||
| ) |
Constructs a double variable.
| v | Value to represent |
| doc | Documentation of the variable |
| Radiant::Variant::Variant | ( | const float * | arr, |
| int | n, | ||
| const char * | doc = 0 |
||
| ) |
Constructs an array of floating point numbers.
| arr | Array of floating points |
| n | Length of an array |
| doc | Documentation of the variable |
| Radiant::Variant::Variant | ( | const int * | arr, |
| int | n, | ||
| const char * | doc = 0 |
||
| ) |
Constructs an array of integers.
| arr | Array of integers |
| n | Length of an array |
| doc | Documentation of the variable |
| const QString& Radiant::Variant::documentation | ( | ) | const |
Returns the documentation.
| void Radiant::Variant::dump | ( | std::ostream & | os | ) | const |
Prints the value to given stream.
| os | Stream where the value is printed |
| double Radiant::Variant::getDouble | ( | double | def = 0.0f | ) | const |
Returns the value as a double.
| def | Default value. Is returned if the value can't be represented as double. |
| int Radiant::Variant::getDoubles | ( | double * | target, |
| int | n | ||
| ) |
Reads an array of doubles from the value.
| [out] | target | Array where the doubles are stored |
| n | Maximum number of doubles to be read |
| float Radiant::Variant::getFloat | ( | float | def = 0.f | ) | const |
Returns the value as a float.
| def | Default value. Is returned if the value can't be represented as float. |
| int Radiant::Variant::getFloats | ( | float * | target, |
| int | n | ||
| ) |
Reads an array of floats from the value.
| [out] | target | Array where the floats are stored |
| n | Maximum number of floats to be read |
| uint64_t Radiant::Variant::getFromHex64 | ( | uint64_t | def = 0 | ) | const |
Returns the value as unsigned 64 bit integer (interpreted as hexadecimal)
| def | Default value. Is returned if the value can't be represented as 64bit unsigned. |
| int Radiant::Variant::getInt | ( | int | def = 0 | ) | const |
Returns the value as int.
| def | Default value. Is returned if the value can't be represented as integer. |
| int Radiant::Variant::getInts | ( | int * | target, |
| int | n | ||
| ) |
Reads an array of integers from the value.
| [out] | target | Array where the integers are stored |
| n | Maximum number of integers to be read |
| const QString& Radiant::Variant::getString | ( | const QString & | def | ) | const |
Returns the value as string or the given default value if the value has not been set.
| def | Default value. Is returned if the value is not yet set. |
| const QString& Radiant::Variant::getString | ( | ) | const |
Returns the value as string.
| bool Radiant::Variant::hasDocumentation | ( | ) | const |
Returns true if the variable has been documented.
| bool Radiant::Variant::isEmpty | ( | ) | const |
Returns true if the value has not been set.
| Radiant::Variant::operator const QString & | ( | ) | const |
Returns the value as string.
| Radiant::Variant::operator double | ( | ) | const |
Returns the value as double.
| Radiant::Variant::operator int | ( | ) | const |
Returns the value as integer.
| void Radiant::Variant::set | ( | const QString & | s | ) |
Sets the value.
| s | Value to set |