\hypertarget{class_qore_1_1_serializable}{}\section{Qore\+::Serializable Class Reference}
\label{class_qore_1_1_serializable}\index{Qore::Serializable@{Qore::Serializable}}


The \mbox{\hyperlink{class_qore_1_1_serializable}{Serializable}} class can be used to mark a class as being serializable.  




Inheritance diagram for Qore\+::Serializable\+:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{class_qore_1_1_serializable__inherit__graph}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{class_qore_1_1_serializable_a7bbf6cf2d7ac53a80e8023790c540c5f}\label{class_qore_1_1_serializable_a7bbf6cf2d7ac53a80e8023790c540c5f}} 
\mbox{\hyperlink{class_qore_1_1_serializable_a7bbf6cf2d7ac53a80e8023790c540c5f}{constructor}} ()
\begin{DoxyCompactList}\small\item\em The constructor does not perform any action; this class is just used to mark a class as serializable by inheriting this class. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{class_qore_1_1_serializable_a10382ed049ba1fc1f3b13a72b24a87b2}\label{class_qore_1_1_serializable_a10382ed049ba1fc1f3b13a72b24a87b2}} 
\mbox{\hyperlink{class_qore_1_1_serializable_a10382ed049ba1fc1f3b13a72b24a87b2}{copy}} ()
\begin{DoxyCompactList}\small\item\em The copy constructor does not perform any action; this class is just used to mark a class as serializable by inheriting this class. \end{DoxyCompactList}\item 
\mbox{\hyperlink{class_qore_1_1_serializable_a65a3f186eb0f67b508c2cc7ecb164ac6}{serialize}} (\mbox{\hyperlink{class_qore_1_1_output_stream}{Output\+Stream}} stream)
\begin{DoxyCompactList}\small\item\em converts the object to binary data representing the object \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_gaf11c7f5c43ced1e9b95bd2270ee87ed9}{binary}} \mbox{\hyperlink{class_qore_1_1_serializable_ae76b3859474a758cf5866ecf0a8c406a}{serialize}} ()
\begin{DoxyCompactList}\small\item\em converts the object to binary data representing the object \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga0231dbb472dd230310af7c7c34f56e92}{hash}}$<$ \mbox{\hyperlink{struct_qore_1_1_serialization_info}{Serialization\+Info}} $>$ \mbox{\hyperlink{class_qore_1_1_serializable_a56d57ea7ff270cccf83b74e40352495f}{serialize\+To\+Data}} ()
\begin{DoxyCompactList}\small\item\em converts the object to a serialization hash representing the object \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Static Public Member Functions}
\begin{DoxyCompactItemize}
\item 
static auto \mbox{\hyperlink{class_qore_1_1_serializable_a0ba3d6e473dd32b896c95a471bfb5a38}{deserialize}} (\mbox{\hyperlink{class_qore_1_1_input_stream}{Input\+Stream}} stream)
\begin{DoxyCompactList}\small\item\em Deserializes data produced with \mbox{\hyperlink{class_qore_1_1_serializable_ae76b3859474a758cf5866ecf0a8c406a}{serialize()}} and returns the value represented by the data. \end{DoxyCompactList}\item 
static auto \mbox{\hyperlink{class_qore_1_1_serializable_a0a780f8c143a6c001b7e28847986ad24}{deserialize}} (\mbox{\hyperlink{group__type__conversion__functions_gaf11c7f5c43ced1e9b95bd2270ee87ed9}{binary}} bin)
\begin{DoxyCompactList}\small\item\em Deserializes data produced with \mbox{\hyperlink{class_qore_1_1_serializable_ae76b3859474a758cf5866ecf0a8c406a}{serialize()}} and returns the value represented by the data. \end{DoxyCompactList}\item 
static auto \mbox{\hyperlink{class_qore_1_1_serializable_aa2aa4a161c1857ef601bb31ea186a443}{deserialize}} (\mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}} bin)
\begin{DoxyCompactList}\small\item\em Deserializes data produced with \mbox{\hyperlink{class_qore_1_1_serializable_ae76b3859474a758cf5866ecf0a8c406a}{serialize()}} and returns the value represented by the data. \end{DoxyCompactList}\item 
static auto \mbox{\hyperlink{class_qore_1_1_serializable_a27190c220319416f248c6e916aeacc51}{deserialize}} (\mbox{\hyperlink{group__type__conversion__functions_ga0231dbb472dd230310af7c7c34f56e92}{hash}}$<$ \mbox{\hyperlink{struct_qore_1_1_serialization_info}{Serialization\+Info}} $>$ data)
\begin{DoxyCompactList}\small\item\em Deserializes data produced with \mbox{\hyperlink{class_qore_1_1_serializable_a56d57ea7ff270cccf83b74e40352495f}{serialize\+To\+Data()}} and returns the value represented by the data. \end{DoxyCompactList}\item 
static \mbox{\hyperlink{group__type__conversion__functions_ga0231dbb472dd230310af7c7c34f56e92}{hash}}$<$ \mbox{\hyperlink{struct_qore_1_1_serialization_info}{Serialization\+Info}} $>$ \mbox{\hyperlink{class_qore_1_1_serializable_a0cb774b9dc126b6c9394ff603cdf7bcd}{deserialize\+To\+Data}} (\mbox{\hyperlink{class_qore_1_1_input_stream}{Input\+Stream}} stream)
\begin{DoxyCompactList}\small\item\em Deserializes data produced with \mbox{\hyperlink{class_qore_1_1_serializable_ae76b3859474a758cf5866ecf0a8c406a}{serialize()}} and returns the value represented by the data. \end{DoxyCompactList}\item 
static \mbox{\hyperlink{group__type__conversion__functions_ga0231dbb472dd230310af7c7c34f56e92}{hash}}$<$ \mbox{\hyperlink{struct_qore_1_1_serialization_info}{Serialization\+Info}} $>$ \mbox{\hyperlink{class_qore_1_1_serializable_a5350224c7216786b903501f299cac733}{deserialize\+To\+Data}} (\mbox{\hyperlink{group__type__conversion__functions_gaf11c7f5c43ced1e9b95bd2270ee87ed9}{binary}} bin)
\begin{DoxyCompactList}\small\item\em Deserializes data produced with \mbox{\hyperlink{class_qore_1_1_serializable_ae76b3859474a758cf5866ecf0a8c406a}{serialize()}} and returns the value represented by the data. \end{DoxyCompactList}\item 
static \mbox{\hyperlink{class_qore_1_1_serializable_a20827429e23566ea2e9cae6a3a9a3df2}{serialize}} (auto val, \mbox{\hyperlink{class_qore_1_1_output_stream}{Output\+Stream}} stream)
\begin{DoxyCompactList}\small\item\em serializes the data and writes the serialized data to the given output stream \end{DoxyCompactList}\item 
static \mbox{\hyperlink{group__type__conversion__functions_gaf11c7f5c43ced1e9b95bd2270ee87ed9}{binary}} \mbox{\hyperlink{class_qore_1_1_serializable_ad20372be9a6f14a550ed2dda357ba51a}{serialize}} (auto val)
\begin{DoxyCompactList}\small\item\em serializes the data and returns the serialized data as a binary object \end{DoxyCompactList}\item 
static \mbox{\hyperlink{group__type__conversion__functions_ga0231dbb472dd230310af7c7c34f56e92}{hash}}$<$ \mbox{\hyperlink{struct_qore_1_1_serialization_info}{Serialization\+Info}} $>$ \mbox{\hyperlink{class_qore_1_1_serializable_ae58790ead4471340b576a69615715b82}{serialize\+To\+Data}} (auto val)
\begin{DoxyCompactList}\small\item\em converts the value to a serialization hash representing the value \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Private Member Functions}
\begin{DoxyCompactItemize}
\item 
nothing \mbox{\hyperlink{class_qore_1_1_serializable_a7d59dd31c2e7f9a06eafb995db5b1381}{deserialize\+Members}} (\mbox{\hyperlink{group__type__conversion__functions_ga0231dbb472dd230310af7c7c34f56e92}{hash}}$<$ auto $>$ members)
\begin{DoxyCompactList}\small\item\em overrides the default automatic member assignment logic for user classes during data deserialization \end{DoxyCompactList}\item 
\+\_\+\+\_\+7\+\_\+ \mbox{\hyperlink{group__type__conversion__functions_ga0231dbb472dd230310af7c7c34f56e92}{hash}}$<$ auto $>$ \mbox{\hyperlink{class_qore_1_1_serializable_ae2a384d8d7fc0a628609f1907ea32b07}{serialize\+Members}} (\+\_\+\+\_\+7\+\_\+ \mbox{\hyperlink{group__type__conversion__functions_ga0231dbb472dd230310af7c7c34f56e92}{hash}}$<$ auto $>$ members)
\begin{DoxyCompactList}\small\item\em overrides the default automatic member retrieval for user classes during data serialization \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
The \mbox{\hyperlink{class_qore_1_1_serializable}{Serializable}} class can be used to mark a class as being serializable. 

