\hypertarget{classHurricane_1_1JsonStack}{}\section{Hurricane\+:\+:Json\+Stack Class Reference}
\label{classHurricane_1_1JsonStack}\index{Hurricane\+::\+Json\+Stack@{Hurricane\+::\+Json\+Stack}}


J\+S\+ON Parser Stack.  


\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
size\+\_\+t \mbox{\hyperlink{classHurricane_1_1JsonStack_a80b1e4cab1a3c4cac83491d18c76534d}{size}} () const
\item 
{\footnotesize template$<$typename T $>$ }\\void \mbox{\hyperlink{classHurricane_1_1JsonStack_a189a4e74a62f898f5fe903a185181bc5}{push\+\_\+back}} (const std\+::string \&, T)
\item 
void \mbox{\hyperlink{classHurricane_1_1JsonStack_a668d3c1974efefb6ced90544b4703fe5}{pop\+\_\+back}} (size\+\_\+t count=1)
\item 
int \mbox{\hyperlink{classHurricane_1_1JsonStack_a6416903ee046d6b8122fe2ffe8c0751b}{rhas}} (const std\+::string \&) const
\item 
{\footnotesize template$<$typename T $>$ }\\T \mbox{\hyperlink{classHurricane_1_1JsonStack_aed841c5329cfb5a72e7df326e995ce73}{as}} (const std\+::string \&) const
\item 
{\footnotesize template$<$typename T $>$ }\\T \mbox{\hyperlink{classHurricane_1_1JsonStack_acc35d32ee522ff75b64122c40ee71113}{as}} (int) const
\item 
void \mbox{\hyperlink{classHurricane_1_1JsonStack_ab949c42fe63dcaad6a8e23954167a9a7}{push\+\_\+back\+\_\+dbo}} (\mbox{\hyperlink{classHurricane_1_1DBo}{D\+Bo}} $\ast$)
\item 
void \mbox{\hyperlink{classHurricane_1_1JsonStack_adeeb2a0300fa248f1f3bff38c4095630}{pop\+\_\+back\+\_\+dbo}} ()
\item 
\mbox{\hyperlink{classHurricane_1_1DBo}{D\+Bo}} $\ast$ \mbox{\hyperlink{classHurricane_1_1JsonStack_a95f403acdc0124c279866bd92ef8500a}{back\+\_\+dbo}} () const
\item 
vector$<$ \mbox{\hyperlink{classHurricane_1_1JsonObject}{Json\+Object}} $\ast$ $>$ \& \mbox{\hyperlink{classHurricane_1_1JsonStack_a974ee9daf5dbf861ed50cae0a51a5cbb}{jobjects}} ()
\item 
{\footnotesize template$<$typename T $>$ }\\T \mbox{\hyperlink{classHurricane_1_1JsonStack_aadbd70d7d19d2eb0a6c9c86ca1583c76}{get\+Entity}} (unsigned int) const
\item 
void \mbox{\hyperlink{classHurricane_1_1JsonStack_a421fdf4a3bab01d75f0aab292cc574d0}{add\+Entity}} (unsigned int json\+Id, \mbox{\hyperlink{classHurricane_1_1Entity}{Entity}} $\ast$)
\item 
void \mbox{\hyperlink{classHurricane_1_1JsonStack_a7e0364c8868b8396db10399a855b8aa1}{print}} (std\+::ostream \&) const
\end{DoxyCompactItemize}


\subsection{Detailed Description}
J\+S\+ON Parser Stack. 

The J\+S\+ON parser stack contains three separate stacks and a lookup table\+:
\begin{DoxyEnumerate}
\item The {\ttfamily attribute} stack. Objects that have been translated from J\+S\+ON to the \mbox{\hyperlink{namespaceHurricane}{Hurricane}} database (or P\+OD objects).
\item The {\ttfamily dbo} stack, similar to the previous one, but contains {\bfseries only} objects whose base class is \mbox{\hyperlink{classHurricane_1_1DBo}{D\+Bo}}.
\item The \mbox{\hyperlink{classHurricane_1_1JsonObject}{Json\+Object}} stack. The stack of objects currently under parsing.
\item A lookup table for the \mbox{\hyperlink{classHurricane_1_1Entity}{Entity}}, between the \mbox{\hyperlink{namespaceHurricane}{Hurricane}} {\ttfamily id} and the J\+S\+ON {\ttfamily id}. 
\end{DoxyEnumerate}

