xmlTiny::TiXmlDocument Class Reference

Always the top level node. More...

#include <OBTtinyxml.h>

Inheritance diagram for xmlTiny::TiXmlDocument:

Inheritance graph
[legend]
Collaboration diagram for xmlTiny::TiXmlDocument:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 TiXmlDocument ()
 Create an empty document, that has no name.
 TiXmlDocument (const char *documentName)
 Create a document with a name. The name of the document is also the filename of the xml.
 TiXmlDocument (const std::string &documentName)
 Constructor.
 TiXmlDocument (const TiXmlDocument &copy)
void operator= (const TiXmlDocument &copy)
virtual ~TiXmlDocument ()
bool LoadFile (TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
 Load a file using the current document value.
bool SaveFile () const
 Save a file using the current document value. Returns true if successful.
bool LoadFile (const char *filename, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
 Load a file using the given filename. Returns true if successful.
bool SaveFile (const char *filename) const
 Save a file using the given filename. Returns true if successful.
bool LoadFile (FILE *, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
 Load a file using the given FILE*.
bool SaveFile (FILE *) const
 Save a file using the given FILE*. Returns true if successful.
bool LoadFile (const std::string &filename, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
bool SaveFile (const std::string &filename) const
 < STL std::string version.
virtual const char * Parse (const char *p, TiXmlParsingData *data=0, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
 Parse the given null terminated block of xml data.
const TiXmlElementRootElement () const
 Get the root element -- the only top level element -- of the document.
TiXmlElementRootElement ()
bool Error () const
 If an error occurs, Error will be set to true.
const char * ErrorDesc () const
 Contains a textual (english) description of the error if one occurs.
int ErrorId () const
 Generally, you probably want the error string ( ErrorDesc() ).
int ErrorRow () const
 Returns the location (if known) of the error.
int ErrorCol () const
 The column where the error occured. See ErrorRow().
void SetTabSize (int _tabsize)
 SetTabSize() allows the error reporting functions (ErrorRow() and ErrorCol()) to report the correct values for row and column.
int TabSize () const
void ClearError ()
 If you have handled the error, it can be reset with this call.
void Print () const
 Write the document to standard out using formatted printing ("pretty print").
virtual void Print (FILE *cfile, int depth=0) const
 Print this Document to a FILE stream.
void SetError (int err, const char *errorLocation, TiXmlParsingData *prevData, TiXmlEncoding encoding)
virtual const
TiXmlDocument
ToDocument () const
 Cast to a more defined type. Will return null not of the requested type.
virtual TiXmlDocumentToDocument ()
 Cast to a more defined type. Will return null not of the requested type.
virtual bool Accept (TiXmlVisitor *content) const
 Walk the XML tree visiting this node and all of its children.

Protected Member Functions

virtual TiXmlNodeClone () const
 Create an exact duplicate of this node and return it.
virtual void StreamIn (std::istream *in, TIXML_STRING *tag)

Private Member Functions

void CopyTo (TiXmlDocument *target) const

Private Attributes

bool error
int errorId
TIXML_STRING errorDesc
int tabsize
TiXmlCursor errorLocation
bool useMicrosoftBOM


Detailed Description

Always the top level node.

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

Definition at line 1390 of file tiny/tmp/OBTtinyxml.h.


Constructor & Destructor Documentation

xmlTiny::TiXmlDocument::TiXmlDocument (  ) 

Create an empty document, that has no name.

Definition at line 887 of file tiny/tmp/OBTtinyxml.cpp.

References ClearError(), tabsize, and useMicrosoftBOM.

Referenced by Clone().

00887                              : TiXmlNode( TiXmlNode::DOCUMENT )
00888 {
00889         tabsize = 4;
00890         useMicrosoftBOM = false;
00891         ClearError();
00892 }

xmlTiny::TiXmlDocument::TiXmlDocument ( const char *  documentName  ) 

Create a document with a name. The name of the document is also the filename of the xml.

Definition at line 894 of file tiny/tmp/OBTtinyxml.cpp.

References ClearError(), tabsize, useMicrosoftBOM, and xmlTiny::TiXmlNode::value.

00894                                                         : TiXmlNode( TiXmlNode::DOCUMENT )
00895 {
00896         tabsize = 4;
00897         useMicrosoftBOM = false;
00898         value = documentName;
00899         ClearError();
00900 }

xmlTiny::TiXmlDocument::TiXmlDocument ( const std::string &  documentName  ) 

Constructor.

xmlTiny::TiXmlDocument::TiXmlDocument ( const TiXmlDocument copy  ) 

Definition at line 914 of file tiny/tmp/OBTtinyxml.cpp.

References CopyTo().

00914                                                         : TiXmlNode( TiXmlNode::DOCUMENT )
00915 {
00916         copy.CopyTo( this );
00917 }

virtual xmlTiny::TiXmlDocument::~TiXmlDocument (  )  [inline, virtual]

Definition at line 1406 of file tiny/tmp/OBTtinyxml.h.

01406 {}


Member Function Documentation

void xmlTiny::TiXmlDocument::operator= ( const TiXmlDocument copy  ) 

Definition at line 920 of file tiny/tmp/OBTtinyxml.cpp.

References xmlTiny::TiXmlNode::Clear(), and CopyTo().

00921 {
00922         Clear();
00923         copy.CopyTo( this );
00924 }

bool xmlTiny::TiXmlDocument::LoadFile ( TiXmlEncoding  encoding = TIXML_DEFAULT_ENCODING  ) 

Load a file using the current document value.

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

Definition at line 927 of file tiny/tmp/OBTtinyxml.cpp.

References xmlTiny::TiXmlNode::Value().

Referenced by LoadFile().

00928 {
00929         // See STL_STRING_BUG below.
00930         //StringToBuffer buf( value );
00931 
00932         return LoadFile( Value(), encoding );
00933 }

bool xmlTiny::TiXmlDocument::SaveFile (  )  const

Save a file using the current document value. Returns true if successful.

Definition at line 936 of file tiny/tmp/OBTtinyxml.cpp.

References xmlTiny::TiXmlNode::Value().

Referenced by SaveFile().

00937 {
00938         // See STL_STRING_BUG below.
00939 //      StringToBuffer buf( value );
00940 //
00941 //      if ( buf.buffer && SaveFile( buf.buffer ) )
00942 //              return true;
00943 //
00944 //      return false;
00945         return SaveFile( Value() );
00946 }

bool xmlTiny::TiXmlDocument::LoadFile ( const char *  filename,
TiXmlEncoding  encoding = TIXML_DEFAULT_ENCODING 
)

Load a file using the given filename. Returns true if successful.

Definition at line 948 of file tiny/tmp/OBTtinyxml.cpp.

References LoadFile(), SetError(), xmlTiny::TIXML_ENCODING_UNKNOWN, xmlTiny::TiXmlBase::TIXML_ERROR_OPENING_FILE, TIXML_STRING, xmlTiny::TiXmlFOpen(), and xmlTiny::TiXmlNode::value.

00949 {
00950         // There was a really terrifying little bug here. The code:
00951         //              value = filename
00952         // in the STL case, cause the assignment method of the std::string to
00953         // be called. What is strange, is that the std::string had the same
00954         // address as it's c_str() method, and so bad things happen. Looks
00955         // like a bug in the Microsoft STL implementation.
00956         // Add an extra string to avoid the crash.
00957         TIXML_STRING filename( _filename );
00958         value = filename;
00959 
00960         // reading in binary mode so that tinyxml can normalize the EOL
00961         FILE* file = TiXmlFOpen( value.c_str (), "rb" );        
00962 
00963         if ( file )
00964         {
00965                 bool result = LoadFile( file, encoding );
00966                 fclose( file );
00967                 return result;
00968         }
00969         else
00970         {
00971                 SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN );
00972                 return false;
00973         }
00974 }

bool xmlTiny::TiXmlDocument::SaveFile ( const char *  filename  )  const

Save a file using the given filename. Returns true if successful.

Definition at line 1091 of file tiny/tmp/OBTtinyxml.cpp.

References SaveFile(), and xmlTiny::TiXmlFOpen().

01092 {
01093         // The old c stuff lives on...
01094         FILE* fp = TiXmlFOpen( filename, "w" );
01095         if ( fp )
01096         {
01097                 bool result = SaveFile( fp );
01098                 fclose( fp );
01099                 return result;
01100         }
01101         return false;
01102 }

bool xmlTiny::TiXmlDocument::LoadFile ( FILE *  file,
TiXmlEncoding  encoding = TIXML_DEFAULT_ENCODING 
)

Load a file using the given FILE*.

Returns true if successful. Note that this method doesn't stream - the entire object pointed at by the FILE* will be interpreted as an XML file. TinyXML doesn't stream in XML from the current file location. Streaming may be added in the future.

Definition at line 976 of file tiny/tmp/OBTtinyxml.cpp.

References xmlTiny::TiXmlCursor::Clear(), xmlTiny::TiXmlNode::Clear(), Error(), xmlTiny::TiXmlBase::location, Parse(), SetError(), xmlTiny::TIXML_ENCODING_UNKNOWN, xmlTiny::TiXmlBase::TIXML_ERROR_DOCUMENT_EMPTY, xmlTiny::TiXmlBase::TIXML_ERROR_OPENING_FILE, and TIXML_STRING.

00977 {
00978         if ( !file ) 
00979         {
00980                 SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN );
00981                 return false;
00982         }
00983 
00984         // Delete the existing data:
00985         Clear();
00986         location.Clear();
00987 
00988         // Get the file size, so we can pre-allocate the string. HUGE speed impact.
00989         long length = 0;
00990         fseek( file, 0, SEEK_END );
00991         length = ftell( file );
00992         fseek( file, 0, SEEK_SET );
00993 
00994         // Strange case, but good to handle up front.
00995         if ( length <= 0 )
00996         {
00997                 SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
00998                 return false;
00999         }
01000 
01001         // If we have a file, assume it is all one big XML file, and read it in.
01002         // The document parser may decide the document ends sooner than the entire file, however.
01003         TIXML_STRING data;
01004         data.reserve( length );
01005 
01006         // Subtle bug here. TinyXml did use fgets. But from the XML spec:
01007         // 2.11 End-of-Line Handling
01008         // <snip>
01009         // <quote>
01010         // ...the XML processor MUST behave as if it normalized all line breaks in external 
01011         // parsed entities (including the document entity) on input, before parsing, by translating 
01012         // both the two-character sequence #xD #xA and any #xD that is not followed by #xA to 
01013         // a single #xA character.
01014         // </quote>
01015         //
01016         // It is not clear fgets does that, and certainly isn't clear it works cross platform. 
01017         // Generally, you expect fgets to translate from the convention of the OS to the c/unix
01018         // convention, and not work generally.
01019 
01020         /*
01021         while( fgets( buf, sizeof(buf), file ) )
01022         {
01023                 data += buf;
01024         }
01025         */
01026 
01027         char* buf = new char[ length+1 ];
01028         buf[0] = 0;
01029 
01030         if ( fread( buf, length, 1, file ) != 1 ) {
01031                 delete [] buf;
01032                 SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN );
01033                 return false;
01034         }
01035 
01036         const char* lastPos = buf;
01037         const char* p = buf;
01038 
01039         buf[length] = 0;
01040         while( *p ) {
01041                 assert( p < (buf+length) );
01042                 if ( *p == 0xa ) {
01043                         // Newline character. No special rules for this. Append all the characters
01044                         // since the last string, and include the newline.
01045                         data.append( lastPos, (p-lastPos+1) );  // append, include the newline
01046                         ++p;                                                                    // move past the newline
01047                         lastPos = p;                                                    // and point to the new buffer (may be 0)
01048                         assert( p <= (buf+length) );
01049                 }
01050                 else if ( *p == 0xd ) {
01051                         // Carriage return. Append what we have so far, then
01052                         // handle moving forward in the buffer.
01053                         if ( (p-lastPos) > 0 ) {
01054                                 data.append( lastPos, p-lastPos );      // do not add the CR
01055                         }
01056                         data += (char)0xa;                                              // a proper newline
01057 
01058                         if ( *(p+1) == 0xa ) {
01059                                 // Carriage return - new line sequence
01060                                 p += 2;
01061                                 lastPos = p;
01062                                 assert( p <= (buf+length) );
01063                         }
01064                         else {
01065                                 // it was followed by something else...that is presumably characters again.
01066                                 ++p;
01067                                 lastPos = p;
01068                                 assert( p <= (buf+length) );
01069                         }
01070                 }
01071                 else {
01072                         ++p;
01073                 }
01074         }
01075         // Handle any left over characters.
01076         if ( p-lastPos ) {
01077                 data.append( lastPos, p-lastPos );
01078         }               
01079         delete [] buf;
01080         buf = 0;
01081 
01082         Parse( data.c_str(), 0, encoding );
01083 
01084         if (  Error() )
01085         return false;
01086     else
01087                 return true;
01088 }

bool xmlTiny::TiXmlDocument::SaveFile ( FILE *  fp  )  const

Save a file using the given FILE*. Returns true if successful.

Definition at line 1105 of file tiny/tmp/OBTtinyxml.cpp.

References Print(), xmlTiny::TIXML_UTF_LEAD_0, xmlTiny::TIXML_UTF_LEAD_1, xmlTiny::TIXML_UTF_LEAD_2, and useMicrosoftBOM.

01106 {
01107         if ( useMicrosoftBOM ) 
01108         {
01109                 const unsigned char TIXML_UTF_LEAD_0 = 0xefU;
01110                 const unsigned char TIXML_UTF_LEAD_1 = 0xbbU;
01111                 const unsigned char TIXML_UTF_LEAD_2 = 0xbfU;
01112 
01113                 fputc( TIXML_UTF_LEAD_0, fp );
01114                 fputc( TIXML_UTF_LEAD_1, fp );
01115                 fputc( TIXML_UTF_LEAD_2, fp );
01116         }
01117         Print( fp, 0 );
01118         return (ferror(fp) == 0);
01119 }

bool xmlTiny::TiXmlDocument::LoadFile ( const std::string &  filename,
TiXmlEncoding  encoding = TIXML_DEFAULT_ENCODING 
) [inline]

Parameters:
encoding  STL std::string version.

Definition at line 1429 of file tiny/tmp/OBTtinyxml.h.

References LoadFile().

01430         {
01431 //              StringToBuffer f( filename );
01432 //              return ( f.buffer && LoadFile( f.buffer, encoding ));
01433                 return LoadFile( filename.c_str(), encoding );
01434         }

bool xmlTiny::TiXmlDocument::SaveFile ( const std::string &  filename  )  const [inline]

< STL std::string version.

Definition at line 1435 of file tiny/tmp/OBTtinyxml.h.

References SaveFile().

01436         {
01437 //              StringToBuffer f( filename );
01438 //              return ( f.buffer && SaveFile( f.buffer ));
01439                 return SaveFile( filename.c_str() );
01440         }

const char * xmlTiny::TiXmlDocument::Parse ( const char *  p,
TiXmlParsingData data = 0,
TiXmlEncoding  encoding = TIXML_DEFAULT_ENCODING 
) [virtual]

Parse the given null terminated block of xml data.

Passing in an encoding to this method (either TIXML_ENCODING_LEGACY or TIXML_ENCODING_UTF8 will force TinyXml to use that encoding, regardless of what TinyXml might otherwise try to detect.

Implements xmlTiny::TiXmlBase.

Definition at line 706 of file tiny/tmp/OBTtinyxmlparser.cpp.

References xmlTiny::TiXmlCursor::Clear(), ClearError(), xmlTiny::TiXmlCursor::col, xmlTiny::TiXmlParsingData::Cursor(), xmlTiny::TiXmlParsingData::cursor, xmlTiny::TiXmlDeclaration::Encoding(), xmlTiny::TiXmlNode::firstChild, xmlTiny::TiXmlNode::Identify(), xmlTiny::TiXmlNode::LinkEndChild(), xmlTiny::TiXmlBase::location, xmlTiny::TiXmlBase::Parse(), xmlTiny::TiXmlCursor::row, SetError(), xmlTiny::TiXmlBase::SkipWhiteSpace(), xmlTiny::TiXmlBase::StringEqual(), TabSize(), xmlTiny::TIXML_ENCODING_LEGACY, xmlTiny::TIXML_ENCODING_UNKNOWN, xmlTiny::TIXML_ENCODING_UTF8, xmlTiny::TiXmlBase::TIXML_ERROR_DOCUMENT_EMPTY, xmlTiny::TIXML_UTF_LEAD_0, xmlTiny::TIXML_UTF_LEAD_1, xmlTiny::TIXML_UTF_LEAD_2, xmlTiny::TiXmlNode::ToDeclaration(), and useMicrosoftBOM.

Referenced by LoadFile().

00707 {
00708         ClearError();
00709 
00710         // Parse away, at the document level. Since a document
00711         // contains nothing but other tags, most of what happens
00712         // here is skipping white space.
00713         if ( !p || !*p )
00714         {
00715                 SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
00716                 return 0;
00717         }
00718 
00719         // Note that, for a document, this needs to come
00720         // before the while space skip, so that parsing
00721         // starts from the pointer we are given.
00722         location.Clear();
00723         if ( prevData )
00724         {
00725                 location.row = prevData->cursor.row;
00726                 location.col = prevData->cursor.col;
00727         }
00728         else
00729         {
00730                 location.row = 0;
00731                 location.col = 0;
00732         }
00733         TiXmlParsingData data( p, TabSize(), location.row, location.col );
00734         location = data.Cursor();
00735 
00736         if ( encoding == TIXML_ENCODING_UNKNOWN )
00737         {
00738                 // Check for the Microsoft UTF-8 lead bytes.
00739                 const unsigned char* pU = (const unsigned char*)p;
00740                 if (    *(pU+0) && *(pU+0) == TIXML_UTF_LEAD_0
00741                          && *(pU+1) && *(pU+1) == TIXML_UTF_LEAD_1
00742                          && *(pU+2) && *(pU+2) == TIXML_UTF_LEAD_2 )
00743                 {
00744                         encoding = TIXML_ENCODING_UTF8;
00745                         useMicrosoftBOM = true;
00746                 }
00747         }
00748 
00749     p = SkipWhiteSpace( p, encoding );
00750         if ( !p )
00751         {
00752                 SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
00753                 return 0;
00754         }
00755 
00756         while ( p && *p )
00757         {
00758                 TiXmlNode* node = Identify( p, encoding );
00759                 if ( node )
00760                 {
00761                         p = node->Parse( p, &data, encoding );
00762                         LinkEndChild( node );
00763                 }
00764                 else
00765                 {
00766                         break;
00767                 }
00768 
00769                 // Did we get encoding info?
00770                 if (    encoding == TIXML_ENCODING_UNKNOWN
00771                          && node->ToDeclaration() )
00772                 {
00773                         TiXmlDeclaration* dec = node->ToDeclaration();
00774                         const char* enc = dec->Encoding();
00775                         assert( enc );
00776 
00777                         if ( *enc == 0 )
00778                                 encoding = TIXML_ENCODING_UTF8;
00779                         else if ( StringEqual( enc, "UTF-8", true, TIXML_ENCODING_UNKNOWN ) )
00780                                 encoding = TIXML_ENCODING_UTF8;
00781                         else if ( StringEqual( enc, "UTF8", true, TIXML_ENCODING_UNKNOWN ) )
00782                                 encoding = TIXML_ENCODING_UTF8; // incorrect, but be nice
00783                         else 
00784                                 encoding = TIXML_ENCODING_LEGACY;
00785                 }
00786 
00787                 p = SkipWhiteSpace( p, encoding );
00788         }
00789 
00790         // Was this empty?
00791         if ( !firstChild ) {
00792                 SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, encoding );
00793                 return 0;
00794         }
00795 
00796         // All is well.
00797         return p;
00798 }

const TiXmlElement* xmlTiny::TiXmlDocument::RootElement (  )  const [inline]

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

In well formed XML, there should only be one. TinyXml is tolerant of multiple elements at the document level.

Definition at line 1453 of file tiny/tmp/OBTtinyxml.h.

References xmlTiny::TiXmlNode::FirstChildElement().

01453 { return FirstChildElement(); }

TiXmlElement* xmlTiny::TiXmlDocument::RootElement (  )  [inline]

Definition at line 1454 of file tiny/tmp/OBTtinyxml.h.

References xmlTiny::TiXmlNode::FirstChildElement().

01454 { return FirstChildElement(); }

bool xmlTiny::TiXmlDocument::Error (  )  const [inline]

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

Also,

Definition at line 1461 of file tiny/tmp/OBTtinyxml.h.

References error.

Referenced by LoadFile().

01461 { return error; }

const char* xmlTiny::TiXmlDocument::ErrorDesc (  )  const [inline]

Contains a textual (english) description of the error if one occurs.

Definition at line 1464 of file tiny/tmp/OBTtinyxml.h.

References errorDesc.

01464 { return errorDesc.c_str (); }

int xmlTiny::TiXmlDocument::ErrorId (  )  const [inline]

Generally, you probably want the error string ( ErrorDesc() ).

But if you prefer the ErrorId, this function will fetch it.

Definition at line 1469 of file tiny/tmp/OBTtinyxml.h.

References errorId.

01469 { return errorId; }

int xmlTiny::TiXmlDocument::ErrorRow (  )  const [inline]

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.)

See also:
SetTabSize, Row, Column

Definition at line 1478 of file tiny/tmp/OBTtinyxml.h.

References errorLocation, and xmlTiny::TiXmlCursor::row.

01478 { return errorLocation.row+1; }

int xmlTiny::TiXmlDocument::ErrorCol (  )  const [inline]

The column where the error occured. See ErrorRow().

Definition at line 1479 of file tiny/tmp/OBTtinyxml.h.

References xmlTiny::TiXmlCursor::col, and errorLocation.

void xmlTiny::TiXmlDocument::SetTabSize ( int  _tabsize  )  [inline]

SetTabSize() allows the error reporting functions (ErrorRow() and ErrorCol()) 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 DOM 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:

		TiXmlDocument doc;
		doc.SetTabSize( 8 );
		doc.Load( "myfile.xml" );
		

See also:
Row, Column

Definition at line 1505 of file tiny/tmp/OBTtinyxml.h.

References tabsize.

01505 { tabsize = _tabsize; }

int xmlTiny::TiXmlDocument::TabSize (  )  const [inline]

Definition at line 1507 of file tiny/tmp/OBTtinyxml.h.

References tabsize.

Referenced by Parse().

01507 { return tabsize; }

void xmlTiny::TiXmlDocument::ClearError (  )  [inline]

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

The error state is automatically cleared if you Parse a new XML block.

Definition at line 1512 of file tiny/tmp/OBTtinyxml.h.

References xmlTiny::TiXmlCursor::col, error, errorDesc, errorId, errorLocation, and xmlTiny::TiXmlCursor::row.

Referenced by Parse(), and TiXmlDocument().

01512                                                                         {       error = false; 
01513                                                                                                 errorId = 0; 
01514                                                                                                 errorDesc = ""; 
01515                                                                                                 errorLocation.row = errorLocation.col = 0; 
01516                                                                                                 //errorLocation.last = 0; 
01517                                                                                         }

void xmlTiny::TiXmlDocument::Print (  )  const [inline]

Write the document to standard out using formatted printing ("pretty print").

Definition at line 1520 of file tiny/tmp/OBTtinyxml.h.

Referenced by SaveFile().

01520 { Print( stdout, 0 ); }

void xmlTiny::TiXmlDocument::Print ( FILE *  cfile,
int  depth = 0 
) const [virtual]

Print this Document to a FILE stream.

Implements xmlTiny::TiXmlBase.

Definition at line 1152 of file tiny/tmp/OBTtinyxml.cpp.

References xmlTiny::TiXmlNode::FirstChild(), and xmlTiny::TiXmlAttribute::Print().

01153 {
01154         assert( cfile );
01155         for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() )
01156         {
01157                 node->Print( cfile, depth );
01158                 fprintf( cfile, "\n" );
01159         }
01160 }

