finalize schema/data setup

Signed-off-by: Folling <mail@folling.io>
This commit is contained in:
folling 2025-01-01 13:49:05 +01:00 committed by Folling
parent 4d7bf09c4e
commit 954b8a11a3
Signed by: folling
SSH key fingerprint: SHA256:S9qEx5WCFFLK49tE/LKnKuJYM5sw+++Dn6qJbbyxnCY
89 changed files with 2324 additions and 6271 deletions

View file

@ -1,7 +1,9 @@
#pragma once
/// \file project.h
/// \author Folling <folling@ikarus.world>
/// \author Folling <mail@folling.io>
#include <cstdint>
#include <ikarus/errors.h>
#include <ikarus/macros.h>
@ -15,10 +17,19 @@
IKARUS_BEGIN_HEADER
/// \brief An Ikarus project.
/// \details A project may only be open once at a time. Opening a project from two different locations Gets undefined
/// \details A project may only be open once at a time.
/// Opening a project from two different locations results in undefined
/// behavior.
struct IkarusProject;
/// \brief Flags for creating a project.
enum IkarusProjectCreateFlags {
/// \brief No flags.
IkarusProjectCreateFlags_None = 0,
/// \brief Allow overwriting existing files.
IkarusProjectCreateFlags_AllowOverwrite = 1 << 0,
};
/// \brief Creates a persisted project on the filesystem.
/// \param path The path to the project.
/// \pre \li Must not be null.
@ -26,126 +37,168 @@ struct IkarusProject;
/// \param name The name of the project. Must neither be null nor empty.
/// \pre \li Must not be null.
/// \pre \li Must not be empty.
/// \param flags Flags for creating the project.
/// \param error_out \see errors.h
/// \return The created project or null if an error occurs.
/// \remark Must be freed using #ikarus_free. Freeing does not delete the project from the filesystem. For that, use
/// ikarus_project_delete
IKA_API IkarusProject * ikarus_project_create(
char const * path,
char const * name,
IkarusErrorData * error_out
/// \remark Must be closed with #ikarus_project_close.
IKA_API struct IkarusProject * ikarus_project_create(
char const * path,
char const * name,
IkarusProjectCreateFlags flags,
IkarusErrorData * error_out
);
/// \brief Creates a project in memory.
/// \brief Flags for creating a project in memory.
enum IkarusProjectCreateInMemoryFlags {
/// \brief No flags.
IkarusProjectCreateInMemoryFlags_None = 0,
};
/// \brief Creates a project in memory. The project is not persisted.
/// \param name The name of the project. Must neither be null nor empty.
/// \pre \li Must not be null.
/// \pre \li Must not be empty.
/// \param flags Flags for creating the project.
/// \param error_out \see errors.h
/// \return The created project or null if an error occurs.
/// \remark Must be freed using #ikarus_free. Freeing does not delete the project from the filesystem. For that, use
/// ikarus_project_delete
IKA_API IkarusProject *
ikarus_project_create_in_memory(char const * name, IkarusErrorData * error_out);
/// \remark Must be closed with #ikarus_project_close.
IKA_API struct IkarusProject * ikarus_project_create_in_memory(
char const * name,
IkarusProjectCreateInMemoryFlags flags,
IkarusErrorData * error_out
);
/// \brief Flags for opening a project.
enum IkarusProjectOpenFlags {
/// \brief No flags.
IkarusProjectOpenFlags_None = 0,
};
/// \brief Opens an existing project.
/// \param path The path to the project.
/// \pre \li Must not be null.
/// \pre \li Must point to an existing project on the system.
/// \param flags Flags for opening the project.
/// \param error_out \see errors.h
/// \return The opened project or null if an error occurs.
/// \remark Must be freed using ikarus_free. Freeing does not delete the project from the filesystem. For that, use
/// ikarus_project_delete
IKA_API IkarusProject *
ikarus_project_open(char const * path, IkarusErrorData * error_out);
/// \brief Gets the name of a project.
/// \param project The project to get the name of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param error_out \see errors.h
/// \return The name of the project.
/// \remark Ownership remains with libikarus, must not be freed.
IKA_API char const * ikarus_project_get_name(
IkarusProject const * project,
IkarusErrorData * error_out
/// \remark Must be closed with #ikarus_project_close.
IKA_API struct IkarusProject * ikarus_project_open(
char const * path,
IkarusProjectOpenFlags flags,
IkarusErrorData * error_out
);
/// \brief Sets the name of a project.
/// \param project The project to set the name of.
/// \brief Flags for closing a project in memory.
enum IkarusProjectCloseFlags {
/// \brief No flags.
IkarusProjectCloseFlags_None = 0,
};
/// \brief Closes a project. This function must be called to free resources.
/// \param project The project to close.
/// \pre \li Must not be null.
/// \pre \li Must be open.
/// \param flags Flags for closing the project.
/// \param error_out \see errors.h
/// \remark The project must not be used after closing.
/// \remark Does not delete the project from the filesystem.
/// \remark Mutually exclusive with #ikarus_project_delete.
IKA_API void ikarus_project_close(
struct IkarusProject * project,
IkarusProjectCloseFlags flags,
IkarusErrorData * error_out
);
/// \brief Flags for deleting a project.
enum IkarusProjectDeleteFlags {
/// \brief No flags.
IkarusProjectDeleteFlags_None = 0,
};
/// \brief Deletes a project from the filesystem.
/// \param project The project to delete.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param new_name The new name of the project.
/// \pre \li Must not be null.
/// \pre \li Must not be empty.
/// \param flags Flags for deleting the project.
/// \param error_out \see errors.h
IKA_API void ikarus_project_set_name(
IkarusProject * project,
char const * new_name,
IkarusErrorData * error_out
/// \remark The project must not be used after deletion.
/// \remark Mutually exclusive with #ikarus_project_close.
IKA_API void ikarus_project_delete(
struct IkarusProject * project,
IkarusProjectDeleteFlags flags,
IkarusErrorData * error_out
);
/// \brief Gets the name of a project.
/// \param project The project to delete.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param error_out \see errors.h
/// \returns The name of the project or null if an error occurs.
IKA_API char const * ikarus_project_get_name(
struct IkarusProject const * project,
IkarusErrorData * error_out
);
/// \brief Gets the path of a project.
/// \param project The project to get the path of.
/// \param project The project to delete.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param error_out \see errors.h
/// \return The path of the project.
/// \remark Ownership remains with libikarus, must not be freed.
/// \returns The path of the project or null if an error occurs.
IKA_API char const * ikarus_project_get_path(
IkarusProject const * project,
IkarusErrorData * error_out
struct IkarusProject const * project,
IkarusErrorData * error_out
);
/// \brief Gets the entities of a project.
/// \param project The project to get the entities of.
/// \brief Gets all entities in a project.
/// \param project The project from which to get the entities.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \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 size_out An out parameter for the number of entities in the returned array
/// or undefined if an error occurs.
/// \param error_out \see errors.h
IKA_API void ikarus_project_get_entities(
IkarusProject * project,
struct IkarusEntity ** entities_out,
size_t entities_out_size,
IkarusErrorData * error_out
/// \returns An array of entities or null if an error occurs.
IKA_API struct IkarusEntity ** ikarus_project_get_entities(
struct IkarusProject const * project,
size_t * size_out,
IkarusErrorData * error_out
);
/// \brief Gets the number of entities of a project.
/// \param project The project to get the number of entities of.
/// \brief Gets how many entities in a project there are.
/// \param project The project from which to get the count.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param error_out \see errors.h
/// \return The number of entities or undefined if an error occurs.
IKA_API size_t ikarus_project_get_entity_count(
IkarusProject const * project,
IkarusErrorData * error_out
/// \return The count or 0 if an error occurs.
IKA_API size_t ikarus_project_get_entities_count(
IkarusProject const * project,
IkarusErrorData * error_out
);
/// \brief Gets the blueprints of a project.
/// \param project The project to get the blueprints of.
/// \brief Gets all blueprints from a project.
/// \param project The project from which to get the blueprints.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param blueprints_out The buffer to write the blueprints to.
/// \pre \li Must not be null.
/// \param blueprints_out_size The size of the buffer.
/// \param size_out An out parameter for the number of blueprints in the returned array
/// or undefined if an error occurs.
/// \param error_out \see errors.h
IKA_API void ikarus_project_get_blueprints(
IkarusProject * project,
struct IkarusBlueprint ** blueprints_out,
size_t blueprints_out_size,
IkarusErrorData * error_out
/// \return An array of blueprints or null if an error occurs.
IKA_API struct IkarusBlueprint ** ikarus_project_get_blueprints(
struct IkarusProject const * project,
size_t * size_out,
IkarusErrorData * error_out
);
/// \brief Gets the number of blueprints of a project.
/// \param project The project to get the number of blueprints of.
/// \brief Gets how many blueprints in a project there are.
/// \param project The project from which to get the count.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param error_out \see errors.h
/// \return The number of blueprints or undefined if an error occurs.
IKA_API size_t ikarus_project_get_blueprint_count(
IkarusProject const * project,
IkarusErrorData * error_out
/// \return The count or 0 if an error occurs.
IKA_API size_t ikarus_project_get_blueprints_count(
IkarusProject const * project,
IkarusErrorData * error_out
);
IKARUS_END_HEADER