We\textquotesingle{}ve seen already a simple example of how to use Eet Data Descriptors to handle our structures, but it didn\textquotesingle{}t show how this works when you have structures inside other structures.

Now, there\textquotesingle{}s a very simple case of this, for when you have inline structs to keep your big structure more organized, you don\textquotesingle{}t need anything else besides what \mbox{\hyperlink{eet-data-simple_8c-example}{this simple example does}}. Just use something like {\ttfamily some\+\_\+struct.\+sub\+\_\+struct.\+member} when adding the member to the descriptor and it will work.

For example\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{keyword}{typedef}\ \textcolor{keyword}{struct}}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{int}\ a\_number;}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{char}\ *a\_string;}
\DoxyCodeLine{\ \ \ \textcolor{keyword}{struct\ }\{}
\DoxyCodeLine{\ \ \ \ \ \ \textcolor{keywordtype}{int}\ other\_num;}
\DoxyCodeLine{\ \ \ \ \ \ \textcolor{keywordtype}{int}\ one\_more;}
\DoxyCodeLine{\ \ \ \}\ sub;}
\DoxyCodeLine{\}\ some\_struct;}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordtype}{void}\ some\_function()}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ ...}
\DoxyCodeLine{\ \ \ my\_desc\ =\ \mbox{\hyperlink{group__Eet__Data__Group_ga5c2ad8edc9910f201b0dcbdbc5cc2694}{eet\_data\_descriptor\_stream\_new}}(\&eddc);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eet__Data__Group_gac38ce778d7eba37cfca8a19efb7a9b3a}{EET\_DATA\_DESCRIPTOR\_ADD\_BASIC}}(my\_desc,\ some\_struct,\ \textcolor{stringliteral}{"{}a\_number"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ a\_number,\ \mbox{\hyperlink{group__Eet__Data__Group_ga4e196733795867f14c6e387af7287baa}{EET\_T\_INT}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eet__Data__Group_gac38ce778d7eba37cfca8a19efb7a9b3a}{EET\_DATA\_DESCRIPTOR\_ADD\_BASIC}}(my\_desc,\ some\_struct,\ \textcolor{stringliteral}{"{}a\_string"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ a\_string,\ \mbox{\hyperlink{group__Eet__Data__Group_ga0d2cf409bf3f151156d74d18ac59e3d1}{EET\_T\_STRING}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eet__Data__Group_gac38ce778d7eba37cfca8a19efb7a9b3a}{EET\_DATA\_DESCRIPTOR\_ADD\_BASIC}}(my\_desc,\ some\_struct,\ \textcolor{stringliteral}{"{}sub.other\_num"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ sub.other\_num,\ \mbox{\hyperlink{group__Eet__Data__Group_ga4e196733795867f14c6e387af7287baa}{EET\_T\_INT}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eet__Data__Group_gac38ce778d7eba37cfca8a19efb7a9b3a}{EET\_DATA\_DESCRIPTOR\_ADD\_BASIC}}(my\_desc,\ some\_struct,\ \textcolor{stringliteral}{"{}sub.one\_more"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ sub.one\_more,\ \mbox{\hyperlink{group__Eet__Data__Group_ga4e196733795867f14c6e387af7287baa}{EET\_T\_INT}});}
\DoxyCodeLine{\ \ \ ...}
\DoxyCodeLine{\}}

\end{DoxyCode}


But this is not what we are here for today. When we talk about nested structures, what we really want are things like lists and hashes to be taken into consideration automatically, and all their contents saved and loaded just like ordinary integers and strings are.

And of course, Eet can do that, and considering the work it saves you as a programmer, we could say it\textquotesingle{}s even easier to do than handling just integers.

Let\textquotesingle{}s begin with our example then, which is not all too different from the simple one introduced earlier.

We won\textquotesingle{}t ignore the headers this time to show how easy it is to use Eina data types with Eet, but we\textquotesingle{}ll still skip most of the code that is not pertinent to what we want to show now, but as usual, you can get it full by following \mbox{\hyperlink{eet-data-nested_8c-example}{this link}}.

 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <\mbox{\hyperlink{Eina_8h}{Eina.h}}>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <\mbox{\hyperlink{Eet_8h}{Eet.h}}>}}
