The Value class is used to wrap all basic data-types (bool,int,double,string) in something generic. The value object always stores an explicit basic data-type. This has three main uses:
More...
#include <dd_value.h>
|
string | getType () const |
| gets the type this value wrapper stores More...
|
|
bool | toBool () const |
| converts the stored value into a boolean. More...
|
|
double | toDouble () const |
| converts the stored value into a double. More...
|
|
int | toInt () const |
| converts the stored value into an integer. More...
|
|
string | toString () const |
| converts the stored value into a string. More...
|
|
| Value (int val) |
| creates an integer value wrapper More...
|
|
| Value (double val) |
| creates an double value wrapper More...
|
|
| Value (const string &val) |
| creates a string value wrapper More...
|
|
| Value (const char *val) |
| creates a c-string value wrapper, though it is considered a regular string. More...
|
|
| Value (bool val) |
| creates an integer value wrapper More...
|
|
The Value class is used to wrap all basic data-types (bool,int,double,string) in something generic. The value object always stores an explicit basic data-type. This has three main uses:
- Values can represent all basic data-types. This means that arguments that need something relatively similar from all basic data-types can now just use the value in its argument. This also goes for when you need to return something that is of different data-types from different classes (one can only return integer, other can only return strings).
- Values can be explicitly converted to all basic data-types they wrap. This means that converting an int to a string is far easier.
- Values store the type they were instantiated with. This can be tested against to get the original piece of data the value stored.
Definition at line 29 of file dd_value.h.
ddynamic_reconfigure::Value::Value |
( |
int |
val | ) |
|
|
inlineexplicit |
creates an integer value wrapper
- Parameters
-
Definition at line 40 of file dd_value.h.
ddynamic_reconfigure::Value::Value |
( |
double |
val | ) |
|
|
inlineexplicit |
creates an double value wrapper
- Parameters
-
Definition at line 49 of file dd_value.h.
ddynamic_reconfigure::Value::Value |
( |
const string & |
val | ) |
|
|
inlineexplicit |
creates a string value wrapper
- Parameters
-
Definition at line 58 of file dd_value.h.
ddynamic_reconfigure::Value::Value |
( |
const char * |
val | ) |
|
|
inlineexplicit |
creates a c-string value wrapper, though it is considered a regular string.
- Parameters
-
Definition at line 67 of file dd_value.h.
ddynamic_reconfigure::Value::Value |
( |
bool |
val | ) |
|
|
inlineexplicit |
creates an integer value wrapper
- Parameters
-
Definition at line 75 of file dd_value.h.
string ddynamic_reconfigure::Value::getType |
( |
| ) |
const |
|
inline |
gets the type this value wrapper stores
- Returns
- a string containing the type: one of {"int","double","bool","string"}
Definition at line 84 of file dd_value.h.
bool ddynamic_reconfigure::Value::toBool |
( |
| ) |
const |
|
inline |
converts the stored value into a boolean.
- Returns
- for native integers: returns true if the value is bigger than 0, false otherwise. for native doubles: returns true if the value is bigger than 0, false otherwise. for native booleans: returns itself for native strings: returns true if the string's value is 'true', false otherwise.
Definition at line 152 of file dd_value.h.
double ddynamic_reconfigure::Value::toDouble |
( |
| ) |
const |
|
inline |
converts the stored value into a double.
- Returns
- for native integers: returns itself for native doubles: returns a itself for native booleans: returns 1.0 if true, 0.0 if false. for native strings: if the string contains a floating value (for example "1.1" contains the double '1.1' in it), it will return the double interpretation of that string. Otherwise, returns the hash value of the string.
Definition at line 133 of file dd_value.h.
int ddynamic_reconfigure::Value::toInt |
( |
| ) |
const |
|
inline |
converts the stored value into an integer.
- Returns
- for native integers: returns itself. for native doubles: returns a casted integer. for native booleans: returns 1 if true, 0 if false. for native strings: if the string contains an integer value (for example "1" contains the int '1' in it), it will return the integer interpretation of that string. Otherwise, returns the hash value of the string.
Definition at line 97 of file dd_value.h.
string ddynamic_reconfigure::Value::toString |
( |
| ) |
const |
|
inline |
converts the stored value into a string.
- Returns
- for native integers: returns the number in string form ('1' -> "1") for native doubles: returns the number in shorthand string form ('1.0' -> "1") for native booleans: returns "true" if true, "false" if false. for native strings: returns itself.
Definition at line 116 of file dd_value.h.
bool ddynamic_reconfigure::Value::bool_val_ |
|
private |
double ddynamic_reconfigure::Value::double_val_ |
|
private |
int ddynamic_reconfigure::Value::int_val_ |
|
private |
string ddynamic_reconfigure::Value::str_val_ |
|
private |
string ddynamic_reconfigure::Value::type_ |
|
private |
The documentation for this class was generated from the following file: