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>
Public Member Functions | |
string | getType () const |
gets the type this value wrapper stores | |
bool | toBool () const |
converts the stored value into a boolean. | |
double | toDouble () const |
converts the stored value into a double. | |
int | toInt () const |
converts the stored value into an integer. | |
string | toString () const |
converts the stored value into a string. | |
Value (int val) | |
creates an integer value wrapper | |
Value (double val) | |
creates an double value wrapper | |
Value (const string &val) | |
creates a string value wrapper | |
Value (const char *val) | |
creates a c-string value wrapper, though it is considered a regular string. | |
Value (bool val) | |
creates an integer value wrapper | |
Private Attributes | |
bool | bool_val_ |
double | double_val_ |
int | int_val_ |
string | str_val_ |
string | type_ |
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:
1. 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).
2. Values can be explicitly converted to all basic data-types they wrap. This means that converting an int to a string is far easier.
3. 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 | ) | [inline, explicit] |
creates an integer value wrapper
val | the int to wrap |
Definition at line 40 of file dd_value.h.
ddynamic_reconfigure::Value::Value | ( | double | val | ) | [inline, explicit] |
creates an double value wrapper
val | the double to wrap |
Definition at line 49 of file dd_value.h.
ddynamic_reconfigure::Value::Value | ( | const string & | val | ) | [inline, explicit] |
creates a string value wrapper
val | the string to wrap |
Definition at line 58 of file dd_value.h.
ddynamic_reconfigure::Value::Value | ( | const char * | val | ) | [inline, explicit] |
creates a c-string value wrapper, though it is considered a regular string.
val | the c-string to wrap |
Definition at line 67 of file dd_value.h.
ddynamic_reconfigure::Value::Value | ( | bool | val | ) | [inline, explicit] |
creates an integer value wrapper
val | the boolean to wrap |
Definition at line 75 of file dd_value.h.
string ddynamic_reconfigure::Value::getType | ( | ) | const [inline] |
gets the type this value wrapper stores
Definition at line 84 of file dd_value.h.
bool ddynamic_reconfigure::Value::toBool | ( | ) | const [inline] |
converts the stored value into a boolean.
Definition at line 152 of file dd_value.h.
double ddynamic_reconfigure::Value::toDouble | ( | ) | const [inline] |
converts the stored value into a double.
Definition at line 133 of file dd_value.h.
int ddynamic_reconfigure::Value::toInt | ( | ) | const [inline] |
converts the stored value into an integer.
Definition at line 97 of file dd_value.h.
string ddynamic_reconfigure::Value::toString | ( | ) | const [inline] |
converts the stored value into a string.
Definition at line 116 of file dd_value.h.
bool ddynamic_reconfigure::Value::bool_val_ [private] |
Definition at line 34 of file dd_value.h.
double ddynamic_reconfigure::Value::double_val_ [private] |
Definition at line 33 of file dd_value.h.
int ddynamic_reconfigure::Value::int_val_ [private] |
Definition at line 31 of file dd_value.h.
string ddynamic_reconfigure::Value::str_val_ [private] |
Definition at line 32 of file dd_value.h.
string ddynamic_reconfigure::Value::type_ [private] |
Definition at line 32 of file dd_value.h.