7 #include <boost/functional/hash.hpp> 9 #ifndef DDYNAMIC_RECONFIGURE_DD_VALUE_H 10 #define DDYNAMIC_RECONFIGURE_DD_VALUE_H 12 using namespace boost;
40 inline explicit Value(
int val) : double_val_(0.0), bool_val_(false) {
49 inline explicit Value(
double val) : int_val_(0), bool_val_(false) {
58 inline explicit Value(
const string &val) : int_val_(0), double_val_(0.0), bool_val_(false) {
67 inline explicit Value(
const char* val) : int_val_(0), double_val_(0.0), bool_val_(false) {
68 *
this =
Value(
string(val));
75 inline explicit Value(
bool val) : int_val_(0), double_val_(0.0) {
98 if (type_ ==
"string") {
100 if (sscanf(str_val_.c_str(),
"%d", &i) == 0) {
101 return (
int) boost::hash<string>()(str_val_);
104 }
else if (type_ ==
"bool") {
return bool_val_ ? 1 : 0; }
105 else if (type_ ==
"double") {
return (
int) double_val_; }
106 else {
return int_val_; }
118 if(type_ ==
"string") {
return str_val_;}
119 else if(type_ ==
"bool") {
return bool_val_ ?
"true" :
"false";}
120 else if(type_ ==
"double") {ss << double_val_;
return ss.str();}
121 else {ss << int_val_;
return ss.str();}
134 if(type_ ==
"string") {
136 if(sscanf(str_val_.c_str(),
"%lf", &f) == 0) {
137 return boost::hash<string>()(str_val_);
140 }
else if(type_ ==
"bool") {
return bool_val_ ? 1.0 : 0.0;}
141 else if(type_ ==
"double") {
return double_val_;}
142 else {
return int_val_;}
153 if(type_ ==
"string") {
return str_val_ ==
"true";}
154 else if(type_ ==
"bool") {
return bool_val_;}
155 else if(type_ ==
"double") {
return double_val_ > 0.0;}
156 else {
return int_val_ > 0;}
161 #endif //DDYNAMIC_RECONFIGURE_DD_VALUE_H