-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcsMap.h
More file actions
43 lines (37 loc) · 1.24 KB
/
csMap.h
File metadata and controls
43 lines (37 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef CSMAP_H_INCLUDED
#define CSMAP_H_INCLUDED
#include <stdio.h> //for console printing (debugging)
#include <stdlib.h> //for calloc/free
#include <string.h> //for str___() functions
#include <math.h> //for log10()
//#defines:
#ifndef bool
#define bool char
#define false 0
#define true 1
#define boolToString(bool) (bool ? "true" : "false")
#endif // bool
#ifndef NULL
#define NULL ((void*) 0)
#endif //NULL
typedef struct _csMap
{
char** keys;
char** values;
int entries;
struct _csMap** subMaps;
int* entryTypes; /**< 0 - value, 1 - subMap, 2 - array */
} csMap;
void initCSMap(csMap* map, int numEntries, char* keys[], char* values[], csMap* subMaps[], int* entryType[]);
void jsonToCSMap(csMap* map, char* json);
char* csMapToJson(csMap map);
char* csMapToArray(csMap map);
void stringToCSMap(csMap* map, char* str);
char* traverseCSMapByKey(csMap map, char* key);
csMap* traverseCSMapByKeyGetMap(csMap map, char* key);
bool addDataEntryToCSMap(csMap* map, char* key, char* value);
bool addArrayEntryToCSMap(csMap* map, char* name, csMap arr);
bool addObjEntryToCSMap(csMap* map, char* name, csMap obj);
bool removeEntryFromCSMap(csMap* map, char* key);
void destroyCSMap(csMap* map);
#endif // CSMAP_H_INCLUDED