The ROme OpTimistic Simulator  2.0.0
A General-Purpose Multithreaded Parallel/Distributed Simulation Platform
jsmn_helper.h
1 #ifndef JSMN_HELPER_H_
2 #define JSMN_HELPER_H_
3 
4 #include <lib/jsmn.h>
5 #include <stdbool.h>
6 
7 // This typedef is useful in avoiding accidental token modifications
8 typedef const jsmntok_t c_jsmntok_t;
9 
10 int load_and_parse_json_file(const char *file_name, char **file_str_p, jsmntok_t **tokens_p);
11 
15  int a;
16  unsigned b;
17 };
18 
20 #define GNT_CLOSURE_INITIALIZER {0, 0}
21 
23 void init_gnt_closure (struct _gnt_closure_t *closure);
24 
35 c_jsmntok_t* get_next_token (c_jsmntok_t *base_t, c_jsmntok_t *t, struct _gnt_closure_t *closure);
36 
45 c_jsmntok_t* get_value_token_by_key (c_jsmntok_t *base_t, const char *base, c_jsmntok_t *t_obj, const char *key);
46 
54 size_t children_count_token (c_jsmntok_t *base_t, c_jsmntok_t *t);
55 
63 c_jsmntok_t* get_at_token (c_jsmntok_t *base_t, c_jsmntok_t *t, size_t i);
64 
72 int parse_double_token (const char *base, c_jsmntok_t *t, double *result);
73 
81 int parse_unsigned_token (const char *base, c_jsmntok_t *t, unsigned *result);
82 
91 int strcmp_token (const char *base, c_jsmntok_t *t, const char* str);
92 
93 int parse_unsigned_by_key (c_jsmntok_t *base_t, const char *base, c_jsmntok_t *t_obj, const char *key, unsigned *result);
94 int parse_double_by_key (c_jsmntok_t *base_t, const char *base, c_jsmntok_t *t_obj, const char *key, double *result);
95 int parse_boolean_by_key (c_jsmntok_t *base_t, const char *base, c_jsmntok_t *t_obj, const char *key, bool *result);
96 
97 int parse_double_array (c_jsmntok_t *base_t, const char *base, c_jsmntok_t *t_arr, unsigned expected_count, double *result);
98 unsigned parse_string_choice (c_jsmntok_t *base_t, const char *base, c_jsmntok_t *t_str, unsigned cnt, const char *choices[cnt]);
99 
100 
101 #endif /* JSMN_HELPER_H_ */
Definition: jsmn.h:43