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're attaining ourselves to two new data types to store in an Eet file -- {\bfseries unions} and {\bfseries variants}. We don't try to come with data mapping to real world use cases, here. Instead, we'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'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'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\+N\+G} 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 = calloc(1, \textcolor{keyword}{sizeof} (Example\_Variant));
466    va->t.type = eet\_mapping[0].name;
467    st1 = calloc(1, \textcolor{keyword}{sizeof} (Example\_Struct1));
468    \_st1\_set(st1, atof(v1), atoi(v2), \hyperlink{group__Eina__Stringshare__Group_gac7a3f073cafb7af63b2c7cc2eabd1c1f}{eina\_stringshare\_add}(v3));
469    va->data = st1;
470 
471    \textcolor{keywordflow}{return} va;
472 \}
473 
474 \textcolor{keyword}{static} Example\_Variant *
475 \_variant\_2\_new(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *v1,
476                \textcolor{keyword}{const} \textcolor{keywordtype}{char} *v2)
477 \{
478    printf(\textcolor{stringliteral}{"varinant 2 new\(\backslash\)n"});
479 
480    Example\_Struct2 *st2;
481    Example\_Variant *va = calloc(1, \textcolor{keyword}{sizeof}(Example\_Variant));
482    \textcolor{keywordflow}{if} (!va)
483      \{
484         fprintf(
485           stderr, \textcolor{stringliteral}{"ERROR: could not allocate an Example\_Variant struct.\(\backslash\)n"});
486         \textcolor{keywordflow}{return} NULL;
487      \}
488 
489    va = calloc(1, \textcolor{keyword}{sizeof} (Example\_Variant));
490 
491    va->t.type = eet\_mapping[1].name;
492 
493    printf(\textcolor{stringliteral}{"type gets %s\(\backslash\)n"}, va->t.type);
494 
495    st2 = calloc(1, \textcolor{keyword}{sizeof} (Example\_Struct2));
496    \_st2\_set(st2, atoi(v1), atoi(v2));
497    va->data = st2;
498 
499    \textcolor{keywordflow}{return} va;
500 \}
501 
502 \textcolor{keyword}{static} Example\_Variant *
503 \_variant\_3\_new(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *v1)
504 \{
505    Example\_Struct3 *st3;
506    Example\_Variant *va = calloc(1, \textcolor{keyword}{sizeof}(Example\_Variant));
507    \textcolor{keywordflow}{if} (!va)
508      \{
509         fprintf(
510           stderr, \textcolor{stringliteral}{"ERROR: could not allocate an Example\_Variant struct.\(\backslash\)n"});
511         \textcolor{keywordflow}{return} NULL;
512      \}
513 
514    va = calloc(1, \textcolor{keyword}{sizeof} (Example\_Variant));
515    va->t.type = eet\_mapping[2].name;
516    st3 = calloc(1, \textcolor{keyword}{sizeof} (Example\_Struct3));
517    \_st3\_set(st3, atoi(v1));
518    va->data = st3;
519 
520    \textcolor{keywordflow}{return} va;
521 \}
522 
523 \textcolor{keyword}{static} Example\_Lists *
524 \_data\_new(\textcolor{keywordtype}{void})
525 \{
526    Example\_Lists *example\_lists = calloc(1, \textcolor{keyword}{sizeof}(Example\_Lists));
527    \textcolor{keywordflow}{if} (!example\_lists)
528      \{
529         fprintf(stderr, \textcolor{stringliteral}{"ERROR: could not allocate a Example\_Lists struct.\(\backslash\)n"});
530         \textcolor{keywordflow}{return} NULL;
531      \}
532 
533    \textcolor{keywordflow}{return} example\_lists;
534 \} \textcolor{comment}{/* \_data\_new */}
535 
536 \textcolor{keyword}{static} \textcolor{keywordtype}{void}
537 \_union\_free(Example\_Union *un)
538 \{
539    \textcolor{keywordflow}{if} (un->type == EET\_STRUCT1)
540      \{
541         Example\_Struct1 *st1 = &(un->u.st1);
542         \_string\_free(st1->s1);
543      \}
544 
545    free(un);
546 \}
547 
548 \textcolor{keyword}{static} \textcolor{keywordtype}{void}
549 \_variant\_free(Example\_Variant *va)
550 \{
551    \textcolor{keywordflow}{if} (!strcmp(va->t.type, eet\_mapping[0].name))
552      \{
553         Example\_Struct1 *st1 = va->data;
554         \_string\_free(st1->s1);
555      \}
556 
557    free(va->data);
558    free(va);
559 \}
560 
561 \textcolor{keyword}{static} \textcolor{keywordtype}{void}
562 \_data\_free(Example\_Lists *cache)
563 \{
564    Example\_Union *un;
565    Example\_Variant *va;
566 
567    \hyperlink{group__Eina__List__Group_gae27a2c686a0a11693f9b06957c9bba83}{EINA\_LIST\_FREE}(cache->union\_list, un)
568      \_union\_free(un);
569 
570    \hyperlink{group__Eina__List__Group_gae27a2c686a0a11693f9b06957c9bba83}{EINA\_LIST\_FREE}(cache->variant\_list, va)
571      \_variant\_free(va);
572 
573    free(cache);
574 \} \textcolor{comment}{/* \_data\_free */}
575 
576 static Example\_Lists *
577 \_data\_load(const \textcolor{keywordtype}{char} *filename)
578 \{
579    Example\_Lists *data;
580    \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});
581    \textcolor{keywordflow}{if} (!ef)
582      \{
583         fprintf(stderr, \textcolor{stringliteral}{"ERROR: could not open '%s' for read\(\backslash\)n"}, filename);
584         \textcolor{keywordflow}{return} NULL;
585      \}
586 
587    data = \hyperlink{group__Eet__Data__Group_ga4d1807cbbc448304f22a8808318a3429}{eet\_data\_read}(ef, \_lists\_descriptor, CACHE\_FILE\_ENTRY);
588    \textcolor{keywordflow}{if} (!data)
589      \{
590         \hyperlink{group__Eet__File__Group_ga1675fef1f6012c1e02ae313d13dc3e03}{eet\_close}(ef);
591         \textcolor{keywordflow}{return} NULL;
592      \}
593 
594    \textcolor{keywordflow}{if} (\_cache\_file)
595      \hyperlink{group__Eet__File__Group_ga1675fef1f6012c1e02ae313d13dc3e03}{eet\_close}(\_cache\_file);
596 
597    \_cache\_file = ef;
598    \_cache\_dict = \hyperlink{group__Eet__File__Group_gab45ad39596d2fb54a88fda93e7fa0b0f}{eet\_dictionary\_get}(ef);
599 
600    \textcolor{keywordflow}{return} data;
601 \} \textcolor{comment}{/* \_data\_load */}
602 
603 \textcolor{keyword}{static} \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}
604 \_data\_save(\textcolor{keyword}{const} Example\_Lists *cache,
605            \textcolor{keyword}{const} \textcolor{keywordtype}{char}          *filename)
606 \{
607    \textcolor{keywordtype}{char} tmp[PATH\_MAX];
608    \hyperlink{group__Eet__File__Group_ga8d9779184a9870c1a225f1f40c76e8a7}{Eet\_File} *ef;
609    \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool} ret;
610    \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} i, len;
611    \textcolor{keyword}{struct }stat st;
612 
613    len = \hyperlink{group__Eina__String__Group_ga6bda31d2e1b6d2737b7fe1784780cd2f}{eina\_strlcpy}(tmp, filename, \textcolor{keyword}{sizeof}(tmp));
614    \textcolor{keywordflow}{if} (len + 12 >= (\textcolor{keywordtype}{int})\textcolor{keyword}{sizeof}(tmp))
615      \{
616         fprintf(stderr, \textcolor{stringliteral}{"ERROR: file name is too big: %s\(\backslash\)n"}, filename);
617         \textcolor{keywordflow}{return} \hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE};
618      \}
619 
620    i = 0;
621    \textcolor{keywordflow}{do}
622      \{
623         snprintf(tmp + len, 12, \textcolor{stringliteral}{".%u"}, i);
624         i++;
625      \}
626    \textcolor{keywordflow}{while} (stat(tmp, &st) == 0);
627 
628    ef = \hyperlink{group__Eet__File__Group_ga5f55956b860aa2c77af9b1a880c4c256}{eet\_open}(tmp, \hyperlink{group__Eet__File__Group_ggaa8e1a7af50fefaf15eb2f69543d24998a8f395f56fba48be007c65be51d799ee9}{EET\_FILE\_MODE\_WRITE});
629    \textcolor{keywordflow}{if} (!ef)
630      \{
631         fprintf(stderr, \textcolor{stringliteral}{"ERROR: could not open '%s' for write\(\backslash\)n"}, tmp);
632         \textcolor{keywordflow}{return} \hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE};
633      \}
634 
635    ret = \hyperlink{group__Eet__Data__Group_gac66d1c49e3490bc5d803982d833ff8aa}{eet\_data\_write}
636        (ef, \_lists\_descriptor, CACHE\_FILE\_ENTRY, cache, \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE});
637 
638    \hyperlink{group__Eet__File__Group_ga1675fef1f6012c1e02ae313d13dc3e03}{eet\_close}(ef);
639 
640    \textcolor{keywordflow}{if} (ret)
641      \{
642         unlink(filename);
643         \hyperlink{evil__stdio_8h_ab92755272ef649e2c6e74ab80def85be}{rename}(tmp, filename);
644      \}
645 
646    \textcolor{keywordflow}{return} ret;
647 \} \textcolor{comment}{/* \_data\_save */}
648 
649 \textcolor{keyword}{static} \textcolor{keywordtype}{void}
650 \_print\_union(\textcolor{keyword}{const} Example\_Union *un)
651 \{
652    printf(\textcolor{stringliteral}{"\(\backslash\)t  |   type: %s'\(\backslash\)n"}, eet\_mapping[un->type - 1].name);
653 
654    \textcolor{keywordflow}{switch} (un->type)
655      \{
656       \textcolor{keywordflow}{case} EET\_STRUCT1:
657         printf(\textcolor{stringliteral}{"\(\backslash\)t\(\backslash\)t  val1: %f\(\backslash\)n"}, un->u.st1.val1);
658         printf(\textcolor{stringliteral}{"\(\backslash\)t\(\backslash\)t  stuff: %d\(\backslash\)n"}, un->u.st1.stuff);
659         printf(\textcolor{stringliteral}{"\(\backslash\)t\(\backslash\)t  s1: %s\(\backslash\)n"}, un->u.st1.s1);
660         \textcolor{keywordflow}{break};
661 
662       \textcolor{keywordflow}{case} EET\_STRUCT2:
663         printf(\textcolor{stringliteral}{"\(\backslash\)t\(\backslash\)t  val1: %i\(\backslash\)n"}, un->u.st2.b1);
664         printf(\textcolor{stringliteral}{"\(\backslash\)t\(\backslash\)t  stuff: %lli\(\backslash\)n"}, un->u.st2.v1);
665         \textcolor{keywordflow}{break};
666 
667       \textcolor{keywordflow}{case} EET\_STRUCT3:
668         printf(\textcolor{stringliteral}{"\(\backslash\)t\(\backslash\)t  val1: %i\(\backslash\)n"}, un->u.st3.body);
669         \textcolor{keywordflow}{break};
670 
671       \textcolor{keywordflow}{case} EET\_BASIC\_FLOAT:
672         printf(\textcolor{stringliteral}{"\(\backslash\)t\(\backslash\)t  float: %f\(\backslash\)n"}, un->u.f);
673         \textcolor{keywordflow}{break};
674 
675       \textcolor{keywordflow}{case} EET\_BASIC\_STRING:
676         printf(\textcolor{stringliteral}{"\(\backslash\)t\(\backslash\)t  string: %s\(\backslash\)n"}, un->u.string);
677         \textcolor{keywordflow}{break};
678 
679       \textcolor{keywordflow}{default}:
680         \textcolor{keywordflow}{return};
681      \}
682 \}
683 
684 \textcolor{keyword}{static} \textcolor{keywordtype}{void}
685 \_print\_variant(\textcolor{keyword}{const} Example\_Variant *va)
686 \{
687    printf(\textcolor{stringliteral}{"\(\backslash\)t  |   type: %s'\(\backslash\)n"}, va->t.type);
688 
689    \textcolor{keywordflow}{switch} (va->t.type[2])
690      \{
691       \textcolor{keywordflow}{case} \textcolor{charliteral}{'1'}:
692       \{
693          Example\_Struct1 *st1 = va->data;
694 
695          printf(\textcolor{stringliteral}{"\(\backslash\)t\(\backslash\)t  val1: %f\(\backslash\)n"}, st1->val1);
696          printf(\textcolor{stringliteral}{"\(\backslash\)t\(\backslash\)t  stuff: %d\(\backslash\)n"}, st1->stuff);
697          printf(\textcolor{stringliteral}{"\(\backslash\)t\(\backslash\)t  s1: %s\(\backslash\)n"}, st1->s1);
698       \}
699       \textcolor{keywordflow}{break};
700 
701       \textcolor{keywordflow}{case} \textcolor{charliteral}{'2'}:
702       \{
703          Example\_Struct2 *st2 = va->data;
704 
705          printf(\textcolor{stringliteral}{"\(\backslash\)t\(\backslash\)t  val1: %i\(\backslash\)n"}, st2->b1);
706          printf(\textcolor{stringliteral}{"\(\backslash\)t\(\backslash\)t  stuff: %lli\(\backslash\)n"}, st2->v1);
707       \}
708       \textcolor{keywordflow}{break};
709 
710       \textcolor{keywordflow}{case} \textcolor{charliteral}{'3'}:
711       \{
712          Example\_Struct3 *st3 = va->data;
713 
714          printf(\textcolor{stringliteral}{"\(\backslash\)t\(\backslash\)t  val1: %i\(\backslash\)n"}, st3->body);
715       \}
716       \textcolor{keywordflow}{break};
717 
718       \textcolor{keywordflow}{default}:
719         \textcolor{keywordflow}{return};
720      \}
721 \}
722 
723 \textcolor{keywordtype}{int}
724 main(\textcolor{keywordtype}{int}   argc,
725      \textcolor{keywordtype}{char} *argv[])
726 \{
727    Example\_Lists *data\_lists;
728    \textcolor{keywordtype}{int} ret = 0;
729 
730    \textcolor{keywordflow}{if} (argc < 3)
731      \{
732         fprintf(stderr,
733                 \textcolor{stringliteral}{"Usage:\(\backslash\)n\(\backslash\)t%s <input> <output> [action action-params]\(\backslash\)n\(\backslash\)n"}
734                 \textcolor{stringliteral}{"where actions and their parameters are:\(\backslash\)n"}
735                 \textcolor{stringliteral}{"\(\backslash\)tunion <type> [fields]\(\backslash\)n"}
736                 \textcolor{stringliteral}{"\(\backslash\)tvariant <type> [fields]\(\backslash\)n"}
737                 \textcolor{stringliteral}{"\(\backslash\)n"},
738                 argv[0]);
739         \textcolor{keywordflow}{return} -1;
740      \}
741 
742    \hyperlink{group__Eina__Main__Group_gabf448ada5bc81a07342b66c6f818ee5e}{eina\_init}();
743    \hyperlink{group__Eet__Group_ga9903687bfa20fe9a9e59d4c1d213e89a}{eet\_init}();
744    \_data\_descriptors\_init();
745 
746    data\_lists = \_data\_load(argv[1]);
747    \textcolor{keywordflow}{if} (!data\_lists)
748      \{
749         printf(\textcolor{stringliteral}{"Creating new data lists.\(\backslash\)n"});
750         data\_lists = \_data\_new();
751         \textcolor{keywordflow}{if} (!data\_lists)
752           \{
753              ret = -2;
754              \textcolor{keywordflow}{goto} end;
755           \}
756      \}
757 
758    \textcolor{keywordflow}{if} (argc > 3)
759      \{
760         \textcolor{keywordflow}{if} (strcmp(argv[3], \textcolor{stringliteral}{"union"}) == 0)
761           \{
762              \textcolor{keywordflow}{if} (argc > 4)
763                \{
764                   \textcolor{keywordtype}{int} type = atoi(argv[4]);
765                   Example\_Union *un;
766 
767                   \textcolor{keywordflow}{if} (type < EET\_STRUCT1 || type > EET\_BASIC\_STRING)
768                     \{
769                        fprintf(stderr,
770                                \textcolor{stringliteral}{"ERROR: invalid type parameter (%s).\(\backslash\)n"},
771                                argv[4]);
772                        \textcolor{keywordflow}{goto} cont;
773                     \}
774 
775                   \textcolor{keywordflow}{switch} (type)
776                     \{
777                      \textcolor{keywordflow}{case} 1:
778                        \textcolor{keywordflow}{if} (argc != 8)
779                          \{
780                             fprintf(
781                               stderr, \textcolor{stringliteral}{"ERROR: wrong number of parameters"}
782                                       \textcolor{stringliteral}{" (%d).\(\backslash\)n"}, argc);
783                             \textcolor{keywordflow}{goto} cont;
784                          \}
785 
786                        un = \_union\_1\_new(
787                            argv[5], argv[6], argv[7]);
788                        \textcolor{keywordflow}{if} (!un)
789                          \{
790                             fprintf(
791                               stderr, \textcolor{stringliteral}{"ERROR: could not create the "}
792                                       \textcolor{stringliteral}{"requested union.\(\backslash\)n"});
793                             \textcolor{keywordflow}{goto} cont;
794                          \}
795                        data\_lists->union\_list =
796                          \hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}(data\_lists->union\_list, un);
797                        \textcolor{keywordflow}{break};
798 
799                      \textcolor{keywordflow}{case} 2:
800                        \textcolor{keywordflow}{if} (argc != 7)
801                          \{
802                             fprintf(
803                               stderr, \textcolor{stringliteral}{"ERROR: wrong number of parameters"}
804                                       \textcolor{stringliteral}{" (%d).\(\backslash\)n"}, argc);
805                             \textcolor{keywordflow}{goto} cont;
806                          \}
807 
808                        un = \_union\_2\_new(argv[5], argv[6]);
809                        \textcolor{keywordflow}{if} (!un)
810                          \{
811                             fprintf(
812                               stderr, \textcolor{stringliteral}{"ERROR: could not create the "}
813                                       \textcolor{stringliteral}{"requested union.\(\backslash\)n"});
814                             \textcolor{keywordflow}{goto} cont;
815                          \}
816                        data\_lists->union\_list =
817                          \hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}(data\_lists->union\_list, un);
818                        \textcolor{keywordflow}{break};
819 
820                      \textcolor{keywordflow}{case} 3:
821                        \textcolor{keywordflow}{if} (argc != 6)
822                          \{
823                             fprintf(
824                               stderr, \textcolor{stringliteral}{"ERROR: wrong number of parameters"}
825                                       \textcolor{stringliteral}{" (%d).\(\backslash\)n"}, argc);
826                             \textcolor{keywordflow}{goto} cont;
827                          \}
828 
829                        un = \_union\_3\_new(argv[5]);
830                        \textcolor{keywordflow}{if} (!un)
831                          \{
832                             fprintf(
833                               stderr, \textcolor{stringliteral}{"ERROR: could not create the "}
834                                       \textcolor{stringliteral}{"requested union.\(\backslash\)n"});
835                             \textcolor{keywordflow}{goto} cont;
836                          \}
837                        data\_lists->union\_list =
838                          \hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}(data\_lists->union\_list, un);
839                        \textcolor{keywordflow}{break};
840 
841                      \textcolor{keywordflow}{case} EET\_BASIC\_FLOAT:
842                        \textcolor{keywordflow}{if} (argc != 6)
843                          \{
844                             fprintf(
845                               stderr, \textcolor{stringliteral}{"ERROR: wrong number of parameters"}
846                                       \textcolor{stringliteral}{" (%d).\(\backslash\)n"}, argc);
847                             \textcolor{keywordflow}{goto} cont;
848                          \}
849 
850                        un = \_union\_float\_new(argv[5]);
851                        \textcolor{keywordflow}{if} (!un)
852                          \{
853                             fprintf(
854                               stderr, \textcolor{stringliteral}{"ERROR: could not create the "}
855                                       \textcolor{stringliteral}{"requested union.\(\backslash\)n"});
856                             \textcolor{keywordflow}{goto} cont;
857                          \}
858                        data\_lists->union\_list =
859                          \hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}(data\_lists->union\_list, un);
860                        \textcolor{keywordflow}{break};
861 
862                      \textcolor{keywordflow}{case} EET\_BASIC\_STRING:
863                        \textcolor{keywordflow}{if} (argc != 6)
864                          \{
865                             fprintf(
866                               stderr, \textcolor{stringliteral}{"ERROR: wrong number of parameters"}
867                                       \textcolor{stringliteral}{" (%d).\(\backslash\)n"}, argc);
868                             \textcolor{keywordflow}{goto} cont;
869                          \}
870 
871                        un = \_union\_string\_new(argv[5]);
872                        \textcolor{keywordflow}{if} (!un)
873                          \{
874                             fprintf(
875                               stderr, \textcolor{stringliteral}{"ERROR: could not create the "}
876                                       \textcolor{stringliteral}{"requested union.\(\backslash\)n"});
877                             \textcolor{keywordflow}{goto} cont;
878                          \}
879                        data\_lists->union\_list =
880                          \hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}(data\_lists->union\_list, un);
881                        \textcolor{keywordflow}{break};
882 
883                      \textcolor{keywordflow}{default}:
884                        fprintf(
885                          stderr, \textcolor{stringliteral}{"ERROR: bad type of of struct passed\(\backslash\)n"});
886                        \textcolor{keywordflow}{goto} cont;
887                     \}
888                \}
889              \textcolor{keywordflow}{else}
890                fprintf(stderr,
891                        \textcolor{stringliteral}{"ERROR: wrong number of parameters (%d).\(\backslash\)n"},
892                        argc);
893           \}
894         \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (strcmp(argv[3], \textcolor{stringliteral}{"variant"}) == 0)
895           \{
896              \textcolor{keywordflow}{if} (argc > 4)
897                \{
898                   \textcolor{keywordtype}{int} type = atoi(argv[4]);
899                   Example\_Variant *va;
900 
901                   \textcolor{keywordflow}{if} (type < EET\_STRUCT1 || type > EET\_STRUCT3)
902                     \{
903                        fprintf(stderr,
904                                \textcolor{stringliteral}{"ERROR: invalid type parameter (%s).\(\backslash\)n"},
905                                argv[4]);
906                        \textcolor{keywordflow}{goto} cont;
907                     \}
908 
909                   \textcolor{keywordflow}{switch} (type)
910                     \{
911                      \textcolor{keywordflow}{case} 1:
912                        \textcolor{keywordflow}{if} (argc != 8)
913                          \{
914                             fprintf(
915                               stderr, \textcolor{stringliteral}{"ERROR: wrong number of parameters"}
916                                       \textcolor{stringliteral}{" (%d).\(\backslash\)n"}, argc);
917                             \textcolor{keywordflow}{goto} cont;
918                          \}
919 
920                        va = \_variant\_1\_new(
921                            argv[5], argv[6], argv[7]);
922                        \textcolor{keywordflow}{if} (!va)
923                          \{
924                             fprintf(
925                               stderr, \textcolor{stringliteral}{"ERROR: could not create the "}
926                                       \textcolor{stringliteral}{"requested variant.\(\backslash\)n"});
927                             \textcolor{keywordflow}{goto} cont;
928                          \}
929                        data\_lists->variant\_list =
930                          \hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}(data\_lists->variant\_list, va);
931                        \textcolor{keywordflow}{break};
932 
933                      \textcolor{keywordflow}{case} 2:
934                        \textcolor{keywordflow}{if} (argc != 7)
935                          \{
936                             fprintf(
937                               stderr, \textcolor{stringliteral}{"ERROR: wrong number of parameters"}
938                                       \textcolor{stringliteral}{" (%d).\(\backslash\)n"}, argc);
939                             \textcolor{keywordflow}{goto} cont;
940                          \}
941 
942                        va = \_variant\_2\_new(argv[5], argv[6]);
943                        \textcolor{keywordflow}{if} (!va)
944                          \{
945                             fprintf(
946                               stderr, \textcolor{stringliteral}{"ERROR: could not create the "}
947                                       \textcolor{stringliteral}{"requested variant.\(\backslash\)n"});
948                             \textcolor{keywordflow}{goto} cont;
949                          \}
950                        data\_lists->variant\_list =
951                          \hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}(data\_lists->variant\_list, va);
952                        \textcolor{keywordflow}{break};
953 
954                      \textcolor{keywordflow}{case} 3:
955                        \textcolor{keywordflow}{if} (argc != 6)
956                          \{
957                             fprintf(
958                               stderr, \textcolor{stringliteral}{"ERROR: wrong number of parameters"}
959                                       \textcolor{stringliteral}{" (%d).\(\backslash\)n"}, argc);
960                             \textcolor{keywordflow}{goto} cont;
961                          \}
962 
963                        va = \_variant\_3\_new(argv[5]);
964                        \textcolor{keywordflow}{if} (!va)
965                          \{
966                             fprintf(
967                               stderr, \textcolor{stringliteral}{"ERROR: could not create the "}
968                                       \textcolor{stringliteral}{"requested variant.\(\backslash\)n"});
969                             \textcolor{keywordflow}{goto} cont;
970                          \}
971                        data\_lists->variant\_list =
972                          \hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}(data\_lists->variant\_list, va);
973                        \textcolor{keywordflow}{break};
974 
975                      \textcolor{keywordflow}{default}:
976                        fprintf(
977                          stderr, \textcolor{stringliteral}{"ERROR: bad type of of struct passed\(\backslash\)n"});
978                        \textcolor{keywordflow}{goto} cont;
979                     \}
980                \}
981              \textcolor{keywordflow}{else}
982                fprintf(stderr,
983                        \textcolor{stringliteral}{"ERROR: wrong number of parameters (%d).\(\backslash\)n"},
984                        argc);
985           \}
986         \textcolor{keywordflow}{else}
987           fprintf(stderr, \textcolor{stringliteral}{"ERROR: unknown action '%s'\(\backslash\)n"}, argv[3]);
988      \}
989 
990 cont:
991    printf(\textcolor{stringliteral}{"Cached data:\(\backslash\)n"});
992 
993    printf(\textcolor{stringliteral}{"\(\backslash\)tstats: unions=%u, variants=%u\(\backslash\)n"},
994           \hyperlink{group__Eina__List__Group_ga301729054a498a2df09a5f1dd760697e}{eina\_list\_count}(data\_lists->union\_list),
995           \hyperlink{group__Eina__List__Group_ga301729054a498a2df09a5f1dd760697e}{eina\_list\_count}(data\_lists->variant\_list));
996 
997    \textcolor{keywordflow}{if} (\hyperlink{group__Eina__List__Group_ga301729054a498a2df09a5f1dd760697e}{eina\_list\_count}(data\_lists->union\_list))
998      \{
999         \textcolor{keyword}{const} \hyperlink{struct__Eina__List}{Eina\_List} *l;
1000         \textcolor{keyword}{const} Example\_Union *un;
1001         printf(\textcolor{stringliteral}{"\(\backslash\)t  * union list:\(\backslash\)n"});
1002 
1003         \hyperlink{group__Eina__List__Group_gad02f746a08ee0b12b7ed66d4bc0d71d8}{EINA\_LIST\_FOREACH}(data\_lists->union\_list, l, un)
1004           \{
1005              \_print\_union(un);
1006           \}
1007      \}
1008 
1009    \textcolor{keywordflow}{if} (\hyperlink{group__Eina__List__Group_ga301729054a498a2df09a5f1dd760697e}{eina\_list\_count}(data\_lists->variant\_list))
1010      \{
1011         \textcolor{keyword}{const} \hyperlink{struct__Eina__List}{Eina\_List} *l;
1012         \textcolor{keyword}{const} Example\_Variant *un;
1013         printf(\textcolor{stringliteral}{"\(\backslash\)t  * variant list:\(\backslash\)n"});
1014 
1015         \hyperlink{group__Eina__List__Group_gad02f746a08ee0b12b7ed66d4bc0d71d8}{EINA\_LIST\_FOREACH}(data\_lists->variant\_list, l, un)
1016           \{
1017              \_print\_variant(un);
1018           \}
1019      \}
1020 
1021    printf(\textcolor{stringliteral}{"\(\backslash\)n"});
1022 
1023    \textcolor{keywordflow}{if} (!\_data\_save(data\_lists, argv[2]))
1024      ret = -3;
1025 
1026    \_data\_free(data\_lists);
1027 
1028 end:
1029    \textcolor{keywordflow}{if} (\_cache\_file)
1030      \hyperlink{group__Eet__File__Group_ga1675fef1f6012c1e02ae313d13dc3e03}{eet\_close}(\_cache\_file);
1031    \_data\_descriptors\_shutdown();
1032    \hyperlink{group__Eet__Group_gacbc7583179399d3b3e7b003e911f866f}{eet\_shutdown}();
1033    \hyperlink{group__Eina__Main__Group_ga6741fcaba116e31e96ce14dcfa03f568}{eina\_shutdown}();
1034 
1035    \textcolor{keywordflow}{return} ret;
1036 \} \textcolor{comment}{/* main */}
1037 
\end{DoxyCodeInclude}
 