void xmlTiny::TiXmlDocument::SetError ( int  err,
const char *  errorLocation,
TiXmlParsingData prevData,
TiXmlEncoding  encoding 
)

Definition at line 800 of file tiny/tmp/OBTtinyxmlparser.cpp.

References xmlTiny::TiXmlCursor::Clear(), xmlTiny::TiXmlParsingData::Cursor(), error, errorDesc, errorId, errorLocation, xmlTiny::TiXmlBase::errorString, xmlTiny::TiXmlParsingData::Stamp(), and xmlTiny::TiXmlBase::TIXML_ERROR_STRING_COUNT.

Referenced by xmlTiny::TiXmlNode::Identify(), xmlTiny::TiXmlNode::InsertAfterChild(), xmlTiny::TiXmlNode::InsertBeforeChild(), xmlTiny::TiXmlNode::InsertEndChild(), xmlTiny::TiXmlNode::LinkEndChild(), LoadFile(), xmlTiny::TiXmlDeclaration::Parse(), xmlTiny::TiXmlText::Parse(), xmlTiny::TiXmlAttribute::Parse(), xmlTiny::TiXmlComment::Parse(), xmlTiny::TiXmlUnknown::Parse(), xmlTiny::TiXmlElement::Parse(), Parse(), xmlTiny::TiXmlElement::ReadValue(), and xmlTiny::TiXmlElement::SetAttribute().