This class serves two purposes; to mark classes as serializable and then to implement the actual serialization and deserialization methods.

This class may also be inherited as \mbox{\hyperlink{qore_classes_inheritance}{private\+:internal}} to mark it as serializable (in this case the serialization methods are only available inside the class itself).

Objects are serialized very efficiently; each object in a data structure will only be serialized once, even if it appears multiple times in the data structure. Recursive references and cyclic graphs of objects are also supported for serialization.

Classes that do not inherit this class cannot be serialized; if any non-\/transient member of a serializable class holds an object from a class that does not inherit this class, a {\ttfamily S\+E\+R\+I\+A\+L\+I\+Z\+A\+T\+I\+O\+N-\/\+E\+R\+R\+OR} will be thrown when the object is attempted to be serialized.

Furthermore any attempt to serialize a \mbox{\hyperlink{expressions_closure}{closures}}, \mbox{\hyperlink{expressions_call_reference}{call references}}, or a \mbox{\hyperlink{lvalue_references}{reference}} will result in a {\ttfamily S\+E\+R\+I\+A\+L\+I\+Z\+A\+T\+I\+O\+N-\/\+E\+R\+R\+OR} as well.

\begin{DoxySince}{Since}
Qore 0.\+9 
\end{DoxySince}


\subsection{Member Function Documentation}
\mbox{\Hypertarget{class_qore_1_1_serializable_a0ba3d6e473dd32b896c95a471bfb5a38}\label{class_qore_1_1_serializable_a0ba3d6e473dd32b896c95a471bfb5a38}} 
\index{Qore::Serializable@{Qore::Serializable}!deserialize@{deserialize}}
\index{deserialize@{deserialize}!Qore::Serializable@{Qore::Serializable}}
\subsubsection{\texorpdfstring{deserialize()}{deserialize()}\hspace{0.1cm}{\footnotesize\ttfamily [1/4]}}
{\footnotesize\ttfamily static auto Qore\+::\+Serializable\+::deserialize (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{class_qore_1_1_input_stream}{Input\+Stream}}}]{stream }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Deserializes data produced with \mbox{\hyperlink{class_qore_1_1_serializable_ae76b3859474a758cf5866ecf0a8c406a}{serialize()}} and returns the value represented by the data. 

\begin{DoxyParagraph}{Code Flags\+:}
\mbox{\hyperlink{code_flags_RET_VALUE_ONLY}{R\+E\+T\+\_\+\+V\+A\+L\+U\+E\+\_\+\+O\+N\+LY}}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}{0}
\DoxyCodeLine{auto val = Serializable::deserialize(stream);}
\end{DoxyCode}

\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em stream} & an input stream providing serialized binary data as generated by \mbox{\hyperlink{class_qore_1_1_serializable_ae76b3859474a758cf5866ecf0a8c406a}{serialize()}}\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the value represented by the serialization stream
\end{DoxyReturn}

\begin{DoxyExceptions}{Exceptions}
{\em D\+E\+S\+E\+R\+I\+A\+L\+I\+Z\+A\+T\+I\+O\+N-\/\+E\+R\+R\+OR} & the data cannot be deserialized due to an error in the serialization format or a reference to an unknown class or \mbox{\hyperlink{hashdecl}{Hashdecl\+: Type-\/\+Safe Hash Declarations}} \\
\hline
\end{DoxyExceptions}
\mbox{\Hypertarget{class_qore_1_1_serializable_a0a780f8c143a6c001b7e28847986ad24}\label{class_qore_1_1_serializable_a0a780f8c143a6c001b7e28847986ad24}} 
\index{Qore::Serializable@{Qore::Serializable}!deserialize@{deserialize}}
\index{deserialize@{deserialize}!Qore::Serializable@{Qore::Serializable}}
\subsubsection{\texorpdfstring{deserialize()}{deserialize()}\hspace{0.1cm}{\footnotesize\ttfamily [2/4]}}
{\footnotesize\ttfamily static auto Qore\+::\+Serializable\+::deserialize (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__type__conversion__functions_gaf11c7f5c43ced1e9b95bd2270ee87ed9}{binary}}}]{bin }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Deserializes data produced with \mbox{\hyperlink{class_qore_1_1_serializable_ae76b3859474a758cf5866ecf0a8c406a}{serialize()}} and returns the value represented by the data. 

\begin{DoxyParagraph}{Code Flags\+:}
\mbox{\hyperlink{code_flags_RET_VALUE_ONLY}{R\+E\+T\+\_\+\+V\+A\+L\+U\+E\+\_\+\+O\+N\+LY}}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}{0}
\DoxyCodeLine{auto val = Serializable::deserialize(bin);    }
\end{DoxyCode}

\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em bin} & binary data representing serializeed data as generated by \mbox{\hyperlink{class_qore_1_1_serializable_ae76b3859474a758cf5866ecf0a8c406a}{serialize()}}\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the value represented by the data
\end{DoxyReturn}

\begin{DoxyExceptions}{Exceptions}
{\em D\+E\+S\+E\+R\+I\+A\+L\+I\+Z\+A\+T\+I\+O\+N-\/\+E\+R\+R\+OR} & the data cannot be deserialized due to an error in the serialization format or a reference to an unknown class or \mbox{\hyperlink{hashdecl}{Hashdecl\+: Type-\/\+Safe Hash Declarations}} \\
\hline
\end{DoxyExceptions}
\mbox{\Hypertarget{class_qore_1_1_serializable_aa2aa4a161c1857ef601bb31ea186a443}\label{class_qore_1_1_serializable_aa2aa4a161c1857ef601bb31ea186a443}} 
\index{Qore::Serializable@{Qore::Serializable}!deserialize@{deserialize}}
\index{deserialize@{deserialize}!Qore::Serializable@{Qore::Serializable}}
\subsubsection{\texorpdfstring{deserialize()}{deserialize()}\hspace{0.1cm}{\footnotesize\ttfamily [3/4]}}
{\footnotesize\ttfamily static auto Qore\+::\+Serializable\+::deserialize (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}}}]{bin }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Deserializes data produced with \mbox{\hyperlink{class_qore_1_1_serializable_ae76b3859474a758cf5866ecf0a8c406a}{serialize()}} and returns the value represented by the data. 

\begin{DoxyParagraph}{Code Flags\+:}
\mbox{\hyperlink{code_flags_RET_VALUE_ONLY}{R\+E\+T\+\_\+\+V\+A\+L\+U\+E\+\_\+\+O\+N\+LY}}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}{0}
\DoxyCodeLine{auto val = Serializable::deserialize(bin);}
\end{DoxyCode}

\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em bin} & binary data representing serializeed data as generated by \mbox{\hyperlink{class_qore_1_1_serializable_ae76b3859474a758cf5866ecf0a8c406a}{serialize()}}\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the value represented by the data
\end{DoxyReturn}

