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;
unsigned short int i;
void *data;
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]);
}
for(i = 1; i < 10; i += 2)
{
eina_accessor_data_get(acc, i, &data);
printf("%s\n", (const char *)data);
}
for(i = 1; i < 10; i += 2)
{
eina_accessor_data_get(acc, i, &data);
printf("%s\n", (const char *)data);
}
return 0;
}
Eina Utility library.
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_API void eina_accessor_free(Eina_Accessor *accessor)
Frees an accessor.
Definition: eina_accessor.c:96
EINA_API void * eina_accessor_container_get(Eina_Accessor *accessor)
Gets the container of an accessor.
Definition: eina_accessor.c:107
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_API void eina_array_free(Eina_Array *array)
Frees an array.
Definition: eina_array.c:295
static Eina_Bool eina_array_push(Eina_Array *array, const void *data)
Appends a data item to an array.
EINA_API Eina_Array * eina_array_new(unsigned int step)
Creates a new array.
Definition: eina_array.c:276
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_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_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_API int eina_shutdown(void)
Shuts down the Eina library.
Definition: eina_main.c:379
EINA_API int eina_init(void)
Initializes the Eina library.
Definition: eina_main.c:291
#define EINA_UNUSED
Used to indicate that a function parameter is purposely unused.
Definition: eina_types.h:339
Structure to provide random access to data structures.
Definition: eina_accessor.h:153
Type for an array of data.
Definition: eina_array.h:229
Type for a generic double linked list.
Definition: eina_list.h:318