00801 {       
00802         // The first error in a chain is more accurate - don't set again!
00803         if ( error )
00804                 return;
00805 
00806         assert( err > 0 && err < TIXML_ERROR_STRING_COUNT );
00807         error   = true;
00808         errorId = err;
00809         errorDesc = errorString[ errorId ];
00810 
00811         errorLocation.Clear();
00812         if ( pError && data )
00813         {
00814                 data->Stamp( pError, encoding );
00815                 errorLocation = data->Cursor();
00816         }
00817 }

virtual const TiXmlDocument* xmlTiny::TiXmlDocument::ToDocument (  )  const [inline, virtual]

Cast to a more defined type. Will return null not of the requested type.

Reimplemented from xmlTiny::TiXmlNode.

Definition at line 1533 of file tiny/tmp/OBTtinyxml.h.

virtual TiXmlDocument* xmlTiny::TiXmlDocument::ToDocument (  )  [inline, virtual]

Cast to a more defined type. Will return null not of the requested type.

Reimplemented from xmlTiny::TiXmlNode.

Definition at line 1534 of file tiny/tmp/OBTtinyxml.h.

bool xmlTiny::TiXmlDocument::Accept ( TiXmlVisitor content  )  const [virtual]

Walk the XML tree visiting this node and all of its children.