\begin{DoxyExceptions}{Exceptions}
{\em D\+E\+S\+E\+R\+I\+A\+L\+I\+Z\+A\+T\+I\+O\+N-\/\+E\+R\+R\+OR} & the data cannot be deserialized due to an error in the serialization format or a reference to an unknown class or \mbox{\hyperlink{hashdecl}{Hashdecl\+: Type-\/\+Safe Hash Declarations}}\\
\hline
\end{DoxyExceptions}
\begin{DoxySince}{Since}
Qore 0.\+9.\+2 
\end{DoxySince}
\mbox{\Hypertarget{class_qore_1_1_serializable_a27190c220319416f248c6e916aeacc51}\label{class_qore_1_1_serializable_a27190c220319416f248c6e916aeacc51}} 
\index{Qore::Serializable@{Qore::Serializable}!deserialize@{deserialize}}
\index{deserialize@{deserialize}!Qore::Serializable@{Qore::Serializable}}
\subsubsection{\texorpdfstring{deserialize()}{deserialize()}\hspace{0.1cm}{\footnotesize\ttfamily [4/4]}}
{\footnotesize\ttfamily static auto Qore\+::\+Serializable\+::deserialize (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__type__conversion__functions_ga0231dbb472dd230310af7c7c34f56e92}{hash}}$<$ \mbox{\hyperlink{struct_qore_1_1_serialization_info}{Serialization\+Info}} $>$}]{data }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Deserializes data produced with \mbox{\hyperlink{class_qore_1_1_serializable_a56d57ea7ff270cccf83b74e40352495f}{serialize\+To\+Data()}} and returns the value represented by the data. 

\begin{DoxyParagraph}{Code Flags\+:}
\mbox{\hyperlink{code_flags_RET_VALUE_ONLY}{R\+E\+T\+\_\+\+V\+A\+L\+U\+E\+\_\+\+O\+N\+LY}}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}{0}
\DoxyCodeLine{auto val = Serializable::deserialize(h);}
\end{DoxyCode}

\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em data} & the data representing the object as generated by \mbox{\hyperlink{class_qore_1_1_serializable_a56d57ea7ff270cccf83b74e40352495f}{serialize\+To\+Data()}}\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the value represented by the data
\end{DoxyReturn}

\begin{DoxyExceptions}{Exceptions}
{\em D\+E\+S\+E\+R\+I\+A\+L\+I\+Z\+A\+T\+I\+O\+N-\/\+E\+R\+R\+OR} & the data cannot be deserialized due to an error in the serialization format or a reference to an unknown class or \mbox{\hyperlink{hashdecl}{Hashdecl\+: Type-\/\+Safe Hash Declarations}} \\
\hline
\end{DoxyExceptions}
\mbox{\Hypertarget{class_qore_1_1_serializable_a7d59dd31c2e7f9a06eafb995db5b1381}\label{class_qore_1_1_serializable_a7d59dd31c2e7f9a06eafb995db5b1381}} 
\index{Qore::Serializable@{Qore::Serializable}!deserializeMembers@{deserializeMembers}}
\index{deserializeMembers@{deserializeMembers}!Qore::Serializable@{Qore::Serializable}}
\subsubsection{\texorpdfstring{deserializeMembers()}{deserializeMembers()}}
{\footnotesize\ttfamily nothing Qore\+::\+Serializable\+::deserialize\+Members (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__type__conversion__functions_ga0231dbb472dd230310af7c7c34f56e92}{hash}}$<$ auto $>$}]{members }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



overrides the default automatic member assignment logic for user classes during data deserialization 

