Another eina_inarray example.
authorgastal <gastal@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 6 Mar 2012 14:27:03 +0000 (14:27 +0000)
committergastal <gastal@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 6 Mar 2012 14:27:03 +0000 (14:27 +0000)
Patch by: "Daniel Vieira Franzolin" <daniel@profusion.mobi>

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/eina@68835 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/examples/eina_inarray_02.c [new file with mode: 0644]
src/include/eina_inarray.h

diff --git a/src/examples/eina_inarray_02.c b/src/examples/eina_inarray_02.c
new file mode 100644 (file)
index 0000000..3653b36
--- /dev/null
@@ -0,0 +1,33 @@
+//Compile with:
+//gcc -g eina_inarray_02.c -o eina_inarray_02 `pkg-config --cflags --libs eina`
+
+#include <Eina.h>
+
+int
+main(int argc, char **argv)
+{
+   const char* strings[] = {
+      "helo", "hera", "starbuck", "kat", "boomer",
+      "hotdog", "longshot", "jammer", "crashdown", "hardball",
+      "duck", "racetrack", "apolo", "husker", "freaker",
+      "skulls", "bulldog", "flat top", "hammerhead", "gonzo"
+   };
+   char **str, **str2;
+   Eina_Inarray *iarr;
+   int i;
+
+   eina_init();
+   iarr = eina_inarray_new(sizeof(char *), 0);
+
+   for (i = 0; i < 20; i++){
+      str = &strings[i];
+      eina_inarray_append(iarr, str);
+   }
+
+   printf("Inline array of strings:\n");
+   EINA_INARRAY_FOREACH(iarr, str2)
+     printf("string: %s(pointer: %p)\n", *str2, str2);
+
+   eina_inarray_free(iarr);
+   eina_shutdown();
+}
index c9114b7..079f1e3 100644 (file)
  */
 
 /**
+ * @page eina_inarray_example_02 Eina inline array of strings
+ * @dontinclude eina_inarray_02.c
+ *
+ * This example will create an inline array of strings, add some elements and
+ * then print them. This example is based on @ref eina_array_01_example_page and
+ * @ref eina_inarray_example_01.
+ *
+ * We start with some variable declarations and eina initialization:
+ * @skip int
+ * @until eina_init
+ *
+ * We then create the array much like we did on @ref eina_inarray_example_01:
+ * @until inarray_new
+ *
+ * The point were this example significantly differs from the first eina inline
+ * array example. We'll not be adding the strings themselves to the array since
+ * their size varies, we'll store pointer to the strings instead. We therefore
+ * use @c char** to populate our inline array:
+ * @until }
+ *
+ * The source for this example: @ref eina_inarray_02_c
+ */
+
+/**
+ * @page eina_inarray_02_c eina_inarray_02.c
+ * @include eina_inarray_02.c
+ * @example eina_inarray_02.c
+ */
+
+/**
  * @addtogroup Eina_Data_Types_Group Data Types
  *
  * @since 1.2
  * of the array is a lot more costly than appending, so those operations should
  * be minimized.
  *
- * Example:
- * @ref eina_inarray_example_01
+ * Examples:
+ * @li @ref eina_inarray_example_01
+ * @li @ref eina_inarray_example_02
  *
  * @{
  */