Implements xmlTiny::TiXmlNode.

Definition at line 1163 of file tiny/tmp/OBTtinyxml.cpp.

References xmlTiny::TiXmlNode::FirstChild(), xmlTiny::TiXmlVisitor::VisitEnter(), and xmlTiny::TiXmlVisitor::VisitExit().

01164 {
01165         if ( visitor->VisitEnter( *this ) )
01166         {
01167                 for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() )
01168                 {
01169                         if ( !node->Accept( visitor ) )
01170                                 break;
01171                 }
01172         }
01173         return visitor->VisitExit( *this );
01174 }

TiXmlNode * xmlTiny::TiXmlDocument::Clone (  )  const [protected, virtual]

Create an exact duplicate of this node and return it.

The memory must be deleted by the caller.

Implements xmlTiny::TiXmlNode.

Definition at line 1141 of file tiny/tmp/OBTtinyxml.cpp.

References CopyTo(), and TiXmlDocument().

01142 {
01143         TiXmlDocument* clone = new TiXmlDocument();
01144         if ( !clone )
01145                 return 0;
01146 
01147         CopyTo( clone );
01148         return clone;
01149 }

virtual void xmlTiny::TiXmlDocument::StreamIn ( std::istream *  in,
TIXML_STRING *  tag 
) [protected, virtual]

