1
+ #ifndef NOODLE_PARSER_H
2
+ #define NOODLE_PARSER_H
3
+
4
+ #ifndef NOODLE_NO_STDINT
5
+ # include <stdint.h>
6
+ #endif
7
+
8
+ #ifndef NOODLE_SIZE
9
+ #define NOODLE_SIZE size_t
10
+ #endif
11
+
12
+ #ifndef NOODLE_NO_STDBOOL_H
13
+ #include <stdbool.h>
14
+
15
+ #ifndef NOODLE_BOOL
16
+ #define NOODLE_BOOL bool
17
+ #endif
18
+
19
+ #ifndef NOODLE_TRUE
20
+ #define NOODLE_TRUE true
21
+ #endif
22
+ #ifndef NOODLE_FALSE
23
+ #define NOODLE_FALSE false
24
+ #endif
25
+ #endif
26
+
27
+ #ifndef NOODLE_NO_STDLIB_H
28
+ #include <stdlib.h>
29
+
30
+ #ifndef NOODLE_MALLOC
31
+ #define NOODLE_CALLOC (count , type ) calloc(count, sizeof(type))
32
+ #endif
33
+ #ifndef NOODLE_FREE
34
+ #define NOODLE_FREE (ptr ) free(ptr)
35
+ #endif
36
+
37
+ #ifndef NOODLE_MEMCPY
38
+ #define NOODLE_MEMCPY (dest , src , size ) memcpy(dest, src, size)
39
+ #endif
40
+ #endif
41
+
42
+ #ifndef NOODLE_NO_STRING_H
43
+ #include <string.h>
44
+ #endif
45
+
46
+
47
+ typedef enum NoodleResult_t
48
+ {
49
+ NOODLE_SUCCESS ,
50
+ NOODLE_MEMORY_ALLOC_ERROR ,
51
+ NOODLE_UNEXPECTED_TOKEN_ERROR ,
52
+ } NoodleResult_t ;
53
+
54
+ typedef enum NoodleType_t
55
+ {
56
+ NOODLE_TYPE_GROUP ,
57
+ NOODLE_TYPE_ARRAY ,
58
+ NOODLE_TYPE_INTEGER ,
59
+ NOODLE_TYPE_FLOAT ,
60
+ NOODLE_TYPE_BOOLEAN ,
61
+ NOODLE_TYPE_STRING ,
62
+ } NoodleType_t ;
63
+
64
+ typedef struct Noodle_t Noodle_t ;
65
+ typedef struct NoodleGroup_t NoodleGroup_t ;
66
+ typedef struct NoodleValue_t NoodleValue_t ;
67
+ typedef struct NoodleArray_t NoodleArray_t ;
68
+
69
+ NoodleGroup_t * noodleParse (const char * pContent , size_t contentSize , char * pErrorBuffer , size_t bufferSize );
70
+ NoodleGroup_t * noodleGroupFrom (const NoodleGroup_t * group , const char * name );
71
+ int noodleIntFrom (const NoodleGroup_t * group , const char * name );
72
+ float noodleFloatFrom (const NoodleGroup_t * group , const char * name );
73
+ NOODLE_BOOL noodleBoolFrom (const NoodleGroup_t * group , const char * name );
74
+ const char * noodleStringFrom (const NoodleGroup_t * group , const char * name );
75
+ const NoodleArray_t * noodleArrayFrom (const NoodleGroup_t * group , const char * name );
76
+ size_t noodleCount (const Noodle_t * noodle );
77
+ int noodleIntAt (const NoodleArray_t * array , size_t index );
78
+ float noodleFloatAt (const NoodleArray_t * array , size_t index );
79
+ NOODLE_BOOL noodleBoolAt (const NoodleArray_t * array , size_t index );
80
+ const char * noodleStringAt (const NoodleArray_t * array , size_t index );
81
+ void noodleFree (Noodle_t * noodle );
82
+
83
+ #endif // NOODLE_PARSER_H
0 commit comments