linkahead/value.h

Defines

LIST_VALUE_CONSTRUCTOR(TYPE, SETTER)
namespace linkahead
namespace entity

DataTypes have 2 dimensions: They may be atomic or reference typed, and they may be scalar or list valued. If they are atomic, they have an AtomicDataType. If they are reference typed, the reference name can be obtained with GetName().

MessageCodes for entity messages.

In contrast to the status codes, the message codes are part of the LinkAhead API. Messages (and their codes) represent the state of the entities in a transaction or the server.

For a specification of the message codes, look at the protobuf documentation. The sources and documentation can be found at https://gitlab.indiscale.com/caosdb/src/caosdb-proto.

Typedefs

using ProtoSpecialValue = caosdb::entity::v1::SpecialValue
using ProtoScalarValue = caosdb::entity::v1::ScalarValue
using ValueCase = caosdb::entity::v1::Value::ValueCase
using ScalarValueCase = caosdb::entity::v1::ScalarValue::ScalarValueCase
class AbstractValue
#include <value.h>

Pure abstract base class for values.

Subclassed by linkahead::entity::ScalarValue, linkahead::entity::Value

Public Functions

inline virtual ~AbstractValue() = 0

Pure virtual destructor.

virtual auto IsNull() const noexcept -> bool = 0

Return true iff the value is a NULL value (NULL in the LinkAhead sense).

virtual auto IsString() const noexcept -> bool = 0

Return true iff the value is best represented in C++ types as a std::string.

If true, clients may call GetAsString to receive a std::string representation of the value.

virtual auto IsBool() const noexcept -> bool = 0

Return true iff the value is best represented in C++ types as a bool.

If true, clients may call GetAsBool to receive a bool representation of the value.

virtual auto IsDouble() const noexcept -> bool = 0

Return true iff the value is best represented in C++ types as a double.

If true, clients may call GetAsDouble to receive a double representation of the value.

virtual auto IsInt64() const noexcept -> bool = 0

Return true iff the value is best represented in C++ types as an int64_t.

If true, clients may call GetAsInt64 to receive an int64_t representation of the value.

virtual auto IsVector() const noexcept -> bool = 0

Return true iff the value is best represented in C++ types as a std::vector<ScalarValue>.

If true, clients may call GetAsVector to receive a std::vector<ScalarValue> representation of the value.

virtual auto GetAsString() const noexcept -> const std::string& = 0

Return a std::string representation of this value.

Clients should call IsString before calling this function in order to assure that this value is indeed best represented by a std::string.

The return value is undefined if IsString is false.

virtual auto GetAsBool() const noexcept -> bool = 0

Return a bool representation of this value.

Clients should call IsBool before calling this function in order to assure that this value is indeed best represented by a bool.

The return value is undefined if IsBool is false.

virtual auto GetAsDouble() const noexcept -> double = 0

Return a double representation of this value.

Clients should call IsDouble before calling this function in order to assure that this value is indeed best represented by a double.

The return value is undefined if IsDouble is false.

virtual auto GetAsInt64() const noexcept -> int64_t = 0

Return an int64_t representation of this value.

Clients should call IsInt64 before calling this function in order to assure that this value is indeed best represented by an int64_t.

The return value is undefined if IsInt64 is false.

virtual auto GetAsVector() const noexcept -> const std::vector<ScalarValue>& = 0

Return a std::vector<ScalarValue> representation of this value.

Clients should call IsVector before calling this function in order to assure that this value is indeed best represented by a std::vector<ScalarValue>.

The return value is undefined if IsVector is false.

virtual auto ToString() const noexcept -> const std::string = 0

Protected Functions

virtual auto GetProtoValue() const noexcept -> const ProtoValue* = 0

Friends

friend class Value
class ScalarValue : public linkahead::entity::AbstractValue, public linkahead::utility::ScalarProtoMessageWrapper<ProtoScalarValue>

Public Functions

inline ~ScalarValue()

Destructor.

inline ScalarValue(const ScalarValue &original)

Copy constructor.

inline ScalarValue(ScalarValue &&other)

Move constructor.

inline auto operator=(const ScalarValue &original) -> ScalarValue&

Copy assignment operator.

inline auto operator=(ScalarValue &&other) -> ScalarValue&

Move assignment operator.

inline ScalarValue(ProtoScalarValue *wrapped)
inline virtual auto IsNull() const noexcept -> bool

Return true iff the value is a NULL value (NULL in the LinkAhead sense).

inline virtual auto IsString() const noexcept -> bool

Return true iff the value is best represented in C++ types as a std::string.

If true, clients may call GetAsString to receive a std::string representation of the value.

inline virtual auto GetAsString() const noexcept -> const std::string&

Return a std::string representation of this value.

Clients should call IsString before calling this function in order to assure that this value is indeed best represented by a std::string.

The return value is undefined if IsString is false.

inline virtual auto IsDouble() const noexcept -> bool

Return true iff the value is best represented in C++ types as a double.

If true, clients may call GetAsDouble to receive a double representation of the value.

inline virtual auto GetAsDouble() const noexcept -> double

Return a double representation of this value.

Clients should call IsDouble before calling this function in order to assure that this value is indeed best represented by a double.