Implements xmlTiny::TiXmlNode.

void xmlTiny::TiXmlDocument::CopyTo ( TiXmlDocument target  )  const [private]

Definition at line 1122 of file tiny/tmp/OBTtinyxml.cpp.

References xmlTiny::TiXmlNode::Clone(), xmlTiny::TiXmlNode::CopyTo(), error, errorDesc, errorId, errorLocation, xmlTiny::TiXmlNode::firstChild, xmlTiny::TiXmlNode::LinkEndChild(), xmlTiny::TiXmlNode::NextSibling(), tabsize, and useMicrosoftBOM.

Referenced by Clone(), operator=(), and TiXmlDocument().

01123 {
01124         TiXmlNode::CopyTo( target );
01125 
01126         target->error = error;
01127         target->errorId = errorId;
01128         target->errorDesc = errorDesc;
01129         target->tabsize = tabsize;
01130         target->errorLocation = errorLocation;
01131         target->useMicrosoftBOM = useMicrosoftBOM;
01132 
01133         TiXmlNode* node = 0;
01134         for ( node = firstChild; node; node = node->NextSibling() )
01135         {
01136                 target->LinkEndChild( node->Clone() );
01137         }       
01138 }


Member Data Documentation

bool xmlTiny::TiXmlDocument::error [private]

