10 #ifndef _STRUS_STORAGE_NUMERIC_VARIANT_TYPE_HPP_INCLUDED
11 #define _STRUS_STORAGE_NUMERIC_VARIANT_TYPE_HPP_INCLUDED
74 std::memcpy(
this, &o,
sizeof(*
this));
79 std::memset(
this, 0,
sizeof(*
this));
92 operator const char*()
const {
return m_buf;}
93 const char*
c_str()
const {
return m_buf;}
101 return String( *
this, precision);
118 template <
typename TYPE>
123 case Null:
return TYPE();
132 operator double()
const
134 return cast<double>();
137 operator int64_t()
const
142 operator uint64_t()
const
144 return cast<uint64_t>();
154 return (int64_t)(
variant.Float - 2*std::numeric_limits<double>::epsilon());
158 return (int64_t)(
variant.Float + 2*std::numeric_limits<double>::epsilon());
161 return cast<int64_t>();
175 return (uint64_t)(
variant.Float + 2*std::numeric_limits<double>::epsilon());
178 return cast<uint64_t>();
184 return cast<double>();
275 std::memcpy(
this, &o,
sizeof(*
this));
signed integer number value
Definition: numericVariant.hpp:282
NumericVariant & operator=(double value)
Assignment operator for a single precision floating point number.
Definition: numericVariant.hpp:264
NumericVariant & operator=(int64_t value)
Assignment operator for a singed integer.
Definition: numericVariant.hpp:246
NumericVariant()
Default constructor (as undefined value)
Definition: numericVariant.hpp:54
double Float
value in case of a floating point number
Definition: numericVariant.hpp:298
void init()
Definition: numericVariant.hpp:77
double FloatType
Definition: numericVariant.hpp:288
bool operator>(const NumericVariant &o) const
Test for greater.
Definition: numericVariant.hpp:213
NumericVariant(const NumericVariant &o)
Copy constructor.
Definition: numericVariant.hpp:72
NumericVariant & operator=(uint64_t value)
Assignment operator for an unsinged integer.
Definition: numericVariant.hpp:255
bool operator<=(const NumericVariant &o) const
Test for smaller or equal.
Definition: numericVariant.hpp:221
uint64_t UIntType
Definition: numericVariant.hpp:287
uint64_t touint() const
Cast to an unsigned integer.
Definition: numericVariant.hpp:165
NumericVariant(const char *val_)
Constructor from a string.
Definition: numericVariant.hpp:49
bool defined() const
Find out if this value is defined.
Definition: numericVariant.hpp:111
NumericVariant(double value)
Constructor from a single precision floating point number.
Definition: numericVariant.hpp:42
uint64_t UInt
value in case of an unsigned integer
Definition: numericVariant.hpp:297
const char * c_str() const
Definition: numericVariant.hpp:93
NumericVariant & operator=(const NumericVariant &o)
Assignment operator.
Definition: numericVariant.hpp:273
static NumericVariant asuint(uint64_t val)
Definition: numericVariant.hpp:62
Type
Enumeration of all types an numeric variant can have.
Definition: numericVariant.hpp:280
String tostring(int precision=-1) const
Definition: numericVariant.hpp:99
Atomic type that can hold numeric values of different type.
Definition: numericVariant.hpp:21
String()
Definition: numericVariant.hpp:85
int compare(const NumericVariant &o) const
Comparison of numbers.
unsigned integer number value
Definition: numericVariant.hpp:283
static NumericVariant asint(int64_t val)
Definition: numericVariant.hpp:58
NumericVariant(uint64_t value)
Constructor from an unsigned integer.
Definition: numericVariant.hpp:34
double tofloat() const
Cast to an unsigned integer.
Definition: numericVariant.hpp:182
NumericVariant(int64_t value)
Constructor from a signed integer.
Definition: numericVariant.hpp:26
static const char * typeName(Type type)
Get the name of a type as string.
bool initFromString(const char *src)
Initialize numeric variant parsed from a Ascii source string.
int64_t IntType
Definition: numericVariant.hpp:286
bool operator>=(const NumericVariant &o) const
Test for greater or equal.
Definition: numericVariant.hpp:205
int64_t Int
value in case of a signed integer
Definition: numericVariant.hpp:296
union strus::NumericVariant::@4 variant
Value of this numeric variant.
uninitialized variant value
Definition: numericVariant.hpp:281
TYPE cast() const
Template for casting to a defined value type.
Definition: numericVariant.hpp:119
Type type
Type of this numeric variant.
Definition: numericVariant.hpp:293
Definition: numericVariant.hpp:82
static NumericVariant asdouble(double val)
Definition: numericVariant.hpp:66
bool operator!=(const NumericVariant &o) const
Test for inequality.
Definition: numericVariant.hpp:197
int64_t toint() const
Cast to a signed integer.
Definition: numericVariant.hpp:148
bool isequal(const NumericVariant &o) const
Test for equality.
bool operator<(const NumericVariant &o) const
Test for smaller.
Definition: numericVariant.hpp:229
bool operator==(const NumericVariant &o) const
Test for equality.
Definition: numericVariant.hpp:190