This is an example much like the one shown in \hyperlink{eet_data_file_descriptor}{Advanced use of Eet Data Descriptors}.

The difference is that here we\textquotesingle{}re attaining ourselves to two new data types to store in an Eet file -- {\bfseries unions} and {\bfseries variants}. We don\textquotesingle{}t try to come with data mapping to real world use cases, here. Instead, we\textquotesingle{}re defining 3 different simple structures to be used throughout the example\+:  
\begin{DoxyCodeInclude}
\textcolor{keyword}{typedef} \textcolor{keyword}{struct }\_Example\_Struct1      Example\_Struct1;
\textcolor{keyword}{typedef} \textcolor{keyword}{struct }\_Example\_Struct2      Example\_Struct2;
\textcolor{keyword}{typedef} \textcolor{keyword}{struct }\_Example\_Struct3      Example\_Struct3;
\textcolor{keyword}{struct }\_Example\_Struct1
\{
   \textcolor{keywordtype}{double}      val1;
   \textcolor{keywordtype}{int}         stuff;
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *s1;
\};

\textcolor{keyword}{struct }\_Example\_Struct2
\{
   \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}          b1;
   \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{long} \textcolor{keywordtype}{long} v1;
\};

\textcolor{keyword}{struct }\_Example\_Struct3
\{
   \textcolor{keywordtype}{int} body;
\};

\end{DoxyCodeInclude}


To identify, for both union and variant data cases, the type of each chunk of data, we\textquotesingle{}re defining types to point to each of those structs\+:  
\begin{DoxyCodeInclude}
\textcolor{keyword}{typedef} \textcolor{keyword}{enum} \_Example\_Data\_Type      Example\_Data\_Type;
\textcolor{keyword}{enum} \_Example\_Data\_Type
\{
   EET\_UNKNOWN = 0,
   EET\_STRUCT1,
   EET\_STRUCT2,
   EET\_STRUCT3,
   EET\_BASIC\_FLOAT,
   EET\_BASIC\_STRING
\};

\end{DoxyCodeInclude}


We have also a mapping from those types to name strings, to be used in the Eet unions and variants {\ttfamily type\+\_\+get()} and {\ttfamily type\+\_\+set()} type identifying callbacks\+: 
\begin{DoxyCodeInclude}
\textcolor{keyword}{struct}
\{
   Example\_Data\_Type u;
   \textcolor{keyword}{const} \textcolor{keywordtype}{char}       *name;
\} eet\_mapping[] = \{
   \{ EET\_STRUCT1, \textcolor{stringliteral}{"ST1"} \},
   \{ EET\_STRUCT2, \textcolor{stringliteral}{"ST2"} \},
   \{ EET\_STRUCT3, \textcolor{stringliteral}{"ST3"} \},
   \{ EET\_BASIC\_FLOAT, \textcolor{stringliteral}{"float"} \},
   \{ EET\_BASIC\_STRING, \textcolor{stringliteral}{"string"} \},
   \{ EET\_UNKNOWN, NULL \}
\};

\end{DoxyCodeInclude}


In this example, we have no fancy hash to store our data into profiles/accounts, but just two lists for union and variant data nodes\+:  
\begin{DoxyCodeInclude}
\textcolor{keyword}{typedef} \textcolor{keyword}{struct }\_Example\_Lists        Example\_Lists;
\textcolor{keyword}{struct }\_Example\_Lists
\{
   \hyperlink{struct__Eina__List}{Eina\_List} *union\_list;
   \hyperlink{struct__Eina__List}{Eina\_List} *variant\_list;
\};

\end{DoxyCodeInclude}


Let\textquotesingle{}s begin with our unions, then, which look like\+:  
\begin{DoxyCodeInclude}
\textcolor{keyword}{typedef} \textcolor{keyword}{struct }\_Example\_Union        Example\_Union;
\textcolor{keyword}{struct }\_Example\_Union
\{
   Example\_Data\_Type type;

   \textcolor{keyword}{union }\{
      Example\_Struct1 st1;
      Example\_Struct2 st2;
      Example\_Struct3 st3;
      \textcolor{keywordtype}{float} f;
      \textcolor{keyword}{const} \textcolor{keywordtype}{char}* string;
   \} u;
\};

\end{DoxyCodeInclude}


The first interesting part of the code is where we define our data descriptors for the main lists, the unions and all of structures upon which those two depend.  
\begin{DoxyCodeInclude}
\textcolor{comment}{/* declaring types */}
\_data\_descriptors\_init(\textcolor{keywordtype}{void})
\{
   \hyperlink{struct__Eet__Data__Descriptor__Class}{Eet\_Data\_Descriptor\_Class} eddc;

   \hyperlink{group__Eet__Data__Group_ga0bf94c07d8e69cfaac8dd2d615d7542c}{EET\_EINA\_FILE\_DATA\_DESCRIPTOR\_CLASS\_SET}(&eddc, Example\_Lists);
   \_lists\_descriptor = \hyperlink{group__Eet__Data__Group_ga2a7251edf1f60ced86c4860207331bb6}{eet\_data\_descriptor\_file\_new}(&eddc);

   \_struct\_1\_descriptor = \_st1\_dd();
   \_struct\_2\_descriptor = \_st2\_dd();
   \_struct\_3\_descriptor = \_st3\_dd();

   \textcolor{comment}{/* for union */}
   \hyperlink{group__Eet__Data__Group_ga0bf94c07d8e69cfaac8dd2d615d7542c}{EET\_EINA\_FILE\_DATA\_DESCRIPTOR\_CLASS\_SET}(&eddc, Example\_Union);
   \_union\_descriptor = \hyperlink{group__Eet__Data__Group_ga2a7251edf1f60ced86c4860207331bb6}{eet\_data\_descriptor\_file\_new}(&eddc);

   eddc.\hyperlink{struct__Eet__Data__Descriptor__Class_a4e3696014d6907dadd55840bf6008317}{version} = \hyperlink{group__Eet__Data__Group_ga61a090586eff90415b429f1017acf8a7}{EET\_DATA\_DESCRIPTOR\_CLASS\_VERSION};
   eddc.func.\hyperlink{struct__Eet__Data__Descriptor__Class_af71fcc4124973c0da6aa0e84dce426cb}{type\_get} = \_union\_type\_get;
   eddc.func.\hyperlink{struct__Eet__Data__Descriptor__Class_a1b6477a2a52b797a662c3fff9793f97e}{type\_set} = \_union\_type\_set;
   \_union\_unified\_descriptor = \hyperlink{group__Eet__Data__Group_ga2a7251edf1f60ced86c4860207331bb6}{eet\_data\_descriptor\_file\_new}(&eddc);

   \hyperlink{group__Eet__Data__Group_gad0daa543d93a64add80961ae5387d45a}{EET\_DATA\_DESCRIPTOR\_ADD\_MAPPING}(
     \_union\_unified\_descriptor, \textcolor{stringliteral}{"ST1"}, \_struct\_1\_descriptor);
   \hyperlink{group__Eet__Data__Group_gad0daa543d93a64add80961ae5387d45a}{EET\_DATA\_DESCRIPTOR\_ADD\_MAPPING}(
     \_union\_unified\_descriptor, \textcolor{stringliteral}{"ST2"}, \_struct\_2\_descriptor);
   \hyperlink{group__Eet__Data__Group_gad0daa543d93a64add80961ae5387d45a}{EET\_DATA\_DESCRIPTOR\_ADD\_MAPPING}(
     \_union\_unified\_descriptor, \textcolor{stringliteral}{"ST3"}, \_struct\_3\_descriptor);
   \hyperlink{group__Eet__Data__Group_gaaf153807a88cd2c3483c5c34bb920a95}{EET\_DATA\_DESCRIPTOR\_ADD\_MAPPING\_BASIC}(
     \_union\_unified\_descriptor, \textcolor{stringliteral}{"float"}, \hyperlink{group__Eet__Data__Group_ga447b1b41e09b24ac6b3fbbac8d3efb30}{EET\_T\_FLOAT});
   \hyperlink{group__Eet__Data__Group_gaaf153807a88cd2c3483c5c34bb920a95}{EET\_DATA\_DESCRIPTOR\_ADD\_MAPPING\_BASIC}(
     \_union\_unified\_descriptor, \textcolor{stringliteral}{"string"}, \hyperlink{group__Eet__Data__Group_ga0d2cf409bf3f151156d74d18ac59e3d1}{EET\_T\_STRING});

   \hyperlink{group__Eet__Data__Group_ga07b711dca3d4bcaa0ccb8ced48341b90}{EET\_DATA\_DESCRIPTOR\_ADD\_UNION}(
     \_union\_descriptor, Example\_Union, \textcolor{stringliteral}{"u"}, u, type,
     \_union\_unified\_descriptor);

   \hyperlink{group__Eet__Data__Group_gabb4c7833ba053f2322e6b667a9ec7f04}{EET\_DATA\_DESCRIPTOR\_ADD\_LIST}(
     \_lists\_descriptor, Example\_Lists, \textcolor{stringliteral}{"union\_list"}, union\_list,
     \_union\_descriptor);

\end{DoxyCodeInclude}
 The code for descriptors on {\ttfamily Example\+\_\+\+Struct1}, {\ttfamily Example\+\_\+\+Struct2} and {\ttfamily Example\+\_\+\+Struct3} is straightforward, a matter already covered on \hyperlink{eet_data_file_descriptor}{Advanced use of Eet Data Descriptors}. What is new, here, are the two type matching functions for our unions. There, we must set the {\ttfamily data} pointer to its matching type, on {\ttfamily \+\_\+union\+\_\+type\+\_\+set} and return the correct matching type, on {\ttfamily \+\_\+union\+\_\+type\+\_\+get\+:}  
\begin{DoxyCodeInclude}

\end{DoxyCodeInclude}


With the \hyperlink{group__Eet__Data__Group_gad0daa543d93a64add80961ae5387d45a}{E\+E\+T\+\_\+\+D\+A\+T\+A\+\_\+\+D\+E\+S\+C\+R\+I\+P\+T\+O\+R\+\_\+\+A\+D\+D\+\_\+\+M\+A\+P\+P\+I\+NG} calls, which follow, we make the the link between our type names and their respective structs. The code handling actual data is pretty much the same as in \hyperlink{eet_data_file_descriptor}{Advanced use of Eet Data Descriptors} -- one uses command line arguments to enter new data chunks (or just to visualize the contents of an Eet file), signalling if they are unions or variants. One must also pass the type of the data chuck to enter, with integers 1, 2 or
\begin{DoxyEnumerate}
\item Then, come the fields for each type\+:  
\begin{DoxyCodeInclude}
                \textcolor{stringliteral}{"Usage:\(\backslash\)n\(\backslash\)t%s <input> <output> [action action-params]\(\backslash\)n\(\backslash\)n"}
                \textcolor{stringliteral}{"where actions and their parameters are:\(\backslash\)n"}
                \textcolor{stringliteral}{"\(\backslash\)tunion <type> [fields]\(\backslash\)n"}
                \textcolor{stringliteral}{"\(\backslash\)tvariant <type> [fields]\(\backslash\)n"}
                \textcolor{stringliteral}{"\(\backslash\)n"},
                argv[0]);

