#ifndef ARC_STD_PARSER_CHEMICAL_H_ #define ARC_STD_PARSER_CHEMICAL_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_Chemical ARC_Chemical; /** * @brief a function callback to create a type stored within a config */ typedef void (* ARC_ChemicalType_CopyFn)(void **type, ARC_ParserTagToken *parsedData, ARC_Chemical *chemical); /** * @brief a function callback to destroy a type */ typedef void (* ARC_ChemicalType_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_ChemicalType { ARC_ChemicalType_CopyFn copyFn; ARC_ChemicalType_DestroyFn destroyFn; } ARC_ChemicalType; /** * @brief creates the arc config type (a type that loads in chemical files and can have types added to it) */ void ARC_Chemical_Create(ARC_Chemical **chemical); /** * @brief destroys an ARC_Chemical type */ void ARC_Chemical_Destroy(ARC_Chemical *chemical); /** * @brief adds creation and destruction functions for a new user provided type will be used for chemical load and unload functions * * @note this function uses ARC_Chemical_RegisterTypeWithCStr so it shares error messages with that function * * @param[in] chemical the ARC_Chemical 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 chemical file * @param[in] type the copy and destroy functions for the type used on load and unload */ void ARC_Chemical_RegisterType(ARC_Chemical *chemical, ARC_String *typeName, ARC_ChemicalType type); /** * @brief adds creation and destruction functions for a new user provided type * * @param[in] chemical the ARC_Chemical 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 chemical file * @param[in] type the copy and destroy functions for the type used on load and unload */ void ARC_Chemical_RegisterTypeWithCStr(ARC_Chemical *chemical, const char *typeNameCStr, ARC_ChemicalType type); /** * @brief sets current group in config * * @note ARC_Chemical_Get will use this set group * @note this function uses ARC_Chemical_SetGroupWithCStr so it shares error messages with that function * * @param[in] chemical ARC_Config we are setting current group in * @param[in] groupname name of group that will be set */ void ARC_Chemical_SetGroup(ARC_Chemical *chemical, ARC_String *groupName); /** * @brief sets current group in config * * @note ARC_Chemical_Get will use this set group * * @param[in] chemical ARC_Config we are setting current group in * @param[in] groupname name of group that will be set */ void ARC_Chemical_SetGroupWithCStr(ARC_Chemical *chemical, const char *groupName); /** * @brief get a value from a given keyname * * @note name may be prefaced with :: to specify group * * @param[in] chemical ARC_Chemical to get value from * @param[in] energy name of a variable that has been read in * * @return the stored element on success, or NULL on failure */ void *ARC_Chemical_Get(ARC_Chemical *chemical, ARC_String *energy); /** * @brief get a value from a given keyname * * @note name may be prefaced with :: to specify group * @note this function uses ARC_Chemical_Get so it shares error messages with that function * * @param[in] chemical ARC_Chemical to get value from * @param[in] energy name of a variable that has been read in * * @return the stored element on success, or NULL on failure */ void *ARC_Chemical_GetWithCStr(ARC_Chemical *chemical, const char *energy); /** * @brief TODO: write this */ void ARC_Chemical_LoadFromString(ARC_Chemical *chemical, ARC_String **string); /** * @brief TODO: write this */ void ARC_Chemical_LoadFromFile(ARC_Chemical *chemical, ARC_String *path); /** * @brief TODO: write this */ void ARC_Chemical_UnloadFromString(ARC_Chemical *chemical, ARC_String **string); /** * @brief TODO: write this */ void ARC_Chemical_UnloadFromFile(ARC_Chemical *chemical, ARC_String *data); #define ARC_CHEMICAL_DEFAULT_GROUP " " #define ARC_CHEMICAL_GROUP_TAG_NAME "group" #define ARC_CHEMICAL_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_CHEMICAL_TAB 0x01 #define ARC_CHEMICAL_NEWLINE 0x02 #define ARC_CHEMICAL_SPACE 0x03 #define ARC_CHEMICAL_BANG 0x04 #define ARC_CHEMICAL_QUOTE 0x05 #define ARC_CHEMICAL_HASH 0x06 #define ARC_CHEMICAL_DOLLAR 0x07 #define ARC_CHEMICAL_PERCENT 0x08 #define ARC_CHEMICAL_AMPERSAND 0x09 #define ARC_CHEMICAL_SINGLE_QUOTE 0x0A #define ARC_CHEMICAL_OPEN_PAREN 0x0B #define ARC_CHEMICAL_CLOSE_PAREN 0x0C #define ARC_CHEMICAL_ASTERISK 0x0D #define ARC_CHEMICAL_PLUS 0x0E #define ARC_CHEMICAL_COMMA 0x0F #define ARC_CHEMICAL_MINUS 0x10 #define ARC_CHEMICAL_PERIOD 0x11 #define ARC_CHEMICAL_SLASH 0x12 #define ARC_CHEMICAL_NUMBER 0x13 #define ARC_CHEMICAL_COLON 0x14 #define ARC_CHEMICAL_SEMICOLON 0x15 #define ARC_CHEMICAL_LESS_THAN 0x16 #define ARC_CHEMICAL_GREATER_THAN 0x17 #define ARC_CHEMICAL_EQUAL 0x18 #define ARC_CHEMICAL_QUESTION_MARK 0x19 #define ARC_CHEMICAL_AT 0x1A #define ARC_CHEMICAL_ALPHA_UPPER_CHAR 0x1B #define ARC_CHEMICAL_OPEN_BRACKET 0x1C #define ARC_CHEMICAL_BACKSLASH 0x1D #define ARC_CHEMICAL_CLOSE_BRACKET 0x1E #define ARC_CHEMICAL_CARET 0x1F #define ARC_CHEMICAL_UNDERSCORE 0x20 #define ARC_CHEMICAL_GRAVE 0x21 #define ARC_CHEMICAL_ALPHA_LOWER_CHAR 0x22 #define ARC_CHEMICAL_OPEN_CURLY_BRACE 0x23 #define ARC_CHEMICAL_VERTICAL_LINE 0x24 #define ARC_CHEMICAL_CLOSE_CURLY_BRACE 0x25 #define ARC_CHEMICAL_TILDE 0x26 #define ARC_CHEMICAL_LANGUAGE 0x27 #define ARC_CHEMICAL_GROUP 0x28 #define ARC_CHEMICAL_GROUP_NAME 0x29 #define ARC_CHEMICAL_GROUP_ARGS 0x2A #define ARC_CHEMICAL_VARIABLE_LINES 0x2B #define ARC_CHEMICAL_VARIABLE_LINE 0x2C #define ARC_CHEMICAL_ALLOW_SPACE 0x2D #define ARC_CHEMICAL_TYPE 0x2E #define ARC_CHEMICAL_VALUE 0x2F #define ARC_CHEMICAL_NESTED_VALUE 0x30 #define ARC_CHEMICAL_VALUE_ARGS 0x31 #define ARC_CHEMICAL_VARIABLE 0x32 #define ARC_CHEMICAL_VARIABLE_NAME 0x33 #define ARC_CHEMICAL_VARIABLE_CHAR 0x34 #define ARC_CHEMICAL_STRING 0x35 #define ARC_CHEMICAL_STRING_CHARS 0x36 #define ARC_CHEMICAL_STRING_CHAR 0x37 #define ARC_CHEMICAL_ESCAPE_CHAR 0x38 #define ARC_CHEMICAL_NUMBER_SIGN 0x39 #define ARC_CHEMICAL_NUMBER_TAG 0x3A #define ARC_CHEMICAL_WHITESPACE 0x3B #ifdef __cplusplus } #endif #endif //ARC_STD_PARSER_CHEMICAL_H_