Public Member Functions | Private Attributes | List of all members
ddynamic_reconfigure::Value Class Reference

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 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...
 

Private Attributes

bool bool_val_
 
double double_val_
 
int int_val_
 
string str_val_
 
string type_
 

Detailed Description

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.

Constructor & Destructor Documentation

ddynamic_reconfigure::Value::Value ( int  val)
inlineexplicit

creates an integer value wrapper

Parameters
valthe int to wrap

Definition at line 40 of file dd_value.h.

ddynamic_reconfigure::Value::Value ( double  val)
inlineexplicit

creates an double value wrapper

Parameters
valthe double to wrap

Definition at line 49 of file dd_value.h.

ddynamic_reconfigure::Value::Value ( const string &  val)
inlineexplicit

creates a string value wrapper

Parameters
valthe string to wrap

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
valthe c-string to wrap

Definition at line 67 of file dd_value.h.

ddynamic_reconfigure::Value::Value ( bool  val)
inlineexplicit

creates an integer value wrapper

Parameters
valthe boolean to wrap

Definition at line 75 of file dd_value.h.

Member Function Documentation

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.

Member Data Documentation

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.


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


ddynamic_reconfigure
Author(s): Noam Dori
autogenerated on Thu May 16 2019 02:46:38