\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{keyword}{class }MyClass inherits \mbox{\hyperlink{namespace_qore}{Qore}}::Serializable \{}
\DoxyCodeLine{    private:internal \{}
\DoxyCodeLine{        transient string my\_special\_member;}
\DoxyCodeLine{    \}}
\DoxyCodeLine{}
\DoxyCodeLine{    \textcolor{comment}{\# when defining this member, all member assignment during deserialization must be performed by this method,}}
\DoxyCodeLine{    \textcolor{comment}{\# even for transient members, as no automatic member assignment will be performed}}
\DoxyCodeLine{    deserializeMembers(*hash<auto> members) \{}
\DoxyCodeLine{        my\_special\_member = get\_special\_value();}
\DoxyCodeLine{        self += members;}
\DoxyCodeLine{    \}}
\DoxyCodeLine{\}}
\end{DoxyCode}

\end{DoxyParagraph}
This method is special in that it is only called during data deserialization for user classes for each class in a class hierarchy if the method is defined.

This method in the base class does nothing and should not be called from user classes; this method is declared {\ttfamily private\+:internal} to emphasize that it is only called for the local class by the internal deserialization logic; it may be declared with any access permission, but in any case the method only has an effect for the local class and not for the hierarchy, which makes it different than other Qore class methods (other than the similar \mbox{\hyperlink{class_qore_1_1_serializable_ae2a384d8d7fc0a628609f1907ea32b07}{serialize\+Members()}} method.

This method can be used to implement special deserialization logic when deserializing members of a particular class in a class hierarchy.


\begin{DoxyParams}{Parameters}
{\em members} & locally-\/defined deserialized members to assign to the local class to be assigned manually in this method; this hash will be empty if no members were serialized\\
\hline
\end{DoxyParams}
\begin{DoxyNote}{Note}
If this method is defined, then the class must assign its own members including transient members, as automatic member initialization will not be performed for the local class by the deserialization logic in this case.
\end{DoxyNote}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{class_qore_1_1_serializable_ae2a384d8d7fc0a628609f1907ea32b07}{serialize\+Members()}} 
\end{DoxySeeAlso}
\mbox{\Hypertarget{class_qore_1_1_serializable_a0cb774b9dc126b6c9394ff603cdf7bcd}\label{class_qore_1_1_serializable_a0cb774b9dc126b6c9394ff603cdf7bcd}} 
\index{Qore::Serializable@{Qore::Serializable}!deserializeToData@{deserializeToData}}
\index{deserializeToData@{deserializeToData}!Qore::Serializable@{Qore::Serializable}}
\subsubsection{\texorpdfstring{deserializeToData()}{deserializeToData()}\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily static \mbox{\hyperlink{group__type__conversion__functions_ga0231dbb472dd230310af7c7c34f56e92}{hash}}$<$\mbox{\hyperlink{struct_qore_1_1_serialization_info}{Serialization\+Info}}$>$ Qore\+::\+Serializable\+::deserialize\+To\+Data (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{class_qore_1_1_input_stream}{Input\+Stream}}}]{stream }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Deserializes data produced with \mbox{\hyperlink{class_qore_1_1_serializable_ae76b3859474a758cf5866ecf0a8c406a}{serialize()}} and returns the value represented by the data. 

\begin{DoxyParagraph}{Code Flags\+:}
\mbox{\hyperlink{code_flags_RET_VALUE_ONLY}{R\+E\+T\+\_\+\+V\+A\+L\+U\+E\+\_\+\+O\+N\+LY}}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}{0}
\DoxyCodeLine{hash<SerializationInfo> h = Serializable::deserializeToData(stream);}
\end{DoxyCode}

\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em stream} & an input stream providing serialized binary data as generated by \mbox{\hyperlink{class_qore_1_1_serializable_ae76b3859474a758cf5866ecf0a8c406a}{serialize()}}\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the intermediate \mbox{\hyperlink{struct_qore_1_1_serialization_info}{Serialization\+Info}} hash value represented by the serialization stream
\end{DoxyReturn}

\begin{DoxyExceptions}{Exceptions}
{\em D\+E\+S\+E\+R\+I\+A\+L\+I\+Z\+A\+T\+I\+O\+N-\/\+E\+R\+R\+OR} & the data cannot be deserialized due to an error in the serialization format or a reference to an unknown class or \mbox{\hyperlink{hashdecl}{Hashdecl\+: Type-\/\+Safe Hash Declarations}} \\
\hline
\end{DoxyExceptions}
\mbox{\Hypertarget{class_qore_1_1_serializable_a5350224c7216786b903501f299cac733}\label{class_qore_1_1_serializable_a5350224c7216786b903501f299cac733}} 
\index{Qore::Serializable@{Qore::Serializable}!deserializeToData@{deserializeToData}}
\index{deserializeToData@{deserializeToData}!Qore::Serializable@{Qore::Serializable}}
\subsubsection{\texorpdfstring{deserializeToData()}{deserializeToData()}\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily static \mbox{\hyperlink{group__type__conversion__functions_ga0231dbb472dd230310af7c7c34f56e92}{hash}}$<$\mbox{\hyperlink{struct_qore_1_1_serialization_info}{Serialization\+Info}}$>$ Qore\+::\+Serializable\+::deserialize\+To\+Data (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__type__conversion__functions_gaf11c7f5c43ced1e9b95bd2270ee87ed9}{binary}}}]{bin }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Deserializes data produced with \mbox{\hyperlink{class_qore_1_1_serializable_ae76b3859474a758cf5866ecf0a8c406a}{serialize()}} and returns the value represented by the data. 

\begin{DoxyParagraph}{Code Flags\+:}
\mbox{\hyperlink{code_flags_RET_VALUE_ONLY}{R\+E\+T\+\_\+\+V\+A\+L\+U\+E\+\_\+\+O\+N\+LY}}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}{0}
\DoxyCodeLine{hash<SerializationInfo> h = Serializable::deserializeToData(b);}
\end{DoxyCode}

\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em bin} & binary data representing serializeed data as generated by \mbox{\hyperlink{class_qore_1_1_serializable_ae76b3859474a758cf5866ecf0a8c406a}{serialize()}}\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the intermediate \mbox{\hyperlink{struct_qore_1_1_serialization_info}{Serialization\+Info}} hash value represented by the input data
\end{DoxyReturn}

\begin{DoxyExceptions}{Exceptions}
{\em D\+E\+S\+E\+R\+I\+A\+L\+I\+Z\+A\+T\+I\+O\+N-\/\+E\+R\+R\+OR} & the data cannot be deserialized due to an error in the serialization format or a reference to an unknown class or \mbox{\hyperlink{hashdecl}{Hashdecl\+: Type-\/\+Safe Hash Declarations}} \\
\hline
\end{DoxyExceptions}
\mbox{\Hypertarget{class_qore_1_1_serializable_a65a3f186eb0f67b508c2cc7ecb164ac6}\label{class_qore_1_1_serializable_a65a3f186eb0f67b508c2cc7ecb164ac6}} 
\index{Qore::Serializable@{Qore::Serializable}!serialize@{serialize}}
\index{serialize@{serialize}!Qore::Serializable@{Qore::Serializable}}
\subsubsection{\texorpdfstring{serialize()}{serialize()}\hspace{0.1cm}{\footnotesize\ttfamily [1/4]}}
{\footnotesize\ttfamily Qore\+::\+Serializable\+::serialize (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{class_qore_1_1_output_stream}{Output\+Stream}}}]{stream }\end{DoxyParamCaption})}



