add flatbuffers support and initial rewrite
Signed-off-by: Folling <mail@folling.io>
This commit is contained in:
parent
b5852698e3
commit
70820129ae
72 changed files with 3929 additions and 1403 deletions
|
|
@ -1,20 +1,24 @@
|
|||
#pragma once
|
||||
|
||||
#include <boost/json.hpp>
|
||||
#include <boost/variant2.hpp>
|
||||
|
||||
#include <cppbase/result.hpp>
|
||||
|
||||
#include <ikarus/errors.hpp>
|
||||
#include <ikarus/persistence/project.hpp>
|
||||
#include <ikarus/values/value_cardinality.h>
|
||||
|
||||
constexpr auto IKARUS_VALUE_JSON_TYPE_KEY = "type";
|
||||
constexpr auto IKARUS_VALUE_JSON_CARDINALITY_KEY = "card";
|
||||
constexpr auto IKARUS_VALUE_JSON_DATA_KEY = "data";
|
||||
|
||||
struct IkarusValue {
|
||||
public:
|
||||
using Data = boost::variant2::variant<struct IkarusToggleValue *, struct IkarusNumberValue *, struct IkarusTextValue *>;
|
||||
using Data = std::variant<struct IkarusToggleValue *, struct IkarusNumberValue *, struct IkarusTextValue *>;
|
||||
constexpr static auto SMALL_VEC_VALUE_SIZE = 8;
|
||||
|
||||
public:
|
||||
explicit IkarusValue(Data data);
|
||||
explicit IkarusValue(Data data, IkarusValueCardinality cardinality);
|
||||
|
||||
IkarusValue(IkarusValue const &) = default;
|
||||
IkarusValue(IkarusValue &&) noexcept = default;
|
||||
|
|
@ -32,6 +36,7 @@ public:
|
|||
|
||||
public:
|
||||
Data data;
|
||||
IkarusValueCardinality cardinality;
|
||||
};
|
||||
|
||||
template<>
|
||||
|
|
@ -74,3 +79,20 @@ IkarusValue * fetch_value_from_db(IkarusProject * project, IkarusErrorData * err
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define IKARUS_FAIL_IF_VALUE_MISSING_IMPL(var_name, entity, name, ret) \
|
||||
IKARUS_VTRYRV_OR_FAIL( \
|
||||
bool const var_name, \
|
||||
ret, \
|
||||
"unable to check whether value exists: {}", \
|
||||
IkarusErrorInfo_Database_QueryFailed, \
|
||||
(entity)->project->db->template query_one<bool>( \
|
||||
"SELECT EXISTS(SELECT 1 FROM `entity_values` WHERE `entity` = ? AND `name` = ?)", \
|
||||
(entity)->id, \
|
||||
name \
|
||||
) \
|
||||
) \
|
||||
\
|
||||
IKARUS_FAIL_IF(!(var_name), ret, "entity value does not exist", IkarusErrorInfo_Client_Misuse);
|
||||
|
||||
#define IKARUS_FAIL_IF_VALUE_MISSING(entity, name, ret) IKARUS_FAIL_IF_VALUE_MISSING_IMPL(CPPBASE_UNIQUE_NAME(exists), entity, name, ret);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue