summaryrefslogtreecommitdiff
path: root/legacy/eina
diff options
context:
space:
mode:
authorJonas M. Gastal <jgastal@profusion.mobi>2011-06-13 16:42:25 +0000
committerJonas M. Gastal <jgastal@profusion.mobi>2011-06-13 16:42:25 +0000
commit0be4917595d971725ac66dd80027c14a4c4414c2 (patch)
tree8683cbefbe4318ecb38239247aeced62e143862c /legacy/eina
parentb403eb49e0756360d4c5b4de24f35bd5050de296 (diff)
eina: Eina_Accessor documentation.
SVN revision: 60284
Diffstat (limited to 'legacy/eina')
-rw-r--r--legacy/eina/src/examples/Makefile.am2
-rw-r--r--legacy/eina/src/examples/eina_accessor_01.c55
-rw-r--r--legacy/eina/src/include/eina_accessor.h51
3 files changed, 108 insertions, 0 deletions
diff --git a/legacy/eina/src/examples/Makefile.am b/legacy/eina/src/examples/Makefile.am
index 756dcffb27..fb0fa2fbff 100644
--- a/legacy/eina/src/examples/Makefile.am
+++ b/legacy/eina/src/examples/Makefile.am
@@ -11,6 +11,7 @@ LDADD = \
11 $(top_builddir)/src/lib/libeina.la 11 $(top_builddir)/src/lib/libeina.la
12 12
13SRCS = \ 13SRCS = \
14 eina_accessor_01.c \
14 eina_array_01.c \ 15 eina_array_01.c \
15 eina_array_02.c \ 16 eina_array_02.c \
16 eina_hash_01.c \ 17 eina_hash_01.c \
@@ -30,6 +31,7 @@ endif
30 31
31if EFL_BUILD_EXAMPLES 32if EFL_BUILD_EXAMPLES
32pkglib_PROGRAMS += \ 33pkglib_PROGRAMS += \
34 eina_accessor_01 \
33 eina_array_01 \ 35 eina_array_01 \
34 eina_array_02 \ 36 eina_array_02 \
35 eina_hash_01 \ 37 eina_hash_01 \
diff --git a/legacy/eina/src/examples/eina_accessor_01.c b/legacy/eina/src/examples/eina_accessor_01.c
new file mode 100644
index 0000000000..c48fdc63f4
--- /dev/null
+++ b/legacy/eina/src/examples/eina_accessor_01.c
@@ -0,0 +1,55 @@
1//Compile with:
2//gcc -g `pkg-config --cflags --libs eina` eina_accessor_01.c -o eina_accessor_01
3
4#include <stdio.h>
5
6#include <Eina.h>
7
8int
9main(int argc, char **argv)
10{
11 const char *strings[] = {
12 "even", "odd", "even", "odd", "even", "odd", "even", "odd", "even", "odd"
13 };
14 const char *more_strings[] = {
15 "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
16 };
17 Eina_Array *array;
18 Eina_List *list = NULL;
19 Eina_Accessor *acc;
20 unsigned short int i;
21 void *data;
22
23 eina_init();
24
25 array = eina_array_new(10);
26
27 for (i = 0; i < 10; i++)
28 {
29 eina_array_push(array, strings[i]);
30 list = eina_list_append(list, more_strings[i]);
31 }
32
33 acc = eina_array_accessor_new(array);
34 for(i = 1; i < 10; i += 2)
35 {
36 eina_accessor_data_get(acc, i, &data);
37 printf("%s\n", (const char *)data);
38 }
39 eina_accessor_free(acc);
40 eina_array_free(array);
41
42 acc = eina_list_accessor_new(list);
43 for(i = 1; i < 10; i += 2)
44 {
45 eina_accessor_data_get(acc, i, &data);
46 printf("%s\n", (const char *)data);
47 }
48
49 eina_list_free(eina_accessor_container_get(acc));
50 eina_accessor_free(acc);
51
52 eina_shutdown();
53
54 return 0;
55}
diff --git a/legacy/eina/src/include/eina_accessor.h b/legacy/eina/src/include/eina_accessor.h
index 505efa3119..1b437501bb 100644
--- a/legacy/eina/src/include/eina_accessor.h
+++ b/legacy/eina/src/include/eina_accessor.h
@@ -25,6 +25,57 @@
25#include "eina_magic.h" 25#include "eina_magic.h"
26 26
27/** 27/**
28 * @page eina_accessor_example_01_page Eina_Accessor usage
29 * @dontinclude eina_accessor_01.c
30 *
31 * We start by including neccessary headers, declaring variables and
32 * initializing eina:
33 * @skip #include
34 * @until eina_init
35 *
36 * Next we populate our array and list:
37 * @until }
38 *
39 * Now that we have two containers populated we can actually start the example
40 * and create an accessor:
41 * @until accessor_new
42 *
43 * Once having the accessor we can use it to access certain elements in the
44 * container:
45 * @until }
46 * @note Unlike iterators accessors allow us non-linear access, which allows us
47 * to print only the odd elements in the container.
48 *
49 * As with every other resource we allocate we need to free the accessor(and the
50 * array):
51 * @until array_free
52 *
53 * Now we create another accessor, this time for the list:
54 * @until accessor_new
55 *
56 * And now the interesting bit, we use the same code we used above to print
57 * parts of the array to print parts of the list:
58 * @until }
59 *
60 * And to free the list we use a gimmick, instead of freeing @a list, we ask the
61 * accessor for it's container and free that:
62 * @until list_free
63 *
64 * Finally we shut eina down and leave:
65 * @until }
66 *
67 * The full source code can be found on the examples folder
68 * on the @ref eina_accessor_01_c "eina_accessor_01.c" file.
69 */
70
71/**
72 * @page eina_accessor_01_c Eina_Accessor usage example
73 *
74 * @include eina_accessor_01.c
75 * @example eina_accessor_01.c
76 */
77
78/**
28 * @addtogroup Eina_Accessor_Group Accessor Functions 79 * @addtogroup Eina_Accessor_Group Accessor Functions
29 * 80 *
30 * @brief These functions manage accessor on containers. 81 * @brief These functions manage accessor on containers.