finished config.h documentation, need to write config.md

This commit is contained in:
herbglitch 2025-03-28 01:34:29 -06:00
parent fc48793109
commit cb48a9f573
4 changed files with 217 additions and 44 deletions

View file

@ -9,8 +9,6 @@ extern "C" {
#include "arc/std/config.h"
typedef struct ARC_Config ARC_Config;
/**
* @brief
*/

View file

@ -15,11 +15,19 @@ typedef struct ARC_Config ARC_Config;
/**
* @brief a function callback to create a type stored within a config
*
* @param[out] type the place to store the type copy, should be set to NULL on error
* @param[in] parsedData the parsed data used to copy from. will be <value> as defined in the language
* @param[in] config the config that is reading in the data, can be used within the copy function to add a new type (check ARC_ConfigType_SpriteCopyFn for an example)
* @param[in] userdata userdata that was stored in the type during type register
*/
typedef void (* ARC_ConfigType_CopyFn)(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata);
/**
* @brief a function callback to destroy a type
*
* @param[in] config the config that is destroying the data, can be used within the destroy function to remove a previously added tag (check ARC_ConfigType_SpriteDestroyFn for an example)
* @param[in] type the type to be destroyed
*/
typedef void (* ARC_ConfigType_DestroyFn)(ARC_Config *config, void *type);
@ -196,20 +204,50 @@ void ARC_Config_LoadFromFile(ARC_Config *config, ARC_String *path);
void ARC_Config_LoadFromFileWithCStr(ARC_Config *config, const char *path);
/**
* @brief TODO: write this
* @brief takes a given file path and unloads it into the config
*
* @note this path will be based on wherever the executable is run from
*
* @breif config the config to unload the file from
* @breif path the location of the .chemical file to unload
*/
void ARC_Config_UnloadFromString(ARC_Config *config, ARC_String **string);
/**
* @brief TODO: write this
* @brief takes a given file path and unloads it into the config
*
* @note this path will be based on wherever the executable is run from
*
* @breif config the config to unload the file from
* @breif path the location of the .chemical file to unload
*/
void ARC_Config_UnloadFromFile(ARC_Config *config, ARC_String *data);
/**
* @{
* @brief defaults used by arc config can be defined before building to change them
*/
#ifndef ARC_CONFIG_DEFAULT_GROUP
#define ARC_CONFIG_DEFAULT_GROUP " "
#define ARC_CONFIG_GROUP_TAG_NAME "group"
#define ARC_CONFIG_GROUP_SEPARATOR "::"
#endif
//the grouping is based on the ascii table, but the ids are sequential to make finding tokens quicker (look at the lexer continious for more explanation)
#ifndef ARC_CONFIG_GROUP_TAG_NAME
#define ARC_CONFIG_GROUP_TAG_NAME "group"
#endif
#ifndef ARC_CONFIG_GROUP_SEPARATOR
#define ARC_CONFIG_GROUP_SEPARATOR "::"
#endif
/**
* @}
*/
/**
* @{
* @brief tokens used in the config langauge, defined here for use in ARC_ConfigType_CopyFn and ARC_ConfigType_DestroyFn
*
* @note the grouping is based on the ascii table, but the ids are sequential to make finding tokens quicker (look at the lexer continious for more explanation)
*/
#define ARC_CONFIG_TAB 0x01
#define ARC_CONFIG_NEWLINE 0x02
@ -282,6 +320,9 @@ void ARC_Config_UnloadFromFile(ARC_Config *config, ARC_String *data);
#define ARC_CONFIG_LINE_CHARS 0x41
#define ARC_CONFIG_MULTI_LINE_CHARS 0x42
#define ARC_CONFIG_COMMENT_CHAR 0x43
/**
* @}
*/
/**
* @brief TODO: write this
@ -289,132 +330,266 @@ void ARC_Config_UnloadFromFile(ARC_Config *config, ARC_String *data);
void ARC_Config_InitStd(ARC_Config *config);
/**
* @brief
* @brief a function callback to create an ARC_Bool stored within a config
*
* @note this function is an ARC_ConfigType_CopyFn callback
*
* @param[out] type the place to store the type copy, should be set to NULL on error
* @param[in] parsedData the parsed data used to copy from. will be <value> as defined in the language
* @param[in] config the config that is reading in the data, can be used within the copy function to add a new type (check ARC_ConfigType_SpriteCopyFn for an example)
* @param[in] userdata userdata that was stored in the type during type register
*/
void ARC_ConfigType_BoolCopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata);
/**
* @brief
* @brief a function callback to destroy an ARC_Bool type
*
* @note this function is an ARC_ConfigType_DestroyFn callback
*
* @param[in] config the config that is destroying the data, can be used within the destroy function to remove a previously added tag (check ARC_ConfigType_SpriteDestroyFn for an example)
* @param[in] type the type to be destroyed
*/
void ARC_ConfigType_BoolDestroyFn(ARC_Config *config, void *type);
/**
* @brief
*/
void ARC_ConfigType_CharCopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata);
/**
* @brief
*/
void ARC_ConfigType_CharDestroyFn(ARC_Config *config, void *type);
/**
* @brief
* @brief a function callback to create an int8_t stored within a config
*
* @note this function is an ARC_ConfigType_CopyFn callback
*
* @param[out] type the place to store the type copy, should be set to NULL on error
* @param[in] parsedData the parsed data used to copy from. will be <value> as defined in the language
* @param[in] config the config that is reading in the data, can be used within the copy function to add a new type (check ARC_ConfigType_SpriteCopyFn for an example)
* @param[in] userdata userdata that was stored in the type during type register
*/
void ARC_ConfigType_Int8CopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata);
/**
* @brief
* @brief a function callback to destroy an int8_t type
*
* @note this function is an ARC_ConfigType_DestroyFn callback
*
* @param[in] config the config that is destroying the data, can be used within the destroy function to remove a previously added tag (check ARC_ConfigType_SpriteDestroyFn for an example)
* @param[in] type the type to be destroyed
*/
void ARC_ConfigType_Int8DestroyFn(ARC_Config *config, void *type);
/**
* @brief
* @brief a function callback to create an uint8_t stored within a config
*
* @note this function is an ARC_ConfigType_CopyFn callback
*
* @param[out] type the place to store the type copy, should be set to NULL on error
* @param[in] parsedData the parsed data used to copy from. will be <value> as defined in the language
* @param[in] config the config that is reading in the data, can be used within the copy function to add a new type (check ARC_ConfigType_SpriteCopyFn for an example)
* @param[in] userdata userdata that was stored in the type during type register
*/
void ARC_ConfigType_Uint8CopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata);
/**
* @brief
* @brief a function callback to destroy an uint8_t type
*
* @note this function is an ARC_ConfigType_DestroyFn callback
*
* @param[in] config the config that is destroying the data, can be used within the destroy function to remove a previously added tag (check ARC_ConfigType_SpriteDestroyFn for an example)
* @param[in] type the type to be destroyed
*/
void ARC_ConfigType_Uint8DestroyFn(ARC_Config *config, void *type);
/**
* @brief
* @brief a function callback to create an int16_t stored within a config
*
* @note this function is an ARC_ConfigType_CopyFn callback
*
* @param[out] type the place to store the type copy, should be set to NULL on error
* @param[in] parsedData the parsed data used to copy from. will be <value> as defined in the language
* @param[in] config the config that is reading in the data, can be used within the copy function to add a new type (check ARC_ConfigType_SpriteCopyFn for an example)
* @param[in] userdata userdata that was stored in the type during type register
*/
void ARC_ConfigType_Int16CopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata);
/**
* @brief
* @brief a function callback to destroy an int16_t type
*
* @note this function is an ARC_ConfigType_DestroyFn callback
*
* @param[in] config the config that is destroying the data, can be used within the destroy function to remove a previously added tag (check ARC_ConfigType_SpriteDestroyFn for an example)
* @param[in] type the type to be destroyed
*/
void ARC_ConfigType_Int16DestroyFn(ARC_Config *config, void *type);
/**
* @brief
* @brief a function callback to create an uint16_t stored within a config
*
* @note this function is an ARC_ConfigType_CopyFn callback
*
* @param[out] type the place to store the type copy, should be set to NULL on error
* @param[in] parsedData the parsed data used to copy from. will be <value> as defined in the language
* @param[in] config the config that is reading in the data, can be used within the copy function to add a new type (check ARC_ConfigType_SpriteCopyFn for an example)
* @param[in] userdata userdata that was stored in the type during type register
*/
void ARC_ConfigType_Uint16CopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata);
/**
* @brief
* @brief a function callback to destroy an uint16_t type
*
* @note this function is an ARC_ConfigType_DestroyFn callback
*
* @param[in] config the config that is destroying the data, can be used within the destroy function to remove a previously added tag (check ARC_ConfigType_SpriteDestroyFn for an example)
* @param[in] type the type to be destroyed
*/
void ARC_ConfigType_Uint16DestroyFn(ARC_Config *config, void *type);
/**
* @brief
* @brief a function callback to create an int32_t stored within a config
*
* @note this function is an ARC_ConfigType_CopyFn callback
*
* @param[out] type the place to store the type copy, should be set to NULL on error
* @param[in] parsedData the parsed data used to copy from. will be <value> as defined in the language
* @param[in] config the config that is reading in the data, can be used within the copy function to add a new type (check ARC_ConfigType_SpriteCopyFn for an example)
* @param[in] userdata userdata that was stored in the type during type register
*/
void ARC_ConfigType_Int32CopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata);
/**
* @brief
* @brief a function callback to destroy an int32_t type
*
* @note this function is an ARC_ConfigType_DestroyFn callback
*
* @param[in] config the config that is destroying the data, can be used within the destroy function to remove a previously added tag (check ARC_ConfigType_SpriteDestroyFn for an example)
* @param[in] type the type to be destroyed
*/
void ARC_ConfigType_Int32DestroyFn(ARC_Config *config, void *type);
/**
* @brief
* @brief a function callback to create an uint32_t stored within a config
*
* @note this function is an ARC_ConfigType_CopyFn callback
*
* @param[out] type the place to store the type copy, should be set to NULL on error
* @param[in] parsedData the parsed data used to copy from. will be <value> as defined in the language
* @param[in] config the config that is reading in the data, can be used within the copy function to add a new type (check ARC_ConfigType_SpriteCopyFn for an example)
* @param[in] userdata userdata that was stored in the type during type register
*/
void ARC_ConfigType_Uint32CopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata);
/**
* @brief
* @brief a function callback to destroy an uint32_t type
*
* @note this function is an ARC_ConfigType_DestroyFn callback
*
* @param[in] config the config that is destroying the data, can be used within the destroy function to remove a previously added tag (check ARC_ConfigType_SpriteDestroyFn for an example)
* @param[in] type the type to be destroyed
*/
void ARC_ConfigType_Uint32DestroyFn(ARC_Config *config, void *type);
/**
* @brief
* @brief a function callback to create an int64_t stored within a config
*
* @note this function is an ARC_ConfigType_CopyFn callback
*
* @param[out] type the place to store the type copy, should be set to NULL on error
* @param[in] parsedData the parsed data used to copy from. will be <value> as defined in the language
* @param[in] config the config that is reading in the data, can be used within the copy function to add a new type (check ARC_ConfigType_SpriteCopyFn for an example)
* @param[in] userdata userdata that was stored in the type during type register
*/
void ARC_ConfigType_Int64CopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata);
/**
* @brief
* @brief a function callback to destroy an int64_t type
*
* @note this function is an ARC_ConfigType_DestroyFn callback
*
* @param[in] config the config that is destroying the data, can be used within the destroy function to remove a previously added tag (check ARC_ConfigType_SpriteDestroyFn for an example)
* @param[in] type the type to be destroyed
*/
void ARC_ConfigType_Int64DestroyFn(ARC_Config *config, void *type);
/**
* @brief
* @brief a function callback to create an uint64_t stored within a config
*
* @note this function is an ARC_ConfigType_CopyFn callback
*
* @param[out] type the place to store the type copy, should be set to NULL on error
* @param[in] parsedData the parsed data used to copy from. will be <value> as defined in the language
* @param[in] config the config that is reading in the data, can be used within the copy function to add a new type (check ARC_ConfigType_SpriteCopyFn for an example)
* @param[in] userdata userdata that was stored in the type during type register
*/
void ARC_ConfigType_Uint64CopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata);
/**
* @brief
* @brief a function callback to destroy an uint64_t type
*
* @note this function is an ARC_ConfigType_DestroyFn callback
*
* @param[in] config the config that is destroying the data, can be used within the destroy function to remove a previously added tag (check ARC_ConfigType_SpriteDestroyFn for an example)
* @param[in] type the type to be destroyed
*/
void ARC_ConfigType_Uint64DestroyFn(ARC_Config *config, void *type);
/**
* @brief
* @brief a function callback to create a float stored within a config
*
* @note this function is an ARC_ConfigType_CopyFn callback
*
* @param[out] type the place to store the type copy, should be set to NULL on error
* @param[in] parsedData the parsed data used to copy from. will be <value> as defined in the language
* @param[in] config the config that is reading in the data, can be used within the copy function to add a new type (check ARC_ConfigType_SpriteCopyFn for an example)
* @param[in] userdata userdata that was stored in the type during type register
*/
void ARC_ConfigType_FloatCopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata);
/**
* @brief
* @brief a function callback to destroy a float type
*
* @note this function is an ARC_ConfigType_DestroyFn callback
*
* @param[in] config the config that is destroying the data, can be used within the destroy function to remove a previously added tag (check ARC_ConfigType_SpriteDestroyFn for an example)
* @param[in] type the type to be destroyed
*/
void ARC_ConfigType_FloatDestroyFn(ARC_Config *config, void *type);
/**
* @brief
* @brief a function callback to create a double stored within a config
*
* @note this function is an ARC_ConfigType_CopyFn callback
*
* @param[out] type the place to store the type copy, should be set to NULL on error
* @param[in] parsedData the parsed data used to copy from. will be <value> as defined in the language
* @param[in] config the config that is reading in the data, can be used within the copy function to add a new type (check ARC_ConfigType_SpriteCopyFn for an example)
* @param[in] userdata userdata that was stored in the type during type register
*/
void ARC_ConfigType_DoubleCopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata);
/**
* @brief
* @brief a function callback to destroy a double type
*
* @note this function is an ARC_ConfigType_DestroyFn callback
*
* @param[in] config the config that is destroying the data, can be used within the destroy function to remove a previously added tag (check ARC_ConfigType_SpriteDestroyFn for an example)
* @param[in] type the type to be destroyed
*/
void ARC_ConfigType_DoubleDestroyFn(ARC_Config *config, void *type);
/**
* @brief
* @brief a function callback to create an ARC_String stored within a config
*
* @note this function is an ARC_ConfigType_CopyFn callback
*
* @param[out] type the place to store the type copy, should be set to NULL on error
* @param[in] parsedData the parsed data used to copy from. will be <value> as defined in the language
* @param[in] config the config that is reading in the data, can be used within the copy function to add a new type (check ARC_ConfigType_SpriteCopyFn for an example)
* @param[in] userdata userdata that was stored in the type during type register
*/
void ARC_ConfigType_StringCopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata);
/**
* @brief
* @brief a function callback to destroy an ARC_String type
*
* @note this function is an ARC_ConfigType_DestroyFn callback
*
* @param[in] config the config that is destroying the data, can be used within the destroy function to remove a previously added tag (check ARC_ConfigType_SpriteDestroyFn for an example)
* @param[in] type the type to be destroyed
*/
void ARC_ConfigType_StringDestroyFn(ARC_Config *config, void *type);