#ifndef ARC_STD_PARSER_PARSERLANG_H_ #define ARC_STD_PARSER_PARSERLANG_H_ #ifdef __cplusplus extern "C" { #endif #include "arc/std/bool.h" #include "arc/std/parser.h" #include "arc/std/string.h" #include /* -> NEWLINE | | NEWLINE | LAMBDA -> COMMA | -> COMMON_CHAR | COMON_CHAR */ /** * @brief a callback for the csv parser to use to cast that data the stored data * * @note this callback will only be called on non-header data * * @param[in/out] data the csv data casted into the users type * @param[in] string an value of the csv as a string */ typedef uint32_t (* ARC_ParserCSV_CastTypeFn)(void **data, ARC_String *string); /** * @brief a callback for the csv parser to use to free csv data * * @note this callback will only be called on non-header data * * @param[in] data the csv data to free */ typedef uint32_t (* ARC_ParserCSV_DestroyTypeFn)(void *data); /** * @brief defines a csv data type, data is set by the callback passed in when createing a parserCSV as parser * * @note this data can be retieved after parsing by calling get data, check arc/std/parser.h for more information * @note destroyTypeFn is stored here (for clearing as userdata is not passed in then) but should not be used by anything but the parser */ typedef struct ARC_ParserCSVData { ARC_Bool hasHeader; ARC_String **headers; uint32_t width; uint32_t height; void **data; ARC_ParserCSV_DestroyTypeFn destroyTypeFn; } ARC_ParserCSVData; /** * @brief creates a parser for the Parser Lang * * @note the rules will be inited for the parser lang * @note the parsed data will be saved as a vector of ARC_ParserLanguageTag * * @param[out] parser the parser to create */ void ARC_ParserCSV_CreateAsParser(ARC_Parser **parser, ARC_Bool header, ARC_ParserCSV_CastTypeFn castTypeFn, ARC_ParserCSV_DestroyTypeFn destroyTypeFn); #ifdef __cplusplus } #endif #endif //ARC_STD_PARSER_PARSERLANG_H_