MeterLogger
Data Structures | Macros | Functions
jsontree.h File Reference
#include "c_types.h"
#include "json/json.h"
Include dependency graph for jsontree.h:

Go to the source code of this file.

Data Structures

struct  jsontree_context
 
struct  jsontree_value
 
struct  jsontree_string
 
struct  jsontree_int
 
struct  jsontree_callback
 
struct  jsontree_pair
 
struct  jsontree_object
 
struct  jsontree_array
 

Macros

#define JSONTREE_MAX_DEPTH   10
 
#define JSONTREE_STRING(text)   {JSON_TYPE_STRING, (text)}
 
#define JSONTREE_PAIR(name, value)   {(name), (struct jsontree_value *)(value)}
 
#define JSONTREE_CALLBACK(output, set)   {JSON_TYPE_CALLBACK, (output), (set)}
 
#define JSONTREE_OBJECT(name, ...)
 
#define JSONTREE_PAIR_ARRAY(value)   (struct jsontree_value *)(value)
 
#define JSONTREE_ARRAY(name, ...)
 
#define JSONTREE_OBJECT_EXT(name, ...)
 

Functions

void jsontree_setup (struct jsontree_context *js_ctx, struct jsontree_value *root, int(*putchar)(int))
 
void jsontree_reset (struct jsontree_context *js_ctx)
 
const char * jsontree_path_name (const struct jsontree_context *js_ctx, int depth)
 
void jsontree_write_int (const struct jsontree_context *js_ctx, int value)
 
void jsontree_write_int_array (const struct jsontree_context *js_ctx, const int *text, uint32 length)
 
void jsontree_write_atom (const struct jsontree_context *js_ctx, const char *text)
 
void jsontree_write_string (const struct jsontree_context *js_ctx, const char *text)
 
int jsontree_print_next (struct jsontree_context *js_ctx)
 
struct jsontree_valuejsontree_find_next (struct jsontree_context *js_ctx, int type)
 

Detailed Description

JSON output generation

Author
Niclas Finne nfi@s.nosp@m.ics..nosp@m.se Joakim Eriksson joaki.nosp@m.me@s.nosp@m.ics.s.nosp@m.e

Definition in file jsontree.h.

Macro Definition Documentation

◆ JSONTREE_ARRAY

#define JSONTREE_ARRAY (   name,
  ... 
)
Value:
static struct jsontree_value* jsontree_value_##name[] = {__VA_ARGS__}; \
static struct jsontree_array name = { \
JSON_TYPE_ARRAY, \
sizeof(jsontree_value_##name)/sizeof(struct jsontree_value*), \
jsontree_value_##name }

Definition at line 113 of file jsontree.h.

◆ JSONTREE_CALLBACK

#define JSONTREE_CALLBACK (   output,
  set 
)    {JSON_TYPE_CALLBACK, (output), (set)}

Definition at line 103 of file jsontree.h.

◆ JSONTREE_MAX_DEPTH

#define JSONTREE_MAX_DEPTH   10

Definition at line 49 of file jsontree.h.

◆ JSONTREE_OBJECT

#define JSONTREE_OBJECT (   name,
  ... 
)
Value:
static struct jsontree_pair jsontree_pair_##name[] = {__VA_ARGS__}; \
static struct jsontree_object name = { \
JSON_TYPE_OBJECT, \
sizeof(jsontree_pair_##name)/sizeof(struct jsontree_pair), \
jsontree_pair_##name }
const char * name
Definition: jsontree.h:85

Definition at line 105 of file jsontree.h.

◆ JSONTREE_OBJECT_EXT

#define JSONTREE_OBJECT_EXT (   name,
  ... 
)
Value:
static struct jsontree_pair jsontree_pair_##name[] = {__VA_ARGS__}; \
struct jsontree_object name = { \
JSON_TYPE_OBJECT, \
sizeof(jsontree_pair_##name)/sizeof(struct jsontree_pair), \
jsontree_pair_##name }
const char * name
Definition: jsontree.h:85

Definition at line 120 of file jsontree.h.

◆ JSONTREE_PAIR

#define JSONTREE_PAIR (   name,
  value 
)    {(name), (struct jsontree_value *)(value)}

Definition at line 102 of file jsontree.h.

◆ JSONTREE_PAIR_ARRAY

#define JSONTREE_PAIR_ARRAY (   value)    (struct jsontree_value *)(value)

Definition at line 112 of file jsontree.h.

◆ JSONTREE_STRING

#define JSONTREE_STRING (   text)    {JSON_TYPE_STRING, (text)}

Definition at line 101 of file jsontree.h.

Function Documentation

◆ jsontree_find_next()

struct jsontree_value* jsontree_find_next ( struct jsontree_context js_ctx,
int  type 
)

◆ jsontree_path_name()

const char* jsontree_path_name ( const struct jsontree_context js_ctx,
int  depth 
)

◆ jsontree_print_next()

int jsontree_print_next ( struct jsontree_context js_ctx)

◆ jsontree_reset()

void jsontree_reset ( struct jsontree_context js_ctx)

◆ jsontree_setup()

void jsontree_setup ( struct jsontree_context js_ctx,
struct jsontree_value root,
int(*)(int)  putchar 
)

◆ jsontree_write_atom()

void jsontree_write_atom ( const struct jsontree_context js_ctx,
const char *  text 
)

◆ jsontree_write_int()

void jsontree_write_int ( const struct jsontree_context js_ctx,
int  value 
)

◆ jsontree_write_int_array()

void jsontree_write_int_array ( const struct jsontree_context js_ctx,
const int *  text,
uint32  length 
)

◆ jsontree_write_string()

void jsontree_write_string ( const struct jsontree_context js_ctx,
const char *  text 
)