35 #if !defined(_Value_h_) 38 #include "format_string.h" 42 typedef enum { kIntegerValue, kStringValue, kFloatValue } value_type_t;
70 virtual value_type_t
getType()
const {
return m_type; }
84 virtual size_t getSize()
const = 0;
91 virtual std::string
toString()
const = 0;
111 typedef enum { kSigned, kSignedLong, kUnsigned, kUnsignedLong }
int_type_t;
117 :
Value(kIntegerValue)
129 :
Value(kIntegerValue)
142 , m_value(other.m_value)
143 , m_intType(other.m_intType)
159 virtual size_t getSize()
const {
return sizeof(m_value); }
168 return (m_intType == kSignedLong || m_intType == kUnsignedLong) ? m_value : (uint32_t)m_value;
183 operator uint64_t()
const {
return m_value; }
205 if (m_intType == kUnsigned)
206 return format_string(
"%uU", (uint32_t)m_value);
207 else if (m_intType == kSigned)
208 return format_string(
"%d", (int32_t)m_value);
209 else if (m_intType == kUnsignedLong)
210 return format_string(
"%lluU", m_value);
212 return format_string(
"%lld", (int64_t)m_value);
271 , m_value(other.m_value)
300 virtual size_t getSize()
const {
return sizeof(m_value); }
314 operator double()
const {
return m_value; }
321 operator float()
const {
return static_cast<float>(m_value); }
354 virtual std::string
toString()
const {
return format_string(
"%g", m_value); }
379 :
Value(kStringValue)
390 :
Value(kStringValue)
401 :
Value(kStringValue)
412 :
Value(kStringValue)
413 , m_value(other.m_value)
429 virtual size_t getSize()
const {
return m_value.size(); }
436 const std::string &
getString()
const {
return m_value; }
443 operator const char *()
const {
return m_value.c_str(); }
450 operator const std::string &()
const {
return m_value; }
457 operator std::string &() {
return m_value; }
464 operator const std::string *() {
return &m_value; }
471 operator std::string *() {
return &m_value; }
517 virtual std::string
toString()
const {
return m_value; }
const std::string & getString() const
Get StringValue value.
Definition: Value.h:436
virtual std::string toString() const
Get StringValue type string representation.
Definition: Value.h:517
uint64_t m_value
The integer value.
Definition: Value.h:223
FloatValue & operator=(float value)
Assign operator.
Definition: Value.h:343
IntegerValue(const IntegerValue &other)
Copy constructor.
Definition: Value.h:140
FloatValue & operator=(const FloatValue &other)
Assign operator.
Definition: Value.h:282
IntegerValue(uint64_t value, int_type_t type=kSigned)
Constructor.
Definition: Value.h:128
StringValue & operator=(const StringValue &other)
Assign operator.
Definition: Value.h:480
virtual std::string getTypeName() const
Get StringValue type name.
Definition: Value.h:422
StringValue(const std::string &value)
Constructor.
Definition: Value.h:389
64-bit integer value.
Definition: Value.h:107
virtual std::string getTypeName() const =0
Get Value type name.
virtual Value * clone() const
Clone FloatValue.
Definition: Value.h:361
uint64_t getValue() const
This function returns value.
Definition: Value.h:166
virtual std::string toString() const =0
Get Value type string representation.
StringValue & operator=(const char *value)
Assign operator.
Definition: Value.h:506
virtual Value * clone() const
Clone IntegerValue.
Definition: Value.h:220
Double floating point value.
Definition: Value.h:230
String value.
Definition: Value.h:372
virtual std::string getTypeName() const
Get IntegerValue type name.
Definition: Value.h:152
virtual size_t getSize() const
Get IntegerValue type size.
Definition: Value.h:159
FloatValue(const FloatValue &other)
Copy constructor.
Definition: Value.h:269
int_type_t m_intType
The integer type.
Definition: Value.h:224
double m_value
The double value.
Definition: Value.h:364
int_type_t
Supported sizes of integers.
Definition: Value.h:111
Abstract base class for values of arbitrary types.
Definition: Value.h:47
virtual value_type_t getType() const
Get Value type.
Definition: Value.h:70
virtual size_t getSize() const
Get StringValue type size.
Definition: Value.h:429
virtual ~Value()
Destructor.
Definition: Value.h:63
virtual Value * clone() const =0
Clone Value.
double getValue() const
This function returns value.
Definition: Value.h:307
virtual std::string getTypeName() const
Get FloatValue type name.
Definition: Value.h:293
virtual Value * clone() const
Clone StringValue.
Definition: Value.h:524
virtual std::string toString() const
Get IntegerValue type string representation.
Definition: Value.h:203
virtual size_t getSize() const
Get FloatValue type size.
Definition: Value.h:300
Value(value_type_t theType)
Constructor.
Definition: Value.h:55
FloatValue(float value)
Constructor.
Definition: Value.h:258
int_type_t getIntType()
This function returns signed/unsigned type.
Definition: Value.h:176
virtual std::string toString() const
Get FloatValue type string representation.
Definition: Value.h:354
IntegerValue(int_type_t type=kSigned)
Constructor.
Definition: Value.h:116
StringValue()
Constructor.
Definition: Value.h:378
FloatValue(double value)
Constructor.
Definition: Value.h:247
FloatValue & operator=(double value)
Assign operator.
Definition: Value.h:330
IntegerValue & operator=(int64_t value)
Assign operator.
Definition: Value.h:192
StringValue(const StringValue &other)
Copy constructor.
Definition: Value.h:411
StringValue & operator=(const std::string &value)
Assign operator.
Definition: Value.h:493
FloatValue()
Constructor.
Definition: Value.h:236
std::string m_value
The string value.
Definition: Value.h:527
virtual size_t getSize() const =0
Get Value type size.
StringValue(const std::string *value)
Constructor.
Definition: Value.h:400