50 static inline int convertFromReal(
int,Real v)
52 if (v>Convert::toReal(INT_MAX))
54 if (v<Convert::toReal(INT_MIN))
56 return (
int)(Convert::toDouble(v));
58 static inline unsigned int convertFromReal(
unsigned int,Real v)
60 if (v>Convert::toReal(UINT_MAX))
64 return (
unsigned int)(Convert::toDouble(v));
66 static inline long convertFromReal(
long,Real v)
68 if (v>Convert::toReal(LONG_MAX))
70 if (v<Convert::toReal(LONG_MIN))
72 return (
long)(Convert::toDouble(v));
74 static inline unsigned long convertFromReal(
unsigned long,Real v)
76 if (v>Convert::toReal(ULONG_MAX))
80 return (
unsigned long)(Convert::toDouble(v));
82 static inline long long convertFromReal(
long long,Real v)
84 if (v>Convert::toReal(LLONG_MAX))
86 if (v<Convert::toReal(LLONG_MIN))
88 return (
long long)(Convert::toDouble(v));
90 static inline unsigned long long convertFromReal(
unsigned long long,Real v)
92 if (v>Convert::toReal(ULLONG_MAX))
96 return (
unsigned long long)(Convert::toDouble(v));
102 : m_real_value(0.), m_int32_value(0), m_int64_value(0),
103 m_bool_value(
false), m_sticky_type(TUnknown) {}
105 : m_real_value(v), m_int32_value(0), m_int64_value(0),
106 m_bool_value(
false), m_sticky_type(TReal) {}
108 : m_real_value(0.), m_int32_value(v), m_int64_value(0),
109 m_bool_value(
false), m_sticky_type(TInt32) {}
111 : m_real_value(0.), m_int32_value(0), m_int64_value(v),
112 m_bool_value(
false), m_sticky_type(TInt64) {}
114 : m_real_value(0.), m_int32_value(0), m_int64_value(v),
115 m_bool_value(v), m_sticky_type(TBool) {}
117 : m_real_value(0.), m_int32_value(0), m_int64_value(0),
118 m_bool_value(
false), m_string_value(v), m_sticky_type(TString) {}
120 void setValue(Real v) { m_real_value = v; m_sticky_type = TReal; }
121 void setValue(Int32 v) { m_int32_value = v; m_sticky_type = TInt32; }
122 void setValue(Int64 v) { m_int64_value = v; m_sticky_type = TInt64; }
123 void setValue(
const String& v) { m_string_value = v; m_sticky_type = TString; }
124 void setValue(
bool v) { m_bool_value = v; m_sticky_type = TBool; }
126 void setValueAll(Real v)
128 m_sticky_type = TReal;
130 m_int32_value = convertFromReal(m_int32_value,v);
131 m_int64_value = convertFromReal(m_int64_value,v);
132 m_bool_value = v!=0.;
133 m_string_value = String::fromNumber(m_real_value);
135 void setValueAll(Int32 v)
137 m_sticky_type = TInt32;
138 m_real_value = Convert::toReal(v);
140 m_int64_value = (Int64)(v);
142 m_string_value = String::fromNumber(m_int32_value);
144 void setValueAll(Int64 v)
146 m_sticky_type = TInt64;
147 m_real_value = Convert::toReal(v);
148 m_int32_value = (Int32)(v);
151 m_string_value = String::fromNumber(m_int64_value);
153 void setValueAll(
bool v)
155 m_sticky_type = TBool;
156 m_real_value = Convert::toReal(v);
157 m_int32_value = v ? 1 : 0;
158 m_int64_value = v ? 1 : 0;
160 m_string_value = String::fromNumber(m_int64_value);
163 void value(
bool& v)
const { v = m_bool_value; }
164 void value(Real& v)
const { v = m_real_value; }
165 void value(Int32& v)
const { v = m_int32_value; }
166 void value(Int64& v)
const { v = m_int64_value; }
167 void value(
String& v)
const { v = m_string_value; }
169 bool asBool()
const {
return m_bool_value; }
170 Real asReal()
const {
return m_real_value; }
171 Integer asInteger()
const;
172 Int32 asInt32()
const {
return m_int32_value; }
173 Int64 asInt64()
const {
return m_int64_value; }
174 const String& asString()
const {
return m_string_value; }
175 eType type()
const {
return m_sticky_type; }