converts the object to binary data representing the object 

\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}{0}
\DoxyCodeLine{obj.serialize(stream);}
\end{DoxyCode}

\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em stream} & an output stream where the serialized data will be written\\
\hline
\end{DoxyParams}
All non-\/serializable data such as \mbox{\hyperlink{expressions_closure}{closures}}, \mbox{\hyperlink{expressions_call_reference}{call references}}, \mbox{\hyperlink{lvalue_references}{references}}, or non-\/serializable objects must be tagged as \mbox{\hyperlink{qore_classes_transient}{Transient Members}} or a {\ttfamily S\+E\+R\+I\+A\+L\+I\+Z\+A\+T\+I\+O\+N-\/\+E\+R\+R\+OR} exception will be thrown.


\begin{DoxyExceptions}{Exceptions}
{\em S\+E\+R\+I\+A\+L\+I\+Z\+A\+T\+I\+O\+N-\/\+E\+R\+R\+OR} & the object cannot be serialized as it contains non-\/serializable data (\mbox{\hyperlink{expressions_closure}{closures}}, \mbox{\hyperlink{expressions_call_reference}{call references}}, \mbox{\hyperlink{lvalue_references}{references}}, and non-\/serializable objects) \\
\hline
\end{DoxyExceptions}
\mbox{\Hypertarget{class_qore_1_1_serializable_ae76b3859474a758cf5866ecf0a8c406a}\label{class_qore_1_1_serializable_ae76b3859474a758cf5866ecf0a8c406a}} 
\index{Qore::Serializable@{Qore::Serializable}!serialize@{serialize}}
\index{serialize@{serialize}!Qore::Serializable@{Qore::Serializable}}
\subsubsection{\texorpdfstring{serialize()}{serialize()}\hspace{0.1cm}{\footnotesize\ttfamily [2/4]}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_gaf11c7f5c43ced1e9b95bd2270ee87ed9}{binary}} Qore\+::\+Serializable\+::serialize (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



converts the object to binary data representing the object 

\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}{0}
\DoxyCodeLine{binary b = obj.serialize();}
\end{DoxyCode}

\end{DoxyParagraph}
\begin{DoxyReturn}{Returns}
a binary object representing the object
\end{DoxyReturn}
All non-\/serializable data such as \mbox{\hyperlink{expressions_closure}{closures}}, \mbox{\hyperlink{expressions_call_reference}{call references}}, \mbox{\hyperlink{lvalue_references}{references}}, or non-\/serializable objects must be tagged as \mbox{\hyperlink{qore_classes_transient}{Transient Members}} or a {\ttfamily S\+E\+R\+I\+A\+L\+I\+Z\+A\+T\+I\+O\+N-\/\+E\+R\+R\+OR} exception will be thrown.


\begin{DoxyExceptions}{Exceptions}
{\em S\+E\+R\+I\+A\+L\+I\+Z\+A\+T\+I\+O\+N-\/\+E\+R\+R\+OR} & the object cannot be serialized as it contains non-\/serializable data (\mbox{\hyperlink{expressions_closure}{closures}}, \mbox{\hyperlink{expressions_call_reference}{call references}}, \mbox{\hyperlink{lvalue_references}{references}}, and non-\/serializable objects) \\
\hline
\end{DoxyExceptions}
\mbox{\Hypertarget{class_qore_1_1_serializable_a20827429e23566ea2e9cae6a3a9a3df2}\label{class_qore_1_1_serializable_a20827429e23566ea2e9cae6a3a9a3df2}} 
\index{Qore::Serializable@{Qore::Serializable}!serialize@{serialize}}
\index{serialize@{serialize}!Qore::Serializable@{Qore::Serializable}}
\subsubsection{\texorpdfstring{serialize()}{serialize()}\hspace{0.1cm}{\footnotesize\ttfamily [3/4]}}
{\footnotesize\ttfamily static Qore\+::\+Serializable\+::serialize (\begin{DoxyParamCaption}\item[{auto}]{val,  }\item[{\mbox{\hyperlink{class_qore_1_1_output_stream}{Output\+Stream}}}]{stream }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



serializes the data and writes the serialized data to the given output stream 

\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}{0}
\DoxyCodeLine{Serializable::serialize(val, stream);}
\end{DoxyCode}

\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em val} & the data to serialize \\
\hline
{\em stream} & an output stream where the serialized data will be written\\
\hline
\end{DoxyParams}
All non-\/serializable data such as \mbox{\hyperlink{expressions_closure}{closures}}, \mbox{\hyperlink{expressions_call_reference}{call references}}, \mbox{\hyperlink{lvalue_references}{references}}, or non-\/serializable objects must be tagged as \mbox{\hyperlink{qore_classes_transient}{Transient Members}} in object members or a {\ttfamily S\+E\+R\+I\+A\+L\+I\+Z\+A\+T\+I\+O\+N-\/\+E\+R\+R\+OR} exception will be thrown.


