eina_accessor_01.c
//Compile with:
//gcc -g eina_accessor_01.c -o eina_accessor_01 `pkg-config --cflags --libs eina`
#include <stdio.h>
#include <Eina.h>
int
main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
{
const char *strings[] = {
"even", "odd", "even", "odd", "even", "odd", "even", "odd", "even", "odd"
};
const char *more_strings[] = {
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
};
Eina_Array *array;
Eina_List *list = NULL;
Eina_Accessor *acc;
unsigned short int i;
void *data;
eina_init();
array = eina_array_new(10);
for (i = 0; i < 10; i++)
{
eina_array_push(array, strings[i]);
list = eina_list_append(list, more_strings[i]);
}
acc = eina_array_accessor_new(array);
for(i = 1; i < 10; i += 2)
{
eina_accessor_data_get(acc, i, &data);
printf("%s\n", (const char *)data);
}
eina_accessor_free(acc);
eina_array_free(array);
acc = eina_list_accessor_new(list);
for(i = 1; i < 10; i += 2)
{
eina_accessor_data_get(acc, i, &data);
printf("%s\n", (const char *)data);
}
eina_list_free(eina_accessor_container_get(acc));
eina_accessor_free(acc);
eina_shutdown();
return 0;
}
Eina.h
Eina Utility library.
eina_accessor_data_get
EINA_API Eina_Bool eina_accessor_data_get(Eina_Accessor *accessor, unsigned int position, void **data)
Gets the data of an accessor at the given position.
Definition: eina_accessor.c:116
eina_accessor_free
EINA_API void eina_accessor_free(Eina_Accessor *accessor)
Frees an accessor.
Definition: eina_accessor.c:96
eina_accessor_container_get
EINA_API void * eina_accessor_container_get(Eina_Accessor *accessor)
Gets the container of an accessor.
Definition: eina_accessor.c:107
eina_array_accessor_new
EINA_API Eina_Accessor * eina_array_accessor_new(const Eina_Array *array)
Gets a new accessor associated with an array.
Definition: eina_array.c:419
eina_array_free
EINA_API void eina_array_free(Eina_Array *array)
Frees an array.
Definition: eina_array.c:295
eina_array_new
EINA_API Eina_Array * eina_array_new(unsigned int step)
Creates a new array.
Definition: eina_array.c:276
eina_array_push
static Eina_Bool eina_array_push(Eina_Array *array, const void *data)
Appends a data item to an array.
eina_list_free
EINA_API Eina_List * eina_list_free(Eina_List *list)
Frees an entire list and all the nodes, ignoring the data contained.
Definition: eina_list.c:823
eina_list_accessor_new
EINA_API Eina_Accessor * eina_list_accessor_new(const Eina_List *list)
Returns a new accessor associated with a list.
Definition: eina_list.c:1620
eina_list_append
EINA_API Eina_List * eina_list_append(Eina_List *list, const void *data)
Appends the given data to the given linked list.
Definition: eina_list.c:584
eina_shutdown
EINA_API int eina_shutdown(void)
Shuts down the Eina library.
Definition: eina_main.c:379
eina_init
EINA_API int eina_init(void)
Initializes the Eina library.
Definition: eina_main.c:291
EINA_UNUSED
#define EINA_UNUSED
Used to indicate that a function parameter is purposely unused.
Definition: eina_types.h:339
_Eina_Accessor
Structure to provide random access to data structures.
Definition: eina_accessor.h:153
_Eina_Array
Type for an array of data.
Definition: eina_array.h:229
_Eina_List
Type for a generic double linked list.
Definition: eina_list.h:318