8 #ifndef META_OCEAN_BASE_VALUE_H
9 #define META_OCEAN_BASE_VALUE_H
68 inline Value() noexcept;
86 explicit
Value(const
bool value);
92 explicit
Value(const int32_t value);
98 explicit
Value(const int64_t value);
122 explicit
Value(const std::
string& value);
129 explicit
Value(const
void* value, const
size_t size);
147 inline
bool isType(const
ValueType valueType) const;
153 inline
bool isBool() const;
159 inline
bool isInt() const;
165 inline
bool isInt64() const;
171 inline
bool isFloat() const;
178 inline
bool isFloat64(const
bool allowIntAndFloat = false) const;
184 inline
bool isString() const;
190 inline
bool isBuffer() const;
196 inline
bool isNull() const;
203 bool boolValue() const;
210 int32_t intValue() const;
217 int64_t int64Value() const;
224 float floatValue() const;
232 double float64Value(const
bool allowIntAndFloat = false) const;
239 std::
string stringValue() const;
247 const
void* bufferValue(
size_t& size) const;
255 std::
string readableString(const
unsigned int floatingPointPrecision = 2u) const;
276 bool operator==(const
Value& value) const;
283 inline
bool operator!=(const
Value& value) const;
289 explicit inline operator
bool() const;
299 static
bool writeToBuffer(const
Value& value, std::vector<uint8_t>& buffer, const
size_t offsetInBuffer = 0);
308 static
Value readFromBuffer(const
void* buffer, const
size_t size);
348 valueType_(VT_INVALID)
385 if (allowIntAndFloat)
412 return !(*
this == value);
415 inline Value::operator bool()
const
417 return valueType_ != VT_INVALID;
This class implements a type independent value.
Definition: Value.h:23
bool isString() const
Returns whether this object holds a string value as internal data.
Definition: Value.h:395
ValueType type() const
Returns the internal data type of this value object.
Definition: Value.h:353
bool isFloat64(const bool allowIntAndFloat=false) const
Returns whether this object holds a 64 bit float value as internal data.
Definition: Value.h:383
bool isType(const ValueType valueType) const
Returns whether the internal data type is equivalent to a given one.
Definition: Value.h:358
bool isBuffer() const
Returns whether this object holds a buffer value as internal data.
Definition: Value.h:400
ValueType
Definition of different internal value type.
Definition: Value.h:30
@ VT_INT_64
64 bit integer value.
Definition: Value.h:38
@ VT_FLOAT_32
Single precision floating point value.
Definition: Value.h:40
@ VT_STRING
String value.
Definition: Value.h:44
@ VT_INT_32
32 bit integer value.
Definition: Value.h:36
@ VT_INVALID
Invalid value type.
Definition: Value.h:32
@ VT_BUFFER
Buffer value.
Definition: Value.h:46
@ VT_BOOL
Boolean value type.
Definition: Value.h:34
@ VT_FLOAT_64
Double precision floating point value.
Definition: Value.h:42
ValueType valueType_
Internal value type.
Definition: Value.h:320
bool isFloat() const
Returns whether this object holds a float value as internal data.
Definition: Value.h:378
bool isInt() const
Returns whether this object holds an integer value as internal data.
Definition: Value.h:368
bool operator!=(const Value &value) const
Returns whether two value objects are not identical (not having same type or not holding the same val...
Definition: Value.h:410
bool isNull() const
Returns whether this object does not holds any internal data.
Definition: Value.h:405
Value() noexcept
Creates an empty value.
Definition: Value.h:347
bool isBool() const
Returns whether this object holds an boolean value as internal data.
Definition: Value.h:363
bool isInt64() const
Returns whether this object holds a 64 bit integer value as internal data.
Definition: Value.h:373
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15
Definition of a struct combining memory pointer and size.
Definition: Value.h:55
size_t size_
The size of the buffer, in bytes.
Definition: Value.h:60
void * buffer_
Pointer of the buffer.
Definition: Value.h:57
Definition of a union holding all possible values.
Definition: Value.h:326
double valueFloat64_
Possible double precision floating point value.
Definition: Value.h:340
int32_t valueInt_
Possible int value.
Definition: Value.h:331
bool valueBool_
Possible boolean value.
Definition: Value.h:328
BufferStruct bufferStruct_
Possible buffer value.
Definition: Value.h:343
float valueFloat_
Possible floating point value.
Definition: Value.h:337
int64_t valueInt64_
Possible int 64 value.
Definition: Value.h:334