109 lines
4.4 KiB
C
109 lines
4.4 KiB
C
#pragma once
|
|
|
|
/// \file text_value.h
|
|
/// \author Folling <folling@ikarus.world>
|
|
|
|
#include <ikarus/errors.h>
|
|
#include <ikarus/macros.h>
|
|
#include <ikarus/values/value_cardinality.h>
|
|
|
|
/// \addtogroup values Values
|
|
/// @{
|
|
|
|
IKARUS_BEGIN_HEADER
|
|
|
|
/// \brief A numeric value. For example "Age" or "Height".
|
|
struct IkarusTextValue;
|
|
|
|
/// \brief Creates an empty text value.
|
|
/// \details If the cardinality is "Single", the value will be initialized with 0.0.
|
|
/// \param cardinality The cardinality of the value.
|
|
/// \param error_out \see errors.h
|
|
/// \return The value or null if an error occurs.
|
|
IKA_API IkarusTextValue * ikarus_text_value_create(IkarusValueCardinality cardinality, IkarusErrorData * error_out);
|
|
|
|
/// \brief Fetches the underlying data of a text value at a specific index.
|
|
/// \param value The text 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.
|
|
/// \param error_out \see errors.h
|
|
/// \return The underlying data or NaN if an error occurs.
|
|
IKA_API char const * ikarus_text_value_get(IkarusTextValue const * value, size_t idx, IkarusErrorData * error_out);
|
|
|
|
/// \brief Fetches the size of the underlying data of a text value.
|
|
/// \param value The text value.
|
|
/// \pre \li Must not be null.
|
|
/// \param error_out \see errors.h
|
|
/// \return The size of the underlying data or 0 if an error occurs.
|
|
IKA_API size_t ikarus_text_value_get_size(IkarusTextValue const * value, IkarusErrorData * error_out);
|
|
|
|
/// \brief Sets the data of a text value at a specific index.
|
|
/// \param value The text 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.
|
|
/// \param error_out \see errors.h
|
|
IKA_API void ikarus_text_value_set(IkarusTextValue * value, size_t idx, char const * new_data, IkarusErrorData * error_out);
|
|
|
|
/// \brief Inserts a data into a text value.
|
|
/// \param value The text value.
|
|
/// \pre \li Must not be null.
|
|
/// \pre \li Cardinality must be "Multiple".
|
|
/// \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.
|
|
/// \param error_out \see errors.h
|
|
IKA_API void ikarus_text_value_insert(IkarusTextValue * value, size_t idx, char const * new_data, IkarusErrorData * error_out);
|
|
|
|
/// \brief Removes a data from a text value.
|
|
/// \param value The text value.
|
|
/// \pre \li Must not be null.
|
|
/// \pre \li Cardinality must be "Multiple".
|
|
/// \param idx The index of the data to remove.
|
|
/// \pre \li Must be less than the size of the value.
|
|
/// \param error_out \see errors.h
|
|
IKA_API void ikarus_text_value_remove(IkarusTextValue * value, size_t idx, IkarusErrorData * error_out);
|
|
|
|
/// \brief Clears a text value.
|
|
/// \param value The text value.
|
|
/// \pre \li Cardinality must be "Multiple".
|
|
/// \param error_out \see errors.h
|
|
IKA_API void ikarus_text_value_clear(IkarusTextValue * value, IkarusErrorData * error_out);
|
|
|
|
/// \brief Converts a text value to a string.
|
|
/// \param value The text value to convert.
|
|
/// \pre \li Must not be null.
|
|
/// \param error_out \see errors.h
|
|
/// \return The converted string.
|
|
/// \remark Must be freed with #ikarus_free.
|
|
IKA_API char const * ikarus_text_value_to_string(IkarusTextValue const * value, IkarusErrorData * error_out);
|
|
|
|
/// \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.
|
|
/// \param error_out \see errors.h
|
|
/// \return True if the values' data are equal, false otherwise.
|
|
IKA_API bool ikarus_text_value_is_equal(IkarusTextValue const * lhs, IkarusTextValue const * rhs, IkarusErrorData * error_out);
|
|
|
|
/// \brief Creates a copy of a text value.
|
|
/// \param value The value to copy.
|
|
/// \pre \li Must not be null.
|
|
/// \param error_out \see errors.h
|
|
/// \return The copied value.
|
|
IKA_API IkarusTextValue * ikarus_text_value_copy(IkarusTextValue const * value, IkarusErrorData * error_out);
|
|
|
|
/// \brief Converts a text value to an entity value.
|
|
/// \param value The text value to convert.
|
|
/// \pre \li Must not be null.
|
|
/// \param error_out \see errors.h
|
|
/// \return The converted entity value.
|
|
/// \remark This is the same pointer, so freeing it implies freeing the original value.
|
|
IKA_API struct IkarusValueData * ikarus_text_value_to_value(IkarusTextValue * value, IkarusErrorData * error_out);
|
|
|
|
IKARUS_END_HEADER
|
|
|
|
/// @}
|