change error system & function signatures
Signed-off-by: Folling <mail@folling.io>
This commit is contained in:
parent
ee85c53354
commit
e17e346768
28 changed files with 633 additions and 651 deletions
|
|
@ -3,6 +3,7 @@
|
|||
/// \file blueprint.h
|
||||
/// \author Folling <folling@ikarus.world>
|
||||
|
||||
#include <ikarus/errors.h>
|
||||
#include <ikarus/macros.h>
|
||||
#include <ikarus/stdtypes.h>
|
||||
|
||||
|
|
@ -24,16 +25,18 @@ struct IkarusBlueprint;
|
|||
/// \param name The name of the blueprint.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must not be empty.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The created blueprint or null if an error occurs.
|
||||
/// \remark Must be freed using #ikarus_free.
|
||||
IKA_API IkarusBlueprint * ikarus_blueprint_create(struct IkarusProject * project, char const * name);
|
||||
IKA_API IkarusBlueprint * ikarus_blueprint_create(struct IkarusProject * project, char const * name, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Deletes & frees a blueprint.
|
||||
/// \param blueprint The blueprint to delete.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \remark The blueprint must not be accessed after deletion.
|
||||
IKA_API void ikarus_blueprint_delete(IkarusBlueprint * blueprint);
|
||||
IKA_API void ikarus_blueprint_delete(IkarusBlueprint * blueprint, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Gets the properties of a blueprint.
|
||||
/// \param blueprint The blueprint to get the properties of.
|
||||
|
|
@ -42,16 +45,22 @@ IKA_API void ikarus_blueprint_delete(IkarusBlueprint * blueprint);
|
|||
/// \param properties_out The buffer to write the properties to.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param properties_out_size The size of the buffer.
|
||||
/// \param error_out \see errors.h
|
||||
/// \see ikarus_blueprint_get_property_count
|
||||
IKA_API void
|
||||
ikarus_blueprint_get_properties(IkarusBlueprint const * blueprint, struct IkarusProperty ** properties_out, size_t properties_out_size);
|
||||
IKA_API void ikarus_blueprint_get_properties(
|
||||
IkarusBlueprint const * blueprint,
|
||||
struct IkarusProperty ** properties_out,
|
||||
size_t properties_out_size,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the number of properties of a blueprint.
|
||||
/// \param blueprint The blueprint to get the number of properties of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The number of properties or undefined if an error occurs.
|
||||
IKA_API size_t ikarus_blueprint_get_property_count(IkarusBlueprint const * blueprint);
|
||||
IKA_API size_t ikarus_blueprint_get_property_count(IkarusBlueprint const * blueprint, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Gets the entities linked to a blueprint.
|
||||
/// \param blueprint The blueprint to get the linked entities of.
|
||||
|
|
@ -60,27 +69,34 @@ IKA_API size_t ikarus_blueprint_get_property_count(IkarusBlueprint const * bluep
|
|||
/// \param entities_out The buffer to write the entities to.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param entities_out_size The size of the buffer.
|
||||
/// \param error_out \see errors.h
|
||||
/// \see ikarus_blueprint_get_linked_entity_count
|
||||
IKA_API void
|
||||
ikarus_blueprint_get_linked_entities(IkarusBlueprint const * blueprint, struct IkarusEntity ** entities_out, size_t entities_out_size);
|
||||
IKA_API void ikarus_blueprint_get_linked_entities(
|
||||
IkarusBlueprint const * blueprint,
|
||||
struct IkarusEntity ** entities_out,
|
||||
size_t entities_out_size,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the number of entities linked to a blueprint.
|
||||
/// \param blueprint The blueprint to get the number of linked entities of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The number of linked entities or undefined if an error occurs.
|
||||
IKA_API size_t ikarus_blueprint_get_linked_entity_count(IkarusBlueprint const * blueprint);
|
||||
IKA_API size_t ikarus_blueprint_get_linked_entity_count(IkarusBlueprint const * blueprint, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Casts a blueprint to an object.
|
||||
/// \param blueprint The blueprint to cast.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The blueprint represented as an object or null if an error occurs.
|
||||
/// \remark This operation is guaranteed to be very fast and is intended to be used frequently.
|
||||
IKA_API struct IkarusObject * ikarus_blueprint_to_object(IkarusBlueprint * blueprint);
|
||||
IKA_API struct IkarusObject * ikarus_blueprint_to_object(IkarusBlueprint * blueprint, IkarusErrorData * error_out);
|
||||
|
||||
/// \see ikarus_blueprint_to_object
|
||||
IKA_API struct IkarusObject const * ikarus_blueprint_to_object_const(IkarusBlueprint const * blueprint);
|
||||
IKA_API struct IkarusObject const * ikarus_blueprint_to_object_const(IkarusBlueprint const * blueprint, IkarusErrorData * error_out);
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <ikarus/errors.h>
|
||||
#include <ikarus/macros.h>
|
||||
#include <ikarus/stdtypes.h>
|
||||
|
||||
|
|
@ -37,24 +38,21 @@ struct IkarusEntity;
|
|||
/// \param project The project the entity is part of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param parent The parent folder of the entity.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param position The position of the entity in the parent folder. \see #FolderPosition
|
||||
/// \pre \li Must be within bounds for the parent folder.
|
||||
/// \param name The name of the entity.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must not be empty.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The created entity or null if an error occurs.
|
||||
/// \remark Must be freed using #ikarus_free.
|
||||
IKA_API IkarusEntity * ikarus_entity_create(struct IkarusProject * project, char const * name);
|
||||
IKA_API IkarusEntity * ikarus_entity_create(struct IkarusProject * project, char const * name, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Deletes an entity.
|
||||
/// \param entity The entity to delete.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \remark The entity must not be accessed after deletion.
|
||||
IKA_API void ikarus_entity_delete(IkarusEntity * entity);
|
||||
IKA_API void ikarus_entity_delete(IkarusEntity * entity, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Checks if an entity is linked to a blueprint.
|
||||
/// \param entity The entity to check.
|
||||
|
|
@ -63,8 +61,10 @@ IKA_API void ikarus_entity_delete(IkarusEntity * entity);
|
|||
/// \param blueprint The blueprint to check.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return True if the entity is linked to the blueprint, false otherwise.
|
||||
IKA_API bool ikarus_entity_is_linked_to_blueprint(IkarusEntity const * entity, struct IkarusBlueprint const * blueprint);
|
||||
IKA_API bool
|
||||
ikarus_entity_is_linked_to_blueprint(IkarusEntity const * entity, struct IkarusBlueprint const * blueprint, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Links an entity to a blueprint.
|
||||
/// \param entity The entity to link.
|
||||
|
|
@ -73,8 +73,9 @@ IKA_API bool ikarus_entity_is_linked_to_blueprint(IkarusEntity const * entity, s
|
|||
/// \param blueprint The blueprint to link the entity to.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \remark No-op if the entity is already linked to the blueprint.
|
||||
IKA_API void ikarus_entity_link_to_blueprint(IkarusEntity * entity, struct IkarusBlueprint * blueprint);
|
||||
IKA_API void ikarus_entity_link_to_blueprint(IkarusEntity * entity, struct IkarusBlueprint * blueprint, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Unlinks an entity from a blueprint. All values of the properties of the blueprint the entity is linked with
|
||||
/// will be deleted.
|
||||
|
|
@ -84,8 +85,9 @@ IKA_API void ikarus_entity_link_to_blueprint(IkarusEntity * entity, struct Ikaru
|
|||
/// \param blueprint The blueprint to unlink the entity from.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \remark No-op if the entity is not linked to the blueprint.
|
||||
IKA_API void ikarus_entity_unlink_from_blueprint(IkarusEntity * entity, struct IkarusBlueprint * blueprint);
|
||||
IKA_API void ikarus_entity_unlink_from_blueprint(IkarusEntity * entity, struct IkarusBlueprint * blueprint, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Checks if an entity has a specific property.
|
||||
/// \param entity The entity to check.
|
||||
|
|
@ -94,15 +96,17 @@ IKA_API void ikarus_entity_unlink_from_blueprint(IkarusEntity * entity, struct I
|
|||
/// \param property The property to check.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return True if the entity has the property, false otherwise.
|
||||
IKA_API bool ikarus_entity_has_property(IkarusEntity const * entity, struct IkarusProperty const * property);
|
||||
IKA_API bool ikarus_entity_has_property(IkarusEntity const * entity, struct IkarusProperty const * property, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Gets the number of properties of an entity.
|
||||
/// \param entity The entity to get the number of properties of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The number of properties or undefined if an error occurs.
|
||||
IKA_API size_t ikarus_entity_get_property_count(IkarusEntity const * entity);
|
||||
IKA_API size_t ikarus_entity_get_property_count(IkarusEntity const * entity, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Gets the properties of an entity.
|
||||
/// \param entity The entity to get the properties of.
|
||||
|
|
@ -110,8 +114,14 @@ IKA_API size_t ikarus_entity_get_property_count(IkarusEntity const * entity);
|
|||
/// \pre \li Must exist.
|
||||
/// \param properties_out The buffer to write the properties to.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param error_out \see errors.h
|
||||
/// \param properties_out_size The size of the buffer.
|
||||
IKA_API void ikarus_entity_get_properties(IkarusEntity const * entity, struct IkarusProperty ** properties_out, size_t properties_out_size);
|
||||
IKA_API void ikarus_entity_get_properties(
|
||||
IkarusEntity const * entity,
|
||||
struct IkarusProperty ** properties_out,
|
||||
size_t properties_out_size,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the value of a property of an entity.
|
||||
/// \details If the entity has never set the value of the property, the default value is returned (which may be
|
||||
|
|
@ -122,10 +132,12 @@ IKA_API void ikarus_entity_get_properties(IkarusEntity const * entity, struct Ik
|
|||
/// \param property The property to get the value of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The value of the property or null if the entity does not have the property or an error occurs.
|
||||
/// \remark Must be freed using
|
||||
/// #ikarus_free.
|
||||
IKA_API struct IkarusEntityValue * ikarus_entity_get_value(IkarusEntity const * entity, struct IkarusProperty const * property);
|
||||
IKA_API struct IkarusEntityValue *
|
||||
ikarus_entity_get_value(IkarusEntity const * entity, struct IkarusProperty const * property, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Sets the value of a property of an entity.
|
||||
/// \param entity The entity to set the value of.
|
||||
|
|
@ -138,19 +150,26 @@ IKA_API struct IkarusEntityValue * ikarus_entity_get_value(IkarusEntity const *
|
|||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must be of the same type as the property.
|
||||
/// \pre \li Must be valid for the property's settings.
|
||||
/// \param error_out \see errors.h
|
||||
/// \remark If the entity does not have the property, this function fails.
|
||||
IKA_API void ikarus_entity_set_value(IkarusEntity * entity, struct IkarusProperty const * property, struct IkarusValue const * value);
|
||||
IKA_API void ikarus_entity_set_value(
|
||||
IkarusEntity * entity,
|
||||
struct IkarusProperty const * property,
|
||||
struct IkarusValue const * value,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Casts an entity to an object.
|
||||
/// \param entity The entity to cast.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The entity represented as an object or null if an error occurs.
|
||||
/// \remark This operation is guaranteed to be very fast and is intended to be used frequently.
|
||||
IKA_API struct IkarusObject * ikarus_entity_to_object(IkarusEntity * entity);
|
||||
IKA_API struct IkarusObject * ikarus_entity_to_object(IkarusEntity * entity, IkarusErrorData * error_out);
|
||||
|
||||
/// \see ikarus_entity_to_object
|
||||
IKA_API struct IkarusObject const * ikarus_entity_to_object_const(IkarusEntity const * entity);
|
||||
IKA_API struct IkarusObject const * ikarus_entity_to_object_const(IkarusEntity const * entity, IkarusErrorData * error_out);
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
/// \file object.h
|
||||
/// \author Folling <folling@ikarus.world>
|
||||
|
||||
#include <ikarus/errors.h>
|
||||
#include <ikarus/macros.h>
|
||||
|
||||
/// \defgroup object Objects
|
||||
|
|
@ -20,10 +21,14 @@ struct IkarusObject;
|
|||
|
||||
/// \brief Compares two objects for equality.
|
||||
/// \details This neither compares the pointers nor does a deep copy. Instead it figures out if the objects _are_ the
|
||||
/// same object. \param lhs The left hand side object. \pre \li Must not be null. \param rhs The right hand side object.
|
||||
/// same object.
|
||||
/// \param lhs The left hand side object.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param rhs The right hand side object.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return True if the objects are equal, false otherwise.
|
||||
IKA_API bool ikarus_object_is_equal(IkarusObject const * lhs, IkarusObject const * rhs);
|
||||
IKA_API bool ikarus_object_is_equal(IkarusObject const * lhs, IkarusObject const * rhs, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Visits an object. Calling the appropriate function for the object's type.
|
||||
/// \param object The object to visit.
|
||||
|
|
@ -34,6 +39,7 @@ IKA_API bool ikarus_object_is_equal(IkarusObject const * lhs, IkarusObject const
|
|||
/// \param property_folder_visitor The function to call if the object is a property folder. Skipped if null.
|
||||
/// \param entity_folder_visitor The function to call if the object is an entity folder. Skipped if null.
|
||||
/// \param data The data passed to the visitor functions.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_object_visit(
|
||||
IkarusObject * object,
|
||||
void (*blueprint_visitor)(struct IkarusBlueprint *, void *),
|
||||
|
|
@ -42,7 +48,8 @@ IKA_API void ikarus_object_visit(
|
|||
void (*blueprint_folder_visitor)(struct IkarusBlueprintFolder *, void *),
|
||||
void (*property_folder_visitor)(struct IkarusPropertyFolder *, void *),
|
||||
void (*entity_folder_visitor)(struct IkarusEntityFolder *, void *),
|
||||
void * data
|
||||
void * data,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \see ikarus_object_visit
|
||||
|
|
@ -54,7 +61,8 @@ IKA_API void ikarus_object_visit_const(
|
|||
void (*blueprint_folder_visitor)(struct IkarusBlueprintFolder const *, void *),
|
||||
void (*property_folder_visitor)(struct IkarusPropertyFolder const *, void *),
|
||||
void (*entity_folder_visitor)(struct IkarusEntityFolder const *, void *),
|
||||
void * data
|
||||
void * data,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
/// \file object_type.h
|
||||
/// \author Folling <folling@ikarus.world>
|
||||
|
||||
#include <ikarus/errors.h>
|
||||
#include <ikarus/macros.h>
|
||||
|
||||
/// \addtogroup objects Objects
|
||||
|
|
@ -24,9 +25,10 @@ enum IkarusObjectType {
|
|||
|
||||
/// \brief Converts an IkarusObjectType to a string.
|
||||
/// \param type The type to convert.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The string representation of the type.
|
||||
/// \remark The returned string must not be freed.
|
||||
char const * ikarus_object_type_to_string(IkarusObjectType type);
|
||||
char const * ikarus_object_type_to_string(IkarusObjectType type, IkarusErrorData * error_out);
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
||||
|
|
|
|||
|
|
@ -3,24 +3,44 @@
|
|||
/// \file number_property.h
|
||||
/// \author Folling <folling@ikarus.world>
|
||||
|
||||
#include <ikarus/errors.h>
|
||||
#include <ikarus/macros.h>
|
||||
|
||||
/// \addtogroup properties Properties
|
||||
/// \brief Number properties store a numeric value. (e.g. "Weight" or "Age")
|
||||
/// \brief Number properties store a value that can be either true or false. (e.g. "Is the character dead?")
|
||||
/// @{
|
||||
|
||||
IKARUS_BEGIN_HEADER
|
||||
|
||||
struct IkarusNumberProperty;
|
||||
|
||||
IKA_API IkarusNumberProperty *
|
||||
ikarus_number_property_create(struct IkarusProject * project, char const * name, struct IkarusPropertySource * property_source);
|
||||
/// \brief Creates a number property.
|
||||
/// \param project The project to create the property in.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param name The name of the property.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must not be empty.
|
||||
/// \param property_source The property source to create the property for.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The created property or null if an error occurs.
|
||||
IKA_API IkarusNumberProperty * ikarus_number_property_create(
|
||||
struct IkarusProject * project,
|
||||
char const * name,
|
||||
struct IkarusPropertySource * property_source,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Sets the default value for a number property.
|
||||
/// \param property The number property.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
IKA_API struct IkarusNumberValue * ikarus_number_property_get_default_value(struct IkarusNumberProperty * property);
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The default value or null if an error occurs.
|
||||
IKA_API struct IkarusNumberValue *
|
||||
ikarus_number_property_get_default_value(struct IkarusNumberProperty * property, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Sets the default value for a number property.
|
||||
/// \param property The number property.
|
||||
|
|
@ -29,9 +49,14 @@ IKA_API struct IkarusNumberValue * ikarus_number_property_get_default_value(stru
|
|||
/// \param default_value The default value.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must be a valid value for the property.
|
||||
/// \param error_out \see errors.h
|
||||
/// \remark Please see \ref property.h "the property documentation" for more information on the interplay between
|
||||
/// default values and other settings.
|
||||
IKA_API void ikarus_number_property_set_default_value(struct IkarusNumberProperty * property, struct IkarusNumberValue * default_value);
|
||||
IKA_API void ikarus_number_property_set_default_value(
|
||||
struct IkarusNumberProperty * property,
|
||||
struct IkarusNumberValue * default_value,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
/// \file property.h
|
||||
/// \author Folling <folling@ikarus.world>
|
||||
|
||||
#include <ikarus/errors.h>
|
||||
#include <ikarus/macros.h>
|
||||
#include <ikarus/objects/properties/property_type.h>
|
||||
#include <ikarus/stdtypes.h>
|
||||
|
|
@ -59,32 +60,36 @@ struct IkarusProperty;
|
|||
/// \param property The property to delete.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \remark The property must not be accessed after deletion.
|
||||
IKA_API void ikarus_property_delete(IkarusProperty * property);
|
||||
IKA_API void ikarus_property_delete(IkarusProperty * property, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Gets the type info of a property.
|
||||
/// \param property The property to get the type info of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The type info of the property or null if an error occurs.
|
||||
/// \remark Must be freed using #ikarus_free.
|
||||
IKA_API IkarusPropertyType ikarus_property_get_type(IkarusProperty const * property);
|
||||
IKA_API IkarusPropertyType ikarus_property_get_type(IkarusProperty const * property, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Gets the source of a property.
|
||||
/// \param property The property to get the source of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The source of the property or null if an error occurs.
|
||||
/// \remark Must be freed using #ikarus_free.
|
||||
IKA_API struct IkarusPropertySource const * ikarus_property_get_source(IkarusProperty const * property);
|
||||
IKA_API struct IkarusPropertySource const * ikarus_property_get_source(IkarusProperty const * property, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Gets the default value of a property.
|
||||
/// \param property The property to get the type info of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The default value of the property or null if an error occurs.
|
||||
/// \remark Must be freed using #ikarus_free.
|
||||
IKA_API struct IkarusValue const * ikarus_property_get_default_value(IkarusProperty const * property);
|
||||
IKA_API struct IkarusValue const * ikarus_property_get_default_value(IkarusProperty const * property, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Visits a property. Calling the appropriate function for the property's type.
|
||||
/// \param property The property to visit.
|
||||
|
|
@ -94,12 +99,14 @@ IKA_API struct IkarusValue const * ikarus_property_get_default_value(IkarusPrope
|
|||
/// \param number_property_visitor The function to call if the property is a number property. Skipped if null.
|
||||
/// \param text_property_visitor The function to call if the property is a text property. Skipped if null.
|
||||
/// \param data The data to pass to the functions.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_property_visit(
|
||||
IkarusProperty * property,
|
||||
void (*toggle_property_visitor)(struct IkarusToggleProperty *, void *),
|
||||
void (*number_property_visitor)(struct IkarusNumberProperty *, void *),
|
||||
void (*text_property_visitor)(struct IkarusTextProperty *, void *),
|
||||
void * data
|
||||
void * data,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \see ikarus_property_visit
|
||||
|
|
@ -108,19 +115,21 @@ IKA_API void ikarus_property_visit_const(
|
|||
void (*toggle_property_visitor)(struct IkarusToggleProperty const *, void *),
|
||||
void (*number_property_visitor)(struct IkarusNumberProperty const *, void *),
|
||||
void (*text_property_visitor)(struct IkarusTextProperty const *, void *),
|
||||
void * data
|
||||
void * data,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Casts a property to an object.
|
||||
/// \param property The property to cast.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The property represented as an object or null if an error occurs.
|
||||
/// \remark This operation is guaranteed to be very fast and is intended to be used frequently.
|
||||
IKA_API struct IkarusObject * ikarus_property_to_object(IkarusProperty * property);
|
||||
IKA_API struct IkarusObject * ikarus_property_to_object(IkarusProperty * property, IkarusErrorData * error_out);
|
||||
|
||||
/// \see ikarus_property_to_object
|
||||
IKA_API struct IkarusObject const * ikarus_property_to_object_const(IkarusProperty const * property);
|
||||
IKA_API struct IkarusObject const * ikarus_property_to_object_const(IkarusProperty const * property, IkarusErrorData * error_out);
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
/// \file property_source.h
|
||||
/// \author Folling <folling@ikarus.world>
|
||||
|
||||
#include <ikarus/errors.h>
|
||||
#include <ikarus/macros.h>
|
||||
|
||||
/// \addtogroup properties Properties
|
||||
|
|
@ -16,17 +17,20 @@ struct IkarusPropertySource;
|
|||
/// \param blueprint The blueprint to create the property source for.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The created property source or null if an error occurs.
|
||||
/// \remark Must be freed using #ikarus_free.
|
||||
IKA_API struct IkarusPropertySource * ikarus_property_source_create_blueprint(struct IkarusBlueprint * blueprint);
|
||||
IKA_API struct IkarusPropertySource *
|
||||
ikarus_property_source_create_blueprint(struct IkarusBlueprint * blueprint, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Creates an entity property source.
|
||||
/// \param entity The entity to create the property source for.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The created property source or null if an error occurs.
|
||||
/// \remark Must be freed using #ikarus_free.
|
||||
IKA_API struct IkarusPropertySource * ikarus_property_source_create_entity(struct IkarusEntity * entity);
|
||||
IKA_API struct IkarusPropertySource * ikarus_property_source_create_entity(struct IkarusEntity * entity, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Visits a property source, calling the appropriate callback.
|
||||
/// \param property_source The property source to visit.
|
||||
|
|
@ -35,11 +39,13 @@ IKA_API struct IkarusPropertySource * ikarus_property_source_create_entity(struc
|
|||
/// \param blueprint_visitor The callback to call if the source is a blueprint, skipped if null.
|
||||
/// \param entity_visitor The callback to call if the source is an entity, skipped if null.
|
||||
/// \param user_data User data to pass to the callbacks.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_property_source_visit(
|
||||
struct IkarusPropertySource * property_source,
|
||||
void (*blueprint_visitor)(struct IkarusBlueprint *, void *),
|
||||
void (*entity_visitor)(struct IkarusEntity *, void *),
|
||||
void * user_data
|
||||
void * user_data,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \see ikarus_property_source_visit
|
||||
|
|
@ -47,7 +53,8 @@ IKA_API void ikarus_property_source_visit_const(
|
|||
struct IkarusPropertySource const * property_source,
|
||||
void (*blueprint_visitor)(struct IkarusBlueprint const *, void *),
|
||||
void (*entity_visitor)(struct IkarusEntity const *, void *),
|
||||
void * user_data
|
||||
void * user_data,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
|
|
|||
|
|
@ -3,24 +3,43 @@
|
|||
/// \file text_property.h
|
||||
/// \author Folling <folling@ikarus.world>
|
||||
|
||||
#include <ikarus/errors.h>
|
||||
#include <ikarus/macros.h>
|
||||
|
||||
/// \addtogroup properties Properties
|
||||
/// \brief Text properties store an arbitrary piece of text. (e.g. "Firstname" or "Description")
|
||||
/// \brief Text properties store a value that can be either true or false. (e.g. "Is the character dead?")
|
||||
/// @{
|
||||
|
||||
IKARUS_BEGIN_HEADER
|
||||
|
||||
struct IkarusTextProperty;
|
||||
|
||||
IKA_API IkarusTextProperty *
|
||||
ikarus_text_property_create(struct IkarusProject * project, char const * name, struct IkarusPropertySource * property_source);
|
||||
/// \brief Creates a text property.
|
||||
/// \param project The project to create the property in.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param name The name of the property.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must not be empty.
|
||||
/// \param property_source The property source to create the property for.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The created property or null if an error occurs.
|
||||
IKA_API IkarusTextProperty * ikarus_text_property_create(
|
||||
struct IkarusProject * project,
|
||||
char const * name,
|
||||
struct IkarusPropertySource * property_source,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Sets the default value for a text property.
|
||||
/// \param property The text property.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
IKA_API struct IkarusTextValue * ikarus_text_property_get_default_value(struct IkarusTextProperty * property);
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The default value or null if an error occurs.
|
||||
IKA_API struct IkarusTextValue * ikarus_text_property_get_default_value(struct IkarusTextProperty * property, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Sets the default value for a text property.
|
||||
/// \param property The text property.
|
||||
|
|
@ -29,9 +48,14 @@ IKA_API struct IkarusTextValue * ikarus_text_property_get_default_value(struct I
|
|||
/// \param default_value The default value.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must be a valid value for the property.
|
||||
/// \param error_out \see errors.h
|
||||
/// \remark Please see \ref property.h "the property documentation" for more information on the interplay between
|
||||
/// default values and other settings.
|
||||
IKA_API void ikarus_text_property_set_default_value(struct IkarusTextProperty * property, struct IkarusTextValue * default_value);
|
||||
IKA_API void ikarus_text_property_set_default_value(
|
||||
struct IkarusTextProperty * property,
|
||||
struct IkarusTextValue * default_value,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
/// \file toggle_property.h
|
||||
/// \author Folling <folling@ikarus.world>
|
||||
|
||||
#include <ikarus/errors.h>
|
||||
#include <ikarus/macros.h>
|
||||
|
||||
/// \addtogroup properties Properties
|
||||
|
|
@ -13,14 +14,33 @@ IKARUS_BEGIN_HEADER
|
|||
|
||||
struct IkarusToggleProperty;
|
||||
|
||||
IKA_API IkarusToggleProperty *
|
||||
ikarus_toggle_property_create(struct IkarusProject * project, char const * name, struct IkarusPropertySource * property_source);
|
||||
/// \brief Creates a toggle property.
|
||||
/// \param project The project to create the property in.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param name The name of the property.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must not be empty.
|
||||
/// \param property_source The property source to create the property for.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The created property or null if an error occurs.
|
||||
IKA_API IkarusToggleProperty * ikarus_toggle_property_create(
|
||||
struct IkarusProject * project,
|
||||
char const * name,
|
||||
struct IkarusPropertySource * property_source,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Sets the default value for a toggle property.
|
||||
/// \param property The toggle property.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
IKA_API struct IkarusToggleValue * ikarus_toggle_property_get_default_value(struct IkarusToggleProperty * property);
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The default value or null if an error occurs.
|
||||
IKA_API struct IkarusToggleValue *
|
||||
ikarus_toggle_property_get_default_value(struct IkarusToggleProperty * property, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Sets the default value for a toggle property.
|
||||
/// \param property The toggle property.
|
||||
|
|
@ -29,9 +49,14 @@ IKA_API struct IkarusToggleValue * ikarus_toggle_property_get_default_value(stru
|
|||
/// \param default_value The default value.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must be a valid value for the property.
|
||||
/// \param error_out \see errors.h
|
||||
/// \remark Please see \ref property.h "the property documentation" for more information on the interplay between
|
||||
/// default values and other settings.
|
||||
IKA_API void ikarus_toggle_property_set_default_value(struct IkarusToggleProperty * property, struct IkarusToggleValue * default_value);
|
||||
IKA_API void ikarus_toggle_property_set_default_value(
|
||||
struct IkarusToggleProperty * property,
|
||||
struct IkarusToggleValue * default_value,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue