caosdb/data_type.h

namespace caosdb::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 CaosDB 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 ProtoAtomicDataType = caosdb::entity::v1alpha1::AtomicDataType
typedef caosdb::entity::v1alpha1::DataType ProtoDataType
using ProtoListDataType = caosdb::entity::v1alpha1::ListDataType
using ProtoReferenceDataType = caosdb::entity::v1alpha1::ReferenceDataType
using DataTypeCase = caosdb::entity::v1alpha1::DataType::DataTypeCase
using ListDataTypeCase = caosdb::entity::v1alpha1::ListDataType::ListDataTypeCase

Enums

enum AtomicDataType

Values:

enumerator UNSPECIFIED
enumerator TEXT
enumerator DOUBLE
enumerator DATETIME
enumerator INTEGER
enumerator BOOLEAN

Variables

const std::map<AtomicDataType, std::string> atomicdatatype_names = {{AtomicDataType::UNSPECIFIED, "UNSPECIFIED"}, {AtomicDataType::TEXT, "TEXT"}, {AtomicDataType::DOUBLE, "DOUBLE"}, {AtomicDataType::DATETIME, "DATETIME"}, {AtomicDataType::INTEGER, "INTEGER"}, {AtomicDataType::BOOLEAN, "BOOLEAN"}}
class DataType : public caosdb::utility::ScalarProtoMessageWrapper<ProtoDataType>

Public Functions

inline DataType(ProtoDataType *wrapped)
inline DataType()
inline DataType(AtomicDataType data_type, bool list_type = false)

Create an AtomicDataType typed DataType. For references, use the std::string constructor.

inline DataType(const std::string &data_type, bool list_type = false)

Create a reference typed DataType.

inline auto IsUndefined() const noexcept -> bool
inline auto IsAtomic() const noexcept -> bool
inline auto GetAsAtomic() const noexcept -> AtomicDataType
inline auto IsReference() const noexcept -> bool
inline auto GetAsReference() const noexcept -> const ReferenceDataType&
inline auto IsList() const noexcept -> bool
inline auto GetAsList() const noexcept -> const ListDataType&
inline auto operator==(const DataType &other) const noexcept -> bool

Return true if other is equal to this object.

This compares the underlying wrapped ProtoMessages and return true if they are both nullptrs or if the serialization is equal.

Public Static Functions

static inline auto ListOf(const AtomicDataType &atomic_data_type) -> DataType
static inline auto ListOf(const std::string reference_data_type) -> DataType

Protected Attributes

mutable std::unique_ptr<ReferenceDataType> reference_data_type
mutable std::unique_ptr<ListDataType> list_data_type

Friends

friend class Entity
friend class Property
class ListDataType : public caosdb::utility::ScalarProtoMessageWrapper<ProtoDataType>

Public Functions

inline auto IsListOfReference() const noexcept -> bool
inline auto GetReferenceDataType() const -> const ReferenceDataType&
inline auto IsListOfAtomic() const noexcept -> bool
inline auto GetAtomicDataType() const -> AtomicDataType

Protected Functions

inline ListDataType()
inline ListDataType(ProtoDataType *wrapped)

Protected Attributes

mutable std::unique_ptr<ReferenceDataType> reference_data_type

Protected Static Functions

static inline auto GetEmptyInstance() -> const ListDataType&
static inline auto Create(ProtoDataType *wrapped) -> std::unique_ptr<ListDataType>

Friends

friend class DataType
class ReferenceDataType : public caosdb::utility::ScalarProtoMessageWrapper<ProtoDataType>

Public Functions

inline auto GetName() const noexcept -> const std::string&
inline auto GetWrapped() const -> const ProtoDataType*

Protected Functions

inline ReferenceDataType()
inline ReferenceDataType(ProtoDataType *wrapped)

Protected Static Functions

static inline auto GetEmptyInstance() -> const ReferenceDataType&
static inline auto Create(ProtoDataType *wrapped) -> std::unique_ptr<ReferenceDataType>

Friends

friend class DataType
friend class ListDataType