9 #if !defined(_Value_h_) 12 #include "format_string.h" 16 typedef enum { kIntegerValue, kStringValue, kFloatValue } value_type_t;
44 virtual value_type_t
getType()
const {
return m_type; }
58 virtual size_t getSize()
const = 0;
65 virtual std::string
toString()
const = 0;
85 typedef enum { kSigned, kSignedLong, kUnsigned, kUnsignedLong }
int_type_t;
91 :
Value(kIntegerValue)
103 :
Value(kIntegerValue)
116 , m_value(other.m_value)
117 , m_intType(other.m_intType)
133 virtual size_t getSize()
const {
return sizeof(m_value); }
142 return (m_intType == kSignedLong || m_intType == kUnsignedLong) ? m_value : (uint32_t)m_value;
157 operator uint64_t()
const {
return m_value; }
179 if (m_intType == kUnsigned)
180 return format_string(
"%uU", (uint32_t)m_value);
181 else if (m_intType == kSigned)
182 return format_string(
"%d", (int32_t)m_value);
183 else if (m_intType == kUnsignedLong)
184 return format_string(
"%lluU", m_value);
186 return format_string(
"%lld", (int64_t)m_value);
245 , m_value(other.m_value)
274 virtual size_t getSize()
const {
return sizeof(m_value); }
288 operator double()
const {
return m_value; }
295 operator float()
const {
return static_cast<float>(m_value); }
328 virtual std::string
toString()
const {
return format_string(
"%g", m_value); }
353 :
Value(kStringValue)
364 :
Value(kStringValue)
375 :
Value(kStringValue)
386 :
Value(kStringValue)
387 , m_value(other.m_value)
403 virtual size_t getSize()
const {
return m_value.size(); }
410 const std::string &
getString()
const {
return m_value; }
417 operator const char *()
const {
return m_value.c_str(); }
424 operator const std::string &()
const {
return m_value; }
431 operator std::string &() {
return m_value; }
438 operator const std::string *() {
return &m_value; }
445 operator std::string *() {
return &m_value; }
491 virtual std::string
toString()
const {
return m_value; }
const std::string & getString() const
Get StringValue value.
Definition: Value.h:410
virtual std::string toString() const
Get StringValue type string representation.
Definition: Value.h:491
uint64_t m_value
The integer value.
Definition: Value.h:197
FloatValue & operator=(float value)
Assign operator.
Definition: Value.h:317
IntegerValue(const IntegerValue &other)
Copy constructor.
Definition: Value.h:114
FloatValue & operator=(const FloatValue &other)
Assign operator.
Definition: Value.h:256
IntegerValue(uint64_t value, int_type_t type=kSigned)
Constructor.
Definition: Value.h:102
StringValue & operator=(const StringValue &other)
Assign operator.
Definition: Value.h:454
virtual std::string getTypeName() const
Get StringValue type name.
Definition: Value.h:396
StringValue(const std::string &value)
Constructor.
Definition: Value.h:363
64-bit integer value.
Definition: Value.h:81
virtual std::string getTypeName() const =0
Get Value type name.
virtual Value * clone() const
Clone FloatValue.
Definition: Value.h:335
uint64_t getValue() const
This function returns value.
Definition: Value.h:140
virtual std::string toString() const =0
Get Value type string representation.
StringValue & operator=(const char *value)
Assign operator.
Definition: Value.h:480
virtual Value * clone() const
Clone IntegerValue.
Definition: Value.h:194
Double floating point value.
Definition: Value.h:204
String value.
Definition: Value.h:346
virtual std::string getTypeName() const
Get IntegerValue type name.
Definition: Value.h:126
virtual size_t getSize() const
Get IntegerValue type size.
Definition: Value.h:133
FloatValue(const FloatValue &other)
Copy constructor.
Definition: Value.h:243
int_type_t m_intType
The integer type.
Definition: Value.h:198
double m_value
The double value.
Definition: Value.h:338
int_type_t
Supported sizes of integers.
Definition: Value.h:85
Abstract base class for values of arbitrary types.
Definition: Value.h:21
virtual value_type_t getType() const
Get Value type.
Definition: Value.h:44
virtual size_t getSize() const
Get StringValue type size.
Definition: Value.h:403
virtual ~Value()
Destructor.
Definition: Value.h:37
virtual Value * clone() const =0
Clone Value.
double getValue() const
This function returns value.
Definition: Value.h:281
virtual std::string getTypeName() const
Get FloatValue type name.
Definition: Value.h:267
virtual Value * clone() const
Clone StringValue.
Definition: Value.h:498
virtual std::string toString() const
Get IntegerValue type string representation.
Definition: Value.h:177
virtual size_t getSize() const
Get FloatValue type size.
Definition: Value.h:274
Value(value_type_t theType)
Constructor.
Definition: Value.h:29
FloatValue(float value)
Constructor.
Definition: Value.h:232
int_type_t getIntType()
This function returns signed/unsigned type.
Definition: Value.h:150
virtual std::string toString() const
Get FloatValue type string representation.
Definition: Value.h:328
IntegerValue(int_type_t type=kSigned)
Constructor.
Definition: Value.h:90
StringValue()
Constructor.
Definition: Value.h:352
FloatValue(double value)
Constructor.
Definition: Value.h:221
FloatValue & operator=(double value)
Assign operator.
Definition: Value.h:304
IntegerValue & operator=(int64_t value)
Assign operator.
Definition: Value.h:166
StringValue(const StringValue &other)
Copy constructor.
Definition: Value.h:385
StringValue & operator=(const std::string &value)
Assign operator.
Definition: Value.h:467
FloatValue()
Constructor.
Definition: Value.h:210
std::string m_value
The string value.
Definition: Value.h:501
virtual size_t getSize() const =0
Get Value type size.
StringValue(const std::string *value)
Constructor.
Definition: Value.h:374