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 template< typename XValType, typename std::enable_if< std::is_convertible< XValType, param_value >::value, XValType >
::type* =
nullptr >
79 void set( XValType a_value );
89 boost::variant< bool, uint64_t, int64_t, double, std::string >
f_value;
121 template<
typename XValType >
128 return static_cast< XValType
>( a_value );
132 return static_cast< XValType
>( a_value );
136 return static_cast< XValType
>( a_value );
140 return static_cast< XValType
>( a_value );
144 std::stringstream t_conv;
160 template<
typename T >
175 template<
typename T >
190 template<
typename T >
205 template<
typename T >
220 template<
typename T >
237 if( a_value.empty() )
return false;
239 std::string t_str_val;
240 bool t_is_numeric =
true;
241 for( std::string::const_iterator t_val_it = a_value.begin(); t_val_it != a_value.end(); ++t_val_it )
243 t_is_numeric = t_is_numeric && ::isdigit( *t_val_it );
244 t_str_val.push_back( ::tolower( *t_val_it ) );
247 if( t_is_numeric )
return std::stoi( t_str_val );
249 std::istringstream t_iss_val( t_str_val );
251 t_iss_val >> std::boolalpha >> t_bool_val;
254 template<
typename T >
267 return std::stoull( a_value );
269 template<
typename T >
272 return (uint64_t)a_value;
282 return std::stoll( a_value );
284 template<
typename T >
287 return (int64_t)a_value;
297 return std::stod( a_value );
299 template<
typename T >
302 return (
double)a_value;
312 return a_value ?
"true" :
"false";
318 template<
typename T >
333 template<
typename T >
352 template<
typename T >
365 inline bool param_value::as< bool >()
const 371 inline uint64_t param_value::as< uint64_t >()
const 377 inline int64_t param_value::as< int64_t >()
const 383 inline double param_value::as< double >()
const 400 template<
typename XValType >
488 template< typename XValType, typename std::enable_if< std::is_convertible< XValType, param_value >::value, XValType >
::type* >
XValType operator()(const std::string &a_value) const
virtual param_ptr_t clone() const
XValType operator()(bool a_value) const
std::string operator()(double) const
std::string operator()(uint64_t) const
scarab::path operator()(T) const
XValType operator()(uint64_t a_value) const
std::string operator()(bool a_value) const
std::string operator()(int64_t) const
XValType operator()(int64_t a_value) const
std::string operator()(const std::string &) const
std::string type(const x_type &a_param)
boost::variant< bool, uint64_t, int64_t, double, std::string > f_value
scarab::path param_value::as< scarab::path >() const
uint64_t operator()(T a_value) const
bool operator()(T a_value) const
bool operator()(bool) const
scarab::path operator()(const std::string &a_value) const
void operator()(T &a_value) const
virtual std::string to_string() const
double operator()(T a_value) const
bool operator()(bool a_value) const
std::string operator()(const std::string &a_value) const
std::string operator()(T a_value) const
int64_t operator()(T a_value) const
void operator()(std::string &a_value) const
uint64_t operator()(const std::string &a_value) const
bool operator()(const std::string &) const
void operator()(bool &a_value) const
SCARAB_API std::ostream & operator<<(std::ostream &out, const param_array &a_value)
double operator()(const std::string &a_value) const
virtual param_ptr_t move_clone()
std::unique_ptr< param > param_ptr_t
void set(XValType a_value)
bool operator()(const std::string &a_value) const
std::string to_string(std::uint64_t x)
bool operator()(int64_t) const
std::string operator()(bool) const
std::string param_value::as< std::string >() const
XValType operator()(double a_value) const
virtual bool is_null() const
std::string as_string() const
int64_t operator()(const std::string &a_value) const
bool operator()(uint64_t) const
bool operator()(double) const
virtual bool is_value() const