The return value is undefined if IsDouble is false.

inline virtual auto IsInt64() const noexcept -> bool

Return true iff the value is best represented in C++ types as an int64_t.

If true, clients may call GetAsInt64 to receive an int64_t representation of the value.

inline virtual auto GetAsInt64() const noexcept -> int64_t

Return an int64_t representation of this value.

Clients should call IsInt64 before calling this function in order to assure that this value is indeed best represented by an int64_t.

The return value is undefined if IsInt64 is false.

inline virtual auto IsBool() const noexcept -> bool

Return true iff the value is best represented in C++ types as a bool.

If true, clients may call GetAsBool to receive a bool representation of the value.

inline virtual auto GetAsBool() const noexcept -> bool

Return a bool representation of this value.

Clients should call IsBool before calling this function in order to assure that this value is indeed best represented by a bool.

The return value is undefined if IsBool is false.

inline virtual auto IsVector() const noexcept -> bool

Return true iff the value is best represented in C++ types as a std::vector<ScalarValue>.

If true, clients may call GetAsVector to receive a std::vector<ScalarValue> representation of the value.

inline virtual auto GetAsVector() const noexcept -> const std::vector<ScalarValue>&

Return a std::vector<ScalarValue> representation of this value.

Clients should call IsVector before calling this function in order to assure that this value is indeed best represented by a std::vector<ScalarValue>.

The return value is undefined if IsVector is false.

inline virtual auto ToString() const noexcept -> const std::string

Return a json representation of this object.

Protected Functions

inline virtual auto GetProtoValue() const noexcept -> const ProtoValue*
inline ScalarValue()

Private Members

mutable ProtoValue *proto_value

Friends

friend class Value
class Value : public linkahead::entity::AbstractValue, public linkahead::utility::ScalarProtoMessageWrapper<ProtoValue>

Public Functions

inline Value(const Value &original)

Copy constructor.

inline Value(Value &&other)

Move constructor.

inline ~Value()

Destructor.

inline Value()
inline explicit Value(const ScalarValue &value)
inline explicit Value(const AbstractValue &value)
inline explicit Value(ProtoValue *wrapped)
inline explicit Value(const ProtoValue &value)
inline explicit Value(const std::string &value)
inline explicit Value(const char *value)
inline explicit Value(double value)
inline explicit Value(int64_t value)
inline explicit Value(int value)
inline explicit Value(bool value)
inline virtual auto IsNull() const noexcept -> bool

Return true iff the value is a NULL value (NULL in the LinkAhead sense).

inline virtual auto IsString() const noexcept -> bool

Return true iff the value is best represented in C++ types as a std::string.

If true, clients may call GetAsString to receive a std::string representation of the value.

inline virtual auto GetAsString() const noexcept -> const std::string&

Return a std::string representation of this value.

Clients should call IsString before calling this function in order to assure that this value is indeed best represented by a std::string.

The return value is undefined if IsString is false.

inline virtual auto IsDouble() const noexcept -> bool

Return true iff the value is best represented in C++ types as a double.

If true, clients may call GetAsDouble to receive a double representation of the value.

inline virtual auto GetAsDouble() const noexcept -> double

Return a double representation of this value.

Clients should call IsDouble before calling this function in order to assure that this value is indeed best represented by a double.

The return value is undefined if IsDouble is false.

inline virtual auto IsInt64() const noexcept -> bool

Return true iff the value is best represented in C++ types as an int64_t.

If true, clients may call GetAsInt64 to receive an int64_t representation of the value.

inline virtual auto GetAsInt64() const noexcept -> int64_t

Return an int64_t representation of this value.

Clients should call IsInt64 before calling this function in order to assure that this value is indeed best represented by an int64_t.

The return value is undefined if IsInt64 is false.

inline virtual auto IsBool() const noexcept -> bool

Return true iff the value is best represented in C++ types as a bool.

If true, clients may call GetAsBool to receive a bool representation of the value.

inline virtual auto GetAsBool() const noexcept -> bool

Return a bool representation of this value.

Clients should call IsBool before calling this function in order to assure that this value is indeed best represented by a bool.

The return value is undefined if IsBool is false.

inline virtual auto IsVector() const noexcept -> bool

Return true iff the value is best represented in C++ types as a std::vector<ScalarValue>.

If true, clients may call GetAsVector to receive a std::vector<ScalarValue> representation of the value.

inline virtual auto GetAsVector() const noexcept -> const std::vector<ScalarValue>&

Return a std::vector<ScalarValue> representation of this value.

Clients should call IsVector before calling this function in order to assure that this value is indeed best represented by a std::vector<ScalarValue>.

The return value is undefined if IsVector is false.

inline auto operator=(const Value &other) -> Value&

Copy assignment operator.

inline auto operator=(Value &&other) -> Value&

Move assignment operator.

inline virtual auto ToString() const noexcept -> const std::string

Return a json representation of this object.

Protected Functions

inline virtual auto GetProtoValue() const noexcept -> const ProtoValue*

Private Members

mutable std::unique_ptr<std::vector<ScalarValue>> collection_values

Friends

friend class Entity
friend class Property