8#ifndef META_OCEAN_BASE_VALUE_H
9#define META_OCEAN_BASE_VALUE_H
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);
153 inline
bool isBool() const;
159 inline
bool isInt() const;
178 inline
bool isFloat64(const
bool allowIntAndFloat = false) const;
196 inline
bool isNull() 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);
379 if (allowIntAndFloat)
406 return !(*
this == value);
409inline Value::operator bool()
const
bool isString() const
Returns whether this object holds a string value as internal data.
Definition Value.h:389
ValueType type() const
Returns the internal data type of this value object.
Definition Value.h:347
bool isFloat64(const bool allowIntAndFloat=false) const
Returns whether this object holds a 64 bit float value as internal data.
Definition Value.h:377
static Value readFromBuffer(const void *buffer, const size_t size)
Reads a Value object from a buffer.
bool isType(const ValueType valueType) const
Returns whether the internal data type is equivalent to a given one.
Definition Value.h:352
static bool writeToBuffer(const Value &value, std::vector< uint8_t > &buffer, const size_t offsetInBuffer=0)
Writes a Value object to a buffer.
float floatValue() const
Returns the internal value as float.
const void * bufferValue(size_t &size) const
Returns the internal value as buffer.
bool isBuffer() const
Returns whether this object holds a buffer value as internal data.
Definition Value.h:394
std::string readableString(const unsigned int floatingPointPrecision=2u) const
Returns the internal value as a readable string not considering the type of the value.
void release()
Releases the value data.
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
Value() noexcept=default
Creates an empty value.
bool boolValue() const
Returns the internal value as a boolean.
int32_t intValue() const
Returns the internal value as integer.
double float64Value(const bool allowIntAndFloat=false) const
Returns the internal value as 64 bit float.
ValueType valueType_
Internal value type.
Definition Value.h:320
int64_t int64Value() const
Returns the internal value as 64 bit integer.
bool isFloat() const
Returns whether this object holds a float value as internal data.
Definition Value.h:372
bool isInt() const
Returns whether this object holds an integer value as internal data.
Definition Value.h:362
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:404
std::string stringValue() const
Returns the internal value as string.
bool isNull() const
Returns whether this object does not holds any internal data.
Definition Value.h:399
bool isBool() const
Returns whether this object holds an boolean value as internal data.
Definition Value.h:357
bool isInt64() const
Returns whether this object holds a 64 bit integer value as internal data.
Definition Value.h:367
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