adjust values api to vector-esque interface
Signed-off-by: Folling <mail@folling.io>
This commit is contained in:
parent
3697759ceb
commit
643ece4342
13 changed files with 297 additions and 220 deletions
|
|
@ -11,14 +11,14 @@
|
|||
|
||||
IKARUS_BEGIN_HEADER
|
||||
|
||||
/// \brief A true/false long doubleean-esque value. For example "Is Dead".
|
||||
/// \brief A numeric value. For example "Age" or "Height".
|
||||
struct IkarusNumberValue;
|
||||
|
||||
/// \brief Creates a number value from doubles.
|
||||
/// \param data The number data or null if you wish to clear the data.
|
||||
/// \brief Creates a number value from long doubles.
|
||||
/// \param data The number 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 or 0 if you wish to clear the data.
|
||||
/// \return The value.
|
||||
/// \param data_size The size of the data array.
|
||||
/// \return The value or null if an error occurs.
|
||||
/// \remark Must be freed with #ikarus_free.
|
||||
IKA_API IkarusNumberValue * ikarus_number_value_create(long double * data, size_t data_size);
|
||||
|
||||
|
|
@ -27,29 +27,44 @@ IKA_API IkarusNumberValue * ikarus_number_value_create(long double * data, size_
|
|||
/// \remark Must be freed with #ikarus_free.
|
||||
IKA_API IkarusNumberValue * ikarus_number_value_create_indeterminate();
|
||||
|
||||
/// \brief Fetches the underlying data of a number value.
|
||||
/// \details You may adjust the returned data as per your hearts desire.
|
||||
/// If you need to grow the data, use #ikarus_number_value_set with a new array.
|
||||
/// Just remember that IkarusValues are plain objects, so changing them won't affect any state.
|
||||
/// They will need to be submitted to other functions such as #ikarus_entity_set_value to have any effect.
|
||||
/// \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 data_size_out An out-parameter for the size of the returned array.
|
||||
/// \remark Ignored if null.
|
||||
/// \return The underlying data. Owned by LibIkarus, most not be freed.
|
||||
/// \warning Undefined if the value is indeterminate.
|
||||
IKA_API long double * ikarus_number_value_get(IkarusNumberValue * value, size_t * data_size_out);
|
||||
/// \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 indeterminate.
|
||||
IKA_API long double const * ikarus_number_value_get(IkarusNumberValue * value, size_t idx);
|
||||
|
||||
/// \see ikarus_number_value_get
|
||||
long double const * ikarus_number_value_get_const(IkarusNumberValue const * value, size_t * data_size_out);
|
||||
|
||||
/// \brief Sets the data of a number value.
|
||||
/// \brief Fetches the size of the underlying data of a number value.
|
||||
/// \param value The number value.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param new_data The new data or null if you wish to clear the data.
|
||||
/// \details LibIkarus does not take ownership of this array.
|
||||
/// \param new_data_size The size of the new data array or 0 if you wish to clear the data.
|
||||
IKA_API void ikarus_number_value_set(IkarusNumberValue * value, long double * new_data, size_t new_data_size);
|
||||
/// \return The size of the underlying data or 0 if an error occurs or the value is indeterminate.
|
||||
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, long double 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.
|
||||
/// \remark This will shift all data after the index by one to the left.
|
||||
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.
|
||||
/// \remark This will shift all data after the index by one to the right.
|
||||
IKA_API void ikarus_number_insert(IkarusNumberValue * value, size_t idx, long double new_data);
|
||||
|
||||
/// \brief Converts a number value to an entity value.
|
||||
/// \param value The number value to convert.
|
||||
|
|
|
|||
|
|
@ -11,14 +11,14 @@
|
|||
|
||||
IKARUS_BEGIN_HEADER
|
||||
|
||||
/// \brief A true/false char const*ean-esque value. For example "Is Dead".
|
||||
/// \brief A textual value. For example "Surname" or "Description".
|
||||
struct IkarusTextValue;
|
||||
|
||||
/// \brief Creates a text value from doubles.
|
||||
/// \param data The text data or null if you wish to clear the data.
|
||||
/// \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 or 0 if you wish to clear the data.
|
||||
/// \return The value.
|
||||
/// \param data_size The size of the data array.
|
||||
/// \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);
|
||||
|
||||
|
|
@ -27,29 +27,39 @@ IKA_API IkarusTextValue * ikarus_text_value_create(char const ** data, size_t da
|
|||
/// \remark Must be freed with #ikarus_free.
|
||||
IKA_API IkarusTextValue * ikarus_text_value_create_indeterminate();
|
||||
|
||||
/// \brief Fetches the underlying data of a text value.
|
||||
/// \details You may adjust the returned data as per your hearts desire.
|
||||
/// If you need to grow the data, use #ikarus_text_value_set with a new array.
|
||||
/// Just remember that IkarusValues are plain objects, so changing them won't affect any state.
|
||||
/// They will need to be submitted to other functions such as #ikarus_entity_set_value to have any effect.
|
||||
/// \see ikarus_number_value_get
|
||||
IKA_API char const * const * ikarus_text_value_get(IkarusTextValue const * 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.
|
||||
/// \param data_size_out An out-parameter for the size of the returned array.
|
||||
/// \remark Ignored if null.
|
||||
/// \return The underlying data. Owned by LibIkarus, most not be freed.
|
||||
/// \warning Undefined if the value is indeterminate.
|
||||
IKA_API char ** ikarus_text_value_get(IkarusTextValue * value, size_t * data_size_out);
|
||||
/// \return The size of the underlying data or 0 if an error occurs or the value is indeterminate.
|
||||
IKA_API size_t ikarus_text_value_get_size(IkarusTextValue const * value);
|
||||
|
||||
/// \see ikarus_text_value_get
|
||||
char const * const * ikarus_text_value_get_const(IkarusTextValue const * value, size_t * data_size_out);
|
||||
|
||||
/// \brief Sets the data of a text value.
|
||||
/// \brief Sets the data of a text value at a specific index.
|
||||
/// \param value The text value.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param new_data The new data or null if you wish to clear the data.
|
||||
/// \details LibIkarus does not take ownership of this array.
|
||||
/// \param new_data_size The size of the new data array or 0 if you wish to clear the data.
|
||||
IKA_API void ikarus_text_value_set(IkarusTextValue * value, char const ** new_data, size_t new_data_size);
|
||||
/// \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_text_value_set(IkarusTextValue * value, size_t idx, char const * new_data);
|
||||
|
||||
/// \brief Removes a data from a text value.
|
||||
/// \param value The text 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.
|
||||
/// \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.
|
||||
/// \param value The text 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.
|
||||
/// \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);
|
||||
|
||||
/// \brief Converts a text value to an entity value.
|
||||
/// \param value The text value to convert.
|
||||
|
|
|
|||
|
|
@ -14,42 +14,52 @@ IKARUS_BEGIN_HEADER
|
|||
/// \brief A true/false boolean-esque value. For example "Is Dead".
|
||||
struct IkarusToggleValue;
|
||||
|
||||
/// \brief Creates a toggle value from doubles.
|
||||
/// \param data The toggle data or null if you wish to clear the data.
|
||||
/// \details LibIkarus does not take ownership of this array.
|
||||
/// \param data_size The size of the data array or 0 if you wish to clear the data.
|
||||
/// \return The value.
|
||||
/// \brief Creates a toggle value from booleans.
|
||||
/// \return The value or null if an error occurs.
|
||||
/// \remark Must be freed with #ikarus_free.
|
||||
IKA_API IkarusToggleValue * ikarus_toggle_value_create(bool * data, size_t data_size);
|
||||
IKA_API IkarusToggleValue * ikarus_toggle_value_create();
|
||||
|
||||
/// \brief Creates an indeterminate toggle value.
|
||||
/// \return The value.
|
||||
/// \remark Must be freed with #ikarus_free.
|
||||
IKA_API IkarusToggleValue * ikarus_toggle_value_create_indeterminate();
|
||||
/// \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 indeterminate.
|
||||
IKA_API bool const * ikarus_toggle_value_get(IkarusToggleValue * value, size_t idx);
|
||||
|
||||
/// \brief Fetches the underlying data of a toggle value.
|
||||
/// \details You may adjust the returned data as per your hearts desire.
|
||||
/// If you need to grow the data, use #ikarus_toggle_value_set with a new array.
|
||||
/// Just remember that IkarusValues are plain objects, so changing them won't affect any state.
|
||||
/// They will need to be submitted to other functions such as #ikarus_entity_set_value to have any effect.
|
||||
/// \brief Fetches the size of the underlying data of a toggle value.
|
||||
/// \param value The toggle value.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param data_size_out An out-parameter for the size of the returned array.
|
||||
/// \remark Ignored if null.
|
||||
/// \return The underlying data. Owned by LibIkarus, most not be freed.
|
||||
/// \warning Undefined if the value is indeterminate.
|
||||
IKA_API bool * ikarus_toggle_value_get(IkarusToggleValue * value, size_t * data_size_out);
|
||||
/// \return The size of the underlying data or 0 if an error occurs or the value is indeterminate.
|
||||
IKA_API size_t ikarus_toggle_value_get_size(IkarusToggleValue const * value);
|
||||
|
||||
/// \see ikarus_toggle_value_get
|
||||
bool const * ikarus_toggle_value_get_const(IkarusToggleValue const * value, size_t * data_size_out);
|
||||
|
||||
/// \brief Sets the data of a toggle value.
|
||||
/// \brief Sets the data of a toggle value at a specific index.
|
||||
/// \param value The toggle value.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param new_data The new data or null if you wish to clear the data.
|
||||
/// \details LibIkarus does not take ownership of this array.
|
||||
/// \param new_data_size The size of the new data array or 0 if you wish to clear the data.
|
||||
IKA_API void ikarus_toggle_value_set(IkarusToggleValue * value, bool * new_data, size_t new_data_size);
|
||||
/// \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_toggle_value_set(IkarusToggleValue * value, size_t idx, bool new_data);
|
||||
|
||||
/// \brief Removes a data from a toggle value.
|
||||
/// \param value The toggle 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_toggle_value_remove(IkarusToggleValue * value, size_t idx);
|
||||
|
||||
/// \brief Inserts a data into a toggle value.
|
||||
/// \param value The toggle 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_toggle_value_insert(IkarusToggleValue * value, size_t idx, bool new_data);
|
||||
|
||||
/// \brief Clears a toggle value.
|
||||
/// \param value The toggle value.
|
||||
/// \remark Noop if the value is indeterminate.
|
||||
IKA_API void ikarus_toggle_value_clear(IkarusToggleValue * value);
|
||||
|
||||
/// \brief Converts a toggle value to an entity value.
|
||||
/// \param value The toggle value to convert.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue