\section{Ti\-Xml\-Document Class Reference}
\label{classTiXmlDocument}\index{Ti\-Xml\-Document@{Ti\-Xml\-Document}}


Always the top level node.  




{\ttfamily \#include $<$tinyxml.\-h$>$}

Inheritance diagram for Ti\-Xml\-Document\-:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=3.000000cm]{classTiXmlDocument}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
{\bf Ti\-Xml\-Document} ()\label{classTiXmlDocument_a9f5e84335708fde98400230f9f12659c}

\begin{DoxyCompactList}\small\item\em Create an empty document, that has no name. \end{DoxyCompactList}\item 
{\bf Ti\-Xml\-Document} (const char $\ast$document\-Name)\label{classTiXmlDocument_ae4508b452d0c3061db085f3db27b8396}

\begin{DoxyCompactList}\small\item\em Create a document with a name. The name of the document is also the filename of the xml. \end{DoxyCompactList}\item 
{\bf Ti\-Xml\-Document} (const std\-::string \&document\-Name)\label{classTiXmlDocument_a2c6e58fb99bfa76cc613f16840022225}

\begin{DoxyCompactList}\small\item\em Constructor. \end{DoxyCompactList}\item 
{\bfseries Ti\-Xml\-Document} (const {\bf Ti\-Xml\-Document} \&copy)\label{classTiXmlDocument_a323a7486e7da6099cdc19a5ff7e74b07}

\item 
void {\bfseries operator=} (const {\bf Ti\-Xml\-Document} \&copy)\label{classTiXmlDocument_aafbfacc3414008f619b1345775ef12a4}

\item 
bool {\bf Load\-File} (Ti\-Xml\-Encoding encoding=T\-I\-X\-M\-L\-\_\-\-D\-E\-F\-A\-U\-L\-T\-\_\-\-E\-N\-C\-O\-D\-I\-N\-G)
\begin{DoxyCompactList}\small\item\em Load a file using the current document value. \end{DoxyCompactList}\item 
bool {\bf Save\-File} () const \label{classTiXmlDocument_a21c0aeb0d0a720169ad4ac89523ebe93}

\begin{DoxyCompactList}\small\item\em Save a file using the current document value. Returns true if successful. \end{DoxyCompactList}\item 
bool {\bf Load\-File} (const char $\ast$filename, Ti\-Xml\-Encoding encoding=T\-I\-X\-M\-L\-\_\-\-D\-E\-F\-A\-U\-L\-T\-\_\-\-E\-N\-C\-O\-D\-I\-N\-G)\label{classTiXmlDocument_a879cdf5e981b8b2d2ef82f2546dd28fb}

\begin{DoxyCompactList}\small\item\em Load a file using the given filename. Returns true if successful. \end{DoxyCompactList}\item 
bool {\bf Save\-File} (const char $\ast$filename) const \label{classTiXmlDocument_ae869f5ebf7fc54c4a1d737fb4689fd44}

\begin{DoxyCompactList}\small\item\em Save a file using the given filename. Returns true if successful. \end{DoxyCompactList}\item 
bool {\bf Load\-File} (F\-I\-L\-E $\ast$, Ti\-Xml\-Encoding encoding=T\-I\-X\-M\-L\-\_\-\-D\-E\-F\-A\-U\-L\-T\-\_\-\-E\-N\-C\-O\-D\-I\-N\-G)
\begin{DoxyCompactList}\small\item\em Load a file using the given F\-I\-L\-E$\ast$. \end{DoxyCompactList}\item 
bool {\bf Save\-File} (F\-I\-L\-E $\ast$) const \label{classTiXmlDocument_acf1672b4538c6d1d441f9f108aea2bf4}

\begin{DoxyCompactList}\small\item\em Save a file using the given F\-I\-L\-E$\ast$. Returns true if successful. \end{DoxyCompactList}\item 
bool {\bf Load\-File} (const std\-::string \&filename, Ti\-Xml\-Encoding encoding=T\-I\-X\-M\-L\-\_\-\-D\-E\-F\-A\-U\-L\-T\-\_\-\-E\-N\-C\-O\-D\-I\-N\-G)
\item 
bool {\bf Save\-File} (const std\-::string \&filename) const \label{classTiXmlDocument_a3d4fae0463f3f03679ba0b7cf6f2df52}

\begin{DoxyCompactList}\small\item\em $<$ S\-T\-L std\-::string version. \end{DoxyCompactList}\item 
virtual const char $\ast$ {\bf Parse} (const char $\ast$p, {\bf Ti\-Xml\-Parsing\-Data} $\ast$data=0, Ti\-Xml\-Encoding encoding=T\-I\-X\-M\-L\-\_\-\-D\-E\-F\-A\-U\-L\-T\-\_\-\-E\-N\-C\-O\-D\-I\-N\-G)
\begin{DoxyCompactList}\small\item\em Parse the given null terminated block of xml data. \end{DoxyCompactList}\item 
const {\bf Ti\-Xml\-Element} $\ast$ {\bf Root\-Element} () const 
\begin{DoxyCompactList}\small\item\em Get the root element -- the only top level element -- of the document. \end{DoxyCompactList}\item 
{\bf Ti\-Xml\-Element} $\ast$ {\bfseries Root\-Element} ()\label{classTiXmlDocument_a0b43e762a23f938b06651bc90b8a1013}

\item 
bool {\bf Error} () const 
\begin{DoxyCompactList}\small\item\em If an error occurs, Error will be set to true. \end{DoxyCompactList}\item 
const char $\ast$ {\bf Error\-Desc} () const \label{classTiXmlDocument_a9d0f689f6e09ea494ea547be8d79c25e}

\begin{DoxyCompactList}\small\item\em Contains a textual (english) description of the error if one occurs. \end{DoxyCompactList}\item 
int {\bf Error\-Id} () const 
\begin{DoxyCompactList}\small\item\em Generally, you probably want the error string ( \doxyref{Error\-Desc()}{p.}{classTiXmlDocument_a9d0f689f6e09ea494ea547be8d79c25e} ). \end{DoxyCompactList}\item 
int {\bf Error\-Row} () const 
\begin{DoxyCompactList}\small\item\em Returns the location (if known) of the error. \end{DoxyCompactList}\item 
int {\bf Error\-Col} () const \label{classTiXmlDocument_aa90bc630ee5203c6109ca5fad3323649}

\begin{DoxyCompactList}\small\item\em The column where the error occured. See \doxyref{Error\-Row()}{p.}{classTiXmlDocument_af30efc75e804aa2e92fb8be3a8cb676e} \end{DoxyCompactList}\item 
void {\bf Set\-Tab\-Size} (int \-\_\-tabsize)
\begin{DoxyCompactList}\small\item\em \doxyref{Set\-Tab\-Size()}{p.}{classTiXmlDocument_a51dac56316f89b35bdb7d0d433ba988e} allows the error reporting functions (\doxyref{Error\-Row()}{p.}{classTiXmlDocument_af30efc75e804aa2e92fb8be3a8cb676e} and \doxyref{Error\-Col()}{p.}{classTiXmlDocument_aa90bc630ee5203c6109ca5fad3323649}) to report the correct values for row and column. \end{DoxyCompactList}\item 
int {\bfseries Tab\-Size} () const \label{classTiXmlDocument_a612360241b85bad0826b2a9ae9cda561}

