#pragma once /// \file number_value.h /// \author Folling #include #include /// \addtogroup values Values /// @{ IKARUS_BEGIN_HEADER /// \brief A numeric value. For example "Age" or "Height". struct IkarusNumberValue; /// \brief Creates a number value. /// \return The value or null if an error occurs. /// \remark Must be freed with #ikarus_free. IKA_API IkarusNumberValue * ikarus_number_value_create(); /// \brief Fetches the underlying data of a number value at a specific index. /// \param value The number value. /// \pre \li Must not be null. /// \param idx The index of the data to fetch. /// \pre \li Must be less than the size of the value. /// \return The underlying data or null if an error occurs or the value is undefined. IKA_API double const * ikarus_number_value_get(IkarusNumberValue * value, size_t idx); /// \brief Fetches the size of the underlying data of a number value. /// \param value The number value. /// \pre \li Must not be null. /// \return The size of the underlying data or 0 if an error occurs or the value is undefined. IKA_API size_t ikarus_number_value_get_size(IkarusNumberValue const * value); /// \brief Sets the data of a number value at a specific index. /// \param value The number value. /// \pre \li Must not be null. /// \param idx The index of the data to set. /// \pre \li Must be less than the size of the value. /// \param new_data The new data. IKA_API void ikarus_number_value_set(IkarusNumberValue * value, size_t idx, double const * new_data); /// \brief Removes a data from a number value. /// \param value The number value. /// \pre \li Must not be null. /// \param idx The index of the data to remove. /// \pre \li Must be less than the size of the value. IKA_API void ikarus_number_value_remove(IkarusNumberValue * value, size_t idx); /// \brief Inserts a data into a number value. /// \param value The number value. /// \pre \li Must not be null. /// \param idx The index of the data to insert. /// \pre \li Must be less than or equal to the size of the value. /// \param new_data The new data. IKA_API void ikarus_number_value_insert(IkarusNumberValue * value, size_t idx, double const * new_data); /// \brief Clears a number value. /// \param value The number value. /// \remark Noop if the value is undefined. IKA_API void ikarus_number_value_clear(IkarusNumberValue * value); /// \brief Checks if a number value is undefined. /// \param value The number value. /// \pre \li Must not be null. /// \return True if the value is undefined, false otherwise. IKA_API bool ikarus_number_value_is_undefined(IkarusNumberValue const * value); /// \brief Changes a number value's undefined state. /// \param value The number value. /// \pre \li Must not be null. /// \param undefined The new undefined state. /// \remark Noop if the value is already undefined. /// \remark If the value is set to undefined, all data will be cleared. /// \remark If the value is set to not undefined, the value is as if newly created. IKA_API void ikarus_number_value_set_undefined(IkarusNumberValue * value, bool undefined); /// \brief Converts a number value to a string. /// \param value The number value to convert. /// \pre \li Must not be null. /// \return The converted string. /// \remark Must be freed with #ikarus_free. /// \remark Undefined if the value is undefined. IKA_API char const * ikarus_number_value_to_string(IkarusNumberValue const * value); /// \brief Checks if two values are equal. /// \param lhs The left hand side value. /// \pre \li Must not be null. /// \param rhs The right hand side value. /// \pre \li Must not be null. /// \return True if the values' data are equal, false otherwise. IKA_API bool ikarus_number_value_is_equal(IkarusNumberValue const * lhs, IkarusNumberValue const * rhs); /// \brief Creates a copy of a number value. /// \param value The value to copy. /// \pre \li Must not be null. /// \return The copied value. /// \remark Must be freed with #ikarus_free. IKA_API IkarusNumberValue * ikarus_number_value_copy(IkarusNumberValue const * value); /// \brief Converts a number value to an entity value. /// \param value The number value to convert. /// \pre \li Must not be null. /// \return The converted entity value. /// \remark This is the same pointer, so freeing it implies freeing the original value. IKA_API struct IkarusValue * ikarus_number_value_to_value(IkarusNumberValue * value); /// \see ikarus_toggle_value_to_value IKA_API struct IkarusValue const * ikarus_number_value_to_value_const(IkarusNumberValue const * value); IKARUS_END_HEADER /// @}