34 #ifndef _Wolframe_SERIALIZE_STRUCT_PRINT_VALUE_HPP_INCLUDED
35 #define _Wolframe_SERIALIZE_STRUCT_PRINT_VALUE_HPP_INCLUDED
38 #include <boost/numeric/conversion/cast.hpp>
39 #include <boost/utility/enable_if.hpp>
40 #include <boost/type_traits.hpp>
59 static typename boost::enable_if_c<
60 boost::is_same<T,std::string>::value
61 ,
const String&>::type
get(
const T&) {
static String rt;
return rt;}
66 static typename boost::enable_if_c<
67 boost::is_same<T,bool>::value
68 ,
const Bool&>::type
get(
const T&) {
static Bool rt;
return rt;}
73 static typename boost::enable_if_c<
74 boost::is_floating_point<T>::value
75 ,
const Double&>::type
get(
const T&) {
static Double rt;
return rt;}
80 static typename boost::enable_if_c<
81 boost::is_arithmetic<T>::value && boost::is_signed<T>::value && !boost::is_floating_point<T>::value && !boost::is_same<T,bool>::value
82 ,
const Int&>::type
get(
const T&) {
static Int rt;
return rt;}
87 static typename boost::enable_if_c<
88 boost::is_arithmetic<T>::value && boost::is_unsigned<T>::value && !boost::is_floating_point<T>::value && !boost::is_same<T,bool>::value
89 ,
const UInt&>::type
get(
const T&) {
static UInt rt;
return rt;}
94 static typename boost::enable_if_c<
95 boost::is_same<T,_Wolframe::types::DateTime>::value
96 ,
const DateTime&>::type
get(
const T&) {
static DateTime rt;
return rt;}
100 template <
typename T>
101 static typename boost::enable_if_c<
102 boost::is_same<T,_Wolframe::types::BigNumber>::value
103 ,
const BigNumber&>::type
get(
const T&) {
static BigNumber rt;
return rt;}
108 template <
typename ValueType>
115 template <
typename ValueType>
118 element.
init( val.c_str(), val.size());
122 template <
typename ValueType>
127 element = boost::numeric_cast<
double>( val);
130 catch (boost::bad_numeric_cast&){}
134 template <
typename ValueType>
139 element = boost::numeric_cast<
int>( val);
142 catch (boost::bad_numeric_cast&){}
147 template <
typename ValueType>
152 element = boost::numeric_cast<
unsigned int>( val);
155 catch (boost::bad_numeric_cast&){}
159 template <
typename ValueType>
166 template <
typename ValueType>
174 namespace _Wolframe {
175 namespace serialize {
177 template <
typename ValueType>
180 return printValue_( val, PrintValueType::get(val), element);
Type for representing arbitrary precision fixed point numbers and big integers as binary coded decima...
bool printValue(const ValueType &val, types::VariantConst &element)
Definition: printValue.hpp:178
Variant value type that represents a variant copy without content ownership.
Definition: variant.hpp:286
Date and datetime value type.
void init(const char *o, std::size_t len)
Initialization as string constant.
Definition: variant.hpp:332