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

Data Structures

struct  nyx_list_iter_t
 Struct describing a JSON list iterator. More...
 
struct  nyx_list_t
 Struct describing a JSON list object. More...
 

Macros

#define NYX_LIST_ITER(list)    ((nyx_list_iter_t) {.idx = 0, .head = ((nyx_list_t *) (list))->head})
 Initializes a JSON list iterator.
 

Typedefs

typedef struct nyx_list_s nyx_list_t
 

Functions

nyx_list_tnyx_list_t::nyx_list_new (void)
 Allocates a new JSON list.
 
void nyx_list_t::nyx_list_free (nyx_list_t *object)
 Frees memory of the provided JSON list object.
 
void nyx_list_t::nyx_list_clear (nyx_list_t *object)
 Clears the content of the provided JSON list object.
 
void nyx_list_t::nyx_list_del (nyx_list_t *object, size_t idx)
 Deletes the entry at the provided index.
 
bool nyx_list_t::nyx_list_iterate (nyx_list_iter_t *iter, size_t *idx, nyx_object_t **object)
 Iterates over a JSON list object.
 
nyx_object_tnyx_list_t::nyx_list_get (const nyx_list_t *object, size_t idx)
 Gets the JSON object at the provided index.
 
__NYX_INLINE__ bool nyx_list_t::nyx_list_push (nyx_list_t *object, void *value)
 Pushes a JSON object in the provided JSON list object.
 
size_t nyx_list_t::nyx_list_size (const nyx_list_t *object)
 Gets the number of items in the provided JSON list object.
 
str_t nyx_list_t::nyx_list_to_string (const nyx_list_t *object)
 Returns a string representing the provided JSON list object.
 
__NYX_INLINE__ bool nyx_list_t::nyx_list_get_boolean (const nyx_list_t *object, size_t idx)
 Gets a boolean value at the provided index.
 
__NYX_INLINE__ double nyx_list_t::nyx_list_get_number (const nyx_list_t *object, size_t idx)
 Gets a number value at the provided index.
 
__NYX_INLINE__ STR_t nyx_list_t::nyx_list_get_string (const nyx_list_t *object, size_t idx)
 Gets a C string value at the provided index.
 

Detailed Description

JSON List Object.

Macro Definition Documentation

◆ NYX_LIST_ITER

#define NYX_LIST_ITER (   list)     ((nyx_list_iter_t) {.idx = 0, .head = ((nyx_list_t *) (list))->head})

Initializes a JSON list iterator.

Parameters
listJSON list object.

Definition at line 1416 of file nyx_node.h.

Function Documentation

◆ nyx_list_new()

nyx_list_t * nyx_list_new ( void  )

Allocates a new JSON list.

Returns
The new JSON list.

Definition at line 28 of file json_list.c.

◆ nyx_list_free()

void nyx_list_free ( nyx_list_t object)

Frees memory of the provided JSON list object.

Parameters
objectJSON list object.

Definition at line 50 of file json_list.c.

◆ nyx_list_clear()

void nyx_list_clear ( nyx_list_t object)

Clears the content of the provided JSON list object.

Parameters
objectJSON list object.

Definition at line 90 of file json_list.c.

◆ nyx_list_del()

void nyx_list_del ( nyx_list_t object,
size_t  idx 
)

Deletes the entry at the provided index.

Parameters
objectJSON list object.
idxIndex.

Definition at line 97 of file json_list.c.

◆ nyx_list_iterate()

bool nyx_list_iterate ( nyx_list_iter_t iter,
size_t *  idx,
nyx_object_t **  object 
)

Iterates over a JSON list object.

Parameters
iterList iterator.
idxPointer to the current element index.
objectPointer to the current JSON object.
Returns
true while elements remain, false otherwise.
size_t idx;
nyx_object_t *object;
for(nyx_list_iter_t iter = NYX_LIST_ITER(list); nyx_list_iterate(&iter, &idx, &object);)
{
...
}
#define NYX_LIST_ITER(list)
Initializes a JSON list iterator.
Definition nyx_node.h:1416
bool nyx_list_iterate(nyx_list_iter_t *iter, size_t *idx, nyx_object_t **object)
Iterates over a JSON list object.
Definition json_list.c:133
Struct describing a JSON list iterator.
Definition nyx_node.h:1402
Struct describing a JSON object.

Definition at line 133 of file json_list.c.

◆ nyx_list_get()

nyx_object_t * nyx_list_get ( const nyx_list_t object,
size_t  idx 
)

Gets the JSON object at the provided index.

Parameters
objectJSON list object.
idxIndex.
Returns
The JSON object at the provided index or NULL.

Definition at line 156 of file json_list.c.

◆ nyx_list_push()

__NYX_INLINE__ bool nyx_list_push ( nyx_list_t object,
void *  value 
)

Pushes a JSON object in the provided JSON list object.

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

Definition at line 1531 of file nyx_node.h.

◆ nyx_list_size()

size_t nyx_list_size ( const nyx_list_t object)

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

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

Definition at line 233 of file json_list.c.

◆ nyx_list_to_string()

str_t nyx_list_to_string ( const nyx_list_t object)

Returns a string representing the provided JSON list object.

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

Definition at line 248 of file json_list.c.

◆ nyx_list_get_boolean()

__NYX_INLINE__ bool nyx_list_get_boolean ( const nyx_list_t object,
size_t  idx 
)

Gets a boolean value at the provided index.

Parameters
objectJSON list object.
idxIndex.
Returns
The related boolean value or false if absent or wrong type.

Definition at line 1573 of file nyx_node.h.

◆ nyx_list_get_number()

__NYX_INLINE__ double nyx_list_get_number ( const nyx_list_t object,
size_t  idx 
)

Gets a number value at the provided index.

Parameters
objectJSON list object.
idxIndex.
Returns
The related number value or NaN if absent or wrong type.

Definition at line 1592 of file nyx_node.h.

◆ nyx_list_get_string()

__NYX_INLINE__ STR_t nyx_list_get_string ( const nyx_list_t object,
size_t  idx 
)

Gets a C string value at the provided index.

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

Definition at line 1611 of file nyx_node.h.