update sqlitecpp & merge property settings into properties

Signed-off-by: Folling <mail@folling.io>
This commit is contained in:
folling 2023-11-27 11:24:55 +01:00 committed by Folling
parent ff9bf0c14a
commit 88ca7769d1
Signed by: folling
SSH key fingerprint: SHA256:S9qEx5WCFFLK49tE/LKnKuJYM5sw+++Dn6qJbbyxnCY
39 changed files with 412 additions and 253 deletions

View file

@ -57,7 +57,7 @@ enum IkarusErrorInfo {
/// Example: A query takes longer than the timeout.
IkarusErrorInfo_Type_LibIkarus_Timeout = 0x0002000300000003,
/// \brief The type of error is unknown.
IkarusErrorInfo_Type_Unknown = 0xFFFFFFFF,
IkarusErrorInfo_Type_Unknown = 0xFFFFFFFFFFFFFFFF,
};
/// \brief Gets the name of an error info.

View file

@ -5,7 +5,7 @@
#include <ikarus/macros.h>
/// \addtogroup global Global
/// \defgroup global Global
/// \brief Information relevant to the entire library.
/// @{

42
include/ikarus/id.h Normal file
View file

@ -0,0 +1,42 @@
// IMPLEMENTATION_DETAIL_DATABASE
/// \file id.h
/// \author Folling <folling@ikarus.world>
/// \privatesection
#pragma once
#include <ikarus/macros.h>
#include <ikarus/objects/object_type.h>
#include <ikarus/stdtypes.h>
IKARUS_BEGIN_HEADER
/// \defgroup id Ids
/// \brief Ids are used to identify objects in the database.
/// \details They are stored as 64 bit integers with the following layout:
/// - first bit: ignored, technically we could use it, but SQLite doesn't support u64 integers.
/// To avoid ordering fiascos and potential index performance degradation we just skip the first bit.
/// - next 7 bits: #IkarusObjectType
/// - last 56 bits: incremented counter generated by the database
/// @{
/// \brief A wrapper around a 64 bit integer that represents the id of an object.
/// \details They are stored as 64 bit integers with the following layout:
/// - first bit: ignored, technically we could use it, but SQLite doesn't support u64 integers.
/// To avoid ordering fiascos and potential index performance degradation we just skip the first bit.
/// - next 7 bits: #IkarusObjectType
/// - last 56 bits: incremented counter generated by the database
using IkarusId = int64_t;
IKA_API IkarusId ikarus_id_from_data_and_type(int64_t data, IkarusObjectType type);
/// \brief Fetches the object type of the given id.
/// \param id The id to fetch the object type for.
/// \return The object type of the given id.
IKA_API IkarusObjectType ikarus_id_get_object_type(IkarusId id);
/// @}
IKARUS_END_HEADER

View file

