Nyx Node
Loading...
Searching...
No Matches
Collaboration diagram for JSON Dict Object:

Data Structures

struct  nyx_dict_iter_t
 Struct describing a JSON dict iterator. More...
 
struct  nyx_dict_t
 Struct describing a JSON dict object. More...
 

Macros

#define NYX_DICT_ITER(dict)    ((nyx_dict_iter_t) {.idx = 0, .head = ((nyx_dict_t *) (dict))->head})
 Initializes a JSON dict iterator.
 

Typedefs

typedef struct nyx_dict_s nyx_dict_t
 

Functions

nyx_dict_tnyx_dict_t::nyx_dict_new (void)
 Allocates a new JSON dict object.
 
void nyx_dict_t::nyx_dict_free (nyx_dict_t *object)
 Frees memory of the provided JSON dict object.
 
void nyx_dict_t::nyx_dict_clear (nyx_dict_t *object)
 Clears the content of the provided JSON dict object.
 
void nyx_dict_t::nyx_dict_del (nyx_dict_t *object, STR_t key)
 Deletes the entry of the provided key.
 
bool nyx_dict_t::nyx_dict_iterate (nyx_dict_iter_t *iter, STR_t *key, nyx_object_t **object)
 Iterates over a JSON dict object.
 
nyx_object_tnyx_dict_t::nyx_dict_get (const nyx_dict_t *object, STR_t key)
 Gets the JSON object of the provided key.
 
bool nyx_dict_t::nyx_dict_set (nyx_dict_t *object, STR_t key, void *value)
 Sets a JSON object in the provided JSON dict object.
 
size_t nyx_dict_t::nyx_dict_size (const nyx_dict_t *object)
 Gets the number of items in the provided JSON dict object.
 
str_t nyx_dict_t::nyx_dict_to_string (const nyx_dict_t *object)
 Returns a string representing the provided JSON dict object.
 
__NYX_INLINE__ bool nyx_dict_t::nyx_dict_get_boolean (const nyx_dict_t *object, STR_t key)
 Gets a boolean value of the provided key.
 
__NYX_INLINE__ double nyx_dict_t::nyx_dict_get_number (const nyx_dict_t *object, STR_t key)
 Gets a number value of the provided key.
 
__NYX_INLINE__ STR_t nyx_dict_t::nyx_dict_get_string (const nyx_dict_t *object, STR_t key)
 Gets a C string value of the provided key.
 

Detailed Description

JSON Dict Object.

Macro Definition Documentation

◆ NYX_DICT_ITER

#define NYX_DICT_ITER (   dict)     ((nyx_dict_iter_t) {.idx = 0, .head = ((nyx_dict_t *) (dict))->head})

Initializes a JSON dict iterator.

Parameters
dictJSON dict.

Definition at line 1176 of file nyx_node.h.

Function Documentation

◆ nyx_dict_new()

nyx_dict_t * nyx_dict_new ( void  )

Allocates a new JSON dict object.

Returns
The new JSON dict object.

Definition at line 32 of file json_dict.c.

◆ nyx_dict_free()

void nyx_dict_free ( nyx_dict_t object)

Frees memory of the provided JSON dict object.

Parameters
objectJSON dict object.

Definition at line 54 of file json_dict.c.

◆ nyx_dict_clear()

void nyx_dict_clear ( nyx_dict_t object)

Clears the content of the provided JSON dict object.

Parameters
objectJSON dict object.

Definition at line 94 of file json_dict.c.

◆ nyx_dict_del()

void nyx_dict_del ( nyx_dict_t object,
STR_t  key 
)

Deletes the entry of the provided key.

Parameters
objectJSON dict object.
keyKey.

Definition at line 101 of file json_dict.c.

◆ nyx_dict_iterate()

bool nyx_dict_iterate ( nyx_dict_iter_t iter,
STR_t key,
nyx_object_t **  object 
)

Iterates over a JSON dict object.

Parameters
iterList iterator.
keyPointer to the current element key.
objectPointer to the current JSON object.
Returns
true while elements remain, false otherwise.
STR_t key;
nyx_object_t *object;
for(nyx_dict_iter_t iter = NYX_DICT_ITER(dict); nyx_dict_iterate(&iter, &key, &object);)
{
...
}
bool nyx_dict_iterate(nyx_dict_iter_t *iter, STR_t *key, nyx_object_t **object)
Iterates over a JSON dict object.
Definition json_dict.c:137
#define NYX_DICT_ITER(dict)
Initializes a JSON dict iterator.
Definition nyx_node.h:1176
#define STR_t
Alias for const char *.
Definition nyx_node.h:71
Struct describing a JSON dict iterator.
Definition nyx_node.h:1162
Struct describing a JSON object.

Definition at line 137 of file json_dict.c.

◆ nyx_dict_get()

nyx_object_t * nyx_dict_get ( const nyx_dict_t object,
STR_t  key 
)

Gets the JSON object of the provided key.

Parameters
objectJSON dict object.
keyKey.
Returns
The JSON object of the provided key or NULL.

Definition at line 160 of file json_dict.c.

◆ nyx_dict_set()

bool nyx_dict_set ( nyx_dict_t object,
STR_t  key,
void *  value 
)

Sets a JSON object in the provided JSON dict object.

Parameters
objectJSON dict object.
keyKey.
valueJSON object to be added.
Returns
true if the value was modified, false otherwise.

Definition at line 179 of file json_dict.c.

◆ nyx_dict_size()

size_t nyx_dict_size ( const nyx_dict_t object)

Gets the number of items in the provided JSON dict object.

Parameters
objectJSON dict object.
Returns
The number of items in the provided JSON dict object.

Definition at line 239 of file json_dict.c.

◆ nyx_dict_to_string()

str_t nyx_dict_to_string ( const nyx_dict_t object)

Returns a string representing the provided JSON dict object.

Parameters
objectJSON dict object.
Returns
A newly allocated string that represents the provided JSON dict object.
Note
Must be freed.

Definition at line 254 of file json_dict.c.

◆ nyx_dict_get_boolean()

__NYX_INLINE__ bool nyx_dict_get_boolean ( const nyx_dict_t object,
STR_t  key 
)

Gets a boolean value of the provided key.

Parameters
objectJSON dict object.
keyKey.
Returns
The related boolean value or false if absent or wrong type.

Definition at line 1323 of file nyx_node.h.

◆ nyx_dict_get_number()

__NYX_INLINE__ double nyx_dict_get_number ( const nyx_dict_t object,
STR_t  key 
)

Gets a number value of the provided key.

Parameters
objectJSON dict object.
keyKey.
Returns
The related number value or NaN if absent or wrong type.

Definition at line 1342 of file nyx_node.h.

◆ nyx_dict_get_string()

__NYX_INLINE__ STR_t nyx_dict_get_string ( const nyx_dict_t object,
STR_t  key 
)

Gets a C string value of the provided key.

Parameters
objectJSON dict object.
keyKey.
Returns
The related C string value or NULL if absent or wrong type.

Definition at line 1361 of file nyx_node.h.