json-gen-c  0.1.5
json-gen-c generate C code for json manipulation
json_context.c File Reference

Implementation of thread-safe JSON parsing context. More...

#include "json_context.h"
#include "error_codes.h"
#include <stdlib.h>
#include <string.h>
Include dependency graph for json_context.c:

Functions

struct json_contextjson_context_new (void)
 Create a new JSON parsing context.
 
void json_context_free (struct json_context *ctx)
 Free a JSON parsing context.
 
int json_context_init (struct json_context *ctx, struct json_field_offset_item *field_items, int item_count, int *hash_table, int hash_size)
 Initialize context with field offset data.
 
struct json_field_offset_itemjson_context_find_field (struct json_context *ctx, const char *struct_name, const char *field_name)
 Find field offset item in thread-safe manner.
 

Detailed Description

Implementation of thread-safe JSON parsing context.

Function Documentation

◆ json_context_find_field()

struct json_field_offset_item * json_context_find_field ( struct json_context ctx,
const char *  struct_name,
const char *  field_name 
)

Find field offset item in thread-safe manner.

Parameters
ctxJSON context
struct_nameStructure name
field_nameField name
Returns
Pointer to field offset item, or NULL if not found

◆ json_context_free()

void json_context_free ( struct json_context ctx)

Free a JSON parsing context.

Parameters
ctxContext to free

◆ json_context_init()

int json_context_init ( struct json_context ctx,
struct json_field_offset_item field_items,
int  item_count,
int *  hash_table,
int  hash_size 
)

Initialize context with field offset data.

Parameters
ctxContext to initialize
field_itemsArray of field offset items
item_countNumber of items in array
hash_tableHash table for lookups
hash_sizeSize of hash table
Returns
0 on success, negative on error

◆ json_context_new()

struct json_context * json_context_new ( void  )

Create a new JSON parsing context.

Returns
Pointer to new context, or NULL on failure