File src/yajl_gen.c

Interface to YAJL's JSON generation facilities.


Included Files


Typedef yajl_gen_state

typedef enum {...} yajl_gen_state
enum  
   {  
      yajl_gen_start;  
      yajl_gen_map_start;  
      yajl_gen_map_key;  
      yajl_gen_map_val;  
      yajl_gen_array_start;  
      yajl_gen_in_array;  
      yajl_gen_complete;  
      yajl_gen_error;  
   }  

Type struct yajl_gen_t

struct yajl_gen_t
struct yajl_gen_t  
   {  
      unsigned int flags;  
      unsigned int depth;  
      const char* indentString;  
      yajl_gen_state state[128];  
      yajl_print_t print;  
      void* ctx;  
      yajl_alloc_funcs alloc;  
   }  

Global Function yajl_gen_alloc()

allocate a generator handle

yajl_gen yajl_gen_alloc ( const yajl_alloc_funcs* afs )
\param allocFuncs an optional pointer to a structure which allows the client to overide the memory allocation used by yajl. May be NULL, in which case malloc/free/realloc will be used.
\returns an allocated handle on success, NULL on failure (bad params)

Prototyped in: src/yajl/yajl_gen.h
Calls: yajl_buf_alloc() src/yajl_buf.c
  yajl_set_default_alloc_funcs() src/yajl_alloc.c
  memset()
Called by: main() reformatter/json_reformat.c
References Functions: yajl_buf_append() src/yajl_buf.c

Global Function yajl_gen_array_close()

yajl_gen_status yajl_gen_array_close ( yajl_gen g )
Prototyped in: src/yajl/yajl_gen.h
Calls: strlen()
Called by: reformat_end_array() reformatter/json_reformat.c

Global Function yajl_gen_array_open()

yajl_gen_status yajl_gen_array_open ( yajl_gen g )
Prototyped in: src/yajl/yajl_gen.h
Calls: strlen()
Called by: reformat_start_array() reformatter/json_reformat.c

Global Function yajl_gen_bool()

yajl_gen_status yajl_gen_bool ( yajl_gen g, int boolean )
Prototyped in: src/yajl/yajl_gen.h
Calls: strlen()
Called by: reformat_boolean() reformatter/json_reformat.c

Global Function yajl_gen_clear()

clear yajl's output buffer, but maintain all internal generation state. This function will not "reset" the generator state, and is intended to enable incremental JSON outputing.

void yajl_gen_clear ( yajl_gen g )

Prototyped in: src/yajl/yajl_gen.h
Calls: yajl_buf_clear() src/yajl_buf.c
Called by: main() reformatter/json_reformat.c
References Functions: yajl_buf_append() src/yajl_buf.c

Global Function yajl_gen_config()

allow the modification of generator options subsequent to handle allocation (via yajl_alloc)

int yajl_gen_config ( yajl_gen g, yajl_gen_option opt, ... )
\returns zero in case of errors, non-zero otherwise

Prototyped in: src/yajl/yajl_gen.h
Calls: yajl_buf_free() src/yajl_buf.c
  __builtin_va_arg(), __builtin_va_end(), __builtin_va_start()
Called by: main() reformatter/json_reformat.c

Global Function yajl_gen_double()

generate a floating point number. number may not be infinity or NaN, as these have no representation in JSON. In these cases the generator will return 'yajl_gen_invalid_number'

yajl_gen_status yajl_gen_double ( yajl_gen g, double number )

Prototyped in: src/yajl/yajl_gen.h
Calls: __isinfd(), __isinff(), __isinfl(), __isnand(), __isnanf(), __isnanl(), sprintf(), strcat(), strlen(), strspn()

Global Function yajl_gen_free()

free a generator handle

void yajl_gen_free ( yajl_gen g )

Prototyped in: src/yajl/yajl_gen.h
Calls: yajl_buf_free() src/yajl_buf.c
Called by: main() reformatter/json_reformat.c
References Functions: yajl_buf_append() src/yajl_buf.c

Global Function yajl_gen_get_buf()

access the null terminated generator buffer. If incrementally outputing JSON, one should call yajl_gen_clear to clear the buffer. This allows stream generation.

yajl_gen_status yajl_gen_get_buf ( yajl_gen g, const unsigned char** buf, size_t* len )

Prototyped in: src/yajl/yajl_gen.h
Calls: yajl_buf_data() src/yajl_buf.c
  yajl_buf_len() src/yajl_buf.c
Called by: main() reformatter/json_reformat.c
References Functions: yajl_buf_append() src/yajl_buf.c

Global Function yajl_gen_integer()

yajl_gen_status yajl_gen_integer ( yajl_gen g, long long int number )
Prototyped in: src/yajl/yajl_gen.h
Calls: sprintf(), strlen()

Global Function yajl_gen_map_close()

yajl_gen_status yajl_gen_map_close ( yajl_gen g )
Prototyped in: src/yajl/yajl_gen.h
Calls: strlen()
Called by: reformat_end_map() reformatter/json_reformat.c

Global Function yajl_gen_map_open()

yajl_gen_status yajl_gen_map_open ( yajl_gen g )
Prototyped in: src/yajl/yajl_gen.h
Calls: strlen()
Called by: reformat_start_map() reformatter/json_reformat.c

Global Function yajl_gen_null()

yajl_gen_status yajl_gen_null ( yajl_gen g )
Prototyped in: src/yajl/yajl_gen.h
Calls: strlen()
Called by: reformat_null() reformatter/json_reformat.c

Global Function yajl_gen_number()

yajl_gen_status yajl_gen_number ( yajl_gen g, const char* s, size_t l )
Prototyped in: src/yajl/yajl_gen.h
Calls: strlen()
Called by: reformat_number() reformatter/json_reformat.c

Global Function yajl_gen_reset()

Reset the generator state. Allows a client to generate multiple json entities in a stream. The "sep" string will be inserted to separate the previously generated entity from the current, NULL means *no separation* of entites (clients beware, generating multiple JSON numbers without a separator, for instance, will result in ambiguous output)

void yajl_gen_reset ( yajl_gen g, const char* sep )
Note: this call will not clear yajl's output buffer. This may be accomplished explicitly by calling yajl_gen_clear()

Prototyped in: src/yajl/yajl_gen.h
Calls: memset(), strlen()
Called by: reformat_boolean() reformatter/json_reformat.c
  reformat_end_array() reformatter/json_reformat.c
  reformat_end_map() reformatter/json_reformat.c
  reformat_map_key() reformatter/json_reformat.c
  reformat_null() reformatter/json_reformat.c
  reformat_number() reformatter/json_reformat.c
  reformat_start_array() reformatter/json_reformat.c
  reformat_start_map() reformatter/json_reformat.c
  reformat_string() reformatter/json_reformat.c

Global Function yajl_gen_string()

yajl_gen_status yajl_gen_string ( yajl_gen g, const unsigned char* str, size_t len )
Prototyped in: src/yajl/yajl_gen.h
Calls: yajl_string_encode() src/yajl_encode.c
  yajl_string_validate_utf8() src/yajl_encode.c
  strlen()
Called by: reformat_map_key() reformatter/json_reformat.c
  reformat_string() reformatter/json_reformat.c