Public Member Functions | Private Attributes
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>

List of all members.

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_

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) [inline, explicit]

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) [inline, explicit]

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) [inline, explicit]

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) [inline, explicit]

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) [inline, explicit]

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

Definition at line 34 of file dd_value.h.

Definition at line 33 of file dd_value.h.

Definition at line 31 of file dd_value.h.

Definition at line 32 of file dd_value.h.

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 Wed May 15 2019 04:39:27