\subsection{Member Function Documentation}
\mbox{\Hypertarget{classHurricane_1_1JsonStack_a80b1e4cab1a3c4cac83491d18c76534d}\label{classHurricane_1_1JsonStack_a80b1e4cab1a3c4cac83491d18c76534d}} 
\index{Hurricane\+::\+Json\+Stack@{Hurricane\+::\+Json\+Stack}!size@{size}}
\index{size@{size}!Hurricane\+::\+Json\+Stack@{Hurricane\+::\+Json\+Stack}}
\subsubsection{\texorpdfstring{size()}{size()}}
{\footnotesize\ttfamily size\+\_\+t Hurricane\+::\+Json\+Stack\+::size (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}

{\bfseries Returns\+:} The size of the attribute stack. \mbox{\Hypertarget{classHurricane_1_1JsonStack_a189a4e74a62f898f5fe903a185181bc5}\label{classHurricane_1_1JsonStack_a189a4e74a62f898f5fe903a185181bc5}} 
\index{Hurricane\+::\+Json\+Stack@{Hurricane\+::\+Json\+Stack}!push\+\_\+back@{push\+\_\+back}}
\index{push\+\_\+back@{push\+\_\+back}!Hurricane\+::\+Json\+Stack@{Hurricane\+::\+Json\+Stack}}
\subsubsection{\texorpdfstring{push\+\_\+back()}{push\_back()}}
{\footnotesize\ttfamily template$<$typename T $>$ \\
void Hurricane\+::\+Json\+Stack\+::push\+\_\+back (\begin{DoxyParamCaption}\item[{const std\+::string \&}]{key,  }\item[{T}]{hobject }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}


\begin{DoxyParams}{Parameters}
{\em key} & Key associated to {\ttfamily hobject} \\
\hline
{\em hobject} & The {\itshape attribute} object.\\
\hline
\end{DoxyParams}
Push back (on top) an element on the {\itshape attribute} stack. 

References Hurricane\+::demangle().



Referenced by Hurricane\+::\+Json\+Object\+::update().

\mbox{\Hypertarget{classHurricane_1_1JsonStack_a668d3c1974efefb6ced90544b4703fe5}\label{classHurricane_1_1JsonStack_a668d3c1974efefb6ced90544b4703fe5}} 
\index{Hurricane\+::\+Json\+Stack@{Hurricane\+::\+Json\+Stack}!pop\+\_\+back@{pop\+\_\+back}}
\index{pop\+\_\+back@{pop\+\_\+back}!Hurricane\+::\+Json\+Stack@{Hurricane\+::\+Json\+Stack}}
\subsubsection{\texorpdfstring{pop\+\_\+back()}{pop\_back()}}
{\footnotesize\ttfamily void Hurricane\+::\+Json\+Stack\+::pop\+\_\+back (\begin{DoxyParamCaption}\item[{size\+\_\+t}]{count = {\ttfamily 1} }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}


\begin{DoxyParams}{Parameters}
{\em count} & The number of element to pop.\\
\hline
\end{DoxyParams}
Remove {\ttfamily count} element(s) from the top of the stack. 

Referenced by Hurricane\+::\+Json\+Object\+::update().

\mbox{\Hypertarget{classHurricane_1_1JsonStack_a6416903ee046d6b8122fe2ffe8c0751b}\label{classHurricane_1_1JsonStack_a6416903ee046d6b8122fe2ffe8c0751b}} 
\index{Hurricane\+::\+Json\+Stack@{Hurricane\+::\+Json\+Stack}!rhas@{rhas}}
\index{rhas@{rhas}!Hurricane\+::\+Json\+Stack@{Hurricane\+::\+Json\+Stack}}
\subsubsection{\texorpdfstring{rhas()}{rhas()}}
{\footnotesize\ttfamily int Hurricane\+::\+Json\+Stack\+::rhas (\begin{DoxyParamCaption}\item[{const std\+::string \&}]{key }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}


\begin{DoxyParams}{Parameters}
{\em key} & The key element\textquotesingle{}s to look for. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the index of the element, from the top.
\end{DoxyReturn}
The function name\textquotesingle{}s stands for \char`\"{}\+Reverse H\+A\+S\char`\"{}. Search from the top of the {\itshape attribute} stack downward an element with {\ttfamily key}. Return an index from the top of the stack, that is, the end of the vector. The returned index is a negative value, for exemple the element on top of the stack has an index of {\ttfamily -\/1}. If no element with a matching key is found, returns 0. 

References Hurricane\+::demangle().



Referenced by Hurricane\+::\+Json\+Object\+::get().

\mbox{\Hypertarget{classHurricane_1_1JsonStack_aed841c5329cfb5a72e7df326e995ce73}\label{classHurricane_1_1JsonStack_aed841c5329cfb5a72e7df326e995ce73}} 
\index{Hurricane\+::\+Json\+Stack@{Hurricane\+::\+Json\+Stack}!as@{as}}
\index{as@{as}!Hurricane\+::\+Json\+Stack@{Hurricane\+::\+Json\+Stack}}
\subsubsection{\texorpdfstring{as()}{as()}\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily template$<$typename T $>$ \\
T Hurricane\+::\+Json\+Stack\+::as (\begin{DoxyParamCaption}\item[{const std\+::string \&}]{key }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}


\begin{DoxyParams}{Parameters}
{\em key} & The key\textquotesingle{}s element to search. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The element, casted as type T.
\end{DoxyReturn}
Search an element with key matching {\ttfamily key}, from the top of the stack. If found, returns the element casted as type {\ttfamily T}. As the cast operation uses {\ttfamily boost\+::any\+\_\+cast$<$$>$}, the exact type {\ttfamily T} must be used ({\bfseries not} a base class of {\ttfamily T}), otherwise the cast will fail and an exception will be thrown. 

References Hurricane\+::demangle().



Referenced by Hurricane\+::\+Json\+Object\+::get().

\mbox{\Hypertarget{classHurricane_1_1JsonStack_acc35d32ee522ff75b64122c40ee71113}\label{classHurricane_1_1JsonStack_acc35d32ee522ff75b64122c40ee71113}} 
\index{Hurricane\+::\+Json\+Stack@{Hurricane\+::\+Json\+Stack}!as@{as}}
\index{as@{as}!Hurricane\+::\+Json\+Stack@{Hurricane\+::\+Json\+Stack}}
\subsubsection{\texorpdfstring{as()}{as()}\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily template$<$typename T $>$ \\
T Hurricane\+::\+Json\+Stack\+::as (\begin{DoxyParamCaption}\item[{int}]{index }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}


\begin{DoxyParams}{Parameters}
{\em index} & the position of the element to convert. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The element, casted as type T.
\end{DoxyReturn}
Cast the element at {\ttfamily index} into type T. As the cast operation uses {\ttfamily boost\+::any\+\_\+cast$<$$>$}, the exact type {\ttfamily T} must be used ({\bfseries not} a base class of {\ttfamily T}), otherwise the cast will fail and an exception will be thrown.

A positive or null index means the element must be taken from the bottom of the stack and a stictly negative one means from the top of the stack. \mbox{\Hypertarget{classHurricane_1_1JsonStack_ab949c42fe63dcaad6a8e23954167a9a7}\label{classHurricane_1_1JsonStack_ab949c42fe63dcaad6a8e23954167a9a7}} 
\index{Hurricane\+::\+Json\+Stack@{Hurricane\+::\+Json\+Stack}!push\+\_\+back\+\_\+dbo@{push\+\_\+back\+\_\+dbo}}
\index{push\+\_\+back\+\_\+dbo@{push\+\_\+back\+\_\+dbo}!Hurricane\+::\+Json\+Stack@{Hurricane\+::\+Json\+Stack}}
\subsubsection{\texorpdfstring{push\+\_\+back\+\_\+dbo()}{push\_back\_dbo()}}
{\footnotesize\ttfamily void Hurricane\+::\+Json\+Stack\+::push\+\_\+back\+\_\+dbo (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{classHurricane_1_1DBo}{D\+Bo}} $\ast$}]{dbo }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}


\begin{DoxyParams}{Parameters}
{\em dbo} & The \mbox{\hyperlink{classHurricane_1_1DataBase}{Data\+Base}} object to push back.\\
\hline
\end{DoxyParams}
Dedicated stack to push objects {\itshape after} they had been casted into the D\+Bo$\ast$ base class. We need to create this separate stack from the {\itshape attribute} stack due to the inability of {\ttfamily boost\+::any\+\_\+cast$<$$>$} to use a base class. \mbox{\Hypertarget{classHurricane_1_1JsonStack_adeeb2a0300fa248f1f3bff38c4095630}\label{classHurricane_1_1JsonStack_adeeb2a0300fa248f1f3bff38c4095630}} 
\index{Hurricane\+::\+Json\+Stack@{Hurricane\+::\+Json\+Stack}!pop\+\_\+back\+\_\+dbo@{pop\+\_\+back\+\_\+dbo}}
\index{pop\+\_\+back\+\_\+dbo@{pop\+\_\+back\+\_\+dbo}!Hurricane\+::\+Json\+Stack@{Hurricane\+::\+Json\+Stack}}
\subsubsection{\texorpdfstring{pop\+\_\+back\+\_\+dbo()}{pop\_back\_dbo()}}
{\footnotesize\ttfamily void Hurricane\+::\+Json\+Stack\+::pop\+\_\+back\+\_\+dbo (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}

Remove one element from the top of the D\+Bo$\ast$ stack. \mbox{\Hypertarget{classHurricane_1_1JsonStack_a95f403acdc0124c279866bd92ef8500a}\label{classHurricane_1_1JsonStack_a95f403acdc0124c279866bd92ef8500a}} 
\index{Hurricane\+::\+Json\+Stack@{Hurricane\+::\+Json\+Stack}!back\+\_\+dbo@{back\+\_\+dbo}}
\index{back\+\_\+dbo@{back\+\_\+dbo}!Hurricane\+::\+Json\+Stack@{Hurricane\+::\+Json\+Stack}}
\subsubsection{\texorpdfstring{back\+\_\+dbo()}{back\_dbo()}}
{\footnotesize\ttfamily \mbox{\hyperlink{classHurricane_1_1DBo}{D\+Bo}} $\ast$ Hurricane\+::\+Json\+Stack\+::back\+\_\+dbo (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}

{\bfseries Returns\+:} The elemet at the top of the D\+Bo$\ast$ stack. \mbox{\Hypertarget{classHurricane_1_1JsonStack_a974ee9daf5dbf861ed50cae0a51a5cbb}\label{classHurricane_1_1JsonStack_a974ee9daf5dbf861ed50cae0a51a5cbb}} 
\index{Hurricane\+::\+Json\+Stack@{Hurricane\+::\+Json\+Stack}!jobjects@{jobjects}}
\index{jobjects@{jobjects}!Hurricane\+::\+Json\+Stack@{Hurricane\+::\+Json\+Stack}}
\subsubsection{\texorpdfstring{jobjects()}{jobjects()}}
{\footnotesize\ttfamily vector$<$ \mbox{\hyperlink{classHurricane_1_1JsonObject}{Json\+Object}} $\ast$ $>$ \& Hurricane\+::\+Json\+Stack\+::jobjects (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}

{\bfseries Returns\+:} the stack of J\+S\+ON objects, for direct manipulation by the involded parties. 

Referenced by Hurricane\+::\+Json\+Object\+::jget().

\mbox{\Hypertarget{classHurricane_1_1JsonStack_aadbd70d7d19d2eb0a6c9c86ca1583c76}\label{classHurricane_1_1JsonStack_aadbd70d7d19d2eb0a6c9c86ca1583c76}} 
\index{Hurricane\+::\+Json\+Stack@{Hurricane\+::\+Json\+Stack}!get\+Entity@{get\+Entity}}
\index{get\+Entity@{get\+Entity}!Hurricane\+::\+Json\+Stack@{Hurricane\+::\+Json\+Stack}}
\subsubsection{\texorpdfstring{get\+Entity()}{getEntity()}}
{\footnotesize\ttfamily template$<$typename T $>$ \\
T Hurricane\+::\+Json\+Stack\+::get\+Entity (\begin{DoxyParamCaption}\item[{unsigned int}]{json\+Id }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}

{\bfseries Returns\+:} The entity, casted as type {\ttfamily T}.

Find an \mbox{\hyperlink{classHurricane_1_1Entity}{Entity}} with the J\+S\+ON id {\ttfamily json\+Id} and cast it into type {\ttfamily T}.

Obviously, this \mbox{\hyperlink{classHurricane_1_1Entity}{Entity}} must have been registered with a call to \mbox{\hyperlink{classHurricane_1_1JsonStack_a421fdf4a3bab01d75f0aab292cc574d0}{add\+Entity()}} before. \mbox{\Hypertarget{classHurricane_1_1JsonStack_a421fdf4a3bab01d75f0aab292cc574d0}\label{classHurricane_1_1JsonStack_a421fdf4a3bab01d75f0aab292cc574d0}} 
\index{Hurricane\+::\+Json\+Stack@{Hurricane\+::\+Json\+Stack}!add\+Entity@{add\+Entity}}
\index{add\+Entity@{add\+Entity}!Hurricane\+::\+Json\+Stack@{Hurricane\+::\+Json\+Stack}}
\subsubsection{\texorpdfstring{add\+Entity()}{addEntity()}}
{\footnotesize\ttfamily void Hurricane\+::\+Json\+Stack\+::add\+Entity (\begin{DoxyParamCaption}\item[{unsigned int}]{json\+Id,  }\item[{\mbox{\hyperlink{classHurricane_1_1Entity}{Entity}} $\ast$}]{entity }\end{DoxyParamCaption})}


\begin{DoxyParams}{Parameters}
{\em json\+Id} & the {\ttfamily id} of the \mbox{\hyperlink{classHurricane_1_1Entity}{Entity}}, in the J\+S\+ON file \\
\hline
{\em entity} & the associated \mbox{\hyperlink{classHurricane_1_1Entity}{Entity}}.\\
\hline
\end{DoxyParams}
When parsing a \mbox{\hyperlink{classHurricane_1_1DataBase}{Data\+Base}} object {\bfseries not} in {\itshape blob} mode, we cannot restore the ids of the Entities as they are in the file. Thus when an \mbox{\hyperlink{classHurricane_1_1Entity}{Entity}} is re-\/created, it comes with a different id. So we have to keep track of the association between this newbox id (in the \mbox{\hyperlink{namespaceHurricane}{Hurricane}} database) and the one in the J\+S\+ON file.

This function adds such an association. \mbox{\Hypertarget{classHurricane_1_1JsonStack_a7e0364c8868b8396db10399a855b8aa1}\label{classHurricane_1_1JsonStack_a7e0364c8868b8396db10399a855b8aa1}} 
\index{Hurricane\+::\+Json\+Stack@{Hurricane\+::\+Json\+Stack}!print@{print}}
\index{print@{print}!Hurricane\+::\+Json\+Stack@{Hurricane\+::\+Json\+Stack}}
\subsubsection{\texorpdfstring{print()}{print()}}
{\footnotesize\ttfamily void Hurricane\+::\+Json\+Stack\+::print (\begin{DoxyParamCaption}\item[{std\+::ostream \&}]{o }\end{DoxyParamCaption}) const}

Dump the contents of the {\itshape attribute} stack int the stream {\ttfamily o}. For debugging purposes. 

The documentation for this class was generated from the following files\+:\begin{DoxyCompactItemize}
\item 
Json\+Object.\+h\item 
Json\+Object.\+dox\end{DoxyCompactItemize}
