2024-12-22 23:31:37 -07:00
# ifndef ARC_STD_PARSER_CHEMICAL_H_
# define ARC_STD_PARSER_CHEMICAL_H_
# ifdef __cplusplus
extern " C " {
# endif
# include <stdint.h>
2024-12-23 00:16:32 -07:00
# include "arc/std/parser.h"
2024-12-22 23:31:37 -07:00
2024-12-23 00:16:32 -07:00
/**
2025-03-06 04:21:01 -07:00
* @ brief the config type for archeus , loads in a config file which syntax is specified in the documentation
* @ TODO : add documentation link here
2024-12-23 00:16:32 -07:00
*/
2024-12-22 23:31:37 -07:00
typedef struct ARC_Chemical ARC_Chemical ;
2025-03-06 03:11:16 -07:00
/**
2025-03-06 04:21:01 -07:00
* @ brief a function callback to create a type stored within a config
2025-03-06 03:11:16 -07:00
*/
typedef void ( * ARC_ChemicalType_CopyFn ) ( void * * type , ARC_ParserTagToken * parsedData , ARC_Chemical * chemical ) ;
/**
2025-03-06 04:21:01 -07:00
* @ brief a function callback to destroy a type
2025-03-06 03:11:16 -07:00
*/
typedef void ( * ARC_ChemicalType_DestroyFn ) ( void * type ) ;
/**
2025-03-06 04:21:01 -07:00
* @ brief the functions for used for loading and unloading a type , the name will be the key of a hashtable
2025-03-06 03:11:16 -07:00
*/
typedef struct ARC_ChemicalType {
ARC_ChemicalType_CopyFn copyFn ;
ARC_ChemicalType_DestroyFn destroyFn ;
} ARC_ChemicalType ;
2024-12-22 23:31:37 -07:00
/**
2025-03-06 04:21:01 -07:00
* @ brief creates the arc config type ( a type that loads in chemical files and can have types added to it )
2024-12-22 23:31:37 -07:00
*/
2024-12-23 00:16:32 -07:00
void ARC_Chemical_Create ( ARC_Chemical * * chemical ) ;
2024-12-22 23:31:37 -07:00
2024-12-23 00:16:32 -07:00
/**
2025-03-06 04:21:01 -07:00
* @ brief destroys an ARC_Chemical type
2024-12-23 00:16:32 -07:00
*/
void ARC_Chemical_Destroy ( ARC_Chemical * chemical ) ;
2024-12-22 23:31:37 -07:00
/**
2025-03-06 04:21:01 -07:00
* @ 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
2024-12-22 23:31:37 -07:00
*/
2025-03-06 03:11:16 -07:00
void ARC_Chemical_RegisterType ( ARC_Chemical * chemical , ARC_String * typeName , ARC_ChemicalType type ) ;
/**
2025-03-06 04:21:01 -07:00
* @ 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
2025-03-06 03:11:16 -07:00
*/
void ARC_Chemical_RegisterTypeWithCStr ( ARC_Chemical * chemical , const char * typeNameCStr , ARC_ChemicalType type ) ;
2024-12-22 23:31:37 -07:00
2024-12-23 00:16:32 -07:00
/**
* @ brief sets current group in config
*
* @ note ARC_Chemical_Get will use this set group
2025-03-06 04:21:01 -07:00
* @ note this function uses ARC_Chemical_SetGroupWithCStr so it shares error messages with that function
2024-12-23 00:16:32 -07:00
*
* @ 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 ) ;
2025-03-06 04:21:01 -07:00
/**
* @ 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 ) ;
2024-12-23 00:16:32 -07:00
/**
* @ brief get a value from a given keyname
*
* @ note name may be prefaced with < group > : : to specify group
*
* @ param [ in ] chemical ARC_Chemical to get value from
* @ param [ in ] element 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 * element ) ;
2025-03-06 04:21:01 -07:00
/**
* @ brief get a value from a given keyname
*
* @ note name may be prefaced with < group > : : to specify group
2025-03-09 06:03:38 -06:00
* @ note this function uses ARC_Chemical_Get so it shares error messages with that function
2025-03-06 04:21:01 -07:00
*
* @ param [ in ] chemical ARC_Chemical to get value from
* @ param [ in ] element 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 * element ) ;
2024-12-23 00:16:32 -07:00
/**
* @ brief TODO : write this
*/
2025-03-06 04:21:01 -07:00
void ARC_Chemical_LoadFromString ( ARC_Chemical * chemical , ARC_String * * string ) ;
2024-12-23 00:16:32 -07:00
/**
* @ brief TODO : write this
*/
2025-03-06 04:21:01 -07:00
void ARC_Chemical_LoadFromFile ( ARC_Chemical * chemical , ARC_String * path ) ;
2024-12-23 00:16:32 -07:00
/**
* @ brief TODO : write this
*/
2025-03-06 04:21:01 -07:00
void ARC_Chemical_UnloadFromString ( ARC_Chemical * chemical , ARC_String * * string ) ;
2024-12-23 00:16:32 -07:00
/**
* @ brief TODO : write this
*/
2025-03-06 04:21:01 -07:00
void ARC_Chemical_UnloadFromFile ( ARC_Chemical * chemical , ARC_String * data ) ;
2024-12-22 23:31:37 -07:00
2025-03-09 06:03:38 -06:00
# 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_WHITESPACE 0x39
# define ARC_CHEMICAL_NUMBER_TAG 0x3A
2024-12-22 23:31:37 -07:00
# ifdef __cplusplus
}
# endif
# endif //ARC_STD_PARSER_CHEMICAL_H_