#ifndef ARC_STD_CONFIG_H_ #define ARC_STD_CONFIG_H_ #ifdef __cplusplus extern "C" { #endif #include #include "arc/std/parser.h" /** * @brief the config type for archeus, loads in a config file which syntax is specified in the documentation * @TODO: add documentation link here */ typedef struct ARC_Config ARC_Config; /** * @brief a function callback to create a type stored within a config */ typedef void (* ARC_ConfigType_CopyFn)(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata); /** * @brief a function callback to destroy a type */ typedef void (* ARC_ConfigType_DestroyFn)(void *type); /** * @brief the functions for used for loading and unloading a type, the name will be the key of a hashtable */ typedef struct ARC_ConfigType { ARC_ConfigType_CopyFn copyFn; ARC_ConfigType_DestroyFn destroyFn; void *userdata; } ARC_ConfigType; /** * @brief creates the arc config type (a type that loads in config files and can have types added to it) * * @param[out] ARC_Config to create */ void ARC_Config_Create(ARC_Config **config); /** * @brief destroys an ARC_Config type * * @param[in] config ARC_Config to destroy */ void ARC_Config_Destroy(ARC_Config *config); /** * @brief adds creation and destruction functions for a new user provided type will be used for config load and unload functions * * @note this function uses ARC_Config_RegisterTypeWithCStr so it shares error messages with that function * * @param[in] config the ARC_Config to set the new type into * @param[in] typeName the name of the type like "uint32" or "ARC_Rect" that will be read in from a config file * @param[in] type the copy and destroy functions for the type used on load and unload */ void ARC_Config_RegisterType(ARC_Config *config, ARC_String *typeName, ARC_ConfigType type); /** * @brief adds creation and destruction functions for a new user provided type * * @param[in] config the ARC_Config to set the new type into * @param[in] typeName the name of the type like "uint32" or "ARC_Rect" that will be read in from a config file * @param[in] type the copy and destroy functions for the type used on load and unload */ void ARC_Config_RegisterTypeWithCStr(ARC_Config *config, const char *typeNameCStr, ARC_ConfigType type); /** * @brief sets current group in config * * @note ARC_Config_Get will use this set group * @note this function uses ARC_Config_SetGroupWithCStr so it shares error messages with that function * * @param[in] config ARC_Config we are setting current group in * @param[in] groupname name of group that will be set */ void ARC_Config_SetGroup(ARC_Config *config, ARC_String *groupName); /** * @brief sets current group in config * * @note ARC_Config_Get will use this set group * * @param[in] config ARC_Config we are setting current group in * @param[in] groupname name of group that will be set */ void ARC_Config_SetGroupWithCStr(ARC_Config *config, const char *groupName); /** * @brief get a value from a given name * * @note name should be prefaced with :: to specify group * * @param[in] config ARC_Config to get value from * @param[in] name name of a variable that has been read in * * @return the stored element on success, or NULL on failure */ void *ARC_Config_Get(ARC_Config *config, ARC_String *name); /** * @brief get a value from a given keyname * * @note name should be prefaced with :: to specify group * @note this function uses ARC_Config_Get so it shares error messages with that function * * @param[in] config ARC_Config to get value from * @param[in] name name of a variable that has been read in * * @return the stored element on success, or NULL on failure */ void *ARC_Config_GetWithCStr(ARC_Config *config, const char *name); /** * @brief TODO: write this */ void ARC_Config_LoadFromString(ARC_Config *config, ARC_String **string); /** * @brief TODO: write this */ void ARC_Config_LoadFromFile(ARC_Config *config, ARC_String *path); /** * @brief TODO: write this */ void ARC_Config_LoadFromFileWithCStr(ARC_Config *config, const char *path); /** * @brief TODO: write this */ void ARC_Config_UnloadFromString(ARC_Config *config, ARC_String **string); /** * @brief TODO: write this */ void ARC_Config_UnloadFromFile(ARC_Config *config, ARC_String *data); #define ARC_CONFIG_DEFAULT_GROUP " " #define ARC_CONFIG_GROUP_TAG_NAME "group" #define ARC_CONFIG_GROUP_SEPARATOR "::" //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 #define ARC_CONFIG_SPACE 0x03 #define ARC_CONFIG_BANG 0x04 #define ARC_CONFIG_QUOTE 0x05 #define ARC_CONFIG_HASH 0x06 #define ARC_CONFIG_DOLLAR 0x07 #define ARC_CONFIG_PERCENT 0x08 #define ARC_CONFIG_AMPERSAND 0x09 #define ARC_CONFIG_SINGLE_QUOTE 0x0A #define ARC_CONFIG_OPEN_PAREN 0x0B #define ARC_CONFIG_CLOSE_PAREN 0x0C #define ARC_CONFIG_ASTERISK 0x0D #define ARC_CONFIG_PLUS 0x0E #define ARC_CONFIG_COMMA 0x0F #define ARC_CONFIG_MINUS 0x10 #define ARC_CONFIG_PERIOD 0x11 #define ARC_CONFIG_SLASH 0x12 #define ARC_CONFIG_NUMBER 0x13 #define ARC_CONFIG_COLON 0x14 #define ARC_CONFIG_SEMICOLON 0x15 #define ARC_CONFIG_LESS_THAN 0x16 #define ARC_CONFIG_GREATER_THAN 0x17 #define ARC_CONFIG_EQUAL 0x18 #define ARC_CONFIG_QUESTION_MARK 0x19 #define ARC_CONFIG_AT 0x1A #define ARC_CONFIG_ALPHA_UPPER_CHAR 0x1B #define ARC_CONFIG_OPEN_BRACKET 0x1C #define ARC_CONFIG_BACKSLASH 0x1D #define ARC_CONFIG_CLOSE_BRACKET 0x1E #define ARC_CONFIG_CARET 0x1F #define ARC_CONFIG_UNDERSCORE 0x20 #define ARC_CONFIG_GRAVE 0x21 #define ARC_CONFIG_ALPHA_LOWER_CHAR 0x22 #define ARC_CONFIG_OPEN_CURLY_BRACE 0x23 #define ARC_CONFIG_VERTICAL_LINE 0x24 #define ARC_CONFIG_CLOSE_CURLY_BRACE 0x25 #define ARC_CONFIG_TILDE 0x26 #define ARC_CONFIG_LANGUAGE 0x27 #define ARC_CONFIG_GROUP 0x28 #define ARC_CONFIG_GROUP_NAME 0x29 #define ARC_CONFIG_GROUP_ARGS 0x2A #define ARC_CONFIG_VARIABLE_LINES 0x2B #define ARC_CONFIG_VARIABLE_LINE 0x2C #define ARC_CONFIG_ALLOW_SPACE 0x2D #define ARC_CONFIG_TYPE 0x2E #define ARC_CONFIG_VALUE 0x2F #define ARC_CONFIG_NESTED_VALUE 0x30 #define ARC_CONFIG_VALUE_ARGS 0x31 #define ARC_CONFIG_ARRAY 0x32 #define ARC_CONFIG_VARIABLE 0x33 #define ARC_CONFIG_VARIABLE_NAME 0x34 #define ARC_CONFIG_VARIABLE_CHAR 0x35 #define ARC_CONFIG_STRING 0x36 #define ARC_CONFIG_STRING_CHARS 0x37 #define ARC_CONFIG_STRING_CHAR 0x38 #define ARC_CONFIG_ESCAPE_CHAR 0x39 #define ARC_CONFIG_NUMBER_SIGN 0x3A #define ARC_CONFIG_NUMBER_TAG 0x3B #define ARC_CONFIG_WHITESPACE 0x3C #define ARC_CONFIG_COMMENT 0x3D #define ARC_CONFIG_LINE_COMMENT 0x3E #define ARC_CONFIG_MULTI_LINE_COMMENT 0x3F #define ARC_CONFIG_LINE_CHARS 0x40 #define ARC_CONFIG_MULTI_LINE_CHARS 0x41 #define ARC_CONFIG_COMMENT_CHAR 0x42 /** * @brief TODO: write this */ void ARC_Config_InitStd(ARC_Config *config); /** * @brief */ void ARC_ConfigType_BoolCopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata); /** * @brief */ void ARC_ConfigType_BoolDestroyFn(void *type); /** * @brief */ void ARC_ConfigType_CharCopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata); /** * @brief */ void ARC_ConfigType_CharDestroyFn(void *type); /** * @brief */ void ARC_ConfigType_Int8CopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata); /** * @brief */ void ARC_ConfigType_Int8DestroyFn(void *type); /** * @brief */ void ARC_ConfigType_Uint8CopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata); /** * @brief */ void ARC_ConfigType_Uint8DestroyFn(void *type); /** * @brief */ void ARC_ConfigType_Int16CopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata); /** * @brief */ void ARC_ConfigType_Int16DestroyFn(void *type); /** * @brief */ void ARC_ConfigType_Uint16CopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata); /** * @brief */ void ARC_ConfigType_Uint16DestroyFn(void *type); /** * @brief */ void ARC_ConfigType_Int32CopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata); /** * @brief */ void ARC_ConfigType_Int32DestroyFn(void *type); /** * @brief */ void ARC_ConfigType_Uint32CopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata); /** * @brief */ void ARC_ConfigType_Uint32DestroyFn(void *type); /** * @brief */ void ARC_ConfigType_Int64CopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata); /** * @brief */ void ARC_ConfigType_Int64DestroyFn(void *type); /** * @brief */ void ARC_ConfigType_Uint64CopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata); /** * @brief */ void ARC_ConfigType_Uint64DestroyFn(void *type); /** * @brief */ void ARC_ConfigType_FloatCopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata); /** * @brief */ void ARC_ConfigType_FloatDestroyFn(void *type); /** * @brief */ void ARC_ConfigType_DoubleCopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata); /** * @brief */ void ARC_ConfigType_DoubleDestroyFn(void *type); /** * @brief */ void ARC_ConfigType_StringCopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata); /** * @brief */ void ARC_ConfigType_StringDestroyFn(void *type); #ifdef __cplusplus } #endif #endif //!ARC_STD_CONFIG_H_