\item 
void {\bf Clear\-Error} ()
\begin{DoxyCompactList}\small\item\em If you have handled the error, it can be reset with this call. \end{DoxyCompactList}\item 
void {\bf Print} () const 
\begin{DoxyCompactList}\small\item\em Write the document to standard out using formatted printing (\char`\"{}pretty print\char`\"{}). \end{DoxyCompactList}\item 
virtual void {\bf Print} (F\-I\-L\-E $\ast$cfile, int depth=0) const \label{classTiXmlDocument_a7b1aea204fee266b70b9c105c8bf2ada}

\begin{DoxyCompactList}\small\item\em Print this Document to a F\-I\-L\-E stream. \end{DoxyCompactList}\item 
void {\bfseries Set\-Error} (int err, const char $\ast$error\-Location, {\bf Ti\-Xml\-Parsing\-Data} $\ast$prev\-Data, Ti\-Xml\-Encoding encoding)\label{classTiXmlDocument_a735c23e318597b920c94eae77fa206de}

\item 
virtual const {\bf Ti\-Xml\-Document} $\ast$ {\bf To\-Document} () const \label{classTiXmlDocument_a1dc977bde3e4fe85a8eb9d88a35ef5a4}

\begin{DoxyCompactList}\small\item\em Cast to a more defined type. Will return null not of the requested type. \end{DoxyCompactList}\item 
virtual {\bf Ti\-Xml\-Document} $\ast$ {\bf To\-Document} ()\label{classTiXmlDocument_a1025d942a1f328fd742d545e37efdd42}

\begin{DoxyCompactList}\small\item\em Cast to a more defined type. Will return null not of the requested type. \end{DoxyCompactList}\item 
virtual bool {\bf Accept} ({\bf Ti\-Xml\-Visitor} $\ast$content) const \label{classTiXmlDocument_a3daab2f472418ef66315750202f762ae}

\begin{DoxyCompactList}\small\item\em Walk the X\-M\-L tree visiting this node and all of its children. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Protected Member Functions}
\begin{DoxyCompactItemize}
\item 
virtual {\bf Ti\-Xml\-Node} $\ast$ {\bf Clone} () const 
\begin{DoxyCompactList}\small\item\em Create an exact duplicate of this node and return it. \end{DoxyCompactList}\item 
virtual void {\bfseries Stream\-In} (std\-::istream $\ast$in, T\-I\-X\-M\-L\-\_\-\-S\-T\-R\-I\-N\-G $\ast$tag)\label{classTiXmlDocument_ab6d70b2c19e46aedb9903b3c3aa2a568}

\end{DoxyCompactItemize}
\subsection*{Additional Inherited Members}


\subsection{Detailed Description}
Always the top level node. 

A document binds together all the X\-M\-L pieces. It can be saved, loaded, and printed to the screen. The 'value' of a document node is the xml file name. 

\subsection{Member Function Documentation}
\index{Ti\-Xml\-Document@{Ti\-Xml\-Document}!Clear\-Error@{Clear\-Error}}
\index{Clear\-Error@{Clear\-Error}!TiXmlDocument@{Ti\-Xml\-Document}}
\subsubsection[{Clear\-Error}]{\setlength{\rightskip}{0pt plus 5cm}void Ti\-Xml\-Document\-::\-Clear\-Error (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}\label{classTiXmlDocument_ac66b8c28db86363315712a3574e87c35}


If you have handled the error, it can be reset with this call. 

The error state is automatically cleared if you Parse a new X\-M\-L block. 

Referenced by Parse(), and Ti\-Xml\-Document().

\index{Ti\-Xml\-Document@{Ti\-Xml\-Document}!Clone@{Clone}}
\index{Clone@{Clone}!TiXmlDocument@{Ti\-Xml\-Document}}
\subsubsection[{Clone}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Ti\-Xml\-Node} $\ast$ Ti\-Xml\-Document\-::\-Clone (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily [protected]}, {\ttfamily [virtual]}}\label{classTiXmlDocument_ac9e8f09b23454d953b32d1b65cd1409e}


Create an exact duplicate of this node and return it. 

The memory must be deleted by the caller. 

Implements {\bf Ti\-Xml\-Node} \doxyref{}{p.}{classTiXmlNode_a4508cc3a2d7a98e96a54cc09c37a78a4}.



References Ti\-Xml\-Document().

