hat-util  0.6.16
Utility library
json.h File Reference
#include <stdbool.h>
#include <stdint.h>
#include "allocator.h"
#include "buff.h"
Include dependency graph for json.h:

Go to the source code of this file.

Data Structures

union  hat_json_value_t
 

Macros

#define HAT_JSON_MAX_DEPTH   1024
 
#define HAT_JSON_SUCCESS   0
 
#define HAT_JSON_ERROR   (-1)
 
#define HAT_JSON_TOKEN_NULL   0
 
#define HAT_JSON_TOKEN_BOOL   1
 
#define HAT_JSON_TOKEN_INT   2
 
#define HAT_JSON_TOKEN_REAL   3
 
#define HAT_JSON_TOKEN_STR   4
 
#define HAT_JSON_TOKEN_ARR   5
 
#define HAT_JSON_TOKEN_ARR_END   6
 
#define HAT_JSON_TOKEN_OBJ   7
 
#define HAT_JSON_TOKEN_OBJ_KEY   8
 
#define HAT_JSON_TOKEN_OBJ_END   9
 

Typedefs

typedef int hat_json_error_t
 
typedef int hat_json_token_t
 
typedef void *(* hat_json_parser_cb_t) (hat_json_token_t *token, hat_json_value_t *value, void *ctx)
 
typedef hat_json_error_t(* hat_json_writer_cb_t) (char *data, size_t len, void *ctx)
 
typedef struct hat_json_parser_t hat_json_parser_t
 
typedef struct hat_json_writer_t hat_json_writer_t
 

Functions

hat_json_parser_that_json_parser_create (hat_allocator_t *a, hat_json_parser_cb_t cb, void *ctx)
 
hat_json_error_t hat_json_parser_parse (hat_json_parser_t *p, hat_buff_t *buff)
 
bool hat_json_parser_empty (hat_json_parser_t *p)
 
void hat_json_parser_destroy (hat_json_parser_t *p)
 
hat_json_writer_that_json_writer_create (hat_allocator_t *a, hat_json_writer_cb_t cb, void *ctx)
 
void hat_json_writer_write_null (hat_json_writer_t *w)
 
void hat_json_writer_write_bool (hat_json_writer_t *w, bool value)
 
void hat_json_writer_write_int (hat_json_writer_t *w, int64_t value)
 
void hat_json_writer_write_real (hat_json_writer_t *w, double value)
 
void hat_json_writer_write_str (hat_json_writer_t *w, char *value, size_t len)
 
void hat_json_writer_write_arr (hat_json_writer_t *w)
 
void hat_json_writer_write_obj (hat_json_writer_t *w)
 
void hat_json_writer_write_end (hat_json_writer_t *w)
 
void hat_json_writer_destroy (hat_json_writer_t *w)
 

Macro Definition Documentation

◆ HAT_JSON_ERROR

#define HAT_JSON_ERROR   (-1)

◆ HAT_JSON_MAX_DEPTH

#define HAT_JSON_MAX_DEPTH   1024

◆ HAT_JSON_SUCCESS

#define HAT_JSON_SUCCESS   0

◆ HAT_JSON_TOKEN_ARR

#define HAT_JSON_TOKEN_ARR   5

◆ HAT_JSON_TOKEN_ARR_END

#define HAT_JSON_TOKEN_ARR_END   6

◆ HAT_JSON_TOKEN_BOOL

#define HAT_JSON_TOKEN_BOOL   1

◆ HAT_JSON_TOKEN_INT

#define HAT_JSON_TOKEN_INT   2

◆ HAT_JSON_TOKEN_NULL

#define HAT_JSON_TOKEN_NULL   0

◆ HAT_JSON_TOKEN_OBJ

#define HAT_JSON_TOKEN_OBJ   7

◆ HAT_JSON_TOKEN_OBJ_END

#define HAT_JSON_TOKEN_OBJ_END   9

◆ HAT_JSON_TOKEN_OBJ_KEY

#define HAT_JSON_TOKEN_OBJ_KEY   8

◆ HAT_JSON_TOKEN_REAL

#define HAT_JSON_TOKEN_REAL   3

◆ HAT_JSON_TOKEN_STR

#define HAT_JSON_TOKEN_STR   4

Typedef Documentation

◆ hat_json_error_t

typedef int hat_json_error_t

◆ hat_json_parser_cb_t

typedef void*(* hat_json_parser_cb_t) (hat_json_token_t *token, hat_json_value_t *value, void *ctx)

◆ hat_json_parser_t

◆ hat_json_token_t

typedef int hat_json_token_t

◆ hat_json_writer_cb_t

typedef hat_json_error_t(* hat_json_writer_cb_t) (char *data, size_t len, void *ctx)

◆ hat_json_writer_t

Function Documentation

◆ hat_json_parser_create()

hat_json_parser_t* hat_json_parser_create ( hat_allocator_t a,
hat_json_parser_cb_t  cb,
void *  ctx 
)

◆ hat_json_parser_destroy()

void hat_json_parser_destroy ( hat_json_parser_t p)

◆ hat_json_parser_empty()

bool hat_json_parser_empty ( hat_json_parser_t p)

◆ hat_json_parser_parse()

hat_json_error_t hat_json_parser_parse ( hat_json_parser_t p,
hat_buff_t buff 
)

◆ hat_json_writer_create()

hat_json_writer_t* hat_json_writer_create ( hat_allocator_t a,
hat_json_writer_cb_t  cb,
void *  ctx 
)

◆ hat_json_writer_destroy()

void hat_json_writer_destroy ( hat_json_writer_t w)

◆ hat_json_writer_write_arr()

void hat_json_writer_write_arr ( hat_json_writer_t w)

◆ hat_json_writer_write_bool()

void hat_json_writer_write_bool ( hat_json_writer_t w,
bool  value 
)

◆ hat_json_writer_write_end()

void hat_json_writer_write_end ( hat_json_writer_t w)

◆ hat_json_writer_write_int()

void hat_json_writer_write_int ( hat_json_writer_t w,
int64_t  value 
)

◆ hat_json_writer_write_null()

void hat_json_writer_write_null ( hat_json_writer_t w)

◆ hat_json_writer_write_obj()

void hat_json_writer_write_obj ( hat_json_writer_t w)

◆ hat_json_writer_write_real()

void hat_json_writer_write_real ( hat_json_writer_t w,
double  value 
)

◆ hat_json_writer_write_str()

void hat_json_writer_write_str ( hat_json_writer_t w,
char *  value,
size_t  len 
)