Adaptive Framework
0.9.0
|
Files | |
file | afw_list.h |
Adaptive Framework afw_list interface helper header. | |
Data Structures | |
struct | afw_list_wrapper_for_array_self_s |
Self for immutable list wrapper for a array. More... | |
Macros | |
#define | AFW_LIST_ERROR_OBJECT_IMMUTABLE AFW_THROW_ERROR_Z(read_only, "List immutable", xctx) |
#define | afw_list_of_create(data_type, p, xctx) afw_list_create_with_options(0, data_type, p, xctx) |
Create an list of a specific data type in memory. More... | |
#define | afw_list_create_generic(p, xctx) afw_list_create_with_options(0, NULL, p, xctx) |
Create an value list in memory. More... | |
#define | AFW_LIST_INITIALIZE_WRAPPER_FOR_ARRAY(instance, _internal, _indirect, _data_type, _count) |
Helper macro to fill out afw_list_wrapper_for_array_self_t. More... | |
#define | AFW_LIST_INITIALIZE_WRAPPER_FOR_ARRAY_P(instance, _internal, _indirect, _data_type, _count, _p) |
Helper macro to fill out afw_list_wrapper_for_array_self_t. More... | |
#define | afw_list_is_immutable(list, xctx) (afw_list_get_setter(list, xctx) == NULL) |
Determine if list is immutable. More... | |
Typedefs | |
typedef struct afw_list_wrapper_for_array_self_s | afw_list_wrapper_for_array_self_t |
Self for immutable list wrapper for a array. More... | |
Functions | |
const afw_list_t * | afw_list_create_with_options (int options, const afw_data_type_t *data_type, const afw_pool_t *p, afw_xctx_t *xctx) |
Create an list in memory with options. More... | |
const afw_list_t * | afw_list_const_create_array_of_objects (const afw_object_t *const *objects, afw_size_t count, const afw_pool_t *p, afw_xctx_t *xctx) |
Create an immutable list from an array of objects. More... | |
const afw_list_t * | afw_list_const_create_array_of_values (const afw_value_t *const *values, afw_size_t count, const afw_pool_t *p, afw_xctx_t *xctx) |
Create an immutable list from an array of values. More... | |
const afw_list_t * | afw_list_const_create_null_terminated_array_of_objects (const afw_object_t *const *objects, const afw_pool_t *p, afw_xctx_t *xctx) |
Create an immutable list from NULL terminated array of objects. More... | |
const afw_list_t * | afw_list_const_create_null_terminated_array_of_values (const afw_value_t *const *values, const afw_pool_t *p, afw_xctx_t *xctx) |
Create an immutable list from NULL terminated array of values. More... | |
const afw_list_t * | afw_list_create_or_clone (const afw_list_t *list, const afw_data_type_t *data_type, afw_boolean_t clone_values, const afw_pool_t *p, afw_xctx_t *xctx) |
Create a clone of a list in memory. More... | |
const afw_list_t * | afw_list_of_create_from_value (const afw_data_type_t *data_type, const afw_value_t *value, const afw_pool_t *p, afw_xctx_t *xctx) |
Create a typed list from a value. More... | |
const afw_list_t * | afw_list_convert_to_list_of_strings (const afw_list_t *list, const afw_pool_t *p, afw_xctx_t *xctx) |
Convert a list to a list of strings. More... | |
afw_list_create_wrapper_for_array (const void *array, afw_boolean_t indirect, const afw_data_type_t *data_type, afw_size_t count, const afw_pool_t *p, afw_xctx_t *xctx) | |
Create a immutable list wrapper for an array. More... | |
afw_list_of_utf8_get_next (const afw_list_t *instance, const afw_iterator_t **iterator, afw_xctx_t *xctx) | |
Get next value from list whose data type cType is afw_utf8_t. More... | |
void | afw_list_set_immutable (const afw_list_t *instance, afw_xctx_t *xctx) |
Set a list to immutable if not already. More... | |
const afw_data_type_t * | afw_list_determine_data_type_and_set_immutable (const afw_list_t *instance, afw_xctx_t *xctx) |
Set list to immutable and determine data type of entries. More... | |
void | afw_list_add_internal (const afw_list_t *instance, const afw_data_type_t *data_type, const void *internal, afw_xctx_t *xctx) |
Call method add of interface afw_list_setter. More... | |
void | afw_list_add_value (const afw_list_t *instance, const afw_value_t *value, afw_xctx_t *xctx) |
Call method add_value of interface afw_list_setter. More... | |
void | afw_list_remove_all_values (const afw_list_t *instance, afw_xctx_t *xctx) |
Call method remove_all_values of interface afw_list_setter. More... | |
void | afw_list_remove_internal (const afw_list_t *instance, const afw_data_type_t *data_type, const void *internal, afw_xctx_t *xctx) |
Call method remove of interface afw_list_setter. More... | |
void | afw_list_remove_value (const afw_list_t *instance, const afw_value_t *value, afw_xctx_t *xctx) |
Call method remove_value of interface afw_list_setter. More... | |
void | afw_list_set_value_by_index (const afw_list_t *instance, afw_size_t index, const afw_value_t *value, afw_xctx_t *xctx) |
Call method set_value_by_index of interface afw_list_setter. More... | |
Variables | |
afw_list_wrapper_for_array_inf | |
inf for afw_list_wrapper_for_array afw_list implementation. More... | |
List API.
#define afw_list_create_generic | ( | p, | |
xctx | |||
) | afw_list_create_with_options(0, NULL, p, xctx) |
Create an value list in memory.
p | to use for the object. |
xctx | of caller. |
Use this function to create a value list that is not associated with an adaptor.
If only values of a single evaluated data type are added, afw_list_get_data_type() will return that data type.
Definition at line 81 of file afw_list.h.
#define AFW_LIST_INITIALIZE_WRAPPER_FOR_ARRAY | ( | instance, | |
_internal, | |||
_indirect, | |||
_data_type, | |||
_count | |||
) |
Helper macro to fill out afw_list_wrapper_for_array_self_t.
instance is pointer to afw_list_wrapper_for_array_self_t.
_internal | array of internal values. |
_indirect | if true array is array of pointers to internal value. |
_data_type | of array. |
_count | of entries in array or -1 for NULL terminated. |
If method afw_list_get_next_value() will be called, use helper macro AFW_LIST_INITIALIZE_WRAPPER_FOR_ARRAY_P() instead. Calling afw_list_get_next() will work fine since it does not allocate memory.
Example:
afw_list_wrapper_for_array_self_t wrapper;
AFW_LIST_INITIALIZE_WRAPPER_FOR_ARRAY(&wrapper, array, data_type, count);
Definition at line 276 of file afw_list.h.
#define AFW_LIST_INITIALIZE_WRAPPER_FOR_ARRAY_P | ( | instance, | |
_internal, | |||
_indirect, | |||
_data_type, | |||
_count, | |||
_p | |||
) |
Helper macro to fill out afw_list_wrapper_for_array_self_t.
instance is pointer to afw_list_wrapper_for_array_self_t.
_internal | array of internal values. |
_indirect | if true array is array of pointers to internal value. |
_data_type | of array. |
_count | of entries in array or -1 for NULL terminated. |
_p | for use by method afw_list_get_next_value(). |
If possible, use AFW_LIST_INITIALIZE_WRAPPER_FOR_ARRAY() instead.
Definition at line 297 of file afw_list.h.
#define afw_list_is_immutable | ( | list, | |
xctx | |||
) | (afw_list_get_setter(list, xctx) == NULL) |
Determine if list is immutable.
instance | of list. |
xctx | of caller. |
Definition at line 454 of file afw_list.h.
#define afw_list_of_create | ( | data_type, | |
p, | |||
xctx | |||
) | afw_list_create_with_options(0, data_type, p, xctx) |
Create an list of a specific data type in memory.
data_type | if list only holds one data type or NULL. |
p | to use for the list. |
xctx | of caller. |
If data_type is NULL and only values of a single evaluated data type are added, afw_list_get_data_type() will return that data type.
Definition at line 64 of file afw_list.h.
Self for immutable list wrapper for a array.
This is self for immutable list wrapper for a array. This can defined and filled out in a local variable instead of calling afw_list_create_wrapper_for_array() if the instance is only needed temporarily. Helper macro AFW_LIST_WRAPPER_FOR_ARRAY_P() can be used to do this.
void afw_list_add_internal | ( | const afw_list_t * | instance, |
const afw_data_type_t * | data_type, | ||
const void * | internal, | ||
afw_xctx_t * | xctx | ||
) |
Call method add of interface afw_list_setter.
instance | Pointer to this value list instance. |
data_type | of internal. |
internal | A value. |
xctx | of caller. |
Definition at line 78 of file afw_list.c.
void afw_list_add_value | ( | const afw_list_t * | instance, |
const afw_value_t * | value, | ||
afw_xctx_t * | xctx | ||
) |
Call method add_value of interface afw_list_setter.
instance | Pointer to this value list instance. |
value | A value. |
xctx | of caller. |
Definition at line 104 of file afw_list.c.
const afw_list_t* afw_list_const_create_array_of_objects | ( | const afw_object_t *const * | objects, |
afw_size_t | count, | ||
const afw_pool_t * | p, | ||
afw_xctx_t * | xctx | ||
) |
Create an immutable list from an array of objects.
values | is address of first value in array. |
count | is number for values. |
p | is pool for result. |
xctx | of caller. |
Definition at line 46 of file afw_list_const_array.c.
const afw_list_t* afw_list_const_create_array_of_values | ( | const afw_value_t *const * | values, |
afw_size_t | count, | ||
const afw_pool_t * | p, | ||
afw_xctx_t * | xctx | ||
) |
Create an immutable list from an array of values.
values | is address of first value in array. |
count | is number for values. |
p | is pool for result. |
xctx | of caller. |
Definition at line 91 of file afw_list_const_array.c.
const afw_list_t* afw_list_const_create_null_terminated_array_of_objects | ( | const afw_object_t *const * | objects, |
const afw_pool_t * | p, | ||
afw_xctx_t * | xctx | ||
) |
Create an immutable list from NULL terminated array of objects.
values | is NULL terminated array of objects. |
p | is pool for result. |
xctx | of caller. |
Definition at line 71 of file afw_list_const_array.c.
const afw_list_t* afw_list_const_create_null_terminated_array_of_values | ( | const afw_value_t *const * | values, |
const afw_pool_t * | p, | ||
afw_xctx_t * | xctx | ||
) |
Create an immutable list from NULL terminated array of values.
values | is NULL terminated array of values. |
p | is pool for result. |
xctx | of caller. |
Definition at line 114 of file afw_list_const_array.c.
const afw_list_t* afw_list_convert_to_list_of_strings | ( | const afw_list_t * | list, |
const afw_pool_t * | p, | ||
afw_xctx_t * | xctx | ||
) |
Convert a list to a list of strings.
list | to convert. |
p | is pool for result. |
xctx | of caller. |
Definition at line 77 of file afw_list_wrapper_for_array.c.
const afw_list_t* afw_list_create_or_clone | ( | const afw_list_t * | list, |
const afw_data_type_t * | data_type, | ||
afw_boolean_t | clone_values, | ||
const afw_pool_t * | p, | ||
afw_xctx_t * | xctx | ||
) |
Create a clone of a list in memory.
list | to clone or NULL. |
data_type | to use if list is NULL. |
clone_values | true will clone values as well. |
p | to use for the list. |
xctx | of caller. |
If data_type is not NULL and list is typed, they must match.
Definition at line 692 of file afw_list_memory.c.
const afw_list_t* afw_list_create_with_options | ( | int | options, |
const afw_data_type_t * | data_type, | ||
const afw_pool_t * | p, | ||
afw_xctx_t * | xctx | ||
) |
Create an list in memory with options.
options | |
data_type | if list only holds one data type or NULL. |
p | to use for the list. |
xctx | of caller. |
If data_type is NULL and only values of a single evaluated data type are added, afw_list_get_data_type() will return that data type.
Definition at line 56 of file afw_list_memory.c.
afw_list_create_wrapper_for_array | ( | const void * | array, |
afw_boolean_t | indirect, | ||
const afw_data_type_t * | data_type, | ||
afw_size_t | count, | ||
const afw_pool_t * | p, | ||
afw_xctx_t * | xctx | ||
) |
Create a immutable list wrapper for an array.
array | of internal values. |
indirect | if true array is array of pointers to internal value. |
data_type | of array. |
count | of entries in array or -1 for NULL terminated. |
p | is pool for result. |
xctx | of caller. |
If indirect is false, array must be an array of data_type->cType. If indirect is true, array must be an array of data_type->cType *.
If count is -1, the array must be a list of pointers. This can either be because data_type->cType ends in an asterisk or the indirect parameter is true.
Definition at line 32 of file afw_list_wrapper_for_array.c.
const afw_data_type_t* afw_list_determine_data_type_and_set_immutable | ( | const afw_list_t * | instance, |
afw_xctx_t * | xctx | ||
) |
Set list to immutable and determine data type of entries.
instance | Pointer to this value list instance. |
xctx | of caller. |
If data type of values in list is not already known and all values is list have the same data type, make the list a list of that data type.
Once a list is set to immutable, all other set calls will throw an error.
Definition at line 60 of file afw_list.c.
const afw_list_t* afw_list_of_create_from_value | ( | const afw_data_type_t * | data_type, |
const afw_value_t * | value, | ||
const afw_pool_t * | p, | ||
afw_xctx_t * | xctx | ||
) |
Create a typed list from a value.
data_type | of list |
value. | |
p | to use for the list. |
xctx | of caller. |
Definition at line 731 of file afw_list_memory.c.
afw_list_of_utf8_get_next | ( | const afw_list_t * | instance, |
const afw_iterator_t ** | iterator, | ||
afw_xctx_t * | xctx | ||
) |
Get next value from list whose data type cType is afw_utf8_t.
instance | of list. |
iterator. | |
xctx | of caller. |
Set the iterator to NULL before the first call and anytime you want to start from the first value again.
Definition at line 19 of file afw_list.c.
void afw_list_remove_all_values | ( | const afw_list_t * | instance, |
afw_xctx_t * | xctx | ||
) |
Call method remove_all_values of interface afw_list_setter.
instance | Pointer to this value list instance. |
xctx | of caller. |
Definition at line 128 of file afw_list.c.
void afw_list_remove_internal | ( | const afw_list_t * | instance, |
const afw_data_type_t * | data_type, | ||
const void * | internal, | ||
afw_xctx_t * | xctx | ||
) |
Call method remove of interface afw_list_setter.
instance | Pointer to this value list instance. |
data_type | of internal. |
internal | A value. |
xctx | of caller. |
Definition at line 147 of file afw_list.c.
void afw_list_remove_value | ( | const afw_list_t * | instance, |
const afw_value_t * | value, | ||
afw_xctx_t * | xctx | ||
) |
Call method remove_value of interface afw_list_setter.
instance | Pointer to this value list instance. |
value | Value. |
xctx | of caller. |
Definition at line 168 of file afw_list.c.
void afw_list_set_immutable | ( | const afw_list_t * | instance, |
afw_xctx_t * | xctx | ||
) |
Set a list to immutable if not already.
instance | Pointer to this value list instance. |
xctx | of caller. |
Once a list is set to immutable, all other set calls will throw an error.
Definition at line 44 of file afw_list.c.
void afw_list_set_value_by_index | ( | const afw_list_t * | instance, |
afw_size_t | index, | ||
const afw_value_t * | value, | ||
afw_xctx_t * | xctx | ||
) |
Call method set_value_by_index of interface afw_list_setter.
instance | Pointer to this value list instance. |
index. | |
value. | |
xctx | of caller. |
Definition at line 188 of file afw_list.c.
afw_list_wrapper_for_array_inf |
inf for afw_list_wrapper_for_array afw_list implementation.
See AFW_LIST_INITIALIZE_WRAPPER_FOR_ARRAY() macro.
Definition at line 254 of file afw_list.h.