add flatbuffers support and initial rewrite

Signed-off-by: Folling <mail@folling.io>
This commit is contained in:
folling 2024-05-12 14:15:42 +02:00 committed by Folling
parent 5f7a62ecb7
commit 4d7bf09c4e
Signed by: folling
SSH key fingerprint: SHA256:S9qEx5WCFFLK49tE/LKnKuJYM5sw+++Dn6qJbbyxnCY
72 changed files with 3929 additions and 1403 deletions

View file

@ -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);