\index{Ti\-Xml\-Document@{Ti\-Xml\-Document}!Error@{Error}}
\index{Error@{Error}!TiXmlDocument@{Ti\-Xml\-Document}}
\subsubsection[{Error}]{\setlength{\rightskip}{0pt plus 5cm}bool Ti\-Xml\-Document\-::\-Error (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily [inline]}}\label{classTiXmlDocument_a6dfc01a6e5d58e56acd537dfd3bdeb29}


If an error occurs, Error will be set to true. 

Also,
\begin{DoxyItemize}
\item The \doxyref{Error\-Id()}{p.}{classTiXmlDocument_af96fc2f3f9ec6422782bfe916c9e778f} will contain the integer identifier of the error (not generally useful)
\item The \doxyref{Error\-Desc()}{p.}{classTiXmlDocument_a9d0f689f6e09ea494ea547be8d79c25e} method will return the name of the error. (very useful)
\item The \doxyref{Error\-Row()}{p.}{classTiXmlDocument_af30efc75e804aa2e92fb8be3a8cb676e} and \doxyref{Error\-Col()}{p.}{classTiXmlDocument_aa90bc630ee5203c6109ca5fad3323649} will return the location of the error (if known) 
\end{DoxyItemize}

Referenced by Load\-File().

\index{Ti\-Xml\-Document@{Ti\-Xml\-Document}!Error\-Id@{Error\-Id}}
\index{Error\-Id@{Error\-Id}!TiXmlDocument@{Ti\-Xml\-Document}}
\subsubsection[{Error\-Id}]{\setlength{\rightskip}{0pt plus 5cm}int Ti\-Xml\-Document\-::\-Error\-Id (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily [inline]}}\label{classTiXmlDocument_af96fc2f3f9ec6422782bfe916c9e778f}


Generally, you probably want the error string ( \doxyref{Error\-Desc()}{p.}{classTiXmlDocument_a9d0f689f6e09ea494ea547be8d79c25e} ). 

But if you prefer the Error\-Id, this function will fetch it. \index{Ti\-Xml\-Document@{Ti\-Xml\-Document}!Error\-Row@{Error\-Row}}
\index{Error\-Row@{Error\-Row}!TiXmlDocument@{Ti\-Xml\-Document}}
\subsubsection[{Error\-Row}]{\setlength{\rightskip}{0pt plus 5cm}int Ti\-Xml\-Document\-::\-Error\-Row (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily [inline]}}\label{classTiXmlDocument_af30efc75e804aa2e92fb8be3a8cb676e}


Returns the location (if known) of the error. 

The first column is column 1, and the first row is row 1. A value of 0 means the row and column wasn't applicable (memory errors, for example, have no row/column) or the parser lost the error. (An error in the error reporting, in that case.)

\begin{DoxySeeAlso}{See Also}
\doxyref{Set\-Tab\-Size}{p.}{classTiXmlDocument_a51dac56316f89b35bdb7d0d433ba988e}, \doxyref{Row}{p.}{classTiXmlBase_a024bceb070188df92c2a8d8852dd0853}, \doxyref{Column}{p.}{classTiXmlBase_ab54bfb9b70fe6dd276e7b279cab7f003} 
\end{DoxySeeAlso}


Referenced by marlin\-::\-X\-M\-L\-Parser\-::parse().

\index{Ti\-Xml\-Document@{Ti\-Xml\-Document}!Load\-File@{Load\-File}}
\index{Load\-File@{Load\-File}!TiXmlDocument@{Ti\-Xml\-Document}}
\subsubsection[{Load\-File}]{\setlength{\rightskip}{0pt plus 5cm}bool Ti\-Xml\-Document\-::\-Load\-File (
\begin{DoxyParamCaption}
\item[{Ti\-Xml\-Encoding}]{encoding = {\ttfamily TIXML\-\_\-DEFAULT\-\_\-ENCODING}}
\end{DoxyParamCaption}
)}\label{classTiXmlDocument_a4c852a889c02cf251117fd1d9fe1845f}


Load a file using the current document value. 

Returns true if successful. Will delete any existing document data before loading. 

References Ti\-Xml\-Node\-::\-Value().



Referenced by Load\-File(), marlin\-::\-X\-M\-L\-Fix\-Coll\-Types\-::parse(), and marlin\-::\-X\-M\-L\-Parser\-::parse().

\index{Ti\-Xml\-Document@{Ti\-Xml\-Document}!Load\-File@{Load\-File}}
\index{Load\-File@{Load\-File}!TiXmlDocument@{Ti\-Xml\-Document}}
\subsubsection[{Load\-File}]{\setlength{\rightskip}{0pt plus 5cm}bool Ti\-Xml\-Document\-::\-Load\-File (
\begin{DoxyParamCaption}
\item[{F\-I\-L\-E $\ast$}]{file, }
\item[{Ti\-Xml\-Encoding}]{encoding = {\ttfamily TIXML\-\_\-DEFAULT\-\_\-ENCODING}}
\end{DoxyParamCaption}
)}\label{classTiXmlDocument_a41f6fe7200864d1dca663d230caf8db6}


Load a file using the given F\-I\-L\-E$\ast$. 

Returns true if successful. Note that this method doesn't stream -\/ the entire object pointed at by the F\-I\-L\-E$\ast$ will be interpreted as an X\-M\-L file. Tiny\-X\-M\-L doesn't stream in X\-M\-L from the current file location. Streaming may be added in the future. 

References Ti\-Xml\-Node\-::\-Clear(), Error(), and Parse().

