Verilog Documentation Generator
veridoc-json.h File Reference

Provides declarations of utility functions for writing JSON data to a file stream. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "verilog-parser/src/verilog_ast_common.h"

Go to the source code of this file.

Data Structures

struct  json_file
 A simple structure for helping to write out JSON encoded data. More...
 
struct  json_kvp
 Stores a single <key,value> pair. More...
 
struct  json_object
 A holder for a new json object or collection of properties. More...
 

Enumerations

enum  json_kvp_type { JSON_KVP_INT, JSON_KVP_STR, JSON_KVP_LIST, JSON_KVP_OBJ }
 Describes the type of object stored in a json_kvp. More...
 

Functions

void json_close_file (json_file *tofree)
 Frees the memory allocated to a json_file construct and closes the file. More...
 
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. More...
 
json_filejson_new_file (char *path)
 Creates a new json file handle. More...
 
json_kvpjson_new_kvp (char *key, json_kvp_type type)
 Creates and returns a new KVP object with the supplied key and datatype.
 
json_object * json_new_object ()
 Creates and returns a pointer to a new json object.
 
void json_object_add_int (json_object *obj, char *key, int value)
 Adds an integer and associated key to the supplied object.
 
void json_object_add_list (json_object *obj, char *key, json_object *list)
 Adds a list and associated key to the supplied object.
 
void json_object_add_object (json_object *obj, char *key, json_object *value)
 Adds a object and associated key to the supplied object.
 
void json_object_add_string (json_object *obj, char *key, char *value)
 Adds a string and associated key to the supplied object.
 

Detailed Description

Provides declarations of utility functions for writing JSON data to a file stream.

Provides Funcions for:

  • Creating new output files
  • Creating the main variables for the files.
  • Adding new key,value pairs for
    • strings
    • numbers
    • lists
  • Maintaining and properly emitting lists.
  • Properly closing all of the constructs.

Enumeration Type Documentation

Describes the type of object stored in a json_kvp.

Enumerator
JSON_KVP_INT 

Value is an integer (int)

JSON_KVP_STR 

Value is a string (char*)

JSON_KVP_LIST 

Value is a json_list.

JSON_KVP_OBJ 

Value is a json_object.

Function Documentation

void json_close_file ( json_file tofree)

Frees the memory allocated to a json_file construct and closes the file.

Frees the memory allocated to a json_file construct and closes the file.

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.

Parameters
[in]varName- The name of the first variable (var) in the file, which will hold the forthcoming JSON data structure. Iff NULL, no var X= will be emitted.
[in]varName- The name of the first variable (var) in the file, which will hold the forthcoming JSON data structure. Iff NULL, no var X= will be emitted.
[in]as_list- Emit using the syntax for a list ([...]) rather than an object ({...}).
json_file* json_new_file ( char *  path)

Creates a new json file handle.

Parameters
[in]path- File path of the file to create / overwrite.
Returns
a json_file construct if the output path can be opened, else NULL.
Parameters
[in]path- File path of the file to create / overwrite.
[in]varName- The name of the first variable (var) in the file, which will hold the forthcoming JSON data structure. Iff NULL, no var X= will be emitted.
Returns
a json_file construct if the output path can be opened, else NULL.