8 #ifndef SCARAB_PARAM_VALUE_HH_ 9 #define SCARAB_PARAM_VALUE_HH_ 15 #include <boost/variant.hpp> 58 bool strict_is_equal_to(
const param_value& rhs )
const;
59 bool loose_is_equal_to(
const param_value& rhs )
const;
63 virtual bool is_null()
const;
64 virtual bool is_value()
const;
66 virtual bool has_subset(
const param& a_subset )
const;
68 std::string
type()
const;
72 bool is_double()
const;
73 bool is_string()
const;
76 uint64_t as_uint()
const;
77 int64_t as_int()
const;
78 double as_double()
const;
82 template<
typename XValType >
85 template< typename XValType, typename std::enable_if< std::is_convertible< XValType, param_value >::value, XValType >
::type* =
nullptr >
86 void set( XValType a_value );
96 boost::variant< bool, uint64_t, int64_t, double, std::string >
f_value;
105 template <
typename T,
typename U >
111 template <
typename T >
121 template <
typename T,
typename U >
125 return t_as_string(lhs) == t_as_string(rhs);
128 template <
typename T >
162 template<
typename XValType >
169 return static_cast< XValType
>( a_value );
173 return static_cast< XValType
>( a_value );
177 return static_cast< XValType
>( a_value );
181 return static_cast< XValType
>( a_value );
185 std::stringstream t_conv;
201 template<
typename T >
216 template<
typename T >
231 template<
typename T >
246 template<
typename T >
261 template<
typename T >
278 if( a_value.empty() )
return false;
280 std::string t_str_val;
281 bool t_is_numeric =
true;
282 for( std::string::const_iterator t_val_it = a_value.begin(); t_val_it != a_value.end(); ++t_val_it )
284 t_is_numeric = t_is_numeric && ::isdigit( *t_val_it );
285 t_str_val.push_back( ::tolower( *t_val_it ) );
288 if( t_is_numeric )
return std::stoi( t_str_val );
290 std::istringstream t_iss_val( t_str_val );
292 t_iss_val >> std::boolalpha >> t_bool_val;
295 template<
typename T >
308 return std::stoull( a_value );
310 template<
typename T >
313 return (uint64_t)a_value;
323 return std::stoll( a_value );
325 template<
typename T >
328 return (int64_t)a_value;
338 return std::stod( a_value );
340 template<
typename T >
343 return (
double)a_value;
353 return a_value ?
"true" :
"false";
359 template<
typename T >
374 template<
typename T >
393 template<
typename T >
406 inline bool param_value::as< bool >()
const 412 inline uint64_t param_value::as< uint64_t >()
const 418 inline int64_t param_value::as< int64_t >()
const 424 inline double param_value::as< double >()
const 441 template<
typename XValType >
544 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
constexpr bool operator==(const day &x, const day &y) noexcept
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
bool operator==(const param_value &rhs) const
Strict equality.
std::string operator()(int64_t) const
XValType operator()(int64_t a_value) const
std::string as_string(const T &v)
simple utility to convert various types to a string
std::string operator()(const std::string &) const
bool operator()(const T &, const U &) const
bool strict_is_equal_to(const param_value &rhs) 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
bool operator()(const T &rhs, const U &lhs) 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
bool operator()(const T &lhs, const T &rhs) 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
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
bool loose_is_equal_to(const param_value &rhs) const
int64_t operator()(const std::string &a_value) const
bool operator()(uint64_t) const
auto to_string(T &&value) -> decltype(std::forward< T >(value))
Convert an object to a string (directly forward if this can become a string)
bool operator()(const T &lhs, const T &rhs) const
bool operator()(double) const
virtual bool is_value() const