\index{Ti\-Xml\-Document@{Ti\-Xml\-Document}!Load\-File@{Load\-File}}
\index{Load\-File@{Load\-File}!TiXmlDocument@{Ti\-Xml\-Document}}
\subsubsection[{Load\-File}]{\setlength{\rightskip}{0pt plus 5cm}bool Ti\-Xml\-Document\-::\-Load\-File (
\begin{DoxyParamCaption}
\item[{const std\-::string \&}]{filename, }
\item[{Ti\-Xml\-Encoding}]{encoding = {\ttfamily TIXML\-\_\-DEFAULT\-\_\-ENCODING}}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}\label{classTiXmlDocument_a18ae6ed34fed7991ebc220862dfac884}

\begin{DoxyParams}{Parameters}
{\em encoding} & S\-T\-L std\-::string version. \\
\hline
\end{DoxyParams}


References Load\-File().

\index{Ti\-Xml\-Document@{Ti\-Xml\-Document}!Parse@{Parse}}
\index{Parse@{Parse}!TiXmlDocument@{Ti\-Xml\-Document}}
\subsubsection[{Parse}]{\setlength{\rightskip}{0pt plus 5cm}const char $\ast$ Ti\-Xml\-Document\-::\-Parse (
\begin{DoxyParamCaption}
\item[{const char $\ast$}]{p, }
\item[{{\bf Ti\-Xml\-Parsing\-Data} $\ast$}]{data = {\ttfamily 0}, }
\item[{Ti\-Xml\-Encoding}]{encoding = {\ttfamily TIXML\-\_\-DEFAULT\-\_\-ENCODING}}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [virtual]}}\label{classTiXmlDocument_a789ad2f06f93d52bdb5570b2f3670289}


Parse the given null terminated block of xml data. 

Passing in an encoding to this method (either T\-I\-X\-M\-L\-\_\-\-E\-N\-C\-O\-D\-I\-N\-G\-\_\-\-L\-E\-G\-A\-C\-Y or T\-I\-X\-M\-L\-\_\-\-E\-N\-C\-O\-D\-I\-N\-G\-\_\-\-U\-T\-F8 will force Tiny\-Xml to use that encoding, regardless of what Tiny\-Xml might otherwise try to detect. 

Implements {\bf Ti\-Xml\-Base} \doxyref{}{p.}{classTiXmlBase}.



References Clear\-Error(), Ti\-Xml\-Declaration\-::\-Encoding(), Ti\-Xml\-Node\-::\-Link\-End\-Child(), and Ti\-Xml\-Node\-::\-To\-Declaration().



Referenced by Load\-File().

\index{Ti\-Xml\-Document@{Ti\-Xml\-Document}!Print@{Print}}
\index{Print@{Print}!TiXmlDocument@{Ti\-Xml\-Document}}
\subsubsection[{Print}]{\setlength{\rightskip}{0pt plus 5cm}void Ti\-Xml\-Document\-::\-Print (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily [inline]}}\label{classTiXmlDocument_af08389ec70ee9b2de7f800e206a18510}


Write the document to standard out using formatted printing (\char`\"{}pretty print\char`\"{}). 



References Print().



Referenced by Print(), and Save\-File().

\index{Ti\-Xml\-Document@{Ti\-Xml\-Document}!Root\-Element@{Root\-Element}}
\index{Root\-Element@{Root\-Element}!TiXmlDocument@{Ti\-Xml\-Document}}
\subsubsection[{Root\-Element}]{\setlength{\rightskip}{0pt plus 5cm}const {\bf Ti\-Xml\-Element}$\ast$ Ti\-Xml\-Document\-::\-Root\-Element (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily [inline]}}\label{classTiXmlDocument_ad09d17927f908f40efb406af2fb873be}


Get the root element -- the only top level element -- of the document. 

In well formed X\-M\-L, there should only be one. Tiny\-Xml is tolerant of multiple elements at the document level. 

References Ti\-Xml\-Node\-::\-First\-Child\-Element().



Referenced by marlin\-::\-X\-M\-L\-Parser\-::parse(), and marlin\-::\-X\-M\-L\-Parser\-::replacegroups().

\index{Ti\-Xml\-Document@{Ti\-Xml\-Document}!Set\-Tab\-Size@{Set\-Tab\-Size}}
\index{Set\-Tab\-Size@{Set\-Tab\-Size}!TiXmlDocument@{Ti\-Xml\-Document}}
\subsubsection[{Set\-Tab\-Size}]{\setlength{\rightskip}{0pt plus 5cm}void Ti\-Xml\-Document\-::\-Set\-Tab\-Size (
\begin{DoxyParamCaption}
\item[{int}]{\-\_\-tabsize}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}\label{classTiXmlDocument_a51dac56316f89b35bdb7d0d433ba988e}


\doxyref{Set\-Tab\-Size()}{p.}{classTiXmlDocument_a51dac56316f89b35bdb7d0d433ba988e} allows the error reporting functions (\doxyref{Error\-Row()}{p.}{classTiXmlDocument_af30efc75e804aa2e92fb8be3a8cb676e} and \doxyref{Error\-Col()}{p.}{classTiXmlDocument_aa90bc630ee5203c6109ca5fad3323649}) to report the correct values for row and column. 

It does not change the output or input in any way.

By calling this method, with a tab size greater than 0, the row and column of each node and attribute is stored when the file is loaded. Very useful for tracking the D\-O\-M back in to the source file.

The tab size is required for calculating the location of nodes. If not set, the default of 4 is used. The tabsize is set per document. Setting the tabsize to 0 disables row/column tracking.

Note that row and column tracking is not supported when using operator$>$$>$.

The tab size needs to be enabled before the parse or load. Correct usage\-: \begin{DoxyVerb}    TiXmlDocument doc;
    doc.SetTabSize( 8 );
    doc.Load( "myfile.xml" );\end{DoxyVerb}


\begin{DoxySeeAlso}{See Also}
\doxyref{Row}{p.}{classTiXmlBase_a024bceb070188df92c2a8d8852dd0853}, \doxyref{Column}{p.}{classTiXmlBase_ab54bfb9b70fe6dd276e7b279cab7f003} 
\end{DoxySeeAlso}


The documentation for this class was generated from the following files\-:\begin{DoxyCompactItemize}
\item 
tinyxml.\-h\item 
tinyxml.\-cc\item 
tinyxmlparser.\-cc\end{DoxyCompactItemize}
