c-icap-doc
0.1
|
Arrays which store name/value pair items
More...
Modules | |
Arrays of strings related API | |
Arrays which store name/value pair items | |
Arrays of pointers | |
Arrays of name/pointers to objects pairs | |
Macros | |
#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' | |
Typedefs | |
typedef struct ci_array | ci_array_t |
The ci_array_t objects can store a list of name/value pairs. More... | |
Functions | |
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.
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. |
void ci_array_destroy | ( | ci_array_t * | array | ) |
Destroy an ci_array_t object
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.
array | a pointer to the ci_array_t object |
pos | The position of the item in array |
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
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 |
ci_array_t* ci_array_new | ( | size_t | max_mem_size | ) |
Allocate the required memory and initialize an ci_array_t object
max_mem_size | the maximum memory to use |
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
items | the maximum aray items |
item_size | the items size |
const ci_array_item_t* ci_array_pop | ( | ci_array_t * | array | ) |
Delete the last element of the array.
array | a pointer to the ci_array_t object |
const void* ci_array_search | ( | ci_array_t * | array, |
const char * | name | ||
) |
Search in an array for an item with the given name
array | a pointer to the ci_array_t object |
name | the item to be search for. |