\DoxyCodeLine{\textcolor{keyword}{typedef}\ \textcolor{keyword}{struct}}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{unsigned}\ \textcolor{keywordtype}{int}\ version;\ \textcolor{comment}{//\ it\ is\ recommended\ to\ use\ versioned\ configuration!}}
\DoxyCodeLine{\ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ \ *name;}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{int}\ \ \ \ \ \ \ \ \ \ id;}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{int}\ \ \ \ \ \ \ \ \ \ not\_saved\_value;\ \textcolor{comment}{//\ example\ of\ not\ saved\ data\ inside!}}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}\ \ \ \ enabled;}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{struct__Eina__List}{Eina\_List}}\ \ \ *subs;}
\DoxyCodeLine{\}\ My\_Conf\_Type;}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{typedef}\ \textcolor{keyword}{struct}}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *server;}
\DoxyCodeLine{\ \ \ \textcolor{keywordtype}{int}\ \ \ \ \ \ \ \ \ port;}
\DoxyCodeLine{\}\ My\_Conf\_Subtype;}

\end{DoxyCodeInclude}
 Extremely similar to our previous example. Just a new struct in there, and a pointer to a list in the one we already had. Handling a list of subtypes is easy on our program, but now we\textquotesingle{}ll see what Eet needs to work with them (Hint\+: it\textquotesingle{}s easy too). 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{keyword}{static}\ \mbox{\hyperlink{group__Eet__Data__Group_ga4baec0e840012480a0958c5c3bca276d}{Eet\_Data\_Descriptor}}\ *\_my\_conf\_descriptor;}
\DoxyCodeLine{\textcolor{keyword}{static}\ \mbox{\hyperlink{group__Eet__Data__Group_ga4baec0e840012480a0958c5c3bca276d}{Eet\_Data\_Descriptor}}\ *\_my\_conf\_sub\_descriptor;}

\end{DoxyCodeInclude}
 Since we have two structures now, it\textquotesingle{}s only natural that we\textquotesingle{}ll need two descriptors. One for each, which will be defined exactly as before. 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_my\_conf\_descriptor\_init(\textcolor{keywordtype}{void})}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{struct__Eet__Data__Descriptor__Class}{Eet\_Data\_Descriptor\_Class}}\ eddc;}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eet__Data__Group_ga941b1fcd6c6c72221d9390f9a0ed751c}{EET\_EINA\_STREAM\_DATA\_DESCRIPTOR\_CLASS\_SET}}(\&eddc,\ My\_Conf\_Type);}
\DoxyCodeLine{\ \ \ \_my\_conf\_descriptor\ =\ \mbox{\hyperlink{group__Eet__Data__Group_ga5c2ad8edc9910f201b0dcbdbc5cc2694}{eet\_data\_descriptor\_stream\_new}}(\&eddc);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eet__Data__Group_ga941b1fcd6c6c72221d9390f9a0ed751c}{EET\_EINA\_STREAM\_DATA\_DESCRIPTOR\_CLASS\_SET}}(\&eddc,\ My\_Conf\_Subtype);}
\DoxyCodeLine{\ \ \ \_my\_conf\_sub\_descriptor\ =\ \mbox{\hyperlink{group__Eet__Data__Group_ga5c2ad8edc9910f201b0dcbdbc5cc2694}{eet\_data\_descriptor\_stream\_new}}(\&eddc);}

