Verilog Documentation Generator
veridoc-json.h
Go to the documentation of this file.
1 
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <string.h>
19 #include <assert.h>
20 
21 // For common data structures like linked lists etc.
22 #include "verilog-parser/src/verilog_ast_common.h"
23 
24 #ifndef VERIDOC_JSON_H
25 #define VERIDOC_JSON_H
26 
27 typedef struct json_object_t json_object;
28 
32 typedef struct json_file_t{
33  char * file_path;
34  FILE * fh;
35 } json_file;
36 
37 
44  char * path
45 );
46 
48 void json_close_file(json_file * tofree);
49 
50 // ---------------------------------------------------------------------
51 
56  ast_list * kvps;
57 };
58 
59 
61 json_object * json_new_object();
62 
65  json_object * obj,
66  char * key,
67  char * value
68 );
69 
72  json_object * obj,
73  char * key,
74  int value
75 );
76 
79  json_object * obj,
80  char * key,
81  json_object * list
82 );
83 
86  json_object * obj,
87  char * key,
88  json_object * value
89 );
90 
98 void json_emit_object(
99  json_file * fh,
100  json_object * toemit,
101  char * varName,
102  unsigned char as_list
103 );
104 
105 // ---------------------------------------------------------------------
106 
108 typedef enum json_kvp_type_e{
113 } json_kvp_type;
114 
116 typedef struct json_kvp_t{
117  json_kvp_type type;
118  char * key; //<! The key to the value.
119  union{
120  int integer;
121  char * string;
122  json_object * list;
123  json_object * object;
124  };
125 } json_kvp;
126 
129  char * key,
130  json_kvp_type type
131 );
132 
133 
134 // ---------------------------------------------------------------------
135 
136 #endif
ast_list * kvps
Key value pairs. Each value is a json_kvp.
Definition: veridoc-json.h:56
void json_emit_object(json_file *fh, json_object *toemit, char *varName, unsigned char as_list)
emits the supplied object into the supplied file, with an optional variable name. ...
Definition: veridoc-json.c:122
int integer
IFF type == INT.
Definition: veridoc-json.h:120
Value is a json_object.
Definition: veridoc-json.h:112
void json_close_file(json_file *tofree)
Frees the memory allocated to a json_file construct and closes the file.
Definition: veridoc-json.c:37
json_object * json_new_object()
Creates and returns a pointer to a new json object.
Definition: veridoc-json.c:61
json_file * json_new_file(char *path)
Creates a new json file handle.
Definition: veridoc-json.c:17
json_object * list
IFF type == LIST.
Definition: veridoc-json.h:122
char * string
IFF type == STR.
Definition: veridoc-json.h:121
FILE * fh
The open file handle.
Definition: veridoc-json.h:34
Stores a single <key,value> pair.
Definition: veridoc-json.h:116
void json_object_add_string(json_object *obj, char *key, char *value)
Adds a string and associated key to the supplied object.
Definition: veridoc-json.c:70
json_object * object
IFF type == OBJ.
Definition: veridoc-json.h:123
json_kvp * json_new_kvp(char *key, json_kvp_type type)
Creates and returns a new KVP object with the supplied key and datatype.
Definition: veridoc-json.c:48
json_kvp_type
Describes the type of object stored in a json_kvp.
Definition: veridoc-json.h:108
A holder for a new json object or collection of properties.
Definition: veridoc-json.h:55
void json_object_add_object(json_object *obj, char *key, json_object *value)
Adds a object and associated key to the supplied object.
Definition: veridoc-json.c:103
char * key
What sort of data type does the key point at?
Definition: veridoc-json.h:118
void json_object_add_int(json_object *obj, char *key, int value)
Adds an integer and associated key to the supplied object.
Definition: veridoc-json.c:81
Value is a string (char*)
Definition: veridoc-json.h:110
char * file_path
Output file path.
Definition: veridoc-json.h:33
A simple structure for helping to write out JSON encoded data.
Definition: veridoc-json.h:32
Value is an integer (int)
Definition: veridoc-json.h:109
void json_object_add_list(json_object *obj, char *key, json_object *list)
Adds a list and associated key to the supplied object.
Definition: veridoc-json.c:92
Value is a json_list.
Definition: veridoc-json.h:111