@ -8,12 +8,9 @@
/// \defgroup object Objects
/// \brief Objects are a compound type of all types of objects in the database.
/// \details The following objects currently exist:
/// - blueprints
/// - properties
/// - entities
/// - blueprint folders
/// - property folders
/// - entity folders
/// - \ref blueprint.h "Blueprints"
/// - \ref property.h "Properties"
/// - \ref entity.h "Entities"
/// @{
IKARUS_BEGIN_HEADER
@ -21,6 +18,16 @@ IKARUS_BEGIN_HEADER
/// \brief A generic object. Wraps all types of objects, including folders.
struct IkarusObject;
/// \brief Compares two objects for equality.
/// \details This neither compares the pointers nor does a deep copy. Instead it figures out if the objects _are_ the same
/// object.
/// \param lhs The left hand side object.
/// \pre \li Must not be null.
/// \param rhs The right hand side object.
/// \pre \li Must not be null.
/// \return True if the objects are equal, false otherwise.
IKA_API bool ikarus_object_is_equal(IkarusObject const * lhs, IkarusObject const * rhs);
/// \brief Visits an object. Calling the appropriate function for the object's type.
/// \param object The object to visit.
/// \param blueprint_visitor The function to call if the object is a blueprint. Skipped if null.
@ -55,4 +62,4 @@ IKA_API void ikarus_object_visit_const(
IKARUS_END_HEADER
// @}
/// @}

View file

@ -14,10 +14,27 @@ IKARUS_BEGIN_HEADER
struct IkarusNumberProperty;
IKA_API IkarusNumberProperty * ikarus_number_property_create(
struct IkarusProject * project,
char const * name,
struct IkarusPropertySource * property_source,
struct IkarusNumberSettings * settings
struct IkarusProject * project, char const * name, struct IkarusPropertySource * property_source
);
/// \brief Sets the default value for a number property.
/// \param property The number property.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \remark The settings take ownership of the value, the caller must not free it.
IKA_API struct IkarusNumberValue * ikarus_number_property_get_default_value(struct IkarusNumberProperty * property);
/// \brief Sets the default value for a number property.
/// \param property The number property.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param default_value The default value.
/// \pre \li Must not be null.
/// \pre \li Must be a valid value for the property.
/// \remark Please see \ref property.h "the property documentation" for more information on the interplay between default values
/// and other settings.
IKA_API void ikarus_number_property_set_default_value(
struct IkarusNumberProperty * property, struct IkarusNumberValue * default_value
);
IKARUS_END_HEADER

View file

@ -29,8 +29,12 @@ IKARUS_BEGIN_HEADER
///
/// Every property has settings which can be used to customise the property further.
/// Two settings that are shared among all properties are the following:
/// - Multiple
/// - Allow undefined
/// - List
/// - May be undefined
///
/// Additionally, each property has a default value. If no default value is provided, a sensible default is chosen.
/// Setting a default value that isn't valid for the property is an error. Changing settings so that the current default value
/// becomes invalid is valid but unsets the custom default value.
///
/// The former transforms a property into a list. Instead of one number, you could then specify a series of numbers.
/// The latter allows you to specify an "unknown" value for a property.
@ -43,6 +47,7 @@ IKARUS_BEGIN_HEADER
///
/// We call properties within entities "Entity Properties" and properties within blueprints "Blueprint Properties".
///
///
/// \remark Properties are scoped to the blueprint or entity they are associated with.
/// \remark Values for properties are lazily created as space saving measure.
/// Fetching the value for some property of some entity will return the property's default value if none is specified.
@ -65,17 +70,6 @@ IKA_API void ikarus_property_delete(IkarusProperty * property);
/// \remark Must be freed using #ikarus_free.
IKA_API IkarusPropertyType ikarus_property_get_type(IkarusProperty const * property);
/// \brief Gets the settings of a property.
/// \param property The property to get the settings of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \return The settings of the property or null if an error occurs.
/// \remark Must be freed using #ikarus_free.
IKA_API struct IkarusPropertySettings * ikarus_property_get_settings(IkarusProperty * property);
/// \see ikarus_property_get_settings
IKA_API struct IkarusPropertySettings const * ikarus_property_get_settings_const(IkarusProperty const * property);
/// \brief Gets the source of a property.
/// \param property The property to get the source of.
/// \pre \li Must not be null.

View file

@ -22,12 +22,6 @@ enum IkarusPropertyType {
IkarusPropertyType_Text,
};
/// \brief Fetches the default value for a property type.
/// \remark Not to be confused with the default value of a property. See ikarus_property_get_default_value
/// \param type The property type.
/// \return The default value for the property type or null if an error occurs.
IKA_API struct IkarusValue * ikarus_property_type_get_default_default_value(IkarusPropertyType type);
IKARUS_END_HEADER
/// @}

View file

@ -14,10 +14,27 @@ IKARUS_BEGIN_HEADER
struct IkarusTextProperty;
IKA_API IkarusTextProperty * ikarus_text_property_create(
struct IkarusProject * project,
char const * name,
struct IkarusPropertySource * property_source,
struct IkarusTextSettings * settings
struct IkarusProject * project, char const * name, struct IkarusPropertySource * property_source
);
/// \brief Sets the default value for a text property.
/// \param property The text property.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \remark The settings take ownership of the value, the caller must not free it.
IKA_API struct IkarusTextValue * ikarus_text_property_get_default_value(struct IkarusTextProperty * property);
/// \brief Sets the default value for a text property.
/// \param property The text property.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param default_value The default value.
/// \pre \li Must not be null.
/// \pre \li Must be a valid value for the property.
/// \remark Please see \ref property.h "the property documentation" for more information on the interplay between default values
/// and other settings.
IKA_API void ikarus_text_property_set_default_value(
struct IkarusTextProperty * property, struct IkarusTextValue * default_value
);
IKARUS_END_HEADER

View file

@ -14,10 +14,27 @@ IKARUS_BEGIN_HEADER
struct IkarusToggleProperty;
IKA_API IkarusToggleProperty * ikarus_toggle_property_create(
struct IkarusProject * project,
char const * name,
struct IkarusPropertySource * property_source,
struct IkarusToggleSettings * settings
struct IkarusProject * project, char const * name, struct IkarusPropertySource * property_source
);
/// \brief Sets the default value for a toggle property.
/// \param property The toggle property.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \remark The settings take ownership of the value, the caller must not free it.
IKA_API struct IkarusToggleValue * ikarus_toggle_property_get_default_value(struct IkarusToggleProperty * property);
/// \brief Sets the default value for a toggle property.
/// \param property The toggle property.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param default_value The default value.
/// \pre \li Must not be null.
/// \pre \li Must be a valid value for the property.
/// \remark Please see \ref property.h "the property documentation" for more information on the interplay between default values
/// and other settings.
IKA_API void ikarus_toggle_property_set_default_value(
struct IkarusToggleProperty * property, struct IkarusToggleValue * default_value
);
IKARUS_END_HEADER

View file

@ -5,7 +5,7 @@
#include <ikarus/macros.h>
/// \addtogroup entity_value Entity Values
/// \addtogroup values Values
/// @{
IKARUS_BEGIN_HEADER
@ -42,3 +42,5 @@ IKA_API void ikarus_number_value_set(IkarusNumberValue * value, bool new_value);
IKA_API struct IkarusValue * ikarus_number_value_to_value(IkarusNumberValue * number_value);
IKARUS_END_HEADER
/// @}

View file

@ -5,7 +5,7 @@
#include <ikarus/macros.h>
/// \addtogroup entity_value Entity Values
/// \addtogroup values Values
/// @{
IKARUS_BEGIN_HEADER
@ -43,3 +43,5 @@ IKA_API void ikarus_text_value_set(IkarusTextValue * value, bool new_value);
IKA_API struct IkarusValue * ikarus_text_value_to_value(IkarusTextValue * text_value);
IKARUS_END_HEADER
/// @}

View file

@ -5,7 +5,7 @@
#include <ikarus/macros.h>
/// \addtogroup entity_value Entity Values
/// \addtogroup values Values
/// @{
IKARUS_BEGIN_HEADER
@ -42,3 +42,5 @@ IKA_API void ikarus_toggle_value_set(IkarusToggleValue * value, bool new_value);
IKA_API struct IkarusValue * ikarus_toggle_value_to_value(IkarusToggleValue * toggle_value);
IKARUS_END_HEADER
/// @}

View file

@ -5,7 +5,7 @@
#include <ikarus/macros.h>
/// \defgroup entity_value Entity Values
/// \defgroup values Values
/// \brief The values stored in entities.
/// \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.