\end{DoxyCodeInclude}
 We create our descriptors, each for one type, and as before, we are going to use a simple macro to set their contents, to save on typing. 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{preprocessor}{\#define\ MY\_CONF\_ADD\_BASIC(member,\ eet\_type)\ \(\backslash\)}}
\DoxyCodeLine{\textcolor{preprocessor}{\ \ EET\_DATA\_DESCRIPTOR\_ADD\_BASIC\ \ \ \ \ \ \ \ \ \ \ \ \ \(\backslash\)}}
\DoxyCodeLine{\textcolor{preprocessor}{\ \ \ \ (\_my\_conf\_descriptor,\ My\_Conf\_Type,\ \#\ member,\ member,\ eet\_type)}}
\DoxyCodeLine{\textcolor{preprocessor}{\#define\ MY\_CONF\_SUB\_ADD\_BASIC(member,\ eet\_type)\ \(\backslash\)}}
\DoxyCodeLine{\textcolor{preprocessor}{\ \ EET\_DATA\_DESCRIPTOR\_ADD\_BASIC\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\backslash\)}}
\DoxyCodeLine{\textcolor{preprocessor}{\ \ \ \ (\_my\_conf\_sub\_descriptor,\ My\_Conf\_Subtype,\ \#\ member,\ member,\ eet\_type)}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ MY\_CONF\_SUB\_ADD\_BASIC(server,\ \mbox{\hyperlink{group__Eet__Data__Group_ga0d2cf409bf3f151156d74d18ac59e3d1}{EET\_T\_STRING}});}
\DoxyCodeLine{\ \ \ MY\_CONF\_SUB\_ADD\_BASIC(port,\ \mbox{\hyperlink{group__Eet__Data__Group_ga4e196733795867f14c6e387af7287baa}{EET\_T\_INT}});}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ MY\_CONF\_ADD\_BASIC(version,\ \mbox{\hyperlink{group__Eet__Data__Group_gacf6a3c9f06e10e20be5b02cd8c6a220b}{EET\_T\_UINT}});}
\DoxyCodeLine{\ \ \ MY\_CONF\_ADD\_BASIC(name,\ \mbox{\hyperlink{group__Eet__Data__Group_ga0d2cf409bf3f151156d74d18ac59e3d1}{EET\_T\_STRING}});}
\DoxyCodeLine{\ \ \ MY\_CONF\_ADD\_BASIC(\textcolor{keywordtype}{id},\ \mbox{\hyperlink{group__Eet__Data__Group_ga4e196733795867f14c6e387af7287baa}{EET\_T\_INT}});}
\DoxyCodeLine{\ \ \ MY\_CONF\_ADD\_BASIC(enabled,\ \mbox{\hyperlink{group__Eet__Data__Group_ga09a1341cc158fda0ba60ad2386ecd795}{EET\_T\_UCHAR}});}

\end{DoxyCodeInclude}
 So far, nothing new. We have our descriptors and we know already how to save them separately. But what we want is to link them together, and even more so, we want our main type to hold a list of more than one of the new sub type. So how do we do that?

Simple enough, we tell Eet that our main descriptor will hold a list, of which each node will point to some type described by our new descriptor. 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eet__Data__Group_gabb4c7833ba053f2322e6b667a9ec7f04}{EET\_DATA\_DESCRIPTOR\_ADD\_LIST}}}
\DoxyCodeLine{\ \ \ \ \ (\_my\_conf\_descriptor,\ My\_Conf\_Type,\ \textcolor{stringliteral}{"{}subs"{}},\ subs,\ \_my\_conf\_sub\_descriptor);}

\end{DoxyCodeInclude}
 And that\textquotesingle{}s all. We are closing the function now so as to not leave dangling curly braces, but there\textquotesingle{}s nothing more to show in this example. Only other additions are the necessary code to free our new data, but you can see it in the full code listing. 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#undef\ MY\_CONF\_ADD\_BASIC}}
\DoxyCodeLine{\textcolor{preprocessor}{\#undef\ MY\_CONF\_SUB\_ADD\_BASIC}}
\DoxyCodeLine{\}\ \textcolor{comment}{/*\ \_my\_conf\_descriptor\_init\ */}}

\end{DoxyCodeInclude}
