libikarus/include/ikarus/values/value.h
Folling 2e41c36d84
make values capable of being a list & add boost
Signed-off-by: Folling <mail@folling.io>
2025-04-15 12:08:01 +02:00

69 lines
2.7 KiB
C

#pragma once
/// \file value.h
/// \author Folling <folling@ikarus.world>
#include <ikarus/macros.h>
/// \defgroup values Values
/// \brief The values of properties.
/// \details Each entity has a value for each property it is associated with.
/// 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
/// \brief The common type for all values.
struct IkarusValue;
/// \brief Checks if a value is indeterminate.
/// \param value The value.
/// \pre \li Must not be null.
/// \return True if the value is indeterminate, false otherwise.
IKA_API bool ikarus_value_is_indeterminate(IkarusValue const * value);
/// \brief Sets the indeterminate state of a value.
/// \param value The value.
/// \pre \li Must not be null.
/// \param indeterminate The new indeterminate state.
IKA_API void ikarus_value_set_indeterminate(IkarusValue * value, bool indeterminate);
/// \brief Converts an entity value to a string.
/// \pre \li Must not be null.
/// \param value The entity value.
/// \return A string representation of the value or null if an error occurred.
/// \remark The returned value is owned by the caller.
IKA_API char const * ikarus_value_to_string(IkarusValue const * value);
/// \brief Visits an entity value, calling the appropriate function for the value's type.
/// \param value The entity value to visit.
/// \pre \li Must not be null.
/// \param toggle_visitor The function to call if the value is a toggle value. Skipped if null.
/// \param number_visitor The function to call if the value is a number value. Skipped if null.
/// \param text_visitor The function to call if the value is a text value. Skipped if null.
/// \param data The data passed to the visitor functions.
IKA_API void ikarus_value_visit(
IkarusValue * value,
void (*toggle_visitor)(struct IkarusToggleValue *, void *),
void (*number_visitor)(struct IkarusNumberValue *, void *),
void (*text_visitor)(struct IkarusTextValue *, void *),
void * data
);
/// \see ikarus_value_visit
IKA_API void ikarus_value_visit_const(
IkarusValue const * value,
void (*toggle_visitor)(struct IkarusToggleValue const *, void *),
void (*number_visitor)(struct IkarusNumberValue const *, void *),
void (*text_visitor)(struct IkarusTextValue const *, void *),
void * data
);
IKARUS_END_HEADER
/// @}