\begin{DoxyExceptions}{Exceptions}
{\em S\+E\+R\+I\+A\+L\+I\+Z\+A\+T\+I\+O\+N-\/\+E\+R\+R\+OR} & the object cannot be serialized as it contains non-\/serializable data (\mbox{\hyperlink{expressions_closure}{closures}}, \mbox{\hyperlink{expressions_call_reference}{call references}}, \mbox{\hyperlink{lvalue_references}{references}}, and non-\/serializable objects) \\
\hline
\end{DoxyExceptions}
\mbox{\Hypertarget{class_qore_1_1_serializable_ad20372be9a6f14a550ed2dda357ba51a}\label{class_qore_1_1_serializable_ad20372be9a6f14a550ed2dda357ba51a}} 
\index{Qore::Serializable@{Qore::Serializable}!serialize@{serialize}}
\index{serialize@{serialize}!Qore::Serializable@{Qore::Serializable}}
\subsubsection{\texorpdfstring{serialize()}{serialize()}\hspace{0.1cm}{\footnotesize\ttfamily [4/4]}}
{\footnotesize\ttfamily static \mbox{\hyperlink{group__type__conversion__functions_gaf11c7f5c43ced1e9b95bd2270ee87ed9}{binary}} Qore\+::\+Serializable\+::serialize (\begin{DoxyParamCaption}\item[{auto}]{val }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



serializes the data and returns the serialized data as a binary object 

\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}{0}
\DoxyCodeLine{binary bin = Serializable::serialize(val);}
\end{DoxyCode}

\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em val} & the data to serialize\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
serialized data representing the input data
\end{DoxyReturn}
All non-\/serializable data such as \mbox{\hyperlink{expressions_closure}{closures}}, \mbox{\hyperlink{expressions_call_reference}{call references}}, \mbox{\hyperlink{lvalue_references}{references}}, or non-\/serializable objects must be tagged as \mbox{\hyperlink{qore_classes_transient}{Transient Members}} in object members or a {\ttfamily S\+E\+R\+I\+A\+L\+I\+Z\+A\+T\+I\+O\+N-\/\+E\+R\+R\+OR} exception will be thrown.