\end{DoxyCodeInclude}

\end{DoxyEnumerate}

Variants are very similar to unions, except that data chunks need {\bfseries not} contain previously allocated space for each of the possible types of data going in them\+:  
\begin{DoxyCodeInclude}
\textcolor{keyword}{typedef} \textcolor{keyword}{struct }\_Example\_Variant\_Type Example\_Variant\_Type;
\textcolor{keyword}{struct }\_Example\_Variant\_Type
\{
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *type;
   \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}   unknow : 1;
\};

\textcolor{keyword}{struct }\_Example\_Variant
\{
   Example\_Variant\_Type t;

   \textcolor{keywordtype}{void}                *data; \textcolor{comment}{/* differently than the union type, we}
\textcolor{comment}{                               * don't need to pre-allocate the memory}
\textcolor{comment}{                               * for the field*/}
\};

\end{DoxyCodeInclude}


The code declaring the data descriptors and handling the data is very similar to the unions part, and is left for the reader to check for him/herself. The complete code of the example follows.


\begin{DoxyCodeInclude}
1 \textcolor{comment}{//Compile with:}
2 \textcolor{comment}{// gcc -o eet-data-file\_descriptor\_02 eet-data-file\_descriptor\_02.c `pkg-config --cflags --libs eet eina`}
3 
4 \textcolor{preprocessor}{#include <\hyperlink{Eina_8h}{Eina.h}>}
5 \textcolor{preprocessor}{#include <\hyperlink{Eet_8h}{Eet.h}>}
6 \textcolor{preprocessor}{#include <stdio.h>}
7 \textcolor{preprocessor}{#include <limits.h>}
8 \textcolor{preprocessor}{#include <sys/types.h>}
9 \textcolor{preprocessor}{#include <sys/stat.h>}
10 \textcolor{preprocessor}{#include <unistd.h>}
11 
12 \textcolor{keyword}{typedef} \textcolor{keyword}{enum} \_Example\_Data\_Type      Example\_Data\_Type;
13 \textcolor{keyword}{typedef} \textcolor{keyword}{struct }\_Example\_Variant\_Type Example\_Variant\_Type;
14 \textcolor{keyword}{typedef} \textcolor{keyword}{struct }\_Example\_Variant      Example\_Variant;
15 \textcolor{keyword}{typedef} \textcolor{keyword}{struct }\_Example\_Union        Example\_Union;
16 \textcolor{keyword}{typedef} \textcolor{keyword}{struct }\_Example\_Struct1      Example\_Struct1;
17 \textcolor{keyword}{typedef} \textcolor{keyword}{struct }\_Example\_Struct2      Example\_Struct2;
18 \textcolor{keyword}{typedef} \textcolor{keyword}{struct }\_Example\_Struct3      Example\_Struct3;
19 \textcolor{keyword}{typedef} \textcolor{keyword}{struct }\_Example\_Lists        Example\_Lists;
20 
21 \textcolor{keyword}{enum} \_Example\_Data\_Type
22 \{
23    EET\_UNKNOWN = 0,
24    EET\_STRUCT1,
25    EET\_STRUCT2,
26    EET\_STRUCT3,
27    EET\_BASIC\_FLOAT,
28    EET\_BASIC\_STRING
29 \};
30 
31 \textcolor{keyword}{struct}
32 \{
33    Example\_Data\_Type u;
34    \textcolor{keyword}{const} \textcolor{keywordtype}{char}       *name;
35 \} eet\_mapping[] = \{
36    \{ EET\_STRUCT1, \textcolor{stringliteral}{"ST1"} \},
37    \{ EET\_STRUCT2, \textcolor{stringliteral}{"ST2"} \},
38    \{ EET\_STRUCT3, \textcolor{stringliteral}{"ST3"} \},
39    \{ EET\_BASIC\_FLOAT, \textcolor{stringliteral}{"float"} \},
40    \{ EET\_BASIC\_STRING, \textcolor{stringliteral}{"string"} \},
41    \{ EET\_UNKNOWN, NULL \}
42 \};
43 
44 \textcolor{keyword}{struct }\_Example\_Struct1
45 \{
46    \textcolor{keywordtype}{double}      val1;
47    \textcolor{keywordtype}{int}         stuff;
48    \textcolor{keyword}{const} \textcolor{keywordtype}{char} *s1;
49 \};
50 
51 \textcolor{keyword}{struct }\_Example\_Struct2
52 \{
53    \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}          b1;
54    \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{long} \textcolor{keywordtype}{long} v1;
55 \};
56 
57 \textcolor{keyword}{struct }\_Example\_Struct3
58 \{
59    \textcolor{keywordtype}{int} body;
60 \};
61 
62 \textcolor{keyword}{struct }\_Example\_Union
63 \{
64    Example\_Data\_Type type;
65 
66    \textcolor{keyword}{union }\{
67       Example\_Struct1 st1;
68       Example\_Struct2 st2;
69       Example\_Struct3 st3;
70       \textcolor{keywordtype}{float} f;
71       \textcolor{keyword}{const} \textcolor{keywordtype}{char}* string;
72    \} u;
73 \};
74 
75 \textcolor{keyword}{struct }\_Example\_Variant\_Type
76 \{
77    \textcolor{keyword}{const} \textcolor{keywordtype}{char} *type;
78    \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}   unknow : 1;
79 \};
80 
81 \textcolor{keyword}{struct }\_Example\_Variant
82 \{
83    Example\_Variant\_Type t;
84 
85    \textcolor{keywordtype}{void}                *data; \textcolor{comment}{/* differently than the union type, we}
86 \textcolor{comment}{                               * don't need to pre-allocate the memory}
87 \textcolor{comment}{                               * for the field*/}
88 \};
89 
90 \textcolor{keyword}{struct }\_Example\_Lists
91 \{
92    \hyperlink{struct__Eina__List}{Eina\_List} *union\_list;
93    \hyperlink{struct__Eina__List}{Eina\_List} *variant\_list;
94 \};
95 
96 \textcolor{keyword}{static} \textcolor{keywordtype}{void}
97 \_st1\_set(Example\_Struct1 *st1,
98          \textcolor{keywordtype}{double}           v1,
99          \textcolor{keywordtype}{int}              v2,
100          \textcolor{keyword}{const} \textcolor{keywordtype}{char}      *v3)
101 \{
102    st1->val1 = v1;
103    st1->stuff = v2;
104    st1->s1 = v3;
105 \} \textcolor{comment}{/* \_st1\_set */}
106 
107 \textcolor{keyword}{static} \textcolor{keywordtype}{void}
108 \_st2\_set(Example\_Struct2   *st2,
109          \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}          v1,
110          \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{long} \textcolor{keywordtype}{long} v2)
111 \{
112    st2->b1 = v1;
113    st2->v1 = v2;
114 \} \textcolor{comment}{/* \_st2\_set */}
115 
116 \textcolor{keyword}{static} \textcolor{keywordtype}{void}
117 \_st3\_set(Example\_Struct3 *st3,
118          \textcolor{keywordtype}{int}              v1)
119 \{
120    st3->body = v1;
121 \} \textcolor{comment}{/* \_st3\_set */}
122 
123 \textcolor{keyword}{static} \textcolor{keyword}{const} \textcolor{keywordtype}{char} *
124 \textcolor{comment}{/* union}
125 \textcolor{comment}{   type\_get() */}
126 \_union\_type\_get(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *data,
127                 \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}  *unknow)
128 \{
129    \textcolor{keyword}{const} Example\_Data\_Type *u = data;
130    \textcolor{keywordtype}{int} i;
131 
132    \textcolor{keywordflow}{if} (unknow)
133      *unknow = \hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE};
134 
135    \textcolor{keywordflow}{for} (i = 0; eet\_mapping[i].name != NULL; ++i)
136      \textcolor{keywordflow}{if} (*u == eet\_mapping[i].u)
137        \textcolor{keywordflow}{return} eet\_mapping[i].name;
138 
139    \textcolor{keywordflow}{if} (unknow)
140      *unknow = \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE};
141 
142    \textcolor{keywordflow}{return} NULL;
143 \} \textcolor{comment}{/* \_union\_type\_get */}
144 
145 \textcolor{keyword}{static} \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}
146 \_union\_type\_set(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *type,
147                 \textcolor{keywordtype}{void}       *data,
148                 \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}   unknow)
149 \{
150    Example\_Data\_Type *u = data;
151    \textcolor{keywordtype}{int} i;
152 
153    \textcolor{keywordflow}{if} (unknow)
154      \textcolor{keywordflow}{return} \hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE};
155 
156    \textcolor{keywordflow}{for} (i = 0; eet\_mapping[i].name != NULL; ++i)
157      \textcolor{keywordflow}{if} (strcmp(eet\_mapping[i].name, type) == 0)
158        \{
159           *u = eet\_mapping[i].u;
160           \textcolor{keywordflow}{return} \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE};
161        \}
162 
163    \textcolor{keywordflow}{return} \hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE};
164 \} \textcolor{comment}{/* \_union\_type\_set */}
165 
166 \textcolor{keyword}{static} \textcolor{keyword}{const} \textcolor{keywordtype}{char} *
167 \_variant\_type\_get(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *data,
168                   \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}  *unknow)
169 \{
170    \textcolor{keyword}{const} Example\_Variant\_Type *type = data;
171    \textcolor{keywordtype}{int} i;
172 
173    \textcolor{keywordflow}{if} (unknow)
174      *unknow = type->unknow;
175 
176    \textcolor{keywordflow}{for} (i = 0; eet\_mapping[i].name != NULL; ++i)
177      \textcolor{keywordflow}{if} (strcmp(type->type, eet\_mapping[i].name) == 0)
178        \textcolor{keywordflow}{return} eet\_mapping[i].name;
179 
180    \textcolor{keywordflow}{if} (unknow)
181      *unknow = \hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE};
182 
183    \textcolor{keywordflow}{return} type->type;
184 \} \textcolor{comment}{/* \_variant\_type\_get */}
185 
186 \textcolor{keyword}{static} \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}
187 \_variant\_type\_set(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *type,
188                   \textcolor{keywordtype}{void}       *data,
189                   \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}   unknow)
190 \{
191    Example\_Variant\_Type *vt = data;
192 
193    vt->type = type;
194    vt->unknow = unknow;
195    \textcolor{keywordflow}{return} \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE};
196 \} \textcolor{comment}{/* \_variant\_type\_set */}
197 
198 \textcolor{keyword}{static} \hyperlink{group__Eet__Data__Group_ga4baec0e840012480a0958c5c3bca276d}{Eet\_Data\_Descriptor} *
199 \_st1\_dd(\textcolor{keywordtype}{void})
200 \{
201    \hyperlink{struct__Eet__Data__Descriptor__Class}{Eet\_Data\_Descriptor\_Class} eddc;
202    \hyperlink{group__Eet__Data__Group_ga4baec0e840012480a0958c5c3bca276d}{Eet\_Data\_Descriptor} *res;
203 
204    \hyperlink{group__Eet__Data__Group_ga0bf94c07d8e69cfaac8dd2d615d7542c}{EET\_EINA\_FILE\_DATA\_DESCRIPTOR\_CLASS\_SET}(&eddc, Example\_Struct1);
205    res = \hyperlink{group__Eet__Data__Group_ga2a7251edf1f60ced86c4860207331bb6}{eet\_data\_descriptor\_file\_new}(&eddc);
206    \hyperlink{group__Eet__Data__Group_gac38ce778d7eba37cfca8a19efb7a9b3a}{EET\_DATA\_DESCRIPTOR\_ADD\_BASIC}(
207      res, Example\_Struct1, \textcolor{stringliteral}{"val1"}, val1, \hyperlink{group__Eet__Data__Group_gac2d8336b1127fd382c65416cf45cd3e8}{EET\_T\_DOUBLE});
208    \hyperlink{group__Eet__Data__Group_gac38ce778d7eba37cfca8a19efb7a9b3a}{EET\_DATA\_DESCRIPTOR\_ADD\_BASIC}(
209      res, Example\_Struct1, \textcolor{stringliteral}{"stuff"}, stuff, \hyperlink{group__Eet__Data__Group_ga4e196733795867f14c6e387af7287baa}{EET\_T\_INT});
210    \hyperlink{group__Eet__Data__Group_gac38ce778d7eba37cfca8a19efb7a9b3a}{EET\_DATA\_DESCRIPTOR\_ADD\_BASIC}(
211      res, Example\_Struct1, \textcolor{stringliteral}{"s1"}, s1, \hyperlink{group__Eet__Data__Group_ga0d2cf409bf3f151156d74d18ac59e3d1}{EET\_T\_STRING});
212 
213    \textcolor{keywordflow}{return} res;
214 \} \textcolor{comment}{/* \_st1\_dd */}
215 
216 \textcolor{keyword}{static} \hyperlink{group__Eet__Data__Group_ga4baec0e840012480a0958c5c3bca276d}{Eet\_Data\_Descriptor} *
217 \_st2\_dd(\textcolor{keywordtype}{void})
218 \{
219    \hyperlink{struct__Eet__Data__Descriptor__Class}{Eet\_Data\_Descriptor\_Class} eddc;
220    \hyperlink{group__Eet__Data__Group_ga4baec0e840012480a0958c5c3bca276d}{Eet\_Data\_Descriptor} *res;
221 
222    \hyperlink{group__Eet__Data__Group_ga0bf94c07d8e69cfaac8dd2d615d7542c}{EET\_EINA\_FILE\_DATA\_DESCRIPTOR\_CLASS\_SET}(&eddc, Example\_Struct2);
223    res = \hyperlink{group__Eet__Data__Group_ga2a7251edf1f60ced86c4860207331bb6}{eet\_data\_descriptor\_file\_new}(&eddc);
224    \hyperlink{group__Eet__Data__Group_gac38ce778d7eba37cfca8a19efb7a9b3a}{EET\_DATA\_DESCRIPTOR\_ADD\_BASIC}(
225      res, Example\_Struct2, \textcolor{stringliteral}{"b1"}, b1, \hyperlink{group__Eet__Data__Group_ga09a1341cc158fda0ba60ad2386ecd795}{EET\_T\_UCHAR});
226    \hyperlink{group__Eet__Data__Group_gac38ce778d7eba37cfca8a19efb7a9b3a}{EET\_DATA\_DESCRIPTOR\_ADD\_BASIC}(
227      res, Example\_Struct2, \textcolor{stringliteral}{"v1"}, v1, \hyperlink{group__Eet__Data__Group_gac984c4b3f0ad353a14679cf39a70ebd7}{EET\_T\_ULONG\_LONG});
228 
229    \textcolor{keywordflow}{return} res;
230 \} \textcolor{comment}{/* \_st2\_dd */}
231 
232 \textcolor{keyword}{static} \hyperlink{group__Eet__Data__Group_ga4baec0e840012480a0958c5c3bca276d}{Eet\_Data\_Descriptor} *
233 \_st3\_dd(\textcolor{keywordtype}{void})
234 \{
235    \hyperlink{struct__Eet__Data__Descriptor__Class}{Eet\_Data\_Descriptor\_Class} eddc;
236    \hyperlink{group__Eet__Data__Group_ga4baec0e840012480a0958c5c3bca276d}{Eet\_Data\_Descriptor} *res;
237 
238    \hyperlink{group__Eet__Data__Group_ga0bf94c07d8e69cfaac8dd2d615d7542c}{EET\_EINA\_FILE\_DATA\_DESCRIPTOR\_CLASS\_SET}(&eddc, Example\_Struct3);
239    res = \hyperlink{group__Eet__Data__Group_ga2a7251edf1f60ced86c4860207331bb6}{eet\_data\_descriptor\_file\_new}(&eddc);
240    \hyperlink{group__Eet__Data__Group_gac38ce778d7eba37cfca8a19efb7a9b3a}{EET\_DATA\_DESCRIPTOR\_ADD\_BASIC}(
241      res, Example\_Struct3, \textcolor{stringliteral}{"body"}, body, \hyperlink{group__Eet__Data__Group_ga4e196733795867f14c6e387af7287baa}{EET\_T\_INT});
242 
243    \textcolor{keywordflow}{return} res;
244 \} \textcolor{comment}{/* \_st3\_dd */}
245 
246 \textcolor{comment}{/* string that represents the entry in the eet file. you might like to}
247 \textcolor{comment}{ * have different profiles or so in the same file, this is possible}
248 \textcolor{comment}{ * with different strings}
249 \textcolor{comment}{ */}
250 \textcolor{keyword}{static} \textcolor{keyword}{const} \textcolor{keywordtype}{char} CACHE\_FILE\_ENTRY[] = \textcolor{stringliteral}{"cache"};
251 
252 \textcolor{comment}{/* keep the descriptor static global, so it can be shared by different}
253 \textcolor{comment}{ * functions (load/save) of this and only this file.}
254 \textcolor{comment}{ */}
255 \textcolor{keyword}{static} \hyperlink{group__Eet__Data__Group_ga4baec0e840012480a0958c5c3bca276d}{Eet\_Data\_Descriptor} *\_lists\_descriptor;
256 \textcolor{keyword}{static} \hyperlink{group__Eet__Data__Group_ga4baec0e840012480a0958c5c3bca276d}{Eet\_Data\_Descriptor} *\_struct\_1\_descriptor;
257 \textcolor{keyword}{static} \hyperlink{group__Eet__Data__Group_ga4baec0e840012480a0958c5c3bca276d}{Eet\_Data\_Descriptor} *\_struct\_2\_descriptor;
258 \textcolor{keyword}{static} \hyperlink{group__Eet__Data__Group_ga4baec0e840012480a0958c5c3bca276d}{Eet\_Data\_Descriptor} *\_struct\_3\_descriptor;
259 \textcolor{keyword}{static} \hyperlink{group__Eet__Data__Group_ga4baec0e840012480a0958c5c3bca276d}{Eet\_Data\_Descriptor} *\_union\_descriptor;
260 \textcolor{keyword}{static} \hyperlink{group__Eet__Data__Group_ga4baec0e840012480a0958c5c3bca276d}{Eet\_Data\_Descriptor} *\_variant\_descriptor;
261 \textcolor{keyword}{static} \hyperlink{group__Eet__Data__Group_ga4baec0e840012480a0958c5c3bca276d}{Eet\_Data\_Descriptor} *\_union\_unified\_descriptor;
262 \textcolor{keyword}{static} \hyperlink{group__Eet__Data__Group_ga4baec0e840012480a0958c5c3bca276d}{Eet\_Data\_Descriptor} *\_variant\_unified\_descriptor;
263 
264 \textcolor{comment}{/* keep file handle alive, so mmap()ed strings are all alive as}
265 \textcolor{comment}{ * well */}
266 \textcolor{keyword}{static} \hyperlink{group__Eet__File__Group_ga8d9779184a9870c1a225f1f40c76e8a7}{Eet\_File} *\_cache\_file = NULL;
267 \textcolor{keyword}{static} \hyperlink{group__Eet__File__Group_gaf0984c8280699ca5a3c4966f5580324c}{Eet\_Dictionary} *\_cache\_dict = NULL;
268 
269 \textcolor{keyword}{static} \textcolor{keywordtype}{void}
270 \textcolor{comment}{/* declaring types */}
271 \_data\_descriptors\_init(\textcolor{keywordtype}{void})
272 \{
273    \hyperlink{struct__Eet__Data__Descriptor__Class}{Eet\_Data\_Descriptor\_Class} eddc;
274 
275    \hyperlink{group__Eet__Data__Group_ga0bf94c07d8e69cfaac8dd2d615d7542c}{EET\_EINA\_FILE\_DATA\_DESCRIPTOR\_CLASS\_SET}(&eddc, Example\_Lists);
276    \_lists\_descriptor = \hyperlink{group__Eet__Data__Group_ga2a7251edf1f60ced86c4860207331bb6}{eet\_data\_descriptor\_file\_new}(&eddc);
277 
278    \_struct\_1\_descriptor = \_st1\_dd();
279    \_struct\_2\_descriptor = \_st2\_dd();
280    \_struct\_3\_descriptor = \_st3\_dd();
281 
282    \textcolor{comment}{/* for union */}
283    \hyperlink{group__Eet__Data__Group_ga0bf94c07d8e69cfaac8dd2d615d7542c}{EET\_EINA\_FILE\_DATA\_DESCRIPTOR\_CLASS\_SET}(&eddc, Example\_Union);
284    \_union\_descriptor = \hyperlink{group__Eet__Data__Group_ga2a7251edf1f60ced86c4860207331bb6}{eet\_data\_descriptor\_file\_new}(&eddc);
285 
286    eddc.\hyperlink{struct__Eet__Data__Descriptor__Class_a4e3696014d6907dadd55840bf6008317}{version} = \hyperlink{group__Eet__Data__Group_ga61a090586eff90415b429f1017acf8a7}{EET\_DATA\_DESCRIPTOR\_CLASS\_VERSION};
287    eddc.func.\hyperlink{struct__Eet__Data__Descriptor__Class_af71fcc4124973c0da6aa0e84dce426cb}{type\_get} = \_union\_type\_get;
288    eddc.func.\hyperlink{struct__Eet__Data__Descriptor__Class_a1b6477a2a52b797a662c3fff9793f97e}{type\_set} = \_union\_type\_set;
289    \_union\_unified\_descriptor = \hyperlink{group__Eet__Data__Group_ga2a7251edf1f60ced86c4860207331bb6}{eet\_data\_descriptor\_file\_new}(&eddc);
290 
291    \hyperlink{group__Eet__Data__Group_gad0daa543d93a64add80961ae5387d45a}{EET\_DATA\_DESCRIPTOR\_ADD\_MAPPING}(
292      \_union\_unified\_descriptor, \textcolor{stringliteral}{"ST1"}, \_struct\_1\_descriptor);
293    \hyperlink{group__Eet__Data__Group_gad0daa543d93a64add80961ae5387d45a}{EET\_DATA\_DESCRIPTOR\_ADD\_MAPPING}(
294      \_union\_unified\_descriptor, \textcolor{stringliteral}{"ST2"}, \_struct\_2\_descriptor);
295    \hyperlink{group__Eet__Data__Group_gad0daa543d93a64add80961ae5387d45a}{EET\_DATA\_DESCRIPTOR\_ADD\_MAPPING}(
296      \_union\_unified\_descriptor, \textcolor{stringliteral}{"ST3"}, \_struct\_3\_descriptor);
297    \hyperlink{group__Eet__Data__Group_gaaf153807a88cd2c3483c5c34bb920a95}{EET\_DATA\_DESCRIPTOR\_ADD\_MAPPING\_BASIC}(
298      \_union\_unified\_descriptor, \textcolor{stringliteral}{"float"}, \hyperlink{group__Eet__Data__Group_ga447b1b41e09b24ac6b3fbbac8d3efb30}{EET\_T\_FLOAT});
299    \hyperlink{group__Eet__Data__Group_gaaf153807a88cd2c3483c5c34bb920a95}{EET\_DATA\_DESCRIPTOR\_ADD\_MAPPING\_BASIC}(
300      \_union\_unified\_descriptor, \textcolor{stringliteral}{"string"}, \hyperlink{group__Eet__Data__Group_ga0d2cf409bf3f151156d74d18ac59e3d1}{EET\_T\_STRING});
301 
302    \hyperlink{group__Eet__Data__Group_ga07b711dca3d4bcaa0ccb8ced48341b90}{EET\_DATA\_DESCRIPTOR\_ADD\_UNION}(
303      \_union\_descriptor, Example\_Union, \textcolor{stringliteral}{"u"}, u, type,
304      \_union\_unified\_descriptor);
305 
306    \hyperlink{group__Eet__Data__Group_gabb4c7833ba053f2322e6b667a9ec7f04}{EET\_DATA\_DESCRIPTOR\_ADD\_LIST}(
307      \_lists\_descriptor, Example\_Lists, \textcolor{stringliteral}{"union\_list"}, union\_list,
308      \_union\_descriptor);
309 
310    \textcolor{comment}{/* for variant */}
311    \hyperlink{group__Eet__Data__Group_ga0bf94c07d8e69cfaac8dd2d615d7542c}{EET\_EINA\_FILE\_DATA\_DESCRIPTOR\_CLASS\_SET}(&eddc, Example\_Variant);
312    \_variant\_descriptor = \hyperlink{group__Eet__Data__Group_ga2a7251edf1f60ced86c4860207331bb6}{eet\_data\_descriptor\_file\_new}(&eddc);
313 
314    eddc.\hyperlink{struct__Eet__Data__Descriptor__Class_a4e3696014d6907dadd55840bf6008317}{version} = \hyperlink{group__Eet__Data__Group_ga61a090586eff90415b429f1017acf8a7}{EET\_DATA\_DESCRIPTOR\_CLASS\_VERSION};
315    eddc.func.\hyperlink{struct__Eet__Data__Descriptor__Class_af71fcc4124973c0da6aa0e84dce426cb}{type\_get} = \_variant\_type\_get;
316    eddc.func.\hyperlink{struct__Eet__Data__Descriptor__Class_a1b6477a2a52b797a662c3fff9793f97e}{type\_set} = \_variant\_type\_set;
317    \_variant\_unified\_descriptor = \hyperlink{group__Eet__Data__Group_gae300b4a97dbaab30a200edbb97f108c1}{eet\_data\_descriptor\_stream\_new}(&eddc);
318 
319    \hyperlink{group__Eet__Data__Group_gad0daa543d93a64add80961ae5387d45a}{EET\_DATA\_DESCRIPTOR\_ADD\_MAPPING}(
320      \_variant\_unified\_descriptor, \textcolor{stringliteral}{"ST1"}, \_struct\_1\_descriptor);
321    \hyperlink{group__Eet__Data__Group_gad0daa543d93a64add80961ae5387d45a}{EET\_DATA\_DESCRIPTOR\_ADD\_MAPPING}(
322      \_variant\_unified\_descriptor, \textcolor{stringliteral}{"ST2"}, \_struct\_2\_descriptor);
323    \hyperlink{group__Eet__Data__Group_gad0daa543d93a64add80961ae5387d45a}{EET\_DATA\_DESCRIPTOR\_ADD\_MAPPING}(
324      \_variant\_unified\_descriptor, \textcolor{stringliteral}{"ST3"}, \_struct\_3\_descriptor);
325 
326    \hyperlink{group__Eet__Data__Group_ga8851a40b130061262a8dd009f0457a65}{EET\_DATA\_DESCRIPTOR\_ADD\_VARIANT}(
327      \_variant\_descriptor, Example\_Variant, \textcolor{stringliteral}{"data"}, data, t,
328      \_variant\_unified\_descriptor);
329 
330    \hyperlink{group__Eet__Data__Group_gabb4c7833ba053f2322e6b667a9ec7f04}{EET\_DATA\_DESCRIPTOR\_ADD\_LIST}(
331      \_lists\_descriptor, Example\_Lists, \textcolor{stringliteral}{"variant\_list"}, variant\_list,
332      \_variant\_descriptor);
333 \} \textcolor{comment}{/* \_data\_descriptors\_init */}
334 
335 \textcolor{keyword}{static} \textcolor{keywordtype}{void}
336 \_data\_descriptors\_shutdown(\textcolor{keywordtype}{void})
337 \{
338    \hyperlink{group__Eet__Data__Group_ga3e2b601720973d0e1f4683768a593c4d}{eet\_data\_descriptor\_free}(\_lists\_descriptor);
339    \hyperlink{group__Eet__Data__Group_ga3e2b601720973d0e1f4683768a593c4d}{eet\_data\_descriptor\_free}(\_struct\_1\_descriptor);
340    \hyperlink{group__Eet__Data__Group_ga3e2b601720973d0e1f4683768a593c4d}{eet\_data\_descriptor\_free}(\_struct\_2\_descriptor);
341    \hyperlink{group__Eet__Data__Group_ga3e2b601720973d0e1f4683768a593c4d}{eet\_data\_descriptor\_free}(\_struct\_3\_descriptor);
342    \hyperlink{group__Eet__Data__Group_ga3e2b601720973d0e1f4683768a593c4d}{eet\_data\_descriptor\_free}(\_union\_descriptor);
343    \hyperlink{group__Eet__Data__Group_ga3e2b601720973d0e1f4683768a593c4d}{eet\_data\_descriptor\_free}(\_variant\_descriptor);
344    \hyperlink{group__Eet__Data__Group_ga3e2b601720973d0e1f4683768a593c4d}{eet\_data\_descriptor\_free}(\_union\_unified\_descriptor);
345    \hyperlink{group__Eet__Data__Group_ga3e2b601720973d0e1f4683768a593c4d}{eet\_data\_descriptor\_free}(\_variant\_unified\_descriptor);
346 \} \textcolor{comment}{/* \_data\_descriptors\_shutdown */}
347 
348 \textcolor{comment}{/* need to check if the pointer came from mmap()ed area in}
349 \textcolor{comment}{ * eet\_dictionary or it was allocated with eina\_stringshare\_add()}
350 \textcolor{comment}{ */}
351 \textcolor{keyword}{static} \textcolor{keywordtype}{void}
352 \_string\_free(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *str)
353 \{
354    \textcolor{keywordflow}{if} (!str)
355      \textcolor{keywordflow}{return};
356 
357    \textcolor{keywordflow}{if} ((\_cache\_dict) && (\hyperlink{group__Eet__File__Group_ga53290da52edb929b85e51f25e79d27c8}{eet\_dictionary\_string\_check}(\_cache\_dict, str)))
358      \textcolor{keywordflow}{return};
359 
360    \hyperlink{group__Eina__Stringshare__Group_ga4453d2aff2b325c7b45048f30df9b1f5}{eina\_stringshare\_del}(str);
361 \} \textcolor{comment}{/* \_string\_free */}
362 
363 \textcolor{keyword}{static} Example\_Union *
364 \_union\_1\_new(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *v1,
365              \textcolor{keyword}{const} \textcolor{keywordtype}{char} *v2,
366              \textcolor{keyword}{const} \textcolor{keywordtype}{char} *v3)
367 \{
368    Example\_Union *un = calloc(1, \textcolor{keyword}{sizeof}(Example\_Union));
369    \textcolor{keywordflow}{if} (!un)
370      \{
371         fprintf(
372           stderr, \textcolor{stringliteral}{"ERROR: could not allocate an Example\_Union struct.\(\backslash\)n"});
373         \textcolor{keywordflow}{return} NULL;
374      \}
375 
376    un->type = EET\_STRUCT1;
377    \_st1\_set(&(un->u.st1), atof(v1), atoi(v2), \hyperlink{group__Eina__Stringshare__Group_gac7a3f073cafb7af63b2c7cc2eabd1c1f}{eina\_stringshare\_add}(v3));
378 
379    \textcolor{keywordflow}{return} un;
380 \}
381 
382 \textcolor{keyword}{static} Example\_Union *
383 \_union\_2\_new(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *v1,
384              \textcolor{keyword}{const} \textcolor{keywordtype}{char} *v2)
385 \{
386    Example\_Union *un = calloc(1, \textcolor{keyword}{sizeof}(Example\_Union));
387    \textcolor{keywordflow}{if} (!un)
388      \{
389         fprintf(
390           stderr, \textcolor{stringliteral}{"ERROR: could not allocate an Example\_Union struct.\(\backslash\)n"});
391         \textcolor{keywordflow}{return} NULL;
392      \}
393 
394    un->type = EET\_STRUCT2;
395    \_st2\_set(&(un->u.st2), atoi(v1), atoi(v2));
396 
397    \textcolor{keywordflow}{return} un;
398 \}
399 
400 \textcolor{keyword}{static} Example\_Union *
401 \_union\_3\_new(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *v1)
402 \{
403    Example\_Union *un = calloc(1, \textcolor{keyword}{sizeof}(Example\_Union));
404    \textcolor{keywordflow}{if} (!un)
405      \{
406         fprintf(
407           stderr, \textcolor{stringliteral}{"ERROR: could not allocate an Example\_Union struct.\(\backslash\)n"});
408         \textcolor{keywordflow}{return} NULL;
409      \}
410 
411    un->type = EET\_STRUCT3;
412    \_st3\_set(&(un->u.st3), atoi(v1));
413 
414    \textcolor{keywordflow}{return} un;
415 \}
416 
417 \textcolor{keyword}{static} Example\_Union *
418 \_union\_float\_new(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *v1)
419 \{
420    Example\_Union *un = calloc(1, \textcolor{keyword}{sizeof}(Example\_Union));
421    \textcolor{keywordflow}{if} (!un)
422      \{
423         fprintf(
424           stderr, \textcolor{stringliteral}{"ERROR: could not allocate an Example\_Union struct.\(\backslash\)n"});
425         \textcolor{keywordflow}{return} NULL;
426      \}
427 
428    un->type = EET\_BASIC\_FLOAT;
429    un->u.f = atof(v1);
430 
431    \textcolor{keywordflow}{return} un;
432 \}
433 
434 \textcolor{keyword}{static} Example\_Union *
435 \_union\_string\_new(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *v1)
436 \{
437    Example\_Union *un = calloc(1, \textcolor{keyword}{sizeof}(Example\_Union));
438    \textcolor{keywordflow}{if} (!un)
439      \{
440         fprintf(
441           stderr, \textcolor{stringliteral}{"ERROR: could not allocate an Example\_Union struct.\(\backslash\)n"});
442         \textcolor{keywordflow}{return} NULL;
443      \}
444 
445    un->type = EET\_BASIC\_STRING;
446    un->u.string = v1;
447 
448    \textcolor{keywordflow}{return} un;
449 \}
450 
451 \textcolor{keyword}{static} Example\_Variant *
452 \_variant\_1\_new(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *v1,
453                \textcolor{keyword}{const} \textcolor{keywordtype}{char} *v2,
454                \textcolor{keyword}{const} \textcolor{keywordtype}{char} *v3)
455 \{
456    Example\_Struct1 *st1;
457    Example\_Variant *va = calloc(1, \textcolor{keyword}{sizeof}(Example\_Variant));
458    \textcolor{keywordflow}{if} (!va)
459      \{
460         fprintf(
461           stderr, \textcolor{stringliteral}{"ERROR: could not allocate an Example\_Variant struct.\(\backslash\)n"});
462         \textcolor{keywordflow}{return} NULL;
463      \}
464 
465    va->t.type = eet\_mapping[0].name;
466    st1 = calloc(1, \textcolor{keyword}{sizeof} (Example\_Struct1));
467    \_st1\_set(st1, atof(v1), atoi(v2), \hyperlink{group__Eina__Stringshare__Group_gac7a3f073cafb7af63b2c7cc2eabd1c1f}{eina\_stringshare\_add}(v3));
468    va->data = st1;
469 
470    \textcolor{keywordflow}{return} va;
471 \}
472 
473 \textcolor{keyword}{static} Example\_Variant *
474 \_variant\_2\_new(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *v1,
475                \textcolor{keyword}{const} \textcolor{keywordtype}{char} *v2)
476 \{
477    printf(\textcolor{stringliteral}{"varinant 2 new\(\backslash\)n"});
478 
479    Example\_Struct2 *st2;
480    Example\_Variant *va = calloc(1, \textcolor{keyword}{sizeof}(Example\_Variant));
481    \textcolor{keywordflow}{if} (!va)
482      \{
483         fprintf(
484           stderr, \textcolor{stringliteral}{"ERROR: could not allocate an Example\_Variant struct.\(\backslash\)n"});
485         \textcolor{keywordflow}{return} NULL;
486      \}
487 
488    va->t.type = eet\_mapping[1].name;
489 
490    printf(\textcolor{stringliteral}{"type gets %s\(\backslash\)n"}, va->t.type);
491 
492    st2 = calloc(1, \textcolor{keyword}{sizeof} (Example\_Struct2));
493    \_st2\_set(st2, atoi(v1), atoi(v2));
494    va->data = st2;
495 
496    \textcolor{keywordflow}{return} va;
497 \}
498 
499 \textcolor{keyword}{static} Example\_Variant *
500 \_variant\_3\_new(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *v1)
501 \{
502    Example\_Struct3 *st3;
503    Example\_Variant *va = calloc(1, \textcolor{keyword}{sizeof}(Example\_Variant));
504    \textcolor{keywordflow}{if} (!va)
505      \{
506         fprintf(
507           stderr, \textcolor{stringliteral}{"ERROR: could not allocate an Example\_Variant struct.\(\backslash\)n"});
508         \textcolor{keywordflow}{return} NULL;
509      \}
510 
511    va->t.type = eet\_mapping[2].name;
512    st3 = calloc(1, \textcolor{keyword}{sizeof} (Example\_Struct3));
513    \_st3\_set(st3, atoi(v1));
514    va->data = st3;
515 
516    \textcolor{keywordflow}{return} va;
517 \}
518 
519 \textcolor{keyword}{static} Example\_Lists *
520 \_data\_new(\textcolor{keywordtype}{void})
521 \{
522    Example\_Lists *example\_lists = calloc(1, \textcolor{keyword}{sizeof}(Example\_Lists));
523    \textcolor{keywordflow}{if} (!example\_lists)
524      \{
525         fprintf(stderr, \textcolor{stringliteral}{"ERROR: could not allocate a Example\_Lists struct.\(\backslash\)n"});
526         \textcolor{keywordflow}{return} NULL;
527      \}
528 
529    \textcolor{keywordflow}{return} example\_lists;
530 \} \textcolor{comment}{/* \_data\_new */}
531 
532 \textcolor{keyword}{static} \textcolor{keywordtype}{void}
533 \_union\_free(Example\_Union *un)
534 \{
535    \textcolor{keywordflow}{if} (un->type == EET\_STRUCT1)
536      \{
537         Example\_Struct1 *st1 = &(un->u.st1);
538         \_string\_free(st1->s1);
539      \}
540 
541    free(un);
542 \}
543 
544 \textcolor{keyword}{static} \textcolor{keywordtype}{void}
545 \_variant\_free(Example\_Variant *va)
546 \{
547    \textcolor{keywordflow}{if} (!strcmp(va->t.type, eet\_mapping[0].name))
548      \{
549         Example\_Struct1 *st1 = va->data;
550         \_string\_free(st1->s1);
551      \}
552 
553    free(va->data);
554    free(va);
555 \}
556 
557 \textcolor{keyword}{static} \textcolor{keywordtype}{void}
558 \_data\_free(Example\_Lists *cache)
559 \{
560    Example\_Union *un;
561    Example\_Variant *va;
562 
563    \hyperlink{group__Eina__List__Group_gae27a2c686a0a11693f9b06957c9bba83}{EINA\_LIST\_FREE}(cache->union\_list, un)
564      \_union\_free(un);
565 
566    \hyperlink{group__Eina__List__Group_gae27a2c686a0a11693f9b06957c9bba83}{EINA\_LIST\_FREE}(cache->variant\_list, va)
567      \_variant\_free(va);
568 
569    free(cache);
570 \} \textcolor{comment}{/* \_data\_free */}
571 
572 static Example\_Lists *
573 \_data\_load(const \textcolor{keywordtype}{char} *filename)
574 \{
575    Example\_Lists *data;
576    \hyperlink{group__Eet__File__Group_ga8d9779184a9870c1a225f1f40c76e8a7}{Eet\_File} *ef = \hyperlink{group__Eet__File__Group_ga5f55956b860aa2c77af9b1a880c4c256}{eet\_open}(filename, \hyperlink{group__Eet__File__Group_ggaa8e1a7af50fefaf15eb2f69543d24998a416f7e9a76b8131a44bbeedb13060c81}{EET\_FILE\_MODE\_READ});
577    \textcolor{keywordflow}{if} (!ef)
578      \{
579         fprintf(stderr, \textcolor{stringliteral}{"ERROR: could not open '%s' for read\(\backslash\)n"}, filename);
580         \textcolor{keywordflow}{return} NULL;
581      \}
582 
583    data = \hyperlink{group__Eet__Data__Group_ga4d1807cbbc448304f22a8808318a3429}{eet\_data\_read}(ef, \_lists\_descriptor, CACHE\_FILE\_ENTRY);
584    \textcolor{keywordflow}{if} (!data)
585      \{
586         \hyperlink{group__Eet__File__Group_ga1675fef1f6012c1e02ae313d13dc3e03}{eet\_close}(ef);
587         \textcolor{keywordflow}{return} NULL;
588      \}
589 
590    \textcolor{keywordflow}{if} (\_cache\_file)
591      \hyperlink{group__Eet__File__Group_ga1675fef1f6012c1e02ae313d13dc3e03}{eet\_close}(\_cache\_file);
592 
593    \_cache\_file = ef;
594    \_cache\_dict = \hyperlink{group__Eet__File__Group_gab45ad39596d2fb54a88fda93e7fa0b0f}{eet\_dictionary\_get}(ef);
595 
596    \textcolor{keywordflow}{return} data;
597 \} \textcolor{comment}{/* \_data\_load */}
598 
599 \textcolor{keyword}{static} \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}
600 \_data\_save(\textcolor{keyword}{const} Example\_Lists *cache,
601            \textcolor{keyword}{const} \textcolor{keywordtype}{char}          *filename)
602 \{
603    \textcolor{keywordtype}{char} tmp[PATH\_MAX];
604    \hyperlink{group__Eet__File__Group_ga8d9779184a9870c1a225f1f40c76e8a7}{Eet\_File} *ef;
605    \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool} ret;
606    \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} i, len;
607    \textcolor{keyword}{struct }stat st;
608 
609    len = \hyperlink{group__Eina__String__Group_ga6bda31d2e1b6d2737b7fe1784780cd2f}{eina\_strlcpy}(tmp, filename, \textcolor{keyword}{sizeof}(tmp));
610    \textcolor{keywordflow}{if} (len + 12 >= (\textcolor{keywordtype}{int})\textcolor{keyword}{sizeof}(tmp))
611      \{
612         fprintf(stderr, \textcolor{stringliteral}{"ERROR: file name is too big: %s\(\backslash\)n"}, filename);
613         \textcolor{keywordflow}{return} \hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE};
614      \}
615 
616    i = 0;
617    \textcolor{keywordflow}{do}
618      \{
619         snprintf(tmp + len, 12, \textcolor{stringliteral}{".%u"}, i);
620         i++;
621      \}
622    \textcolor{keywordflow}{while} (stat(tmp, &st) == 0);
623 
624    ef = \hyperlink{group__Eet__File__Group_ga5f55956b860aa2c77af9b1a880c4c256}{eet\_open}(tmp, \hyperlink{group__Eet__File__Group_ggaa8e1a7af50fefaf15eb2f69543d24998a8f395f56fba48be007c65be51d799ee9}{EET\_FILE\_MODE\_WRITE});
625    \textcolor{keywordflow}{if} (!ef)
626      \{
627         fprintf(stderr, \textcolor{stringliteral}{"ERROR: could not open '%s' for write\(\backslash\)n"}, tmp);
628         \textcolor{keywordflow}{return} \hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE};
629      \}
630 
631    ret = \hyperlink{group__Eet__Data__Group_gac66d1c49e3490bc5d803982d833ff8aa}{eet\_data\_write}
632        (ef, \_lists\_descriptor, CACHE\_FILE\_ENTRY, cache, \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE});
633 
634    \hyperlink{group__Eet__File__Group_ga1675fef1f6012c1e02ae313d13dc3e03}{eet\_close}(ef);
635 
636    \textcolor{keywordflow}{if} (ret)
637      \{
638         unlink(filename);
639         rename(tmp, filename);
640      \}
641 
642    \textcolor{keywordflow}{return} ret;
643 \} \textcolor{comment}{/* \_data\_save */}
644 
645 \textcolor{keyword}{static} \textcolor{keywordtype}{void}
646 \_print\_union(\textcolor{keyword}{const} Example\_Union *un)
647 \{
648    printf(\textcolor{stringliteral}{"\(\backslash\)t  |   type: %s'\(\backslash\)n"}, eet\_mapping[un->type - 1].name);
649 
650    \textcolor{keywordflow}{switch} (un->type)
651      \{
652       \textcolor{keywordflow}{case} EET\_STRUCT1:
653         printf(\textcolor{stringliteral}{"\(\backslash\)t\(\backslash\)t  val1: %f\(\backslash\)n"}, un->u.st1.val1);
654         printf(\textcolor{stringliteral}{"\(\backslash\)t\(\backslash\)t  stuff: %d\(\backslash\)n"}, un->u.st1.stuff);
655         printf(\textcolor{stringliteral}{"\(\backslash\)t\(\backslash\)t  s1: %s\(\backslash\)n"}, un->u.st1.s1);
656         \textcolor{keywordflow}{break};
657 
658       \textcolor{keywordflow}{case} EET\_STRUCT2:
659         printf(\textcolor{stringliteral}{"\(\backslash\)t\(\backslash\)t  val1: %i\(\backslash\)n"}, un->u.st2.b1);
660         printf(\textcolor{stringliteral}{"\(\backslash\)t\(\backslash\)t  stuff: %lli\(\backslash\)n"}, un->u.st2.v1);
661         \textcolor{keywordflow}{break};
662 
663       \textcolor{keywordflow}{case} EET\_STRUCT3:
664         printf(\textcolor{stringliteral}{"\(\backslash\)t\(\backslash\)t  val1: %i\(\backslash\)n"}, un->u.st3.body);
665         \textcolor{keywordflow}{break};
666 
667       \textcolor{keywordflow}{case} EET\_BASIC\_FLOAT:
668         printf(\textcolor{stringliteral}{"\(\backslash\)t\(\backslash\)t  float: %f\(\backslash\)n"}, un->u.f);
669         \textcolor{keywordflow}{break};
670 
671       \textcolor{keywordflow}{case} EET\_BASIC\_STRING:
672         printf(\textcolor{stringliteral}{"\(\backslash\)t\(\backslash\)t  string: %s\(\backslash\)n"}, un->u.string);
673         \textcolor{keywordflow}{break};
674 
675       \textcolor{keywordflow}{default}:
676         \textcolor{keywordflow}{return};
677      \}
678 \}
679 
680 \textcolor{keyword}{static} \textcolor{keywordtype}{void}
681 \_print\_variant(\textcolor{keyword}{const} Example\_Variant *va)
682 \{
683    printf(\textcolor{stringliteral}{"\(\backslash\)t  |   type: %s'\(\backslash\)n"}, va->t.type);
684 
685    \textcolor{keywordflow}{switch} (va->t.type[2])
686      \{
687       \textcolor{keywordflow}{case} \textcolor{charliteral}{'1'}:
688       \{
689          Example\_Struct1 *st1 = va->data;
690 
691          printf(\textcolor{stringliteral}{"\(\backslash\)t\(\backslash\)t  val1: %f\(\backslash\)n"}, st1->val1);
692          printf(\textcolor{stringliteral}{"\(\backslash\)t\(\backslash\)t  stuff: %d\(\backslash\)n"}, st1->stuff);
693          printf(\textcolor{stringliteral}{"\(\backslash\)t\(\backslash\)t  s1: %s\(\backslash\)n"}, st1->s1);
694       \}
695       \textcolor{keywordflow}{break};
696 
697       \textcolor{keywordflow}{case} \textcolor{charliteral}{'2'}:
698       \{
699          Example\_Struct2 *st2 = va->data;
700 
701          printf(\textcolor{stringliteral}{"\(\backslash\)t\(\backslash\)t  val1: %i\(\backslash\)n"}, st2->b1);
702          printf(\textcolor{stringliteral}{"\(\backslash\)t\(\backslash\)t  stuff: %lli\(\backslash\)n"}, st2->v1);
703       \}
704       \textcolor{keywordflow}{break};
705 
706       \textcolor{keywordflow}{case} \textcolor{charliteral}{'3'}:
707       \{
708          Example\_Struct3 *st3 = va->data;
709 
710          printf(\textcolor{stringliteral}{"\(\backslash\)t\(\backslash\)t  val1: %i\(\backslash\)n"}, st3->body);
711       \}
712       \textcolor{keywordflow}{break};
713 
714       \textcolor{keywordflow}{default}:
715         \textcolor{keywordflow}{return};
716      \}
717 \}
718 
719 \textcolor{keywordtype}{int}
720 main(\textcolor{keywordtype}{int}   argc,
721      \textcolor{keywordtype}{char} *argv[])
722 \{
723    Example\_Lists *data\_lists;
724    \textcolor{keywordtype}{int} ret = 0;
725 
726    \textcolor{keywordflow}{if} (argc < 3)
727      \{
728         fprintf(stderr,
729                 \textcolor{stringliteral}{"Usage:\(\backslash\)n\(\backslash\)t%s <input> <output> [action action-params]\(\backslash\)n\(\backslash\)n"}
730                 \textcolor{stringliteral}{"where actions and their parameters are:\(\backslash\)n"}
731                 \textcolor{stringliteral}{"\(\backslash\)tunion <type> [fields]\(\backslash\)n"}
732                 \textcolor{stringliteral}{"\(\backslash\)tvariant <type> [fields]\(\backslash\)n"}
733                 \textcolor{stringliteral}{"\(\backslash\)n"},
734                 argv[0]);
735         \textcolor{keywordflow}{return} -1;
736      \}
737 
738    \hyperlink{group__Eina__Main__Group_gabf448ada5bc81a07342b66c6f818ee5e}{eina\_init}();
739    \hyperlink{group__Eet__Group_ga9903687bfa20fe9a9e59d4c1d213e89a}{eet\_init}();
740    \_data\_descriptors\_init();
741 
742    data\_lists = \_data\_load(argv[1]);
743    \textcolor{keywordflow}{if} (!data\_lists)
744      \{
745         printf(\textcolor{stringliteral}{"Creating new data lists.\(\backslash\)n"});
746         data\_lists = \_data\_new();
747         \textcolor{keywordflow}{if} (!data\_lists)
748           \{
749              ret = -2;
750              \textcolor{keywordflow}{goto} end;
751           \}
752      \}
753 
754    \textcolor{keywordflow}{if} (argc > 3)
755      \{
756         \textcolor{keywordflow}{if} (strcmp(argv[3], \textcolor{stringliteral}{"union"}) == 0)
757           \{
758              \textcolor{keywordflow}{if} (argc > 4)
759                \{
760                   \textcolor{keywordtype}{int} type = atoi(argv[4]);
761                   Example\_Union *un;
762 
763                   \textcolor{keywordflow}{if} (type < EET\_STRUCT1 || type > EET\_BASIC\_STRING)
764                     \{
765                        fprintf(stderr,
766                                \textcolor{stringliteral}{"ERROR: invalid type parameter (%s).\(\backslash\)n"},
767                                argv[4]);
768                        \textcolor{keywordflow}{goto} cont;
769                     \}
770 
771                   \textcolor{keywordflow}{switch} (type)
772                     \{
773                      \textcolor{keywordflow}{case} 1:
774                        \textcolor{keywordflow}{if} (argc != 8)
775                          \{
776                             fprintf(
777                               stderr, \textcolor{stringliteral}{"ERROR: wrong number of parameters"}
778                                       \textcolor{stringliteral}{" (%d).\(\backslash\)n"}, argc);
779                             \textcolor{keywordflow}{goto} cont;
780                          \}
781 
782                        un = \_union\_1\_new(
783                            argv[5], argv[6], argv[7]);
784                        \textcolor{keywordflow}{if} (!un)
785                          \{
786                             fprintf(
787                               stderr, \textcolor{stringliteral}{"ERROR: could not create the "}
788                                       \textcolor{stringliteral}{"requested union.\(\backslash\)n"});
789                             \textcolor{keywordflow}{goto} cont;
790                          \}
791                        data\_lists->union\_list =
792                          \hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}(data\_lists->union\_list, un);
793                        \textcolor{keywordflow}{break};
794 
795                      \textcolor{keywordflow}{case} 2:
796                        \textcolor{keywordflow}{if} (argc != 7)
797                          \{
798                             fprintf(
799                               stderr, \textcolor{stringliteral}{"ERROR: wrong number of parameters"}
800                                       \textcolor{stringliteral}{" (%d).\(\backslash\)n"}, argc);
801                             \textcolor{keywordflow}{goto} cont;
802                          \}
803 
804                        un = \_union\_2\_new(argv[5], argv[6]);
805                        \textcolor{keywordflow}{if} (!un)
806                          \{
807                             fprintf(
808                               stderr, \textcolor{stringliteral}{"ERROR: could not create the "}
809                                       \textcolor{stringliteral}{"requested union.\(\backslash\)n"});
810                             \textcolor{keywordflow}{goto} cont;
811                          \}
812                        data\_lists->union\_list =
813                          \hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}(data\_lists->union\_list, un);
814                        \textcolor{keywordflow}{break};
815 
816                      \textcolor{keywordflow}{case} 3:
817                        \textcolor{keywordflow}{if} (argc != 6)
818                          \{
819                             fprintf(
820                               stderr, \textcolor{stringliteral}{"ERROR: wrong number of parameters"}
821                                       \textcolor{stringliteral}{" (%d).\(\backslash\)n"}, argc);
822                             \textcolor{keywordflow}{goto} cont;
823                          \}
824 
825                        un = \_union\_3\_new(argv[5]);
826                        \textcolor{keywordflow}{if} (!un)
827                          \{
828                             fprintf(
829                               stderr, \textcolor{stringliteral}{"ERROR: could not create the "}
830                                       \textcolor{stringliteral}{"requested union.\(\backslash\)n"});
831                             \textcolor{keywordflow}{goto} cont;
832                          \}
833                        data\_lists->union\_list =
834                          \hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}(data\_lists->union\_list, un);
835                        \textcolor{keywordflow}{break};
836 
837                      \textcolor{keywordflow}{case} EET\_BASIC\_FLOAT:
838                        \textcolor{keywordflow}{if} (argc != 6)
839                          \{
840                             fprintf(
841                               stderr, \textcolor{stringliteral}{"ERROR: wrong number of parameters"}
842                                       \textcolor{stringliteral}{" (%d).\(\backslash\)n"}, argc);
843                             \textcolor{keywordflow}{goto} cont;
844                          \}
845 
846                        un = \_union\_float\_new(argv[5]);
847                        \textcolor{keywordflow}{if} (!un)
848                          \{
849                             fprintf(
850                               stderr, \textcolor{stringliteral}{"ERROR: could not create the "}
851                                       \textcolor{stringliteral}{"requested union.\(\backslash\)n"});
852                             \textcolor{keywordflow}{goto} cont;
853                          \}
854                        data\_lists->union\_list =
855                          \hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}(data\_lists->union\_list, un);
856                        \textcolor{keywordflow}{break};
857 
858                      \textcolor{keywordflow}{case} EET\_BASIC\_STRING:
859                        \textcolor{keywordflow}{if} (argc != 6)
860                          \{
861                             fprintf(
862                               stderr, \textcolor{stringliteral}{"ERROR: wrong number of parameters"}
863                                       \textcolor{stringliteral}{" (%d).\(\backslash\)n"}, argc);
864                             \textcolor{keywordflow}{goto} cont;
865                          \}
866 
867                        un = \_union\_string\_new(argv[5]);
868                        \textcolor{keywordflow}{if} (!un)
869                          \{
870                             fprintf(
871                               stderr, \textcolor{stringliteral}{"ERROR: could not create the "}
872                                       \textcolor{stringliteral}{"requested union.\(\backslash\)n"});
873                             \textcolor{keywordflow}{goto} cont;
874                          \}
875                        data\_lists->union\_list =
876                          \hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}(data\_lists->union\_list, un);
877                        \textcolor{keywordflow}{break};
878 
879                      \textcolor{keywordflow}{default}:
880                        fprintf(
881                          stderr, \textcolor{stringliteral}{"ERROR: bad type of of struct passed\(\backslash\)n"});
882                        \textcolor{keywordflow}{goto} cont;
883                     \}
884                \}
885              \textcolor{keywordflow}{else}
886                fprintf(stderr,
887                        \textcolor{stringliteral}{"ERROR: wrong number of parameters (%d).\(\backslash\)n"},
888                        argc);
889           \}
890         \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (strcmp(argv[3], \textcolor{stringliteral}{"variant"}) == 0)
891           \{
892              \textcolor{keywordflow}{if} (argc > 4)
893                \{
894                   \textcolor{keywordtype}{int} type = atoi(argv[4]);
895                   Example\_Variant *va;
896 
897                   \textcolor{keywordflow}{if} (type < EET\_STRUCT1 || type > EET\_STRUCT3)
898                     \{
899                        fprintf(stderr,
900                                \textcolor{stringliteral}{"ERROR: invalid type parameter (%s).\(\backslash\)n"},
901                                argv[4]);
902                        \textcolor{keywordflow}{goto} cont;
903                     \}
904 
905                   \textcolor{keywordflow}{switch} (type)
906                     \{
907                      \textcolor{keywordflow}{case} 1:
908                        \textcolor{keywordflow}{if} (argc != 8)
909                          \{
910                             fprintf(
911                               stderr, \textcolor{stringliteral}{"ERROR: wrong number of parameters"}
912                                       \textcolor{stringliteral}{" (%d).\(\backslash\)n"}, argc);
913                             \textcolor{keywordflow}{goto} cont;
914                          \}
915 
916                        va = \_variant\_1\_new(
917                            argv[5], argv[6], argv[7]);
918                        \textcolor{keywordflow}{if} (!va)
919                          \{
920                             fprintf(
921                               stderr, \textcolor{stringliteral}{"ERROR: could not create the "}
922                                       \textcolor{stringliteral}{"requested variant.\(\backslash\)n"});
923                             \textcolor{keywordflow}{goto} cont;
924                          \}
925                        data\_lists->variant\_list =
926                          \hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}(data\_lists->variant\_list, va);
927                        \textcolor{keywordflow}{break};
928 
929                      \textcolor{keywordflow}{case} 2:
930                        \textcolor{keywordflow}{if} (argc != 7)
931                          \{
932                             fprintf(
933                               stderr, \textcolor{stringliteral}{"ERROR: wrong number of parameters"}
934                                       \textcolor{stringliteral}{" (%d).\(\backslash\)n"}, argc);
935                             \textcolor{keywordflow}{goto} cont;
936                          \}
937 
938                        va = \_variant\_2\_new(argv[5], argv[6]);
939                        \textcolor{keywordflow}{if} (!va)
940                          \{
941                             fprintf(
942                               stderr, \textcolor{stringliteral}{"ERROR: could not create the "}
943                                       \textcolor{stringliteral}{"requested variant.\(\backslash\)n"});
944                             \textcolor{keywordflow}{goto} cont;
945                          \}
946                        data\_lists->variant\_list =
947                          \hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}(data\_lists->variant\_list, va);
948                        \textcolor{keywordflow}{break};
949 
950                      \textcolor{keywordflow}{case} 3:
951                        \textcolor{keywordflow}{if} (argc != 6)
952                          \{
953                             fprintf(
954                               stderr, \textcolor{stringliteral}{"ERROR: wrong number of parameters"}
955                                       \textcolor{stringliteral}{" (%d).\(\backslash\)n"}, argc);
956                             \textcolor{keywordflow}{goto} cont;
957                          \}
958 
959                        va = \_variant\_3\_new(argv[5]);
960                        \textcolor{keywordflow}{if} (!va)
961                          \{
962                             fprintf(
963                               stderr, \textcolor{stringliteral}{"ERROR: could not create the "}
964                                       \textcolor{stringliteral}{"requested variant.\(\backslash\)n"});
965                             \textcolor{keywordflow}{goto} cont;
966                          \}
967                        data\_lists->variant\_list =
968                          \hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}(data\_lists->variant\_list, va);
969                        \textcolor{keywordflow}{break};
970 
971                      \textcolor{keywordflow}{default}:
972                        fprintf(
973                          stderr, \textcolor{stringliteral}{"ERROR: bad type of of struct passed\(\backslash\)n"});
974                        \textcolor{keywordflow}{goto} cont;
975                     \}
976                \}
977              \textcolor{keywordflow}{else}
978                fprintf(stderr,
979                        \textcolor{stringliteral}{"ERROR: wrong number of parameters (%d).\(\backslash\)n"},
980                        argc);
981           \}
982         \textcolor{keywordflow}{else}
983           fprintf(stderr, \textcolor{stringliteral}{"ERROR: unknown action '%s'\(\backslash\)n"}, argv[3]);
984      \}
985 
986 cont:
987    printf(\textcolor{stringliteral}{"Cached data:\(\backslash\)n"});
988 
989    printf(\textcolor{stringliteral}{"\(\backslash\)tstats: unions=%u, variants=%u\(\backslash\)n"},
990           \hyperlink{group__Eina__List__Group_ga301729054a498a2df09a5f1dd760697e}{eina\_list\_count}(data\_lists->union\_list),
991           \hyperlink{group__Eina__List__Group_ga301729054a498a2df09a5f1dd760697e}{eina\_list\_count}(data\_lists->variant\_list));
992 
993    \textcolor{keywordflow}{if} (\hyperlink{group__Eina__List__Group_ga301729054a498a2df09a5f1dd760697e}{eina\_list\_count}(data\_lists->union\_list))
994      \{
995         \textcolor{keyword}{const} \hyperlink{struct__Eina__List}{Eina\_List} *l;
996         \textcolor{keyword}{const} Example\_Union *un;
997         printf(\textcolor{stringliteral}{"\(\backslash\)t  * union list:\(\backslash\)n"});
998 
999         \hyperlink{group__Eina__List__Group_gad02f746a08ee0b12b7ed66d4bc0d71d8}{EINA\_LIST\_FOREACH}(data\_lists->union\_list, l, un)
1000           \{
1001              \_print\_union(un);
1002           \}
1003      \}
1004 
1005    \textcolor{keywordflow}{if} (\hyperlink{group__Eina__List__Group_ga301729054a498a2df09a5f1dd760697e}{eina\_list\_count}(data\_lists->variant\_list))
1006      \{
1007         \textcolor{keyword}{const} \hyperlink{struct__Eina__List}{Eina\_List} *l;
1008         \textcolor{keyword}{const} Example\_Variant *un;
1009         printf(\textcolor{stringliteral}{"\(\backslash\)t  * variant list:\(\backslash\)n"});
1010 
1011         \hyperlink{group__Eina__List__Group_gad02f746a08ee0b12b7ed66d4bc0d71d8}{EINA\_LIST\_FOREACH}(data\_lists->variant\_list, l, un)
1012           \{
1013              \_print\_variant(un);
1014           \}
1015      \}
1016 
1017    printf(\textcolor{stringliteral}{"\(\backslash\)n"});
1018 
1019    \textcolor{keywordflow}{if} (!\_data\_save(data\_lists, argv[2]))
1020      ret = -3;
1021 
1022    \_data\_free(data\_lists);
1023 
1024 end:
1025    \textcolor{keywordflow}{if} (\_cache\_file)
1026      \hyperlink{group__Eet__File__Group_ga1675fef1f6012c1e02ae313d13dc3e03}{eet\_close}(\_cache\_file);
1027    \_data\_descriptors\_shutdown();
1028    \hyperlink{group__Eet__Group_gacbc7583179399d3b3e7b003e911f866f}{eet\_shutdown}();
1029    \hyperlink{group__Eina__Main__Group_ga6741fcaba116e31e96ce14dcfa03f568}{eina\_shutdown}();
1030 
1031    \textcolor{keywordflow}{return} ret;
1032 \} \textcolor{comment}{/* main */}
1033 
\end{DoxyCodeInclude}
 