move sub-functions of value impls to concrete types
Signed-off-by: Folling <mail@folling.io>
This commit is contained in:
parent
7536cf4c7c
commit
03c18debec
14 changed files with 339 additions and 119 deletions
|
|
@ -11,29 +11,27 @@
|
|||
|
||||
IKARUS_BEGIN_HEADER
|
||||
|
||||
/// \brief A textual value. For example "Surname" or "Description".
|
||||
/// \brief A textual value. For example "Surname" or "Description"
|
||||
struct IkarusTextValue;
|
||||
|
||||
/// \brief Creates a text value from strings.
|
||||
/// \param data The text data or null if you wish to create an empty value.
|
||||
/// \details LibIkarus does not take ownership of this array.
|
||||
/// \param data_size The size of the data array.
|
||||
/// \brief Creates a text value.
|
||||
/// \return The value or null if an error occurs.
|
||||
/// \remark Must be freed with #ikarus_free.
|
||||
IKA_API IkarusTextValue * ikarus_text_value_create(char const ** data, size_t data_size);
|
||||
IKA_API IkarusTextValue * ikarus_text_value_create();
|
||||
|
||||
/// \brief Creates an indeterminate text value.
|
||||
/// \return The value.
|
||||
/// \remark Must be freed with #ikarus_free.
|
||||
IKA_API IkarusTextValue * ikarus_text_value_create_indeterminate();
|
||||
|
||||
/// \see ikarus_number_value_get
|
||||
IKA_API char const * const * ikarus_text_value_get(IkarusTextValue const * value, size_t idx);
|
||||
/// \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.
|
||||
/// \remark This value is owned by LibIkarus and must not be freed.
|
||||
IKA_API char const * ikarus_text_value_get(IkarusTextValue * value, size_t idx);
|
||||
|
||||
/// \brief Fetches the size of the underlying data of a text value.
|
||||
/// \param value The text value.
|
||||
/// \pre \li Must not be null.
|
||||
/// \return The size of the underlying data or 0 if an error occurs or the value is indeterminate.
|
||||
/// \return The size of the underlying data or 0 if an error occurs or the value is undefined.
|
||||
IKA_API size_t ikarus_text_value_get_size(IkarusTextValue const * value);
|
||||
|
||||
/// \brief Sets the data of a text value at a specific index.
|
||||
|
|
@ -41,7 +39,7 @@ IKA_API size_t ikarus_text_value_get_size(IkarusTextValue const * 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 new_data The new data. LibIkarus assumes ownership of this pointer.
|
||||
IKA_API void ikarus_text_value_set(IkarusTextValue * value, size_t idx, char const * new_data);
|
||||
|
||||
/// \brief Removes a data from a text value.
|
||||
|
|
@ -49,7 +47,6 @@ IKA_API void ikarus_text_value_set(IkarusTextValue * value, size_t idx, char con
|
|||
/// \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.
|
||||
/// \remark This will shift all data after the index by one to the left.
|
||||
IKA_API void ikarus_text_value_remove(IkarusTextValue * value, size_t idx);
|
||||
|
||||
/// \brief Inserts a data into a text value.
|
||||
|
|
@ -58,14 +55,61 @@ IKA_API void ikarus_text_value_remove(IkarusTextValue * value, size_t idx);
|
|||
/// \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.
|
||||
/// \remark This will shift all data after the index by one to the right.
|
||||
IKA_API void ikarus_text_insert(IkarusTextValue * value, size_t idx, char const * new_data);
|
||||
IKA_API void ikarus_text_value_insert(IkarusTextValue * value, size_t idx, char const * new_data);
|
||||
|
||||
/// \brief Clears a text value.
|
||||
/// \param value The text value.
|
||||
/// \remark Noop if the value is undefined.
|
||||
IKA_API void ikarus_text_value_clear(IkarusTextValue * value);
|
||||
|
||||
/// \brief Checks if a text value is undefined.
|
||||
/// \param value The text value.
|
||||
/// \pre \li Must not be null.
|
||||
/// \return True if the value is undefined, false otherwise.
|
||||
IKA_API bool ikarus_text_value_is_undefined(IkarusTextValue const * value);
|
||||
|
||||
/// \brief Changes a text value's undefined state.
|
||||
/// \param value The text 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_text_value_set_undefined(IkarusTextValue * value, bool undefined);
|
||||
|
||||
/// \brief Converts a text value to a string.
|
||||
/// \param value The text 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_text_value_to_string(IkarusTextValue 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_text_value_is_equal(IkarusTextValue const * lhs, IkarusTextValue const * rhs);
|
||||
|
||||
/// \brief Creates a copy of a text 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 IkarusTextValue * ikarus_text_value_copy(IkarusTextValue const * value);
|
||||
|
||||
/// \brief Converts a text value to an entity value.
|
||||
/// \param value The text 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_text_value_to_value(IkarusTextValue * value);
|
||||
|
||||
/// \see ikarus_toggle_value_to_value
|
||||
IKA_API struct IkarusValue const * ikarus_text_value_to_value_const(IkarusTextValue const * value);
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
||||
/// @}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue