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

Classes

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)
 Initializes a JSON list iterator.

Functions

nyx_list_tnyx_list_t::nyx_list_new (void)
 Allocates a new JSON list.
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 *list, 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 *list, size_t idx)
 Gets a text value at the provided index.
__NYX_INLINE__ void nyx_list_t::nyx_list_get_buff (const nyx_list_t *list, size_t idx, __NYX_NULLABLE__ size_t *result_size, __NYX_NULLABLE__ buff_t *result_buff)
 Gets the content of the provided index as a byte buffer.
__NYX_INLINE__ bool nyx_list_t::nyx_list_set_boolean (const nyx_list_t *list, size_t idx, bool value)
 Sets a boolean value of an existing index holding a boolean.
__NYX_INLINE__ bool nyx_list_t::nyx_list_set_number (const nyx_list_t *list, size_t idx, double value)
 Sets a number value of an existing index holding a number.
__NYX_INLINE__ bool nyx_list_t::nyx_list_set_string (const nyx_list_t *list, size_t idx, STR_t value, bool managed)
 Sets a text value of an existing index holding a string.
__NYX_INLINE__ bool nyx_list_t::nyx_list_set_buff (const nyx_list_t *list, size_t idx, size_t size, BUFF_t buff, bool managed)
 Sets the content of an existing index holding a string from a byte buffer.

Detailed Description

JSON List Object.


Class Documentation

◆ nyx_list_iter_t

struct nyx_list_iter_t

Struct describing a JSON list iterator.

Definition at line 1442 of file nyx_node.h.

Public Attributes

size_t idx
 Current zero-based iteration index.
struct nyx_list_node_s * head
 Next JSON object to visit.

◆ nyx_list_t

struct nyx_list_t

Struct describing a JSON list object.

Public Member Functions

nyx_list_tnyx_list_new (void)
 Allocates a new JSON list.
void nyx_list_clear (nyx_list_t *object)
 Clears the content of the provided JSON list object.
void nyx_list_del (nyx_list_t *object, size_t idx)
 Deletes the entry at the provided index.
bool 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_get (const nyx_list_t *object, size_t idx)
 Gets the JSON object at the provided index.
__NYX_INLINE__ bool nyx_list_push (nyx_list_t *object, void *value)
 Pushes a JSON object in the provided JSON list object.
size_t nyx_list_size (const nyx_list_t *object)
 Gets the number of items in the provided JSON list object.
str_t nyx_list_to_string (const nyx_list_t *object)
 Returns a string representing the provided JSON list object.
__NYX_INLINE__ bool 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_get_number (const nyx_list_t *list, size_t idx)
 Gets a number value at the provided index.
__NYX_INLINE__ STR_t nyx_list_get_string (const nyx_list_t *list, size_t idx)
 Gets a text value at the provided index.
__NYX_INLINE__ void nyx_list_get_buff (const nyx_list_t *list, size_t idx, __NYX_NULLABLE__ size_t *result_size, __NYX_NULLABLE__ buff_t *result_buff)
 Gets the content of the provided index as a byte buffer.
__NYX_INLINE__ bool nyx_list_set_boolean (const nyx_list_t *list, size_t idx, bool value)
 Sets a boolean value of an existing index holding a boolean.
__NYX_INLINE__ bool nyx_list_set_number (const nyx_list_t *list, size_t idx, double value)
 Sets a number value of an existing index holding a number.
__NYX_INLINE__ bool nyx_list_set_string (const nyx_list_t *list, size_t idx, STR_t value, bool managed)
 Sets a text value of an existing index holding a string.
__NYX_INLINE__ bool nyx_list_set_buff (const nyx_list_t *list, size_t idx, size_t size, BUFF_t buff, bool managed)
 Sets the content of an existing index holding a string from a byte buffer.

Macro Definition Documentation

◆ NYX_LIST_ITER

#define NYX_LIST_ITER ( list)
Value:
((nyx_list_iter_t) {0, ((nyx_list_t *) (list))->head})
Struct describing a JSON list iterator.
Definition nyx_node.h:1443
Struct describing a JSON list object.

Initializes a JSON list iterator.

Parameters
listJSON list object.

Definition at line 1457 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 18 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 82 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 89 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:1457
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:134
Struct describing a JSON object.

Definition at line 134 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 157 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 1560 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 256 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 with nyx_memory_free.

Definition at line 271 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 1602 of file nyx_node.h.

◆ nyx_list_get_number()

__NYX_INLINE__ double nyx_list_get_number ( const nyx_list_t * list,
size_t idx )

Gets a number value at the provided index.

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

Definition at line 1621 of file nyx_node.h.

◆ nyx_list_get_string()

__NYX_INLINE__ STR_t nyx_list_get_string ( const nyx_list_t * list,
size_t idx )

Gets a text value at the provided index.

Parameters
listJSON list object.
idxIndex.
Returns
The related text value or NULL if absent or wrong type.
Note
The returned text value remains valid until the related string object is modified or released.

Definition at line 1641 of file nyx_node.h.

◆ nyx_list_get_buff()

__NYX_INLINE__ void nyx_list_get_buff ( const nyx_list_t * list,
size_t idx,
__NYX_NULLABLE__ size_t * result_size,
__NYX_NULLABLE__ buff_t * result_buff )

Gets the content of the provided index as a byte buffer.

Parameters
listJSON list object.
idxIndex.
result_sizePointer receiving the number of content bytes.
result_buffPointer receiving the content buffer.
Note
The returned buffer remains valid until the related string object is modified or released.

Definition at line 1662 of file nyx_node.h.

◆ nyx_list_set_boolean()

__NYX_INLINE__ bool nyx_list_set_boolean ( const nyx_list_t * list,
size_t idx,
bool value )

Sets a boolean value of an existing index holding a boolean.

Parameters
listJSON list object.
idxIndex.
valueBoolean value to set.
Returns
true if the value was modified, false otherwise.

Definition at line 1680 of file nyx_node.h.

◆ nyx_list_set_number()

__NYX_INLINE__ bool nyx_list_set_number ( const nyx_list_t * list,
size_t idx,
double value )

Sets a number value of an existing index holding a number.

Parameters
listJSON list object.
idxIndex.
valueNumber value to set.
Returns
true if the value was modified, false otherwise.

Definition at line 1700 of file nyx_node.h.

◆ nyx_list_set_string()

__NYX_INLINE__ bool nyx_list_set_string ( const nyx_list_t * list,
size_t idx,
STR_t value,
bool managed )

Sets a text value of an existing index holding a string.

Parameters
listJSON list object.
idxIndex.
valueText value to set.
managedIf true, ownership of the provided value is transferred to the object.
Returns
true if the value was modified, false otherwise.

Definition at line 1721 of file nyx_node.h.

◆ nyx_list_set_buff()

__NYX_INLINE__ bool nyx_list_set_buff ( const nyx_list_t * list,
size_t idx,
size_t size,
BUFF_t buff,
bool managed )

Sets the content of an existing index holding a string from a byte buffer.

Parameters
listJSON list object.
idxIndex.
sizeNumber of content bytes.
buffContent buffer.
managedIf true, ownership of the provided buffer is transferred to the object.
Returns
true if the value was modified, false otherwise.

Definition at line 1743 of file nyx_node.h.