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

Thread-safe context structure for JSON parsing. More...

#include <stdint.h>
#include <pthread.h>
Include dependency graph for json_context.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  json_field_offset_item
 Field offset item structure for JSON parsing. More...
 
struct  json_context
 Thread-safe JSON parsing context This structure replaces global variables to ensure thread safety. More...
 

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

Thread-safe context structure for JSON parsing.

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