Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Files | Data Structures | Macros | Typedefs | Functions | Variables

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_tafw_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_tafw_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_tafw_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_tafw_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_tafw_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_tafw_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_tafw_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_tafw_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_tafw_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...
 

Detailed Description

List API.

Macro Definition Documentation

◆ afw_list_create_generic

#define afw_list_create_generic (   p,
  xctx 
)     afw_list_create_with_options(0, NULL, p, xctx)

Create an value list in memory.

Parameters
pto use for the object.
xctxof caller.
Returns
Pointer to interface pointer of new value list.

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.

◆ AFW_LIST_INITIALIZE_WRAPPER_FOR_ARRAY

#define AFW_LIST_INITIALIZE_WRAPPER_FOR_ARRAY (   instance,
  _internal,
  _indirect,
  _data_type,
  _count 
)
Value:
(instance)->inf = &afw_list_wrapper_for_array_inf; \
(instance)->p = NULL; \
(instance)->internal = _internal; \
(instance)->indirect = _indirect; \
(instance)->data_type = _data_type; \
(instance)->count = _count
afw_list_wrapper_for_array_inf
inf for afw_list_wrapper_for_array afw_list implementation.
Definition: afw_list.h:254

Helper macro to fill out afw_list_wrapper_for_array_self_t.

instance is pointer to afw_list_wrapper_for_array_self_t.

Parameters
_internalarray of internal values.
_indirectif true array is array of pointers to internal value.
_data_typeof array.
_countof 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.

◆ AFW_LIST_INITIALIZE_WRAPPER_FOR_ARRAY_P

#define AFW_LIST_INITIALIZE_WRAPPER_FOR_ARRAY_P (   instance,
  _internal,
  _indirect,
  _data_type,
  _count,
  _p 
)
Value:
(instance)->inf = &afw_list_wrapper_for_array_inf; \
(instance)->p = _p; \
(instance)->internal = _internal; \
(instance)->indirect = _indirect; \
(instance)->data_type = _data_type; \
(instance)->count = _count

Helper macro to fill out afw_list_wrapper_for_array_self_t.

instance is pointer to afw_list_wrapper_for_array_self_t.

Parameters
_internalarray of internal values.
_indirectif true array is array of pointers to internal value.
_data_typeof array.
_countof entries in array or -1 for NULL terminated.
_pfor 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.

◆ afw_list_is_immutable

#define afw_list_is_immutable (   list,
  xctx 
)    (afw_list_get_setter(list, xctx) == NULL)

Determine if list is immutable.

Parameters
instanceof list.
xctxof caller.
Returns
boolean result.

Definition at line 454 of file afw_list.h.

◆ afw_list_of_create

#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.

Parameters
data_typeif list only holds one data type or NULL.
pto use for the list.
xctxof caller.
Returns
Pointer to interface pointer of new value list.

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.

Typedef Documentation

◆ afw_list_wrapper_for_array_self_t

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.

Function Documentation

◆ afw_list_add_internal()

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.

Parameters
instancePointer to this value list instance.
data_typeof internal.
internalA value.
xctxof caller.

Definition at line 78 of file afw_list.c.

◆ afw_list_add_value()

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.

Parameters
instancePointer to this value list instance.
valueA value.
xctxof caller.

Definition at line 104 of file afw_list.c.

◆ afw_list_const_create_array_of_objects()

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.

Parameters
valuesis address of first value in array.
countis number for values.
pis pool for result.
xctxof caller.
Returns
list instance.

Definition at line 46 of file afw_list_const_array.c.

◆ afw_list_const_create_array_of_values()

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.

Parameters
valuesis address of first value in array.
countis number for values.
pis pool for result.
xctxof caller.
Returns
list instance.

Definition at line 91 of file afw_list_const_array.c.

◆ afw_list_const_create_null_terminated_array_of_objects()

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.

Parameters
valuesis NULL terminated array of objects.
pis pool for result.
xctxof caller.
Returns
list instance.

Definition at line 71 of file afw_list_const_array.c.

◆ afw_list_const_create_null_terminated_array_of_values()

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.

Parameters
valuesis NULL terminated array of values.
pis pool for result.
xctxof caller.
Returns
list instance.

Definition at line 114 of file afw_list_const_array.c.

◆ afw_list_convert_to_list_of_strings()

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.

Parameters
listto convert.
pis pool for result.
xctxof caller.
Returns
converted list or original if already list of strings.

Definition at line 77 of file afw_list_wrapper_for_array.c.

◆ afw_list_create_or_clone()

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.

Parameters
listto clone or NULL.
data_typeto use if list is NULL.
clone_valuestrue will clone values as well.
pto use for the list.
xctxof caller.
Returns
cloned instance of list.

If data_type is not NULL and list is typed, they must match.

Definition at line 692 of file afw_list_memory.c.

◆ afw_list_create_with_options()

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.

Parameters
options
data_typeif list only holds one data type or NULL.
pto use for the list.
xctxof caller.
Returns
Pointer to interface pointer of new value list.

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()

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.

Parameters
arrayof internal values.
indirectif true array is array of pointers to internal value.
data_typeof array.
countof entries in array or -1 for NULL terminated.
pis pool for result.
xctxof caller.
Returns
list instance.

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.

◆ afw_list_determine_data_type_and_set_immutable()

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.

Parameters
instancePointer to this value list instance.
xctxof caller.
Returns
the data type of all values in list or NULL if different or unknown.

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.

◆ afw_list_of_create_from_value()

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.

Parameters
data_typeof list
value.
pto use for the list.
xctxof caller.
Returns
typed list.

Definition at line 731 of file afw_list_memory.c.

◆ afw_list_of_utf8_get_next()

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.

Parameters
instanceof list.
iterator.
xctxof caller.
Returns
(const afw_utf8_t *) or NULL.

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.

◆ afw_list_remove_all_values()

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.

Parameters
instancePointer to this value list instance.
xctxof caller.

Definition at line 128 of file afw_list.c.

◆ afw_list_remove_internal()

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.

Parameters
instancePointer to this value list instance.
data_typeof internal.
internalA value.
xctxof caller.

Definition at line 147 of file afw_list.c.

◆ afw_list_remove_value()

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.

Parameters
instancePointer to this value list instance.
valueValue.
xctxof caller.

Definition at line 168 of file afw_list.c.

◆ afw_list_set_immutable()

void afw_list_set_immutable ( const afw_list_t instance,
afw_xctx_t xctx 
)

Set a list to immutable if not already.

Parameters
instancePointer to this value list instance.
xctxof 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.

◆ afw_list_set_value_by_index()

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.

Parameters
instancePointer to this value list instance.
index.
value.
xctxof caller.

Definition at line 188 of file afw_list.c.

Variable Documentation

◆ afw_list_wrapper_for_array_inf

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.