make values capable of being a list & add boost
Signed-off-by: Folling <mail@folling.io>
This commit is contained in:
parent
08ad2c5c66
commit
733b52575b
16 changed files with 315 additions and 140 deletions
|
|
@ -87,24 +87,26 @@ IncludeCategories:
|
||||||
Priority: 2
|
Priority: 2
|
||||||
- Regex: '^<[a-z0-9_]+>$'
|
- Regex: '^<[a-z0-9_]+>$'
|
||||||
Priority: 3
|
Priority: 3
|
||||||
- Regex: '^<expected/.*>$'
|
- Regex: '^<boost/.*>$'
|
||||||
Priority: 4
|
Priority: 4
|
||||||
- Regex: '^<fmt/.*>$'
|
- Regex: '^<expected/.*>$'
|
||||||
Priority: 5
|
Priority: 5
|
||||||
- Regex: '^<nlohmann/.*>$'
|
- Regex: '^<fmt/.*>$'
|
||||||
Priority: 6
|
Priority: 6
|
||||||
- Regex: '^<range-v3/.*>$'
|
- Regex: '^<nlohmann/.*>$'
|
||||||
Priority: 7
|
Priority: 7
|
||||||
- Regex: '^<catch2/.*>$'
|
- Regex: '^<range-v3/.*>$'
|
||||||
Priority: 8
|
Priority: 8
|
||||||
- Regex: '^<unicode/.*>$'
|
- Regex: '^<catch2/.*>$'
|
||||||
Priority: 9
|
Priority: 9
|
||||||
- Regex: '^<cppbase/.*>$'
|
- Regex: '^<unicode/.*>$'
|
||||||
Priority: 10
|
Priority: 10
|
||||||
- Regex: '^<sqlitecpp/.*>$'
|
- Regex: '^<cppbase/.*>$'
|
||||||
Priority: 11
|
Priority: 11
|
||||||
- Regex: '^<ikarus/.*>$'
|
- Regex: '^<sqlitecpp/.*>$'
|
||||||
Priority: 12
|
Priority: 12
|
||||||
|
- Regex: '^<ikarus/.*>$'
|
||||||
|
Priority: 13
|
||||||
|
|
||||||
IndentAccessModifiers: false
|
IndentAccessModifiers: false
|
||||||
IndentCaseBlocks: false
|
IndentCaseBlocks: false
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ add_subdirectory(vendor)
|
||||||
add_subdirectory(include)
|
add_subdirectory(include)
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|
||||||
|
find_package(Boost REQUIRED)
|
||||||
|
|
||||||
add_library(
|
add_library(
|
||||||
libikarus SHARED
|
libikarus SHARED
|
||||||
${INCLUDE_FILES}
|
${INCLUDE_FILES}
|
||||||
|
|
@ -34,6 +36,12 @@ target_link_libraries(
|
||||||
libikarus PRIVATE
|
libikarus PRIVATE
|
||||||
cppbase
|
cppbase
|
||||||
sqlitecpp
|
sqlitecpp
|
||||||
|
${Boost_LIBRARIES}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(
|
||||||
|
libikarus PRIVATE
|
||||||
|
${Boost_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
|
|
||||||
if (LIBIKARUS_ENABLE_LINTS)
|
if (LIBIKARUS_ENABLE_LINTS)
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,14 @@ IKA_API IkarusPropertyType ikarus_property_get_type(IkarusProperty const * prope
|
||||||
/// \remark Must be freed using #ikarus_free.
|
/// \remark Must be freed using #ikarus_free.
|
||||||
IKA_API struct IkarusPropertySource const * ikarus_property_get_source(IkarusProperty const * property);
|
IKA_API struct IkarusPropertySource const * ikarus_property_get_source(IkarusProperty const * property);
|
||||||
|
|
||||||
|
/// \brief Gets the default value of a property.
|
||||||
|
/// \param property The property to get the type info of.
|
||||||
|
/// \pre \li Must not be null.
|
||||||
|
/// \pre \li Must exist.
|
||||||
|
/// \return The default value of the property or null if an error occurs.
|
||||||
|
/// \remark Must be freed using #ikarus_free.
|
||||||
|
IKA_API struct IkarusValue * ikarus_property_get_default_value(IkarusProperty const * property);
|
||||||
|
|
||||||
/// \brief Visits a property. Calling the appropriate function for the property's type.
|
/// \brief Visits a property. Calling the appropriate function for the property's type.
|
||||||
/// \param property The property to visit.
|
/// \param property The property to visit.
|
||||||
/// \pre \li Must not be null.
|
/// \pre \li Must not be null.
|
||||||
|
|
|
||||||
|
|
@ -4,42 +4,57 @@
|
||||||
/// \author Folling <folling@ikarus.world>
|
/// \author Folling <folling@ikarus.world>
|
||||||
|
|
||||||
#include <ikarus/macros.h>
|
#include <ikarus/macros.h>
|
||||||
|
#include <ikarus/stdtypes.h>
|
||||||
|
|
||||||
/// \addtogroup values Values
|
/// \addtogroup values Values
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
IKARUS_BEGIN_HEADER
|
IKARUS_BEGIN_HEADER
|
||||||
|
|
||||||
/// \brief A true/false boolean-like value. For example "IsDead".
|
/// \brief A true/false long doubleean-esque value. For example "Is Dead".
|
||||||
struct IkarusNumberValue;
|
struct IkarusNumberValue;
|
||||||
|
|
||||||
/// \brief Creates a number value from a long double.
|
/// \brief Creates a number value from doubles.
|
||||||
/// \param value The numeric value.
|
/// \param data The number data or null if you wish to clear the data.
|
||||||
/// \return The entity value.
|
/// \details LibIkarus does not take ownership of this array.
|
||||||
|
/// \param data_size The size of the data array or 0 if you wish to clear the data.
|
||||||
|
/// \return The value.
|
||||||
/// \remark Must be freed with #ikarus_free.
|
/// \remark Must be freed with #ikarus_free.
|
||||||
IKA_API IkarusNumberValue * ikarus_number_value_create(long double value);
|
IKA_API IkarusNumberValue * ikarus_number_value_create(long double * data, size_t data_size);
|
||||||
|
|
||||||
/// \brief Creates an indeterminate number value.
|
/// \brief Creates an indeterminate number value.
|
||||||
/// \return The entity value.
|
/// \return The value.
|
||||||
/// \remark Must be freed with #ikarus_free.
|
/// \remark Must be freed with #ikarus_free.
|
||||||
IKA_API IkarusNumberValue * ikarus_number_value_create_indeterminate();
|
IKA_API IkarusNumberValue * ikarus_number_value_create_indeterminate();
|
||||||
|
|
||||||
/// \brief Fetches the underlying value of a number value.
|
/// \brief Fetches the underlying data of a number value.
|
||||||
/// \param value The number value.
|
/// \details You may adjust the returned data as per your hearts desire.
|
||||||
/// \return The underlying value.
|
/// If you need to grow the data, use #ikarus_number_value_set with a new array.
|
||||||
/// \warning Undefined if the value is indeterminate.
|
/// Just remember that IkarusValues are plain objects, so changing them won't affect any state.
|
||||||
IKA_API long double ikarus_number_value_get(IkarusNumberValue const * value);
|
/// They will need to be submitted to other functions such as #ikarus_entity_set_value to have any effect.
|
||||||
|
|
||||||
/// \brief Sets the value of a number value.
|
|
||||||
/// \param value The number value.
|
/// \param value The number value.
|
||||||
/// \pre \li Must not be null.
|
/// \pre \li Must not be null.
|
||||||
/// \param new_value The new value.
|
/// \param data_size_out An out-parameter for the size of the returned array.
|
||||||
IKA_API void ikarus_number_value_set(IkarusNumberValue * value, bool new_value);
|
/// \remark Ignored if null.
|
||||||
|
/// \return The underlying data. Owned by LibIkarus, most not be freed.
|
||||||
|
/// \warning Undefined if the value is indeterminate.
|
||||||
|
IKA_API long double * ikarus_number_value_get(IkarusNumberValue * value, size_t * data_size_out);
|
||||||
|
|
||||||
|
/// \see ikarus_number_value_get
|
||||||
|
long double const * ikarus_number_value_get_const(IkarusNumberValue const * value, size_t * data_size_out);
|
||||||
|
|
||||||
|
/// \brief Sets the data of a number value.
|
||||||
|
/// \param value The number value.
|
||||||
|
/// \pre \li Must not be null.
|
||||||
|
/// \param new_data The new data or null if you wish to clear the data.
|
||||||
|
/// \details LibIkarus does not take ownership of this array.
|
||||||
|
/// \param new_data_size The size of the new data array or 0 if you wish to clear the data.
|
||||||
|
IKA_API void ikarus_number_value_set(IkarusNumberValue * value, long double * new_data, size_t new_data_size);
|
||||||
|
|
||||||
/// \brief Converts a number value to an entity value.
|
/// \brief Converts a number value to an entity value.
|
||||||
/// \param number_value The number value to convert.
|
/// \param value The number value to convert.
|
||||||
/// \return The converted entity value.
|
/// \return The converted entity value.
|
||||||
IKA_API struct IkarusValue * ikarus_number_value_to_value(IkarusNumberValue * number_value);
|
IKA_API struct IkarusValue * ikarus_number_value_to_value(IkarusNumberValue * value);
|
||||||
|
|
||||||
IKARUS_END_HEADER
|
IKARUS_END_HEADER
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,43 +4,57 @@
|
||||||
/// \author Folling <folling@ikarus.world>
|
/// \author Folling <folling@ikarus.world>
|
||||||
|
|
||||||
#include <ikarus/macros.h>
|
#include <ikarus/macros.h>
|
||||||
|
#include <ikarus/stdtypes.h>
|
||||||
|
|
||||||
/// \addtogroup values Values
|
/// \addtogroup values Values
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
IKARUS_BEGIN_HEADER
|
IKARUS_BEGIN_HEADER
|
||||||
|
|
||||||
/// \brief A true/false boolean-like value. For example "IsDead".
|
/// \brief A true/false char const*ean-esque value. For example "Is Dead".
|
||||||
struct IkarusTextValue;
|
struct IkarusTextValue;
|
||||||
|
|
||||||
/// \brief Creates a text value from a boolean.
|
/// \brief Creates a text value from doubles.
|
||||||
/// \param value The text value.
|
/// \param data The text data or null if you wish to clear the data.
|
||||||
/// \return The entity value.
|
/// \details LibIkarus does not take ownership of this array.
|
||||||
|
/// \param data_size The size of the data array or 0 if you wish to clear the data.
|
||||||
|
/// \return The value.
|
||||||
/// \remark Must be freed with #ikarus_free.
|
/// \remark Must be freed with #ikarus_free.
|
||||||
IKA_API IkarusTextValue * ikarus_text_value_create(char const * value);
|
IKA_API IkarusTextValue * ikarus_text_value_create(char const ** data, size_t data_size);
|
||||||
|
|
||||||
/// \brief Creates an indeterminate text value.
|
/// \brief Creates an indeterminate text value.
|
||||||
/// \return The entity value.
|
/// \return The value.
|
||||||
/// \remark Must be freed with #ikarus_free.
|
/// \remark Must be freed with #ikarus_free.
|
||||||
IKA_API IkarusTextValue * ikarus_text_value_create_indeterminate();
|
IKA_API IkarusTextValue * ikarus_text_value_create_indeterminate();
|
||||||
|
|
||||||
/// \brief Fetches the underlying value of a text value.
|
/// \brief Fetches the underlying data of a text value.
|
||||||
/// \param value The text value.
|
/// \details You may adjust the returned data as per your hearts desire.
|
||||||
/// \return The underlying value.
|
/// If you need to grow the data, use #ikarus_text_value_set with a new array.
|
||||||
/// \warning Undefined if the value is indeterminate.
|
/// Just remember that IkarusValues are plain objects, so changing them won't affect any state.
|
||||||
/// \remark The value is owned by libikarus and must not be freed.
|
/// They will need to be submitted to other functions such as #ikarus_entity_set_value to have any effect.
|
||||||
IKA_API char const * ikarus_text_value_get_underlying(IkarusTextValue const * value);
|
|
||||||
|
|
||||||
/// \brief Sets the value of a text value.
|
|
||||||
/// \param value The text value.
|
/// \param value The text value.
|
||||||
/// \pre \li Must not be null.
|
/// \pre \li Must not be null.
|
||||||
/// \param new_value The new value.
|
/// \param data_size_out An out-parameter for the size of the returned array.
|
||||||
IKA_API void ikarus_text_value_set(IkarusTextValue * value, bool new_value);
|
/// \remark Ignored if null.
|
||||||
|
/// \return The underlying data. Owned by LibIkarus, most not be freed.
|
||||||
|
/// \warning Undefined if the value is indeterminate.
|
||||||
|
IKA_API char ** ikarus_text_value_get(IkarusTextValue * value, size_t * data_size_out);
|
||||||
|
|
||||||
|
/// \see ikarus_text_value_get
|
||||||
|
char const * const * ikarus_text_value_get_const(IkarusTextValue const * value, size_t * data_size_out);
|
||||||
|
|
||||||
|
/// \brief Sets the data of a text value.
|
||||||
|
/// \param value The text value.
|
||||||
|
/// \pre \li Must not be null.
|
||||||
|
/// \param new_data The new data or null if you wish to clear the data.
|
||||||
|
/// \details LibIkarus does not take ownership of this array.
|
||||||
|
/// \param new_data_size The size of the new data array or 0 if you wish to clear the data.
|
||||||
|
IKA_API void ikarus_text_value_set(IkarusTextValue * value, char const ** new_data, size_t new_data_size);
|
||||||
|
|
||||||
/// \brief Converts a text value to an entity value.
|
/// \brief Converts a text value to an entity value.
|
||||||
/// \param text_value The text value to convert.
|
/// \param value The text value to convert.
|
||||||
/// \return The converted entity value.
|
/// \return The converted entity value.
|
||||||
IKA_API struct IkarusValue * ikarus_text_value_to_value(IkarusTextValue * text_value);
|
IKA_API struct IkarusValue * ikarus_text_value_to_value(IkarusTextValue * value);
|
||||||
|
|
||||||
IKARUS_END_HEADER
|
IKARUS_END_HEADER
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,42 +4,57 @@
|
||||||
/// \author Folling <folling@ikarus.world>
|
/// \author Folling <folling@ikarus.world>
|
||||||
|
|
||||||
#include <ikarus/macros.h>
|
#include <ikarus/macros.h>
|
||||||
|
#include <ikarus/stdtypes.h>
|
||||||
|
|
||||||
/// \addtogroup values Values
|
/// \addtogroup values Values
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
IKARUS_BEGIN_HEADER
|
IKARUS_BEGIN_HEADER
|
||||||
|
|
||||||
/// \brief A true/false boolean-like value. For example "IsDead".
|
/// \brief A true/false boolean-esque value. For example "Is Dead".
|
||||||
struct IkarusToggleValue;
|
struct IkarusToggleValue;
|
||||||
|
|
||||||
/// \brief Creates a toggle value from a boolean.
|
/// \brief Creates a toggle value from doubles.
|
||||||
/// \param value The toggle value.
|
/// \param data The toggle data or null if you wish to clear the data.
|
||||||
/// \return The entity value.
|
/// \details LibIkarus does not take ownership of this array.
|
||||||
|
/// \param data_size The size of the data array or 0 if you wish to clear the data.
|
||||||
|
/// \return The value.
|
||||||
/// \remark Must be freed with #ikarus_free.
|
/// \remark Must be freed with #ikarus_free.
|
||||||
IKA_API IkarusToggleValue * ikarus_toggle_value_create(bool value);
|
IKA_API IkarusToggleValue * ikarus_toggle_value_create(bool * data, size_t data_size);
|
||||||
|
|
||||||
/// \brief Creates an indeterminate toggle value.
|
/// \brief Creates an indeterminate toggle value.
|
||||||
/// \return The entity value.
|
/// \return The value.
|
||||||
/// \remark Must be freed with #ikarus_free.
|
/// \remark Must be freed with #ikarus_free.
|
||||||
IKA_API IkarusToggleValue * ikarus_toggle_value_create_indeterminate();
|
IKA_API IkarusToggleValue * ikarus_toggle_value_create_indeterminate();
|
||||||
|
|
||||||
/// \brief Fetches the underlying value of a toggle value.
|
/// \brief Fetches the underlying data of a toggle value.
|
||||||
/// \param value The toggle value.
|
/// \details You may adjust the returned data as per your hearts desire.
|
||||||
/// \return The underlying value.
|
/// If you need to grow the data, use #ikarus_toggle_value_set with a new array.
|
||||||
/// \warning Undefined if the value is indeterminate.
|
/// Just remember that IkarusValues are plain objects, so changing them won't affect any state.
|
||||||
IKA_API bool ikarus_toggle_value_get(IkarusToggleValue const * value);
|
/// They will need to be submitted to other functions such as #ikarus_entity_set_value to have any effect.
|
||||||
|
|
||||||
/// \brief Sets the value of a toggle value.
|
|
||||||
/// \param value The toggle value.
|
/// \param value The toggle value.
|
||||||
/// \pre \li Must not be null.
|
/// \pre \li Must not be null.
|
||||||
/// \param new_value The new value.
|
/// \param data_size_out An out-parameter for the size of the returned array.
|
||||||
IKA_API void ikarus_toggle_value_set(IkarusToggleValue * value, bool new_value);
|
/// \remark Ignored if null.
|
||||||
|
/// \return The underlying data. Owned by LibIkarus, most not be freed.
|
||||||
|
/// \warning Undefined if the value is indeterminate.
|
||||||
|
IKA_API bool * ikarus_toggle_value_get(IkarusToggleValue * value, size_t * data_size_out);
|
||||||
|
|
||||||
|
/// \see ikarus_toggle_value_get
|
||||||
|
bool const * ikarus_toggle_value_get_const(IkarusToggleValue const * value, size_t * data_size_out);
|
||||||
|
|
||||||
|
/// \brief Sets the data of a toggle value.
|
||||||
|
/// \param value The toggle value.
|
||||||
|
/// \pre \li Must not be null.
|
||||||
|
/// \param new_data The new data or null if you wish to clear the data.
|
||||||
|
/// \details LibIkarus does not take ownership of this array.
|
||||||
|
/// \param new_data_size The size of the new data array or 0 if you wish to clear the data.
|
||||||
|
IKA_API void ikarus_toggle_value_set(IkarusToggleValue * value, bool * new_data, size_t new_data_size);
|
||||||
|
|
||||||
/// \brief Converts a toggle value to an entity value.
|
/// \brief Converts a toggle value to an entity value.
|
||||||
/// \param toggle_value The toggle value to convert.
|
/// \param value The toggle value to convert.
|
||||||
/// \return The converted entity value.
|
/// \return The converted entity value.
|
||||||
IKA_API struct IkarusValue * ikarus_toggle_value_to_value(IkarusToggleValue * toggle_value);
|
IKA_API struct IkarusValue * ikarus_toggle_value_to_value(IkarusToggleValue * value);
|
||||||
|
|
||||||
IKARUS_END_HEADER
|
IKARUS_END_HEADER
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,14 @@
|
||||||
#include <ikarus/macros.h>
|
#include <ikarus/macros.h>
|
||||||
|
|
||||||
/// \defgroup values Values
|
/// \defgroup values Values
|
||||||
/// \brief The values stored in entities.
|
/// \brief The values of properties.
|
||||||
/// \details Each entity has a value for each property it is associated with.
|
/// \details Each entity has a value for each property it is associated with.
|
||||||
/// The value is of the type specified by the property and constrained by the property's settings.
|
/// These value classes represent plain objects. They are not associated with any entity.
|
||||||
/// A value may be indeterminate which means it is unknown or not specified.
|
/// Each value may be indeterminate. \see IkarusProperty
|
||||||
/// \see PropertyType PropertySettings
|
/// Values are stored as lists. If a property is "singular" then its value is a list of size 1.
|
||||||
|
/// Values are typed, with types existing for each of the corresponding property types.
|
||||||
|
/// When setting values for a property the type must match the property type and the value must be valid under the property's
|
||||||
|
/// settings. \see PropertyType
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
IKARUS_BEGIN_HEADER
|
IKARUS_BEGIN_HEADER
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
#include <persistence/function_context.hpp>
|
#include <persistence/function_context.hpp>
|
||||||
#include <persistence/project.hpp>
|
#include <persistence/project.hpp>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <values/value.hpp>
|
||||||
|
|
||||||
IkarusProperty::IkarusProperty(IkarusProject * project, IkarusId id, Data data):
|
IkarusProperty::IkarusProperty(IkarusProject * project, IkarusId id, Data data):
|
||||||
IkarusObject{project, id},
|
IkarusObject{project, id},
|
||||||
|
|
@ -121,6 +122,31 @@ IkarusPropertySource const * ikarus_property_get_source(IkarusProperty const * p
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IkarusValue * ikarus_property_get_default_value(IkarusProperty const * property) {
|
||||||
|
LOG_VERBOSE("fetching property default value");
|
||||||
|
|
||||||
|
LOG_VERBOSE("project={};property={}", property->get_project()->get_path().c_str(), property->get_id());
|
||||||
|
|
||||||
|
auto * ctx = property->get_project()->get_function_context();
|
||||||
|
|
||||||
|
VTRY(
|
||||||
|
auto const value,
|
||||||
|
property->get_project()
|
||||||
|
->get_db()
|
||||||
|
->query_one<int>("SELECT `default_value` FROM `properties` WHERE `id` = ?", property->get_id())
|
||||||
|
.on_error([ctx](auto const& err) {
|
||||||
|
ctx->set_error(
|
||||||
|
fmt::format("failed to fetch property's default value: {}", err),
|
||||||
|
true,
|
||||||
|
IkarusErrorInfo_Source_SubSystem,
|
||||||
|
IkarusErrorInfo_Type_SubSystem_Database
|
||||||
|
);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
return new IkarusValue(property->get_project(), value);
|
||||||
|
}
|
||||||
|
|
||||||
void ikarus_property_visit(
|
void ikarus_property_visit(
|
||||||
IkarusProperty * property,
|
IkarusProperty * property,
|
||||||
void (*toggle_property_visitor)(struct IkarusToggleProperty *, void *),
|
void (*toggle_property_visitor)(struct IkarusToggleProperty *, void *),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
#include "toggle_property.hpp"
|
#include "toggle_property.hpp"
|
||||||
|
|
||||||
IkarusToggleProperty::IkarusToggleProperty(IkarusProject * project, IkarusId id):
|
IkarusToggleProperty::IkarusToggleProperty(IkarusProject * project, IkarusId id):
|
||||||
IkarusProperty{project, id, this} {
|
IkarusProperty{project, id, this} {}
|
||||||
|
|
||||||
|
IkarusToggleProperty * ikarus_toggle_property_create(
|
||||||
|
struct IkarusProject * project, char const * name, struct IkarusPropertySource * property_source
|
||||||
|
) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
CREATE TABLE `objects`
|
CREATE TABLE `objects`
|
||||||
(
|
(
|
||||||
`do_not_access_rowid_alias` INTEGER PRIMARY KEY,
|
`do_not_access_rowid_alias` INTEGER PRIMARY KEY,
|
||||||
`object_type` INT NOT NULL,
|
`object_type` INT NOT NULL,
|
||||||
`id` INT GENERATED ALWAYS AS (`do_not_access_rowid_alias` | (`object_type` << 56)) VIRTUAL,
|
`id` INT GENERATED ALWAYS AS (`do_not_access_rowid_alias` | (`object_type` << 56)
|
||||||
|
) VIRTUAL,
|
||||||
`name` TEXT NOT NULL,
|
`name` TEXT NOT NULL,
|
||||||
`information` TEXT NOT NULL
|
`information` TEXT NOT NULL
|
||||||
) STRICT;
|
) STRICT;
|
||||||
|
|
@ -11,7 +12,7 @@ CREATE UNIQUE INDEX `object_id` ON `objects` (`id`);
|
||||||
CREATE INDEX `object_type` ON `objects` (`object_type`);
|
CREATE INDEX `object_type` ON `objects` (`object_type`);
|
||||||
|
|
||||||
CREATE
|
CREATE
|
||||||
VIRTUAL TABLE `objects_fts` USING fts5
|
VIRTUAL TABLE `objects_fts` USING fts5
|
||||||
(
|
(
|
||||||
`name`,
|
`name`,
|
||||||
`information`,
|
`information`,
|
||||||
|
|
@ -23,7 +24,7 @@ CREATE
|
||||||
"unicode61 remove_diacritics 2 tokenchars '-_'"
|
"unicode61 remove_diacritics 2 tokenchars '-_'"
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE `blueprints`
|
CREATE TABLE `entities`
|
||||||
(
|
(
|
||||||
`id` INT,
|
`id` INT,
|
||||||
|
|
||||||
|
|
@ -31,7 +32,7 @@ CREATE TABLE `blueprints`
|
||||||
FOREIGN KEY (`id`) REFERENCES `objects` (`id`) ON DELETE CASCADE
|
FOREIGN KEY (`id`) REFERENCES `objects` (`id`) ON DELETE CASCADE
|
||||||
) WITHOUT ROWID, STRICT;
|
) WITHOUT ROWID, STRICT;
|
||||||
|
|
||||||
CREATE TABLE `entities`
|
CREATE TABLE `blueprints`
|
||||||
(
|
(
|
||||||
`id` INT,
|
`id` INT,
|
||||||
|
|
||||||
|
|
@ -69,7 +70,7 @@ CREATE INDEX `properties_type` ON `properties` (`type`);
|
||||||
CREATE INDEX `properties_source` ON `properties` (`source`);
|
CREATE INDEX `properties_source` ON `properties` (`source`);
|
||||||
|
|
||||||
CREATE
|
CREATE
|
||||||
VIRTUAL TABLE `property_default_value_fts` USING fts5
|
VIRTUAL TABLE `property_default_value_fts` USING fts5
|
||||||
(
|
(
|
||||||
`default_value`,
|
`default_value`,
|
||||||
content=
|
content=
|
||||||
|
|
@ -81,7 +82,7 @@ CREATE
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE
|
CREATE
|
||||||
VIRTUAL TABLE `property_settings_fts` USING fts5
|
VIRTUAL TABLE `property_settings_fts` USING fts5
|
||||||
(
|
(
|
||||||
`settings`,
|
`settings`,
|
||||||
content=
|
content=
|
||||||
|
|
@ -104,7 +105,7 @@ CREATE TABLE `values`
|
||||||
) WITHOUT ROWID, STRICT;
|
) WITHOUT ROWID, STRICT;
|
||||||
|
|
||||||
CREATE
|
CREATE
|
||||||
VIRTUAL TABLE `values_fts` USING fts5
|
VIRTUAL TABLE `values_fts` USING fts5
|
||||||
(
|
(
|
||||||
`value`,
|
`value`,
|
||||||
content=
|
content=
|
||||||
|
|
|
||||||
|
|
@ -2,25 +2,54 @@
|
||||||
|
|
||||||
#include <values/number_value.hpp>
|
#include <values/number_value.hpp>
|
||||||
|
|
||||||
IkarusNumberValue * ikarus_number_value_create(long double value) {
|
IkarusNumberValue::IkarusNumberValue():
|
||||||
return new IkarusNumberValue{value};
|
IkarusValue{this} {}
|
||||||
|
|
||||||
|
boost::container::vector<long double>& IkarusNumberValue::get_value() {
|
||||||
|
return _value;
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::container::vector<long double> const& IkarusNumberValue::get_value() const {
|
||||||
|
return _value;
|
||||||
|
}
|
||||||
|
|
||||||
|
IkarusNumberValue * ikarus_number_value_create(long double * data, size_t data_size) {
|
||||||
|
auto * ret = new IkarusNumberValue{};
|
||||||
|
|
||||||
|
ikarus_number_value_set(ret, data, data_size);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
IkarusNumberValue * ikarus_number_value_create_indeterminate() {
|
IkarusNumberValue * ikarus_number_value_create_indeterminate() {
|
||||||
auto * ret = new IkarusNumberValue{0.0};
|
auto * ret = new IkarusNumberValue{};
|
||||||
ret->set_intermediate(true);
|
ret->set_intermediate(true);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
long double ikarus_number_value_get(IkarusNumberValue const * value) {
|
long double * ikarus_number_value_get(IkarusNumberValue * value, size_t * data_size_out) {
|
||||||
return value->get_value();
|
// NOLINTNEXTLINE(*-pro-type-const-cast)
|
||||||
|
return const_cast<long double *>(ikarus_number_value_get_const(value, data_size_out));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ikarus_number_value_set(IkarusNumberValue * value, long double new_value) {
|
long double const * ikarus_number_value_get_const(IkarusNumberValue const * value, size_t * data_size_out) {
|
||||||
value->set_value(new_value);
|
if (data_size_out != nullptr) {
|
||||||
|
*data_size_out = value->get_value().size();
|
||||||
|
}
|
||||||
|
|
||||||
|
return value->get_value().data();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct IkarusValue * ikarus_number_value_to_value(IkarusNumberValue * number_value) {
|
void ikarus_number_value_set(IkarusNumberValue * value, long double * new_data, size_t new_data_size) {
|
||||||
return static_cast<IkarusValue *>(number_value);
|
value->get_value().reserve(new_data_size);
|
||||||
|
|
||||||
|
for (auto i = 0; i < new_data_size; ++i) {
|
||||||
|
// NOLINTNEXTLINE(*-pro-bounds-pointer-arithmetic)
|
||||||
|
value->get_value().emplace_back(new_data[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct IkarusValue * ikarus_number_value_to_value(IkarusNumberValue * value) {
|
||||||
|
return static_cast<IkarusValue *>(value);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,14 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include <boost/container/vector.hpp>
|
||||||
|
|
||||||
#include <values/value.hpp>
|
#include <values/value.hpp>
|
||||||
|
|
||||||
/// \private
|
|
||||||
struct IkarusNumberValue final : IkarusValue {
|
struct IkarusNumberValue final : IkarusValue {
|
||||||
public:
|
public:
|
||||||
explicit IkarusNumberValue(long double value):
|
explicit IkarusNumberValue();
|
||||||
IkarusValue{this},
|
|
||||||
_value{value} {}
|
|
||||||
|
|
||||||
IkarusNumberValue(IkarusNumberValue const&) = default;
|
IkarusNumberValue(IkarusNumberValue const&) = default;
|
||||||
IkarusNumberValue(IkarusNumberValue&&) = default;
|
IkarusNumberValue(IkarusNumberValue&&) = default;
|
||||||
|
|
@ -18,14 +19,9 @@ public:
|
||||||
~IkarusNumberValue() override = default;
|
~IkarusNumberValue() override = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
[[nodiscard]] long double get_value() const {
|
[[nodiscard]] boost::container::vector<long double>& get_value();
|
||||||
return _value;
|
[[nodiscard]] boost::container::vector<long double> const& get_value() const;
|
||||||
}
|
|
||||||
|
|
||||||
void set_value(long double value) {
|
|
||||||
_value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
long double _value;
|
boost::container::vector<long double> _value{};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,55 @@
|
||||||
#include "ikarus/values/text_value.h"
|
#include "ikarus/values/text_value.h"
|
||||||
|
|
||||||
#include "text_value.hpp"
|
#include <values/text_value.hpp>
|
||||||
|
|
||||||
IkarusTextValue * ikarus_text_value_create(char const * value) {
|
IkarusTextValue::IkarusTextValue():
|
||||||
return new IkarusTextValue{value};
|
IkarusValue{this} {}
|
||||||
|
|
||||||
|
boost::container::vector<char const *>& IkarusTextValue::get_value() {
|
||||||
|
return _value;
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::container::vector<char const *> const& IkarusTextValue::get_value() const {
|
||||||
|
return _value;
|
||||||
|
}
|
||||||
|
|
||||||
|
IkarusTextValue * ikarus_text_value_create(char const ** data, size_t data_size) {
|
||||||
|
auto * ret = new IkarusTextValue{};
|
||||||
|
|
||||||
|
ikarus_text_value_set(ret, data, data_size);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
IkarusTextValue * ikarus_text_value_create_indeterminate() {
|
IkarusTextValue * ikarus_text_value_create_indeterminate() {
|
||||||
auto * ret = new IkarusTextValue{""};
|
auto * ret = new IkarusTextValue{};
|
||||||
ret->set_intermediate(true);
|
ret->set_intermediate(true);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
char const * ikarus_text_value_get(IkarusTextValue const * value) {
|
char ** ikarus_text_value_get(IkarusTextValue * value, size_t * data_size_out) {
|
||||||
|
// NOLINTNEXTLINE(*-pro-type-const-cast)
|
||||||
|
return const_cast<char **>(ikarus_text_value_get_const(value, data_size_out));
|
||||||
|
}
|
||||||
|
|
||||||
|
char const * const * ikarus_text_value_get_const(IkarusTextValue const * value, size_t * data_size_out) {
|
||||||
|
if (data_size_out != nullptr) {
|
||||||
|
*data_size_out = value->get_value().size();
|
||||||
|
}
|
||||||
|
|
||||||
return value->get_value().data();
|
return value->get_value().data();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ikarus_text_value_set(IkarusTextValue * value, char const * new_value) {
|
void ikarus_text_value_set(IkarusTextValue * value, char const ** new_data, size_t new_data_size) {
|
||||||
value->set_value(new_value);
|
value->get_value().reserve(new_data_size);
|
||||||
|
|
||||||
|
for (auto i = 0; i < new_data_size; ++i) {
|
||||||
|
// NOLINTNEXTLINE(*-pro-bounds-pointer-arithmetic)
|
||||||
|
value->get_value().emplace_back(new_data[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct IkarusValue * ikarus_text_value_to_value(IkarusTextValue * text_value) {
|
struct IkarusValue * ikarus_text_value_to_value(IkarusTextValue * value) {
|
||||||
return static_cast<IkarusValue *>(text_value);
|
return static_cast<IkarusValue *>(value);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,33 +1,28 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include <boost/container/vector.hpp>
|
||||||
|
|
||||||
#include <values/value.hpp>
|
#include <values/value.hpp>
|
||||||
|
|
||||||
/// \private
|
|
||||||
struct IkarusTextValue final : IkarusValue {
|
struct IkarusTextValue final : IkarusValue {
|
||||||
public:
|
public:
|
||||||
explicit IkarusTextValue(std::string value):
|
explicit IkarusTextValue();
|
||||||
IkarusValue{this},
|
|
||||||
_value(std::move(value)) {}
|
|
||||||
|
|
||||||
IkarusTextValue(IkarusTextValue const&) = default;
|
IkarusTextValue(IkarusTextValue const&) = default;
|
||||||
IkarusTextValue(IkarusTextValue&&) noexcept = default;
|
IkarusTextValue(IkarusTextValue&&) = default;
|
||||||
|
|
||||||
IkarusTextValue& operator=(IkarusTextValue const&) = default;
|
IkarusTextValue& operator=(IkarusTextValue const&) = default;
|
||||||
IkarusTextValue& operator=(IkarusTextValue&&) noexcept = default;
|
IkarusTextValue& operator=(IkarusTextValue&&) = default;
|
||||||
|
|
||||||
~IkarusTextValue() override = default;
|
~IkarusTextValue() override = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
[[nodiscard]] std::string_view get_value() const noexcept {
|
[[nodiscard]] boost::container::vector<char const *>& get_value();
|
||||||
return _value;
|
[[nodiscard]] boost::container::vector<char const *> const& get_value() const;
|
||||||
}
|
|
||||||
|
|
||||||
void set_value(std::string_view value) {
|
|
||||||
_value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string _value;
|
boost::container::vector<char const *> _value{};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,60 @@
|
||||||
#include "ikarus/values/toggle_value.h"
|
#include "ikarus/values/toggle_value.h"
|
||||||
|
|
||||||
#include "toggle_value.hpp"
|
#include <values/toggle_value.hpp>
|
||||||
|
|
||||||
IkarusToggleValue * ikarus_toggle_value_create(bool value) {
|
IkarusToggleValue::IkarusToggleValue():
|
||||||
return new IkarusToggleValue{value};
|
IkarusValue{this} {}
|
||||||
|
|
||||||
|
boost::container::vector<bool>& IkarusToggleValue::get_value() {
|
||||||
|
return _value;
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::container::vector<bool> const& IkarusToggleValue::get_value() const {
|
||||||
|
return _value;
|
||||||
|
}
|
||||||
|
|
||||||
|
IkarusToggleValue * ikarus_toggle_value_create(bool * data, size_t data_size) {
|
||||||
|
auto * ret = new IkarusToggleValue{};
|
||||||
|
|
||||||
|
ikarus_toggle_value_set(ret, data, data_size);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
IkarusToggleValue * ikarus_toggle_value_create_indeterminate() {
|
IkarusToggleValue * ikarus_toggle_value_create_indeterminate() {
|
||||||
auto * ret = new IkarusToggleValue{false};
|
auto * ret = new IkarusToggleValue{};
|
||||||
ret->set_intermediate(true);
|
ret->set_intermediate(true);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ikarus_toggle_value_get(IkarusToggleValue const * value) {
|
bool * ikarus_toggle_value_get(IkarusToggleValue * value, size_t * data_size_out) {
|
||||||
return value->get_value();
|
// NOLINTNEXTLINE(*-pro-type-const-cast)
|
||||||
|
return const_cast<bool *>(ikarus_toggle_value_get_const(value, data_size_out));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ikarus_toggle_value_set(IkarusToggleValue * value, bool new_value) {
|
bool const * ikarus_toggle_value_get_const(IkarusToggleValue const * value, size_t * data_size_out) {
|
||||||
value->set_value(new_value);
|
if (data_size_out != nullptr) {
|
||||||
|
*data_size_out = value->get_value().size();
|
||||||
|
}
|
||||||
|
|
||||||
|
return value->get_value().data();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct IkarusValue * ikarus_toggle_value_to_value(IkarusToggleValue * toggle_value) {
|
void ikarus_toggle_value_set(IkarusToggleValue * value, bool * new_data, size_t new_data_size) {
|
||||||
return static_cast<IkarusValue *>(toggle_value);
|
if (new_data == nullptr || new_data_size == 0) {
|
||||||
|
value->get_value().clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
value->get_value().reserve(new_data_size);
|
||||||
|
|
||||||
|
for (auto i = 0; i < new_data_size; ++i) {
|
||||||
|
// NOLINTNEXTLINE(*-pro-bounds-pointer-arithmetic)
|
||||||
|
value->get_value().emplace_back(new_data[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct IkarusValue * ikarus_toggle_value_to_value(IkarusToggleValue * value) {
|
||||||
|
return static_cast<IkarusValue *>(value);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,14 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include <boost/container/vector.hpp>
|
||||||
|
|
||||||
#include <values/value.hpp>
|
#include <values/value.hpp>
|
||||||
|
|
||||||
/// \private
|
|
||||||
struct IkarusToggleValue final : IkarusValue {
|
struct IkarusToggleValue final : IkarusValue {
|
||||||
public:
|
public:
|
||||||
explicit IkarusToggleValue(bool value):
|
explicit IkarusToggleValue();
|
||||||
IkarusValue{this},
|
|
||||||
_value{value} {}
|
|
||||||
|
|
||||||
IkarusToggleValue(IkarusToggleValue const&) = default;
|
IkarusToggleValue(IkarusToggleValue const&) = default;
|
||||||
IkarusToggleValue(IkarusToggleValue&&) = default;
|
IkarusToggleValue(IkarusToggleValue&&) = default;
|
||||||
|
|
@ -18,14 +19,9 @@ public:
|
||||||
~IkarusToggleValue() override = default;
|
~IkarusToggleValue() override = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
[[nodiscard]] bool get_value() const {
|
[[nodiscard]] boost::container::vector<bool>& get_value();
|
||||||
return _value;
|
[[nodiscard]] boost::container::vector<bool> const& get_value() const;
|
||||||
}
|
|
||||||
|
|
||||||
void set_value(bool value) {
|
|
||||||
_value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _value;
|
boost::container::vector<bool> _value{};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue