Tizen Native API
|
Functions | |
void | eina_accessor_free (Eina_Accessor *accessor) |
Frees an accessor. | |
Eina_Bool | eina_accessor_data_get (Eina_Accessor *accessor, unsigned int position, void **data) |
Gets the data of an accessor at the given position. | |
void * | eina_accessor_container_get (Eina_Accessor *accessor) |
Gets the container of an accessor. | |
void | eina_accessor_over (Eina_Accessor *accessor, Eina_Each_Cb cb, unsigned int start, unsigned int end, const void *fdata) |
Iterates over the container and executes a callback on the chosen elements. | |
Eina_Bool | eina_accessor_lock (Eina_Accessor *accessor) |
Locks the container of the accessor. | |
Eina_Bool | eina_accessor_unlock (Eina_Accessor *accessor) |
Unlocks the container of the accessor. | |
Typedefs | |
typedef struct _Eina_Accessor | Eina_Accessor |
The structure type containing the abstract type for accessors. | |
typedef Eina_Bool(* | Eina_Accessor_Get_At_Callback )(Eina_Accessor *it, unsigned int idx, void **data) |
The boolean type for a callback that returns the data of a container as the given index. | |
typedef void *(* | Eina_Accessor_Get_Container_Callback )(Eina_Accessor *it) |
Called to return the container. | |
typedef void(* | Eina_Accessor_Free_Callback )(Eina_Accessor *it) |
Called to free the container. | |
typedef Eina_Bool(* | Eina_Accessor_Lock_Callback )(Eina_Accessor *it) |
The boolean type for a callback that locks the container. | |
Defines | |
#define | FUNC_ACCESSOR_GET_AT(Function) ((Eina_Accessor_Get_At_Callback)Function) |
Definition of a helper macro to cast Function to a Eina_Accessor_Get_At_Callback. | |
#define | FUNC_ACCESSOR_GET_CONTAINER(Function) ((Eina_Accessor_Get_Container_Callback)Function) |
Definition of a helper macro to cast Function to a Eina_Accessor_Get_Container_Callback. | |
#define | FUNC_ACCESSOR_FREE(Function) ((Eina_Accessor_Free_Callback)Function) |
Definition of a helper macro to cast Function to a Eina_Accessor_Free_Callback. | |
#define | FUNC_ACCESSOR_LOCK(Function) ((Eina_Accessor_Lock_Callback)Function) |
Definition of a helper macro to cast Function to a Eina_Iterator_Lock_Callback. | |
#define | EINA_ACCESSOR_FOREACH(accessor, counter, data) |
Definition of the macro to iterate over all the elements easily. |
This group discusses the functions to manage an accessor on containers.
These functions allow to access elements of a container in a generic way, without knowing which container is used (a bit like iterators in the C++ STL). Accessors allows random access (that is, any element in the container). For sequential access, see Iterator Functions.
Getting an accessor to access elements of a given container is done through the functions of that particular container. There is no function to create a generic accessor as accessors absolutely depend on the container. This means you won't find an accessor creation function here, those can be found on the documentation of the container type you're using. Though created with container specific functions, accessors are always deleted by the same function: eina_accessor_free().
To get the data of an element at a given position, use eina_accessor_data_get(). To call a function on chosen elements of a container, use eina_accessor_over().
#define EINA_ACCESSOR_FOREACH | ( | accessor, | |
counter, | |||
data | |||
) |
for ((counter) = 0; \ eina_accessor_data_get((accessor), (counter), (void **)(void *)&(data)); \ (counter)++)
Definition of the macro to iterate over all the elements easily.
This macro allows a convenient way to loop over all elements in an accessor, very similar to EINA_LIST_FOREACH().
Eina_List *list; Eina_Accessor *accessor; unsigned int i; char *data; // list is already filled, // its elements are just duplicated strings accessor = eina_list_accessor_new(list); EINA_ACCESSOR_FOREACH(accessor, i, data) free(data); eina_accessor_free(accessor); eina_list_free(list);
accessor | The accessor to use |
counter | A counter used by eina_accessor_data_get() when iterating over the container. |
data | A pointer to store the data It must be a pointer to support getting its address since eina_accessor_data_get() requires a pointer. |
void* eina_accessor_container_get | ( | Eina_Accessor * | accessor | ) |
Gets the container of an accessor.
This function returns the container that created accessor. If accessor is NULL
, this function returns NULL
.
[in] | accessor | The accessor |
Eina_Bool eina_accessor_data_get | ( | Eina_Accessor * | accessor, |
unsigned int | position, | ||
void ** | data | ||
) |
Gets the data of an accessor at the given position.
This function retrieves the data of the element pointed by accessor at the position position, and stores it in data. If accessor is NULL
or if an error occurs, EINA_FALSE
is returned, otherwise EINA_TRUE
is returned.
[in] | accessor | The accessor |
[in] | position | The position of the element |
[in] | data | The pointer that stores the data to retrieve |
EINA_TRUE
on success, otherwise EINA_FALSE
void eina_accessor_free | ( | Eina_Accessor * | accessor | ) |
Frees an accessor.
This function frees accessor if it is not NULL
.
[in] | accessor | The accessor to free |
Eina_Bool eina_accessor_lock | ( | Eina_Accessor * | accessor | ) |
Locks the container of the accessor.
NULL
or if a problem occurs, EINA_FALSE
is returned, otherwise EINA_TRUE
is returned. If the container isn't lockable, it returns EINA_TRUE
.[in] | accessor | The accessor |
EINA_TRUE
on success, otherwise EINA_FALSE
void eina_accessor_over | ( | Eina_Accessor * | accessor, |
Eina_Each_Cb | cb, | ||
unsigned int | start, | ||
unsigned int | end, | ||
const void * | fdata | ||
) |
Iterates over the container and executes a callback on the chosen elements.
This function iterates over the elements pointed by accessor, starting from the element at position start and ending at the element at position end. For each element, the callback cb is called with the data fdata. If accessor is NULL
or if start is greater than or equal to end, the function returns immediately.
[in] | accessor | The accessor |
[in] | cb | The callback called on the chosen elements |
[in] | start | The position of the first element |
[in] | end | The position of the last element |
[in] | fdata | The data passed to the callback |
Eina_Bool eina_accessor_unlock | ( | Eina_Accessor * | accessor | ) |
Unlocks the container of the accessor.
NULL
or if a problem occurs, EINA_FALSE
is returned, otherwise EINA_TRUE
is returned. If the container is not lockable, it returns EINA_TRUE
.[in] | accessor | The accessor |
EINA_TRUE
on success, otherwise EINA_FALSE