\begin{DoxyExceptions}{Exceptions}
{\em S\+E\+R\+I\+A\+L\+I\+Z\+A\+T\+I\+O\+N-\/\+E\+R\+R\+OR} & the object cannot be serialized as it contains non-\/serializable data (\mbox{\hyperlink{expressions_closure}{closures}}, \mbox{\hyperlink{expressions_call_reference}{call references}}, \mbox{\hyperlink{lvalue_references}{references}}, and non-\/serializable objects) \\
\hline
\end{DoxyExceptions}
\mbox{\Hypertarget{class_qore_1_1_serializable_ae2a384d8d7fc0a628609f1907ea32b07}\label{class_qore_1_1_serializable_ae2a384d8d7fc0a628609f1907ea32b07}} 
\index{Qore::Serializable@{Qore::Serializable}!serializeMembers@{serializeMembers}}
\index{serializeMembers@{serializeMembers}!Qore::Serializable@{Qore::Serializable}}
\subsubsection{\texorpdfstring{serializeMembers()}{serializeMembers()}}
{\footnotesize\ttfamily \+\_\+\+\_\+7\+\_\+ \mbox{\hyperlink{group__type__conversion__functions_ga0231dbb472dd230310af7c7c34f56e92}{hash}}$<$auto$>$ Qore\+::\+Serializable\+::serialize\+Members (\begin{DoxyParamCaption}\item[{\+\_\+\+\_\+7\+\_\+ \mbox{\hyperlink{group__type__conversion__functions_ga0231dbb472dd230310af7c7c34f56e92}{hash}}$<$ auto $>$}]{members }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



overrides the default automatic member retrieval for user classes during data serialization 

\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{keyword}{class }MyClass inherits \mbox{\hyperlink{namespace_qore}{Qore}}::Serializable \{}
\DoxyCodeLine{    private:internal \{}
\DoxyCodeLine{        transient string my\_special\_member;}
\DoxyCodeLine{    \}}
\DoxyCodeLine{}
\DoxyCodeLine{    \textcolor{comment}{\# if this member is defined, all members retrieved from this class will be returned only}}
\DoxyCodeLine{    \textcolor{comment}{\# by this method, as in this case no automatic member retrieval for the given class will be}}
\DoxyCodeLine{    \textcolor{comment}{\# performed}}
\DoxyCodeLine{    hash<auto> serializeMembers() \{}
\DoxyCodeLine{        \textcolor{keywordflow}{return} \{}
\DoxyCodeLine{            \textcolor{stringliteral}{"special\_data"}: get\_special\_data(),}
\DoxyCodeLine{        \}}
\DoxyCodeLine{    \}}
\DoxyCodeLine{\}}
\end{DoxyCode}

\end{DoxyParagraph}
This method is special in that it is only called for user classes for each class in a class hierarchy if the method is defined.

This method in the base class does nothing and should not be called from user classes; this method is declared {\ttfamily private\+:internal} to emphasize that it is only called for the local class by the internal serialization logic; it may be declared with any access permission, but in any case the method only has an effect for the local class and not for the hierarchy, which makes it different than other Qore class methods (other than the similar \mbox{\hyperlink{class_qore_1_1_serializable_a7d59dd31c2e7f9a06eafb995db5b1381}{deserialize\+Members()}} method).

This method can be used to implement special serialization logic when serializing members of a particular class in a class hierarchy.


\begin{DoxyParams}{Parameters}
{\em members} & locally-\/defined serialized non-\/\mbox{\hyperlink{qore_classes_transient}{transient}} members, if any\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
member information to be passed to the class during deserialization; overrides the default member retrieval logic during object serialization
\end{DoxyReturn}
\begin{DoxyNote}{Note}
If this method is defined, then the class must return its own members, as automatic member retrieval will not be performed for the local class by the serialization logic in this case.
\end{DoxyNote}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{class_qore_1_1_serializable_a7d59dd31c2e7f9a06eafb995db5b1381}{deserialize\+Members()}} 
\end{DoxySeeAlso}
\mbox{\Hypertarget{class_qore_1_1_serializable_a56d57ea7ff270cccf83b74e40352495f}\label{class_qore_1_1_serializable_a56d57ea7ff270cccf83b74e40352495f}} 
\index{Qore::Serializable@{Qore::Serializable}!serializeToData@{serializeToData}}
\index{serializeToData@{serializeToData}!Qore::Serializable@{Qore::Serializable}}
\subsubsection{\texorpdfstring{serializeToData()}{serializeToData()}\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_ga0231dbb472dd230310af7c7c34f56e92}{hash}}$<$\mbox{\hyperlink{struct_qore_1_1_serialization_info}{Serialization\+Info}}$>$ Qore\+::\+Serializable\+::serialize\+To\+Data (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



converts the object to a serialization hash representing the object 

\begin{DoxyParagraph}{Code Flags\+:}
\mbox{\hyperlink{code_flags_RET_VALUE_ONLY}{R\+E\+T\+\_\+\+V\+A\+L\+U\+E\+\_\+\+O\+N\+LY}}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}{0}
\DoxyCodeLine{hash<SerializationInfo> h = obj.serializeToData();}
\end{DoxyCode}

\end{DoxyParagraph}
\begin{DoxyReturn}{Returns}
a serialization hash representing the object
\end{DoxyReturn}
All non-\/serializable data such as \mbox{\hyperlink{expressions_closure}{closures}}, \mbox{\hyperlink{expressions_call_reference}{call references}}, \mbox{\hyperlink{lvalue_references}{references}}, or non-\/serializable objects must be tagged as \mbox{\hyperlink{qore_classes_transient}{Transient Members}} or a {\ttfamily S\+E\+R\+I\+A\+L\+I\+Z\+A\+T\+I\+O\+N-\/\+E\+R\+R\+OR} exception will be thrown.


\begin{DoxyExceptions}{Exceptions}
{\em S\+E\+R\+I\+A\+L\+I\+Z\+A\+T\+I\+O\+N-\/\+E\+R\+R\+OR} & the object cannot be serialized as it contains non-\/serializable data (\mbox{\hyperlink{expressions_closure}{closures}}, \mbox{\hyperlink{expressions_call_reference}{call references}}, \mbox{\hyperlink{lvalue_references}{references}}, and non-\/serializable objects) \\
\hline
\end{DoxyExceptions}
\mbox{\Hypertarget{class_qore_1_1_serializable_ae58790ead4471340b576a69615715b82}\label{class_qore_1_1_serializable_ae58790ead4471340b576a69615715b82}} 
\index{Qore::Serializable@{Qore::Serializable}!serializeToData@{serializeToData}}
\index{serializeToData@{serializeToData}!Qore::Serializable@{Qore::Serializable}}
\subsubsection{\texorpdfstring{serializeToData()}{serializeToData()}\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily static \mbox{\hyperlink{group__type__conversion__functions_ga0231dbb472dd230310af7c7c34f56e92}{hash}}$<$\mbox{\hyperlink{struct_qore_1_1_serialization_info}{Serialization\+Info}}$>$ Qore\+::\+Serializable\+::serialize\+To\+Data (\begin{DoxyParamCaption}\item[{auto}]{val }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



converts the value to a serialization hash representing the value 

\begin{DoxyParagraph}{Code Flags\+:}
\mbox{\hyperlink{code_flags_RET_VALUE_ONLY}{R\+E\+T\+\_\+\+V\+A\+L\+U\+E\+\_\+\+O\+N\+LY}}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}{0}
\DoxyCodeLine{hash<SerializationInfo> h = serializeToData(val);}
\end{DoxyCode}

\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em val} & the value to serialize to a serialization data hash\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a serialization hash representing the value
\end{DoxyReturn}
All non-\/serializable data such as \mbox{\hyperlink{expressions_closure}{closures}}, \mbox{\hyperlink{expressions_call_reference}{call references}}, \mbox{\hyperlink{lvalue_references}{references}}, or non-\/serializable objects must be tagged as \mbox{\hyperlink{qore_classes_transient}{Transient Members}} or a {\ttfamily S\+E\+R\+I\+A\+L\+I\+Z\+A\+T\+I\+O\+N-\/\+E\+R\+R\+OR} exception will be thrown.


\begin{DoxyExceptions}{Exceptions}
{\em S\+E\+R\+I\+A\+L\+I\+Z\+A\+T\+I\+O\+N-\/\+E\+R\+R\+OR} & the object cannot be serialized as it contains non-\/serializable data (\mbox{\hyperlink{expressions_closure}{closures}}, \mbox{\hyperlink{expressions_call_reference}{call references}}, \mbox{\hyperlink{lvalue_references}{references}}, and non-\/serializable objects) \\
\hline
\end{DoxyExceptions}
