60 lines
2.2 KiB
C
60 lines
2.2 KiB
C
#pragma once
|
|
|
|
/// \file value.h
|
|
/// \author Folling <folling@ikarus.world>
|
|
|
|
#include <ikarus/macros.h>
|
|
#include <ikarus/stdtypes.h>
|
|
|
|
/// \defgroup entity_value Entity 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.
|
|
/// A value may be indeterminate which means it is unknown or not specified.
|
|
/// \see PropertyType PropertySettings
|
|
/// @{
|
|
|
|
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 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 a copy and 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.
|
|
/// \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
|
|
|
|
/// @}
|