7 #ifndef __FWATOMS_NUMERIC_HXX__ 8 #define __FWATOMS_NUMERIC_HXX__ 10 #include "fwAtoms/Exception.hpp" 12 #include <boost/mpl/and.hpp> 13 #include <boost/numeric/conversion/cast.hpp> 14 #include <boost/utility/enable_if.hpp> 15 #include <boost/variant/get.hpp> 17 #include <type_traits> 28 template<
typename T >
29 static void setValue( Numeric::ValueType& v,
30 typename ::boost::enable_if_c<
32 typename ::boost::remove_reference<
typename std::remove_const <T>::type >::type,
43 template<
typename T >
44 static void setValue( Numeric::ValueType& v,
45 typename ::boost::enable_if_c<
46 ::boost::mpl::and_< std::is_signed<T>, std::is_integral<T> >::value
49 v =
static_cast< std::int64_t
>(value);
54 template<
typename T >
55 static void setValue( Numeric::ValueType& v,
56 typename ::boost::enable_if_c<
57 ::boost::mpl::and_< std::is_unsigned<T>, std::is_integral<T> >::value
60 v =
static_cast< std::uint64_t
>(value);
65 template<
typename T >
66 static void setValue( Numeric::ValueType& v,
67 typename ::boost::enable_if_c< std::is_floating_point<T>::value, T>::type value )
80 NumericSetter::setValue<T>(valueSptr->m_value, value);
93 T operator()( ::boost::blank& )
const 100 T operator()( const ::boost::blank& )
const 108 template <
typename U>
109 T operator()( U& value )
const 111 return ::boost::numeric_cast<T>(value);
127 #endif //__FWATOMS_NUMERIC_HXX__ Implements atoms exception.
static FWATOMS_API ValueType valueFromString(const std::string &s, NumericType type=EMPTY)
Retuns a ValueType from a std::string.
fwAtoms contains basic objects to represent any other kind of object
static Numeric::sptr New(T value)
Build a new numeric type.
T getValue() const
Returns the held value static_casted to T.