Archeus 0.0.0
A C library and game engine that focuses on documentation
Loading...
Searching...
No Matches
csv.h
Go to the documentation of this file.
1#ifndef ARC_STD_PARSER_PARSERLANG_H_
2#define ARC_STD_PARSER_PARSERLANG_H_
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include "arc/std/bool.h"
9#include "arc/std/parser.h"
10#include "arc/std/string.h"
11#include <stdint.h>
12
13/*
14<line> -> <data> NEWLINE <line> | <data> | NEWLINE <line> | LAMBDA
15<data> -> <string> COMMA <data> | <string>
16<string> -> <nonCommaChar> <string> | <nonCommaChar>
17<nonCommaChar> -> CHAR_BEFORE_COMMA | CHAR_AFTER_COMMA
18*/
19
20/**
21 * @brief a callback for the csv parser to use to cast that data the stored data
22 *
23 * @note this callback will only be called on non-header data
24 *
25 * @param[in/out] data the csv data casted into the users type
26 * @param[in] string an value of the csv as a string
27*/
28typedef void (* ARC_ParserCSV_CastTypeFn)(void **data, ARC_String *string);
29
30/**
31 * @brief a callback for the csv parser to use to free csv data
32 *
33 * @note this callback will only be called on non-header data
34 *
35 * @param[in] data the csv data to free
36*/
37typedef void (* ARC_ParserCSV_DestroyTypeFn)(void *data);
38
39/**
40 * @brief defines a csv data type, data is set by the callback passed in when createing a parserCSV as parser
41 *
42 * @note this data can be retieved after parsing by calling get data, check arc/std/parser.h for more information
43*/
52
53/**
54 * @brief creates a parser for the Parser Lang
55 *
56 * @note the rules will be inited for the parser lang
57 * @note the parsed data will be saved as a vector of ARC_ParserLanguageTag
58 *
59 * @param[out] parser the parser to create
60*/
62
63#define ARC_PARSER_CSV_CHAR_COMMA 1
64#define ARC_PARSER_CSV_CHAR_NEWLINE 2
65#define ARC_PARSER_CSV_CHAR_BEFORE_COMMA 3
66#define ARC_PARSER_CSV_CHAR_AFTER_COMMA 4
67#define ARC_PARSER_CSV_LINE 5
68#define ARC_PARSER_CSV_DATA 6
69#define ARC_PARSER_CSV_STRING 7
70#define ARC_PARSER_CSV_NON_COMMA_CHAR 8
71
72#ifdef __cplusplus
73}
74#endif
75
76#endif //ARC_STD_PARSER_PARSERLANG_H_
#define ARC_Bool
Definition bool.h:10
struct ARC_ParserCSVData ARC_ParserCSVData
defines a csv data type, data is set by the callback passed in when createing a parserCSV as parser
void(* ARC_ParserCSV_CastTypeFn)(void **data, ARC_String *string)
a callback for the csv parser to use to cast that data the stored data
Definition csv.h:28
void(* ARC_ParserCSV_DestroyTypeFn)(void *data)
a callback for the csv parser to use to free csv data
Definition csv.h:37
void ARC_ParserCSV_CreateAsParser(ARC_Parser **parser, ARC_Bool header, ARC_ParserCSV_CastTypeFn castTypeFn, ARC_ParserCSV_DestroyTypeFn destroyTypeFn)
creates a parser for the Parser Lang
struct ARC_Parser ARC_Parser
a parser type
Definition parser.h:16
defines a csv data type, data is set by the callback passed in when createing a parserCSV as parser
Definition csv.h:44
uint32_t height
Definition csv.h:49
uint32_t width
Definition csv.h:48
void *** data
Definition csv.h:50
ARC_String ** headers
Definition csv.h:46
ARC_Bool hasHeader
Definition csv.h:45
substring position within a string
Definition string.h:14