make values capable of being a list & add boost

Signed-off-by: Folling <mail@folling.io>
This commit is contained in:
Folling 2023-11-28 11:05:53 +01:00 committed by Folling
parent 43b53fd565
commit 2e41c36d84
Signed by: folling
SSH key fingerprint: SHA256:S9qEx5WCFFLK49tE/LKnKuJYM5sw+++Dn6qJbbyxnCY
16 changed files with 315 additions and 140 deletions

View file

@ -4,42 +4,57 @@
/// \author Folling <folling@ikarus.world>
#include <ikarus/macros.h>
#include <ikarus/stdtypes.h>
/// \addtogroup values Values
/// @{
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;
/// \brief Creates a number value from a long double.
/// \param value The numeric value.
/// \return The entity value.
/// \brief Creates a number value from doubles.
/// \param data The number data or null if you wish to clear the data.
/// \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.
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.
/// \return The entity value.
/// \return The value.
/// \remark Must be freed with #ikarus_free.
IKA_API IkarusNumberValue * ikarus_number_value_create_indeterminate();
/// \brief Fetches the underlying value of a number value.
/// \param value The number value.
/// \return The underlying value.
/// \warning Undefined if the value is indeterminate.
IKA_API long double ikarus_number_value_get(IkarusNumberValue const * value);
/// \brief Sets the value of a number value.
/// \brief Fetches the underlying data of a number value.
/// \details You may adjust the returned data as per your hearts desire.
/// If you need to grow the data, use #ikarus_number_value_set with a new array.
/// Just remember that IkarusValues are plain objects, so changing them won't affect any state.
/// They will need to be submitted to other functions such as #ikarus_entity_set_value to have any effect.
/// \param value The number value.
/// \pre \li Must not be null.
/// \param new_value The new value.
IKA_API void ikarus_number_value_set(IkarusNumberValue * value, bool new_value);
/// \param data_size_out An out-parameter for the size of the returned array.
/// \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.
/// \param number_value The number value to convert.
/// \param value The number value to convert.
/// \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

View file

@ -4,43 +4,57 @@
/// \author Folling <folling@ikarus.world>
#include <ikarus/macros.h>
#include <ikarus/stdtypes.h>
/// \addtogroup values Values
/// @{
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;
/// \brief Creates a text value from a boolean.
/// \param value The text value.
/// \return The entity value.
/// \brief Creates a text value from doubles.
/// \param data The text data or null if you wish to clear the data.
/// \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.
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.
/// \return The entity value.
/// \return The value.
/// \remark Must be freed with #ikarus_free.
IKA_API IkarusTextValue * ikarus_text_value_create_indeterminate();
/// \brief Fetches the underlying value of a text value.
/// \param value The text value.
/// \return The underlying value.
/// \warning Undefined if the value is indeterminate.
/// \remark The value is owned by libikarus and must not be freed.
IKA_API char const * ikarus_text_value_get_underlying(IkarusTextValue const * value);
/// \brief Sets the value of a text value.
/// \brief Fetches the underlying data of a text value.
/// \details You may adjust the returned data as per your hearts desire.
/// If you need to grow the data, use #ikarus_text_value_set with a new array.
/// Just remember that IkarusValues are plain objects, so changing them won't affect any state.
/// They will need to be submitted to other functions such as #ikarus_entity_set_value to have any effect.
/// \param value The text value.
/// \pre \li Must not be null.
/// \param new_value The new value.
IKA_API void ikarus_text_value_set(IkarusTextValue * value, bool new_value);
/// \param data_size_out An out-parameter for the size of the returned array.
/// \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.
/// \param text_value The text value to convert.
/// \param value The text value to convert.
/// \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

View file

@ -4,42 +4,57 @@
/// \author Folling <folling@ikarus.world>
#include <ikarus/macros.h>
#include <ikarus/stdtypes.h>
/// \addtogroup values Values
/// @{
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;
/// \brief Creates a toggle value from a boolean.
/// \param value The toggle value.
/// \return The entity value.
/// \brief Creates a toggle value from doubles.
/// \param data The toggle data or null if you wish to clear the data.
/// \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.
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.
/// \return The entity value.
/// \return The value.
/// \remark Must be freed with #ikarus_free.
IKA_API IkarusToggleValue * ikarus_toggle_value_create_indeterminate();
/// \brief Fetches the underlying value of a toggle value.
/// \param value The toggle value.
/// \return The underlying value.
/// \warning Undefined if the value is indeterminate.
IKA_API bool ikarus_toggle_value_get(IkarusToggleValue const * value);
/// \brief Sets the value of a toggle value.
/// \brief Fetches the underlying data of a toggle value.
/// \details You may adjust the returned data as per your hearts desire.
/// If you need to grow the data, use #ikarus_toggle_value_set with a new array.
/// Just remember that IkarusValues are plain objects, so changing them won't affect any state.
/// They will need to be submitted to other functions such as #ikarus_entity_set_value to have any effect.
/// \param value The toggle value.
/// \pre \li Must not be null.
/// \param new_value The new value.
IKA_API void ikarus_toggle_value_set(IkarusToggleValue * value, bool new_value);
/// \param data_size_out An out-parameter for the size of the returned array.
/// \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.
/// \param toggle_value The toggle value to convert.
/// \param value The toggle value to convert.
/// \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

View file

@ -6,11 +6,14 @@
#include <ikarus/macros.h>
/// \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.
/// The value is of the type specified by the property and constrained by the property's settings.
/// A value may be indeterminate which means it is unknown or not specified.
/// \see PropertyType PropertySettings
/// These value classes represent plain objects. They are not associated with any entity.
/// Each value may be indeterminate. \see IkarusProperty
/// 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