Definition at line 1550 of file tiny/tmp/OBTtinyxml.h.

Referenced by ClearError(), CopyTo(), Error(), and SetError().

int xmlTiny::TiXmlDocument::errorId [private]

Definition at line 1551 of file tiny/tmp/OBTtinyxml.h.

Referenced by ClearError(), CopyTo(), ErrorId(), and SetError().

TIXML_STRING xmlTiny::TiXmlDocument::errorDesc [private]

Definition at line 1552 of file tiny/tmp/OBTtinyxml.h.

Referenced by ClearError(), CopyTo(), ErrorDesc(), and SetError().

int xmlTiny::TiXmlDocument::tabsize [private]

Definition at line 1553 of file tiny/tmp/OBTtinyxml.h.

Referenced by CopyTo(), SetTabSize(), TabSize(), and TiXmlDocument().

TiXmlCursor xmlTiny::TiXmlDocument::errorLocation [private]

Definition at line 1554 of file tiny/tmp/OBTtinyxml.h.

Referenced by ClearError(), CopyTo(), ErrorCol(), ErrorRow(), and SetError().

bool xmlTiny::TiXmlDocument::useMicrosoftBOM [private]

Definition at line 1555 of file tiny/tmp/OBTtinyxml.h.

Referenced by CopyTo(), Parse(), SaveFile(), and TiXmlDocument().


Generated on Wed Oct 1 11:34:26 2008 for OBT by  doxygen 1.5.3