8 #ifndef SCARAB_PARAM_VALUE_HH_ 9 #define SCARAB_PARAM_VALUE_HH_ 15 #include <boost/variant.hpp> 56 virtual bool is_null()
const;
57 virtual bool is_value()
const;
59 virtual bool has_subset(
const param& a_subset )
const;
61 std::string
type()
const;
65 bool is_double()
const;
66 bool is_string()
const;
69 uint64_t as_uint()
const;
70 int64_t as_int()
const;
71 double as_double()
const;
72 std::string as_string()
const;
75 template<
typename XValType >
78 void set(
bool a_value );
79 void set( uint8_t a_value );
80 void set( uint16_t a_value );
81 void set( uint32_t a_value );
82 void set( uint64_t a_value );
83 void set( int8_t a_value );
84 void set( int16_t a_value );
85 void set( int32_t a_value );
86 void set( int64_t a_value );
87 void set(
float a_value );
88 void set(
double a_value );
89 void set(
const std::string& a_value );
90 void set(
const char* a_value );
102 boost::variant< bool, uint64_t, int64_t, double, std::string >
f_value;
134 template<
typename XValType >
141 return static_cast< XValType
>( a_value );
145 return static_cast< XValType
>( a_value );
149 return static_cast< XValType
>( a_value );
153 return static_cast< XValType
>( a_value );
157 std::stringstream t_conv;
173 template<
typename T >
188 template<
typename T >
203 template<
typename T >
218 template<
typename T >
233 template<
typename T >
250 if( a_value.empty() )
return false;
252 std::string t_str_val;
253 bool t_is_numeric =
true;
254 for( std::string::const_iterator t_val_it = a_value.begin(); t_val_it != a_value.end(); ++t_val_it )
256 t_is_numeric = t_is_numeric && ::isdigit( *t_val_it );
257 t_str_val.push_back( ::tolower( *t_val_it ) );
260 if( t_is_numeric )
return std::stoi( t_str_val );
262 std::istringstream t_iss_val( t_str_val );
264 t_iss_val >> std::boolalpha >> t_bool_val;
267 template<
typename T >
280 return std::stoull( a_value );
282 template<
typename T >
285 return (uint64_t)a_value;
295 return std::stoll( a_value );
297 template<
typename T >
300 return (int64_t)a_value;
310 return std::stod( a_value );
312 template<
typename T >
315 return (
double)a_value;
325 return a_value ?
"true" :
"false";
331 template<
typename T >
346 template<
typename T >
365 template<
typename T >
378 inline bool param_value::get< bool >()
const 384 inline uint64_t param_value::get< uint64_t >()
const 390 inline int64_t param_value::get< int64_t >()
const 396 inline double param_value::get< double >()
const 413 template<
typename XValType >
509 f_value = uint64_t(a_value);
515 f_value = uint64_t(a_value);
521 f_value = uint64_t(a_value);
533 f_value = int64_t(a_value);
539 f_value = int64_t(a_value);
545 f_value = int64_t(a_value);
575 f_value = std::string( a_value );
int64_t operator()(T a_value) const
std::string operator()(double) const
scarab::path operator()(const std::string &a_value) const
virtual std::string to_string() const
bool operator()(const std::string &a_value) const
scarab::path operator()(T) const
std::string operator()(int64_t) const
bool operator()(bool) const
std::string operator()(const std::string &) const
std::string type(const x_type &a_param)
void operator()(T &a_value) const
boost::variant< bool, uint64_t, int64_t, double, std::string > f_value
bool operator()(int64_t) const
bool operator()(uint64_t) const
bool operator()(double) const
virtual bool is_value() const
bool operator()(T a_value) const
std::string param_value::get< std::string >() const
bool operator()(const std::string &) const
virtual param_ptr_t clone() const
double operator()(const std::string &a_value) const
std::string operator()(T a_value) const
XValType operator()(bool a_value) const
std::string as_string() const
std::string operator()(uint64_t) const
void operator()(std::string &a_value) const
XValType operator()(int64_t a_value) const
XValType operator()(const std::string &a_value) const
std::string operator()(const std::string &a_value) const
SCARAB_API std::ostream & operator<<(std::ostream &out, const param_array &a_value)
uint64_t operator()(T a_value) const
virtual param_ptr_t move_clone()
uint64_t operator()(const std::string &a_value) const
std::unique_ptr< param > param_ptr_t
std::string operator()(bool) const
scarab::path param_value::get< scarab::path >() const
void operator()(bool &a_value) const
virtual bool is_null() const
std::string to_string(std::uint64_t x)
double operator()(T a_value) const
int64_t operator()(const std::string &a_value) const
std::string operator()(bool a_value) const
XValType operator()(double a_value) const
XValType operator()(uint64_t a_value) const
bool operator()(bool a_value) const