Arrays which store name/value pair items.
More...
|
|
#define | ci_array_value(array, pos) (pos < (array)->count ? (array)->items[pos].value : NULL) |
| | Return the value of item on position 'pos'.
|
| |
|
#define | ci_array_name(array, pos) (pos < (array)->count ? (array)->items[pos].name : NULL) |
| | Return the name of item on position 'pos'.
|
| |
|
#define | ci_array_size(array) ((array)->count) |
| | Return the size of array 'array'.
|
| |
|
| typedef struct ci_array | ci_array_t |
| | The ci_array_t objects can store a list of name/value pairs. More...
|
| |
|
| ci_array_t * | ci_array_new (size_t max_mem_size) |
| | Allocate the required memory and initialize an ci_array_t object. More...
|
| |
| ci_array_t * | ci_array_new2 (size_t items, size_t item_size) |
| | Create and initialize an ci_array_t object for the given number of items. More...
|
| |
| void | ci_array_destroy (ci_array_t *array) |
| | Destroy an ci_array_t object. More...
|
| |
| const ci_array_item_t * | ci_array_add (ci_array_t *array, const char *name, const void *value, size_t size) |
| | Add an name/value pair item to the array. More...
|
| |
| const ci_array_item_t * | ci_array_pop (ci_array_t *array) |
| | Delete the last element of the array. More...
|
| |
| const void * | ci_array_search (ci_array_t *array, const char *name) |
| | Search in an array for an item with the given name. More...
|
| |
| void | ci_array_iterate (const ci_array_t *array, void *data, int(*fn)(void *data, const char *name, const void *)) |
| | Run the given function for each array item. More...
|
| |
| const ci_array_item_t * | ci_array_get_item (ci_array_t *array, int pos) |
| | Get an item of the array. More...
|
| |
Arrays which store name/value pair items.
The ci_array_t objects can store a list of name/value pairs.
Currently can grow up to a fixed size.
| const ci_array_item_t* ci_array_add |
( |
ci_array_t * |
array, |
|
|
const char * |
name, |
|
|
const void * |
value, |
|
|
size_t |
size |
|
) |
| |
Add an name/value pair item to the array.
- Parameters
-
| array | a pointer to the ci_array_t object |
| name | the name part of the name/value pair item to add |
| value | the value part of the name/value pair item to add |
| size | the size of the value part of the new item. |
- Returns
- a pointer to the new array item on success, NULL otherwise
Destroy an ci_array_t object.
- Parameters
-
| array | a pointer to ci_array_t object to be destroyed |
| const ci_array_item_t* ci_array_get_item |
( |
ci_array_t * |
array, |
|
|
int |
pos |
|
) |
| |
Get an item of the array.
- Parameters
-
| array | a pointer to the ci_array_t object |
| pos | The position of the item in array |
- Returns
- a pointer to the array item on success, NULL otherwise
| void ci_array_iterate |
( |
const ci_array_t * |
array, |
|
|
void * |
data, |
|
|
int(*)(void *data, const char *name, const void *) |
fn |
|
) |
| |
Run the given function for each array item.
- Parameters
-
| array | a pointer to the ci_array_t object |
| data | a pointer to data which will be passed on fn function |
| fn | a pointer to the function which will be run for each array item. The iteration will stop if the fn function return non zero value |
Allocate the required memory and initialize an ci_array_t object.
- Parameters
-
| max_mem_size | the maximum memory to use |
- Returns
- the allocated object on success, or NULL on failure
| ci_array_t* ci_array_new2 |
( |
size_t |
items, |
|
|
size_t |
item_size |
|
) |
| |
Create and initialize an ci_array_t object for the given number of items.
- Parameters
-
| items | the maximum aray items |
| item_size | the items size |
- Returns
- the allocated object on success, or NULL on failure
| const ci_array_item_t* ci_array_pop |
( |
ci_array_t * |
array | ) |
|
Delete the last element of the array.
- Parameters
-
| array | a pointer to the ci_array_t object |
- Returns
- a pointer to the popped array item on success, NULL otherwise
| const void* ci_array_search |
( |
ci_array_t * |
array, |
|
|
const char * |
name |
|
) |
| |
Search in an array for an item with the given name.
- Parameters
-
| array | a pointer to the ci_array_t object |
| name | the item to be search for. |
- Returns
- pointer to the value pair of the array item if found, NULL otherwise