libikarus/include/ikarus/values/text_value.h
Folling f847d30c06
implement toggle/number/text values
Signed-off-by: Folling <mail@folling.io>
2025-04-15 12:08:00 +02:00

45 lines
1.5 KiB
C

#pragma once
/// \file text_value.h
/// \author Folling <folling@ikarus.world>
#include <ikarus/macros.h>
/// \addtogroup entity_value Entity Values
/// @{
IKARUS_BEGIN_HEADER
/// \brief A true/false boolean-like value. For example "IsDead".
struct IkarusTextValue;
/// \brief Creates a text value from a boolean.
/// \param value The text value.
/// \return The entity value.
/// \remark Must be freed with #ikarus_free.
IKA_API IkarusTextValue * ikarus_text_value_create(char const * value);
/// \brief Creates an indeterminate text value.
/// \return The entity 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.
/// \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);
/// \brief Converts a text value to an entity value.
/// \param text_value The text value to convert.
/// \return The converted entity value.
IKA_API struct IkarusValue * ikarus_text_value_to_value(IkarusTextValue * text_value);
IKARUS_END_HEADER