antioch-0.4.0
List of all members | Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Friends
tinyxml2::XMLDocument Class Reference

#include <tinyxml2.h>

Inheritance diagram for tinyxml2::XMLDocument:
tinyxml2::XMLNode

Public Member Functions

 XMLDocument (bool processEntities=true, Whitespace=PRESERVE_WHITESPACE)
 constructor More...
 
 ~XMLDocument ()
 
virtual XMLDocumentToDocument ()
 Safely cast to a Document, or null. More...
 
virtual const XMLDocumentToDocument () const
 
int Parse (const char *xml, size_t nBytes=(size_t)(-1))
 
int LoadFile (const char *filename)
 
int LoadFile (FILE *)
 
int SaveFile (const char *filename, bool compact=false)
 
int SaveFile (FILE *fp, bool compact=false)
 
bool ProcessEntities () const
 
Whitespace WhitespaceMode () const
 
bool HasBOM () const
 
void SetBOM (bool useBOM)
 
XMLElementRootElement ()
 
const XMLElementRootElement () const
 
void Print (XMLPrinter *streamer=0)
 
virtual bool Accept (XMLVisitor *visitor) const
 
XMLElementNewElement (const char *name)
 
XMLCommentNewComment (const char *comment)
 
XMLTextNewText (const char *text)
 
XMLDeclarationNewDeclaration (const char *text=0)
 
XMLUnknownNewUnknown (const char *text)
 
void DeleteNode (XMLNode *node)
 
void SetError (int error, const char *str1, const char *str2)
 
bool Error () const
 Return true if there was an error parsing the document. More...
 
int ErrorID () const
 Return the errorID. More...
 
const char * GetErrorStr1 () const
 Return a possibly helpful diagnostic location or string. More...
 
const char * GetErrorStr2 () const
 Return a possibly helpful secondary diagnostic location or string. More...
 
void PrintError () const
 If there is an error, print it to stdout. More...
 
char * Identify (char *p, XMLNode **node)
 
virtual XMLNodeShallowClone (XMLDocument *) const
 
virtual bool ShallowEqual (const XMLNode *) const
 
const XMLDocumentGetDocument () const
 Get the XMLDocument that owns this XMLNode. More...
 
XMLDocumentGetDocument ()
 Get the XMLDocument that owns this XMLNode. More...
 
virtual XMLElementToElement ()
 Safely cast to an Element, or null. More...
 
virtual const XMLElementToElement () const
 
virtual XMLTextToText ()
 Safely cast to Text, or null. More...
 
virtual const XMLTextToText () const
 
virtual XMLCommentToComment ()
 Safely cast to a Comment, or null. More...
 
virtual const XMLCommentToComment () const
 
virtual XMLDeclarationToDeclaration ()
 Safely cast to a Declaration, or null. More...
 
virtual const XMLDeclarationToDeclaration () const
 
virtual XMLUnknownToUnknown ()
 Safely cast to an Unknown, or null. More...
 
virtual const XMLUnknownToUnknown () const
 
const char * Value () const
 
void SetValue (const char *val, bool staticMem=false)
 
const XMLNodeParent () const
 Get the parent of this node on the DOM. More...
 
XMLNodeParent ()
 
bool NoChildren () const
 Returns true if this node has no children. More...
 
const XMLNodeFirstChild () const
 Get the first child node, or null if none exists. More...
 
XMLNodeFirstChild ()
 
const XMLElementFirstChildElement (const char *value=0) const
 
XMLElementFirstChildElement (const char *_value=0)
 
const XMLNodeLastChild () const
 Get the last child node, or null if none exists. More...
 
XMLNodeLastChild ()
 
const XMLElementLastChildElement (const char *value=0) const
 
XMLElementLastChildElement (const char *_value=0)
 
const XMLNodePreviousSibling () const
 Get the previous (left) sibling node of this node. More...
 
XMLNodePreviousSibling ()
 
const XMLElementPreviousSiblingElement (const char *value=0) const
 Get the previous (left) sibling element of this node, with an opitionally supplied name. More...
 
XMLElementPreviousSiblingElement (const char *_value=0)
 
const XMLNodeNextSibling () const
 Get the next (right) sibling node of this node. More...
 
XMLNodeNextSibling ()
 
const XMLElementNextSiblingElement (const char *value=0) const
 Get the next (right) sibling element of this node, with an opitionally supplied name. More...
 
XMLElementNextSiblingElement (const char *_value=0)
 
XMLNodeInsertEndChild (XMLNode *addThis)
 
XMLNodeLinkEndChild (XMLNode *addThis)
 
XMLNodeInsertFirstChild (XMLNode *addThis)
 
XMLNodeInsertAfterChild (XMLNode *afterThis, XMLNode *addThis)
 
void DeleteChildren ()
 
void DeleteChild (XMLNode *node)
 
virtual char * ParseDeep (char *, StrPair *)
 

Protected Attributes

XMLDocumentdocument
 
XMLNodeparent
 
StrPair value
 
XMLNodefirstChild
 
XMLNodelastChild
 
XMLNodeprev
 
XMLNodenext
 

Private Member Functions

 XMLDocument (const XMLDocument &)
 
void operator= (const XMLDocument &)
 
void InitDocument ()
 

Private Attributes

bool writeBOM
 
bool processEntities
 
int errorID
 
Whitespace whitespace
 
const char * errorStr1
 
const char * errorStr2
 
char * charBuffer
 
MemPoolT< sizeof(XMLElement) > elementPool
 
MemPoolT< sizeof(XMLAttribute) > attributePool
 
MemPoolT< sizeof(XMLText) > textPool
 
MemPoolT< sizeof(XMLComment) > commentPool
 

Friends

class XMLElement
 

Detailed Description

A Document binds together all the functionality. It can be saved, loaded, and printed to the screen. All Nodes are connected and allocated to a Document. If the Document is deleted, all its Nodes are also deleted.

Definition at line 1060 of file tinyxml2.h.

Constructor & Destructor Documentation

XMLDocument::XMLDocument ( bool  processEntities = true,
Whitespace  _whitespace = PRESERVE_WHITESPACE 
)
inline

constructor

Definition at line 1546 of file tinyxml2_imp.h.

References tinyxml2::XMLNode::document.

1546  :
1547  XMLNode( 0 ),
1548  writeBOM( false ),
1549  processEntities( _processEntities ),
1550  errorID( 0 ),
1551  whitespace( _whitespace ),
1552  errorStr1( 0 ),
1553  errorStr2( 0 ),
1554  charBuffer( 0 )
1555 {
1556  document = this; // avoid warning about 'this' in initializer list
1557 }
const char * errorStr1
Definition: tinyxml2.h:1220
Whitespace whitespace
Definition: tinyxml2.h:1219
XMLDocument * document
Definition: tinyxml2.h:607
XMLNode(XMLDocument *)
Definition: tinyxml2_imp.h:599
const char * errorStr2
Definition: tinyxml2.h:1221
XMLDocument::~XMLDocument ( )
inline

Definition at line 1561 of file tinyxml2_imp.h.

References attributePool, charBuffer, commentPool, tinyxml2::XMLNode::DeleteChildren(), elementPool, textPool, and TIXMLASSERT.

1562 {
1563  DeleteChildren();
1564  delete [] charBuffer;
1565 
1566 #if 0
1567  textPool.Trace( "text" );
1568  elementPool.Trace( "element" );
1569  commentPool.Trace( "comment" );
1570  attributePool.Trace( "attribute" );
1571 #endif
1572 
1573  TIXMLASSERT( textPool.CurrentAllocs() == 0 );
1574  TIXMLASSERT( elementPool.CurrentAllocs() == 0 );
1575  TIXMLASSERT( commentPool.CurrentAllocs() == 0 );
1576  TIXMLASSERT( attributePool.CurrentAllocs() == 0 );
1577 }
#define TIXMLASSERT(x)
Definition: tinyxml2.h:68
MemPoolT< sizeof(XMLText) > textPool
Definition: tinyxml2.h:1226
MemPoolT< sizeof(XMLElement) > elementPool
Definition: tinyxml2.h:1224
MemPoolT< sizeof(XMLComment) > commentPool
Definition: tinyxml2.h:1227
MemPoolT< sizeof(XMLAttribute) > attributePool
Definition: tinyxml2.h:1225
tinyxml2::XMLDocument::XMLDocument ( const XMLDocument )
private

Member Function Documentation

bool XMLDocument::Accept ( XMLVisitor visitor) const
inlinevirtual

Accept a hierarchical visit of the nodes in the TinyXML DOM. Every node in the XML tree will be conditionally visited and the host will be called back via the TiXmlVisitor interface.

This is essentially a SAX interface for TinyXML. (Note however it doesn't re-parse the XML for the callbacks, so the performance of TinyXML is unchanged by using this interface versus any other.)

The interface has been based on ideas from:

Which are both good references for "visiting".

An example of using Accept():

    TiXmlPrinter printer;
    tinyxmlDoc.Accept( &printer );
    const char* xmlcstr = printer.CStr();

Implements tinyxml2::XMLNode.

Definition at line 582 of file tinyxml2_imp.h.

References tinyxml2::XMLNode::FirstChild(), tinyxml2::XMLNode::NextSibling(), tinyxml2::XMLVisitor::VisitEnter(), and tinyxml2::XMLVisitor::VisitExit().

Referenced by Print().

583 {
584  if ( visitor->VisitEnter( *this ) )
585  {
586  for ( const XMLNode* node=FirstChild(); node; node=node->NextSibling() )
587  {
588  if ( !node->Accept( visitor ) )
589  break;
590  }
591  }
592  return visitor->VisitExit( *this );
593 }
const XMLNode * NextSibling() const
Get the next (right) sibling node of this node.
Definition: tinyxml2.h:523
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
Definition: tinyxml2.h:496
virtual bool VisitEnter(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:352
virtual bool VisitExit(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:354
void XMLNode::DeleteChild ( XMLNode node)
inlineinherited

Delete a child of this node.

Definition at line 661 of file tinyxml2_imp.h.

References DELETE_NODE, tinyxml2::XMLNode::parent, and TIXMLASSERT.

Referenced by DeleteNode().

662 {
663  TIXMLASSERT( node->parent == this );
664  DELETE_NODE( node );
665 }
#define DELETE_NODE(node)
Definition: tinyxml2_imp.h:56
#define TIXMLASSERT(x)
Definition: tinyxml2.h:68
XMLNode * parent
Definition: tinyxml2.h:608
void XMLNode::DeleteChildren ( )
inlineinherited

Delete all the children of this node.

Definition at line 629 of file tinyxml2_imp.h.

References DELETE_NODE, tinyxml2::XMLNode::firstChild, tinyxml2::XMLNode::lastChild, and tinyxml2::XMLNode::Unlink().

Referenced by LoadFile(), Parse(), ~XMLDocument(), and tinyxml2::XMLNode::~XMLNode().

630 {
631  while( firstChild ) {
632  XMLNode* node = firstChild;
633  Unlink( node );
634 
635  DELETE_NODE( node );
636  }
637  firstChild = lastChild = 0;
638 }
#define DELETE_NODE(node)
Definition: tinyxml2_imp.h:56
void Unlink(XMLNode *child)
Definition: tinyxml2_imp.h:642
XMLNode * firstChild
Definition: tinyxml2.h:611
XMLNode * lastChild
Definition: tinyxml2.h:612
void tinyxml2::XMLDocument::DeleteNode ( XMLNode node)
inline

Delete a node associated with this document. It will be unlinked from the DOM.

Definition at line 1190 of file tinyxml2.h.

References tinyxml2::XMLNode::DeleteChild(), and tinyxml2::XMLNode::parent.

1190 { node->parent->DeleteChild( node ); }
bool tinyxml2::XMLDocument::Error ( ) const
inline

Return true if there was an error parsing the document.

Definition at line 1195 of file tinyxml2.h.

References errorID, and tinyxml2::XML_NO_ERROR.

Referenced by tinyxml2::XMLNode::ParseDeep().

int tinyxml2::XMLDocument::ErrorID ( ) const
inline

Return the errorID.

Definition at line 1197 of file tinyxml2.h.

References errorID.

Referenced by Antioch::XMLParser< NumericType >::change_file(), and Antioch::XMLParser< NumericType >::XMLParser().

1197 { return errorID; }
const XMLNode* tinyxml2::XMLNode::FirstChild ( ) const
inlineinherited
XMLNode* tinyxml2::XMLNode::FirstChild ( )
inlineinherited

Definition at line 497 of file tinyxml2.h.

References tinyxml2::XMLNode::firstChild.

497 { return firstChild; }
XMLNode * firstChild
Definition: tinyxml2.h:611
const XMLElement * XMLNode::FirstChildElement ( const char *  value = 0) const
inlineinherited

Get the first child element, or optionally the first child element with the specified name.

Definition at line 740 of file tinyxml2_imp.h.

References tinyxml2::XMLNode::firstChild, tinyxml2::XMLElement::Name(), tinyxml2::XMLNode::next, tinyxml2::XMLUtil::StringEqual(), tinyxml2::XMLElement::ToElement(), and tinyxml2::XMLNode::value.

Referenced by Antioch::XMLParser< NumericType >::efficiencies(), tinyxml2::XMLHandle::FirstChildElement(), tinyxml2::XMLConstHandle::FirstChildElement(), Antioch::XMLParser< NumericType >::get_parameter(), Antioch::XMLParser< NumericType >::products_orders(), Antioch::XMLParser< NumericType >::products_pairs(), Antioch::XMLParser< NumericType >::reactants_orders(), Antioch::XMLParser< NumericType >::reactants_pairs(), Antioch::XMLParser< NumericType >::reaction_kinetics_model(), Antioch::XMLParser< NumericType >::read_thermodynamic_data_root(), RootElement(), Antioch::XMLParser< NumericType >::verify_Kooij_in_place_of_Arrhenius(), and Antioch::XMLParser< NumericType >::where_is_k0().

741 {
742  for( XMLNode* node=firstChild; node; node=node->next ) {
743  XMLElement* element = node->ToElement();
744  if ( element ) {
745  if ( !value || XMLUtil::StringEqual( element->Name(), value ) ) {
746  return element;
747  }
748  }
749  }
750  return 0;
751 }
XMLNode * firstChild
Definition: tinyxml2.h:611
static bool StringEqual(const char *p, const char *q, int nChar=INT_MAX)
Definition: tinyxml2.h:384
const char * Name() const
Get the name of an element (which is the Value() of the node.)
Definition: tinyxml2.h:861
XMLNode * next
Definition: tinyxml2.h:615
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition: tinyxml2.h:865
XMLElement* tinyxml2::XMLNode::FirstChildElement ( const char *  _value = 0)
inlineinherited

Definition at line 502 of file tinyxml2.h.

References tinyxml2::XMLNode::FirstChildElement().

Referenced by tinyxml2::XMLNode::FirstChildElement().

502 { return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->FirstChildElement( _value )); }
friend class XMLElement
Definition: tinyxml2.h:451
const XMLElement * FirstChildElement(const char *value=0) const
Definition: tinyxml2_imp.h:740
XMLNode(XMLDocument *)
Definition: tinyxml2_imp.h:599
const XMLDocument* tinyxml2::XMLNode::GetDocument ( ) const
inlineinherited

Get the XMLDocument that owns this XMLNode.

Definition at line 455 of file tinyxml2.h.

References tinyxml2::XMLNode::document.

455 { return document; }
XMLDocument * document
Definition: tinyxml2.h:607
XMLDocument* tinyxml2::XMLNode::GetDocument ( )
inlineinherited

Get the XMLDocument that owns this XMLNode.

Definition at line 457 of file tinyxml2.h.

References tinyxml2::XMLNode::document.

457 { return document; }
XMLDocument * document
Definition: tinyxml2.h:607
const char* tinyxml2::XMLDocument::GetErrorStr1 ( ) const
inline

Return a possibly helpful diagnostic location or string.

Definition at line 1199 of file tinyxml2.h.

References errorStr1.

Referenced by Antioch::XMLParser< NumericType >::XMLParser().

1199 { return errorStr1; }
const char * errorStr1
Definition: tinyxml2.h:1220
const char* tinyxml2::XMLDocument::GetErrorStr2 ( ) const
inline

Return a possibly helpful secondary diagnostic location or string.

Definition at line 1201 of file tinyxml2.h.

References errorStr2.

Referenced by Antioch::XMLParser< NumericType >::XMLParser().

1201 { return errorStr2; }
const char * errorStr2
Definition: tinyxml2.h:1221
bool tinyxml2::XMLDocument::HasBOM ( ) const
inline

Returns true if this document has a leading Byte Order Mark of UTF8.

Definition at line 1121 of file tinyxml2.h.

References writeBOM.

Referenced by tinyxml2::XMLPrinter::VisitEnter().

1121 { return writeBOM; }
char * XMLDocument::Identify ( char *  p,
XMLNode **  node 
)
inline

Definition at line 505 of file tinyxml2_imp.h.

References commentPool, elementPool, tinyxml2::XMLNode::memPool, tinyxml2::XMLText::SetCData(), tinyxml2::XMLUtil::SkipWhiteSpace(), tinyxml2::XMLUtil::StringEqual(), textPool, TIXMLASSERT, and XMLElement.

Referenced by tinyxml2::XMLNode::ParseDeep().

506 {
507  XMLNode* returnNode = 0;
508  char* start = p;
509  p = XMLUtil::SkipWhiteSpace( p );
510  if( !p || !*p )
511  {
512  return p;
513  }
514 
515  // What is this thing?
516  // - Elements start with a letter or underscore, but xml is reserved.
517  // - Comments: <!--
518  // - Decleration: <?
519  // - Everthing else is unknown to tinyxml.
520  //
521 
522  static const char* xmlHeader = { "<?" };
523  static const char* commentHeader = { "<!--" };
524  static const char* dtdHeader = { "<!" };
525  static const char* cdataHeader = { "<![CDATA[" };
526  static const char* elementHeader = { "<" }; // and a header for everything else; check last.
527 
528  static const int xmlHeaderLen = 2;
529  static const int commentHeaderLen = 4;
530  static const int dtdHeaderLen = 2;
531  static const int cdataHeaderLen = 9;
532  static const int elementHeaderLen = 1;
533 
534 #if defined(_MSC_VER)
535 #pragma warning ( push )
536 #pragma warning ( disable : 4127 )
537 #endif
538  TIXMLASSERT( sizeof( XMLComment ) == sizeof( XMLUnknown ) ); // use same memory pool
539  TIXMLASSERT( sizeof( XMLComment ) == sizeof( XMLDeclaration ) ); // use same memory pool
540 #if defined(_MSC_VER)
541 #pragma warning (pop)
542 #endif
543  if ( XMLUtil::StringEqual( p, xmlHeader, xmlHeaderLen ) ) {
544  returnNode = new (commentPool.Alloc()) XMLDeclaration( this );
545  returnNode->memPool = &commentPool;
546  p += xmlHeaderLen;
547  }
548  else if ( XMLUtil::StringEqual( p, commentHeader, commentHeaderLen ) ) {
549  returnNode = new (commentPool.Alloc()) XMLComment( this );
550  returnNode->memPool = &commentPool;
551  p += commentHeaderLen;
552  }
553  else if ( XMLUtil::StringEqual( p, cdataHeader, cdataHeaderLen ) ) {
554  XMLText* text = new (textPool.Alloc()) XMLText( this );
555  returnNode = text;
556  returnNode->memPool = &textPool;
557  p += cdataHeaderLen;
558  text->SetCData( true );
559  }
560  else if ( XMLUtil::StringEqual( p, dtdHeader, dtdHeaderLen ) ) {
561  returnNode = new (commentPool.Alloc()) XMLUnknown( this );
562  returnNode->memPool = &commentPool;
563  p += dtdHeaderLen;
564  }
565  else if ( XMLUtil::StringEqual( p, elementHeader, elementHeaderLen ) ) {
566  returnNode = new (elementPool.Alloc()) XMLElement( this );
567  returnNode->memPool = &elementPool;
568  p += elementHeaderLen;
569  }
570  else {
571  returnNode = new (textPool.Alloc()) XMLText( this );
572  returnNode->memPool = &textPool;
573  p = start; // Back it up, all the text counts.
574  }
575 
576  *node = returnNode;
577  return p;
578 }
#define TIXMLASSERT(x)
Definition: tinyxml2.h:68
MemPoolT< sizeof(XMLText) > textPool
Definition: tinyxml2.h:1226
static bool StringEqual(const char *p, const char *q, int nChar=INT_MAX)
Definition: tinyxml2.h:384
MemPoolT< sizeof(XMLElement) > elementPool
Definition: tinyxml2.h:1224
static const char * SkipWhiteSpace(const char *p)
Definition: tinyxml2.h:380
void SetCData(bool _isCData)
Declare whether this should be CDATA or standard text.
Definition: tinyxml2.h:646
MemPoolT< sizeof(XMLComment) > commentPool
Definition: tinyxml2.h:1227
MemPool * memPool
Definition: tinyxml2.h:618
friend class XMLElement
Definition: tinyxml2.h:1062
void XMLDocument::InitDocument ( )
inlineprivate

Definition at line 1581 of file tinyxml2_imp.h.

References charBuffer, errorID, errorStr1, errorStr2, and tinyxml2::XML_NO_ERROR.

Referenced by LoadFile(), and Parse().

1582 {
1584  errorStr1 = 0;
1585  errorStr2 = 0;
1586 
1587  delete [] charBuffer;
1588  charBuffer = 0;
1589 
1590 }
const char * errorStr1
Definition: tinyxml2.h:1220
const char * errorStr2
Definition: tinyxml2.h:1221
XMLNode * XMLNode::InsertAfterChild ( XMLNode afterThis,
XMLNode addThis 
)
inlineinherited

Add a node after the specified child node.

Definition at line 718 of file tinyxml2_imp.h.

References tinyxml2::XMLNode::InsertEndChild(), tinyxml2::XMLNode::next, tinyxml2::XMLNode::parent, tinyxml2::XMLNode::prev, and TIXMLASSERT.

719 {
720  TIXMLASSERT( afterThis->parent == this );
721  if ( afterThis->parent != this )
722  return 0;
723 
724  if ( afterThis->next == 0 ) {
725  // The last node or the only node.
726  return InsertEndChild( addThis );
727  }
728  addThis->prev = afterThis;
729  addThis->next = afterThis->next;
730  afterThis->next->prev = addThis;
731  afterThis->next = addThis;
732  addThis->parent = this;
733  return addThis;
734 }
#define TIXMLASSERT(x)
Definition: tinyxml2.h:68
XMLNode * parent
Definition: tinyxml2.h:608
XMLNode * InsertEndChild(XMLNode *addThis)
Definition: tinyxml2_imp.h:669
XMLNode * next
Definition: tinyxml2.h:615
XMLNode * prev
Definition: tinyxml2.h:614
XMLNode * XMLNode::InsertEndChild ( XMLNode addThis)
inlineinherited

Add a child node as the last (right) child.

Definition at line 669 of file tinyxml2_imp.h.

References tinyxml2::XMLNode::firstChild, tinyxml2::XMLNode::lastChild, tinyxml2::XMLNode::next, tinyxml2::XMLNode::parent, tinyxml2::XMLNode::prev, and TIXMLASSERT.

Referenced by tinyxml2::XMLNode::InsertAfterChild(), tinyxml2::XMLNode::LinkEndChild(), and tinyxml2::XMLNode::ParseDeep().

670 {
671  if ( lastChild ) {
673  TIXMLASSERT( lastChild->next == 0 );
674  lastChild->next = addThis;
675  addThis->prev = lastChild;
676  lastChild = addThis;
677 
678  addThis->next = 0;
679  }
680  else {
681  TIXMLASSERT( firstChild == 0 );
682  firstChild = lastChild = addThis;
683 
684  addThis->prev = 0;
685  addThis->next = 0;
686  }
687  addThis->parent = this;
688  return addThis;
689 }
#define TIXMLASSERT(x)
Definition: tinyxml2.h:68
XMLNode * firstChild
Definition: tinyxml2.h:611
XMLNode * parent
Definition: tinyxml2.h:608
XMLNode * next
Definition: tinyxml2.h:615
XMLNode * lastChild
Definition: tinyxml2.h:612
XMLNode * prev
Definition: tinyxml2.h:614
XMLNode * XMLNode::InsertFirstChild ( XMLNode addThis)
inlineinherited

Add a child node as the first (left) child.

Definition at line 693 of file tinyxml2_imp.h.

References tinyxml2::XMLNode::firstChild, tinyxml2::XMLNode::lastChild, tinyxml2::XMLNode::next, tinyxml2::XMLNode::parent, tinyxml2::XMLNode::prev, and TIXMLASSERT.

694 {
695  if ( firstChild ) {
697  TIXMLASSERT( firstChild->prev == 0 );
698 
699  firstChild->prev = addThis;
700  addThis->next = firstChild;
701  firstChild = addThis;
702 
703  addThis->prev = 0;
704  }
705  else {
706  TIXMLASSERT( lastChild == 0 );
707  firstChild = lastChild = addThis;
708 
709  addThis->prev = 0;
710  addThis->next = 0;
711  }
712  addThis->parent = this;
713  return addThis;
714 }
#define TIXMLASSERT(x)
Definition: tinyxml2.h:68
XMLNode * firstChild
Definition: tinyxml2.h:611
XMLNode * parent
Definition: tinyxml2.h:608
XMLNode * next
Definition: tinyxml2.h:615
XMLNode * lastChild
Definition: tinyxml2.h:612
XMLNode * prev
Definition: tinyxml2.h:614
const XMLNode* tinyxml2::XMLNode::LastChild ( ) const
inlineinherited

Get the last child node, or null if none exists.

Definition at line 505 of file tinyxml2.h.

References tinyxml2::XMLNode::lastChild.

Referenced by tinyxml2::XMLHandle::LastChild(), and tinyxml2::XMLConstHandle::LastChild().

505 { return lastChild; }
XMLNode * lastChild
Definition: tinyxml2.h:612
XMLNode* tinyxml2::XMLNode::LastChild ( )
inlineinherited

Definition at line 506 of file tinyxml2.h.

References tinyxml2::XMLNode::LastChild().

Referenced by tinyxml2::XMLNode::LastChild().

506 { return const_cast<XMLNode*>(const_cast<const XMLNode*>(this)->LastChild() ); }
const XMLNode * LastChild() const
Get the last child node, or null if none exists.
Definition: tinyxml2.h:505
XMLNode(XMLDocument *)
Definition: tinyxml2_imp.h:599
const XMLElement * XMLNode::LastChildElement ( const char *  value = 0) const
inlineinherited

Get the last child element or optionally the last child element with the specified name.

Definition at line 755 of file tinyxml2_imp.h.

References tinyxml2::XMLNode::lastChild, tinyxml2::XMLElement::Name(), tinyxml2::XMLNode::prev, tinyxml2::XMLUtil::StringEqual(), tinyxml2::XMLElement::ToElement(), and tinyxml2::XMLNode::value.

Referenced by tinyxml2::XMLHandle::LastChildElement(), and tinyxml2::XMLConstHandle::LastChildElement().

756 {
757  for( XMLNode* node=lastChild; node; node=node->prev ) {
758  XMLElement* element = node->ToElement();
759  if ( element ) {
760  if ( !value || XMLUtil::StringEqual( element->Name(), value ) ) {
761  return element;
762  }
763  }
764  }
765  return 0;
766 }
static bool StringEqual(const char *p, const char *q, int nChar=INT_MAX)
Definition: tinyxml2.h:384
const char * Name() const
Get the name of an element (which is the Value() of the node.)
Definition: tinyxml2.h:861
XMLNode * lastChild
Definition: tinyxml2.h:612
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition: tinyxml2.h:865
XMLNode * prev
Definition: tinyxml2.h:614
XMLElement* tinyxml2::XMLNode::LastChildElement ( const char *  _value = 0)
inlineinherited

Definition at line 512 of file tinyxml2.h.

References tinyxml2::XMLNode::LastChildElement().

Referenced by tinyxml2::XMLNode::LastChildElement().

512 { return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->LastChildElement(_value) ); }
const XMLElement * LastChildElement(const char *value=0) const
Definition: tinyxml2_imp.h:755
friend class XMLElement
Definition: tinyxml2.h:451
XMLNode(XMLDocument *)
Definition: tinyxml2_imp.h:599
XMLNode* tinyxml2::XMLNode::LinkEndChild ( XMLNode addThis)
inlineinherited

Definition at line 535 of file tinyxml2.h.

References tinyxml2::XMLNode::InsertEndChild().

535 { return InsertEndChild( addThis ); }
XMLNode * InsertEndChild(XMLNode *addThis)
Definition: tinyxml2_imp.h:669
int XMLDocument::LoadFile ( const char *  filename)
inline

Load an XML file from disk. Returns XML_NO_ERROR (0) on success, or an errorID.

Definition at line 1644 of file tinyxml2_imp.h.

References tinyxml2::XMLNode::DeleteChildren(), errorID, InitDocument(), SetError(), and tinyxml2::XML_ERROR_FILE_NOT_FOUND.

Referenced by Antioch::XMLParser< NumericType >::XMLParser().

1645 {
1646  DeleteChildren();
1647  InitDocument();
1648  FILE* fp = 0;
1649 
1650  #if defined(_MSC_VER) && (_MSC_VER >= 1400 )
1651  errno_t err = fopen_s(&fp, filename, "rb" );
1652  if ( !fp || err) {
1653  #else
1654  fp = fopen( filename, "rb" );
1655  if ( !fp) {
1656  #endif
1657  SetError( XML_ERROR_FILE_NOT_FOUND, filename, 0 );
1658  return errorID;
1659  }
1660  LoadFile( fp );
1661  fclose( fp );
1662  return errorID;
1663 }
int LoadFile(const char *filename)
void SetError(int error, const char *str1, const char *str2)
int XMLDocument::LoadFile ( FILE *  fp)
inline

Load an XML file from disk. You are responsible for providing and closing the FILE*.

Returns XML_NO_ERROR (0) on success, or an errorID.

Definition at line 1667 of file tinyxml2_imp.h.

References charBuffer, tinyxml2::XMLNode::DeleteChildren(), errorID, InitDocument(), tinyxml2::XMLNode::ParseDeep(), tinyxml2::XMLUtil::ReadBOM(), SetError(), tinyxml2::XMLUtil::SkipWhiteSpace(), writeBOM, tinyxml2::XML_ERROR_EMPTY_DOCUMENT, and tinyxml2::XML_ERROR_FILE_READ_ERROR.

1668 {
1669  DeleteChildren();
1670  InitDocument();
1671 
1672  fseek( fp, 0, SEEK_END );
1673  unsigned size = ftell( fp );
1674  fseek( fp, 0, SEEK_SET );
1675 
1676  if ( size == 0 ) {
1677  return errorID;
1678  }
1679 
1680  charBuffer = new char[size+1];
1681  size_t read = fread( charBuffer, 1, size, fp );
1682  if ( read != size ) {
1684  return errorID;
1685  }
1686 
1687  charBuffer[size] = 0;
1688 
1689  const char* p = charBuffer;
1690  p = XMLUtil::SkipWhiteSpace( p );
1691  p = XMLUtil::ReadBOM( p, &writeBOM );
1692  if ( !p || !*p ) {
1694  return errorID;
1695  }
1696 
1697  ParseDeep( charBuffer + (p-charBuffer), 0 );
1698  return errorID;
1699 }
static const char * SkipWhiteSpace(const char *p)
Definition: tinyxml2.h:380
void SetError(int error, const char *str1, const char *str2)
virtual char * ParseDeep(char *, StrPair *)
Definition: tinyxml2_imp.h:798
static const char * ReadBOM(const char *p, bool *hasBOM)
Definition: tinyxml2_imp.h:286
XMLComment * XMLDocument::NewComment ( const char *  comment)
inline

Create a new Comment associated with this Document. The memory for the Comment is managed by the Document.

Definition at line 1604 of file tinyxml2_imp.h.

References commentPool, and tinyxml2::XMLNode::SetValue().

Referenced by tinyxml2::XMLComment::ShallowClone().

1605 {
1606  XMLComment* comment = new (commentPool.Alloc()) XMLComment( this );
1607  comment->memPool = &commentPool;
1608  comment->SetValue( str );
1609  return comment;
1610 }
void SetValue(const char *val, bool staticMem=false)
Definition: tinyxml2_imp.h:619
MemPoolT< sizeof(XMLComment) > commentPool
Definition: tinyxml2.h:1227
XMLDeclaration * XMLDocument::NewDeclaration ( const char *  text = 0)
inline

Create a new Declaration associated with this Document. The memory for the object is managed by the Document.

If the 'text' param is null, the standard declaration is used.:

        <?xml version="1.0" encoding="UTF-8"?>

Definition at line 1624 of file tinyxml2_imp.h.

References commentPool, and tinyxml2::XMLNode::SetValue().

Referenced by tinyxml2::XMLDeclaration::ShallowClone().

1625 {
1626  XMLDeclaration* dec = new (commentPool.Alloc()) XMLDeclaration( this );
1627  dec->memPool = &commentPool;
1628  dec->SetValue( str ? str : "xml version=\"1.0\" encoding=\"UTF-8\"" );
1629  return dec;
1630 }
void SetValue(const char *val, bool staticMem=false)
Definition: tinyxml2_imp.h:619
MemPoolT< sizeof(XMLComment) > commentPool
Definition: tinyxml2.h:1227
XMLElement * XMLDocument::NewElement ( const char *  name)
inline

Create a new Element associated with this Document. The memory for the Element is managed by the Document.

Definition at line 1594 of file tinyxml2_imp.h.

References elementPool, tinyxml2::XMLElement::SetName(), and XMLElement.

Referenced by tinyxml2::XMLElement::ShallowClone().

1595 {
1596  XMLElement* ele = new (elementPool.Alloc()) XMLElement( this );
1597  ele->memPool = &elementPool;
1598  ele->SetName( name );
1599  return ele;
1600 }
void SetName(const char *str, bool staticMem=false)
Set the name of the element.
Definition: tinyxml2.h:863
MemPoolT< sizeof(XMLElement) > elementPool
Definition: tinyxml2.h:1224
friend class XMLElement
Definition: tinyxml2.h:1062
XMLText * XMLDocument::NewText ( const char *  text)
inline

Create a new Text associated with this Document. The memory for the Text is managed by the Document.

Definition at line 1614 of file tinyxml2_imp.h.

References tinyxml2::XMLNode::SetValue(), and textPool.

Referenced by tinyxml2::XMLText::ShallowClone().

1615 {
1616  XMLText* text = new (textPool.Alloc()) XMLText( this );
1617  text->memPool = &textPool;
1618  text->SetValue( str );
1619  return text;
1620 }
MemPoolT< sizeof(XMLText) > textPool
Definition: tinyxml2.h:1226
void SetValue(const char *val, bool staticMem=false)
Definition: tinyxml2_imp.h:619
XMLUnknown * XMLDocument::NewUnknown ( const char *  text)
inline

Create a new Unknown associated with this Document. The memory for the object is managed by the Document.

Definition at line 1634 of file tinyxml2_imp.h.

References commentPool, and tinyxml2::XMLNode::SetValue().

Referenced by tinyxml2::XMLUnknown::ShallowClone().

1635 {
1636  XMLUnknown* unk = new (commentPool.Alloc()) XMLUnknown( this );
1637  unk->memPool = &commentPool;
1638  unk->SetValue( str );
1639  return unk;
1640 }
void SetValue(const char *val, bool staticMem=false)
Definition: tinyxml2_imp.h:619
MemPoolT< sizeof(XMLComment) > commentPool
Definition: tinyxml2.h:1227
const XMLNode* tinyxml2::XMLNode::NextSibling ( ) const
inlineinherited

Get the next (right) sibling node of this node.

Definition at line 523 of file tinyxml2.h.

References tinyxml2::XMLNode::next.

Referenced by tinyxml2::XMLElement::Accept(), Accept(), tinyxml2::XMLHandle::NextSibling(), and tinyxml2::XMLConstHandle::NextSibling().

523 { return next; }
XMLNode * next
Definition: tinyxml2.h:615
XMLNode* tinyxml2::XMLNode::NextSibling ( )
inlineinherited

Definition at line 524 of file tinyxml2.h.

References tinyxml2::XMLNode::next.

524 { return next; }
XMLNode * next
Definition: tinyxml2.h:615
const XMLElement * XMLNode::NextSiblingElement ( const char *  value = 0) const
inlineinherited

Get the next (right) sibling element of this node, with an opitionally supplied name.

Definition at line 770 of file tinyxml2_imp.h.

References tinyxml2::XMLNode::next, tinyxml2::XMLUtil::StringEqual(), and tinyxml2::XMLElement::ToElement().

Referenced by Antioch::XMLParser< NumericType >::find_element_with_attribute(), tinyxml2::XMLHandle::NextSiblingElement(), tinyxml2::XMLConstHandle::NextSiblingElement(), Antioch::XMLParser< NumericType >::read_thermodynamic_data_root(), and Antioch::XMLParser< NumericType >::where_is_k0().

771 {
772  for( XMLNode* element=this->next; element; element = element->next ) {
773  if ( element->ToElement()
774  && (!value || XMLUtil::StringEqual( value, element->Value() )))
775  {
776  return element->ToElement();
777  }
778  }
779  return 0;
780 }
static bool StringEqual(const char *p, const char *q, int nChar=INT_MAX)
Definition: tinyxml2.h:384
XMLNode * next
Definition: tinyxml2.h:615
XMLElement* tinyxml2::XMLNode::NextSiblingElement ( const char *  _value = 0)
inlineinherited

Definition at line 528 of file tinyxml2.h.

References tinyxml2::XMLNode::NextSiblingElement().

Referenced by tinyxml2::XMLNode::NextSiblingElement().

528 { return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->NextSiblingElement( _value ) ); }
friend class XMLElement
Definition: tinyxml2.h:451
const XMLElement * NextSiblingElement(const char *value=0) const
Get the next (right) sibling element of this node, with an opitionally supplied name.
Definition: tinyxml2_imp.h:770
XMLNode(XMLDocument *)
Definition: tinyxml2_imp.h:599
bool tinyxml2::XMLNode::NoChildren ( ) const
inlineinherited

Returns true if this node has no children.

Definition at line 493 of file tinyxml2.h.

References tinyxml2::XMLNode::firstChild.

493 { return !firstChild; }
XMLNode * firstChild
Definition: tinyxml2.h:611
void tinyxml2::XMLDocument::operator= ( const XMLDocument )
private
const XMLNode* tinyxml2::XMLNode::Parent ( ) const
inlineinherited

Get the parent of this node on the DOM.

Definition at line 489 of file tinyxml2.h.

References tinyxml2::XMLNode::parent.

489 { return parent; }
XMLNode * parent
Definition: tinyxml2.h:608
XMLNode* tinyxml2::XMLNode::Parent ( )
inlineinherited

Definition at line 490 of file tinyxml2.h.

References tinyxml2::XMLNode::parent.

490 { return parent; }
XMLNode * parent
Definition: tinyxml2.h:608
int XMLDocument::Parse ( const char *  xml,
size_t  nBytes = (size_t)(-1) 
)
inline

Parse an XML file from a character string. Returns XML_NO_ERROR (0) on success, or an errorID.

You may optionally pass in the 'nBytes', which is the number of bytes which will be parsed. If not specified, TinyXML will assume 'xml' points to a null terminated string.

Definition at line 1732 of file tinyxml2_imp.h.

References charBuffer, tinyxml2::XMLNode::DeleteChildren(), errorID, InitDocument(), tinyxml2::XMLNode::ParseDeep(), tinyxml2::XMLUtil::ReadBOM(), SetError(), tinyxml2::XMLUtil::SkipWhiteSpace(), writeBOM, and tinyxml2::XML_ERROR_EMPTY_DOCUMENT.

1733 {
1734  DeleteChildren();
1735  InitDocument();
1736 
1737  if ( !p || !*p ) {
1739  return errorID;
1740  }
1741  if ( len == (size_t)(-1) ) {
1742  len = strlen( p );
1743  }
1744  charBuffer = new char[ len+1 ];
1745  memcpy( charBuffer, p, len );
1746  charBuffer[len] = 0;
1747 
1748  p = XMLUtil::SkipWhiteSpace( p );
1749  p = XMLUtil::ReadBOM( p, &writeBOM );
1750  if ( !p || !*p ) {
1752  return errorID;
1753  }
1754 
1755  ParseDeep( charBuffer, 0 );
1756  return errorID;
1757 }
static const char * SkipWhiteSpace(const char *p)
Definition: tinyxml2.h:380
void SetError(int error, const char *str1, const char *str2)
virtual char * ParseDeep(char *, StrPair *)
Definition: tinyxml2_imp.h:798
static const char * ReadBOM(const char *p, bool *hasBOM)
Definition: tinyxml2_imp.h:286
char * XMLNode::ParseDeep ( char *  p,
StrPair parentEnd 
)
inlinevirtualinherited

Reimplemented in tinyxml2::XMLElement, tinyxml2::XMLUnknown, tinyxml2::XMLDeclaration, tinyxml2::XMLComment, and tinyxml2::XMLText.

Definition at line 798 of file tinyxml2_imp.h.

References tinyxml2::XMLElement::CLOSING, tinyxml2::XMLElement::ClosingType(), DELETE_NODE, tinyxml2::XMLNode::document, tinyxml2::StrPair::Empty(), Error(), tinyxml2::StrPair::GetStr(), Identify(), tinyxml2::XMLNode::InsertEndChild(), tinyxml2::XMLElement::OPEN, tinyxml2::XMLNode::ParseDeep(), SetError(), tinyxml2::XMLUtil::StringEqual(), tinyxml2::XMLNode::ToElement(), tinyxml2::XMLNode::Value(), tinyxml2::XMLNode::value, tinyxml2::XML_ERROR_MISMATCHED_ELEMENT, and tinyxml2::XML_ERROR_PARSING.

Referenced by LoadFile(), Parse(), tinyxml2::XMLNode::ParseDeep(), and tinyxml2::XMLElement::ParseDeep().

799 {
800  // This is a recursive method, but thinking about it "at the current level"
801  // it is a pretty simple flat list:
802  // <foo/>
803  // <!-- comment -->
804  //
805  // With a special case:
806  // <foo>
807  // </foo>
808  // <!-- comment -->
809  //
810  // Where the closing element (/foo) *must* be the next thing after the opening
811  // element, and the names must match. BUT the tricky bit is that the closing
812  // element will be read by the child.
813  //
814  // 'endTag' is the end tag for this node, it is returned by a call to a child.
815  // 'parentEnd' is the end tag for the parent, which is filled in and returned.
816 
817  while( p && *p ) {
818  XMLNode* node = 0;
819 
820  p = document->Identify( p, &node );
821  if ( p == 0 || node == 0 ) {
822  break;
823  }
824 
825  StrPair endTag;
826  p = node->ParseDeep( p, &endTag );
827  if ( !p ) {
828  DELETE_NODE( node );
829  node = 0;
830  if ( !document->Error() ) {
832  }
833  break;
834  }
835 
836  // We read the end tag. Return it to the parent.
837  if ( node->ToElement() && node->ToElement()->ClosingType() == XMLElement::CLOSING ) {
838  if ( parentEnd ) {
839  *parentEnd = static_cast<XMLElement*>(node)->value;
840  }
841  DELETE_NODE( node );
842  return p;
843  }
844 
845  // Handle an end tag returned to this level.
846  // And handle a bunch of annoying errors.
847  XMLElement* ele = node->ToElement();
848  if ( ele ) {
849  if ( endTag.Empty() && ele->ClosingType() == XMLElement::OPEN ) {
851  p = 0;
852  }
853  else if ( !endTag.Empty() && ele->ClosingType() != XMLElement::OPEN ) {
855  p = 0;
856  }
857  else if ( !endTag.Empty() ) {
858  if ( !XMLUtil::StringEqual( endTag.GetStr(), node->Value() )) {
860  p = 0;
861  }
862  }
863  }
864  if ( p == 0 ) {
865  DELETE_NODE( node );
866  node = 0;
867  }
868  if ( node ) {
869  this->InsertEndChild( node );
870  }
871  }
872  return 0;
873 }
#define DELETE_NODE(node)
Definition: tinyxml2_imp.h:56
const char * GetStr()
Definition: tinyxml2_imp.h:195
static bool StringEqual(const char *p, const char *q, int nChar=INT_MAX)
Definition: tinyxml2.h:384
bool Error() const
Return true if there was an error parsing the document.
Definition: tinyxml2.h:1195
XMLDocument * document
Definition: tinyxml2.h:607
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition: tinyxml2.h:459
XMLNode * InsertEndChild(XMLNode *addThis)
Definition: tinyxml2_imp.h:669
void SetError(int error, const char *str1, const char *str2)
bool Empty() const
Definition: tinyxml2.h:143
virtual char * ParseDeep(char *, StrPair *)
Definition: tinyxml2_imp.h:798
int ClosingType() const
Definition: tinyxml2.h:1025
const char * Value() const
Definition: tinyxml2.h:482
char * Identify(char *p, XMLNode **node)
Definition: tinyxml2_imp.h:505
const XMLNode* tinyxml2::XMLNode::PreviousSibling ( ) const
inlineinherited

Get the previous (left) sibling node of this node.

Definition at line 515 of file tinyxml2.h.

References tinyxml2::XMLNode::prev.

Referenced by tinyxml2::XMLHandle::PreviousSibling(), and tinyxml2::XMLConstHandle::PreviousSibling().

515 { return prev; }
XMLNode * prev
Definition: tinyxml2.h:614
XMLNode* tinyxml2::XMLNode::PreviousSibling ( )
inlineinherited

Definition at line 516 of file tinyxml2.h.

References tinyxml2::XMLNode::prev.

516 { return prev; }
XMLNode * prev
Definition: tinyxml2.h:614
const XMLElement * XMLNode::PreviousSiblingElement ( const char *  value = 0) const
inlineinherited

Get the previous (left) sibling element of this node, with an opitionally supplied name.

Definition at line 784 of file tinyxml2_imp.h.

References tinyxml2::XMLNode::prev, tinyxml2::XMLUtil::StringEqual(), and tinyxml2::XMLElement::ToElement().

Referenced by tinyxml2::XMLHandle::PreviousSiblingElement(), and tinyxml2::XMLConstHandle::PreviousSiblingElement().

785 {
786  for( XMLNode* element=this->prev; element; element = element->prev ) {
787  if ( element->ToElement()
788  && (!value || XMLUtil::StringEqual( value, element->Value() )))
789  {
790  return element->ToElement();
791  }
792  }
793  return 0;
794 }
static bool StringEqual(const char *p, const char *q, int nChar=INT_MAX)
Definition: tinyxml2.h:384
XMLNode * prev
Definition: tinyxml2.h:614
XMLElement* tinyxml2::XMLNode::PreviousSiblingElement ( const char *  _value = 0)
inlineinherited

Definition at line 520 of file tinyxml2.h.

References tinyxml2::XMLNode::PreviousSiblingElement().

Referenced by tinyxml2::XMLNode::PreviousSiblingElement().

520 { return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->PreviousSiblingElement( _value ) ); }
const XMLElement * PreviousSiblingElement(const char *value=0) const
Get the previous (left) sibling element of this node, with an opitionally supplied name...
Definition: tinyxml2_imp.h:784
friend class XMLElement
Definition: tinyxml2.h:451
XMLNode(XMLDocument *)
Definition: tinyxml2_imp.h:599
void XMLDocument::Print ( XMLPrinter streamer = 0)
inline

Print the Document. If the Printer is not provided, it will print to stdout. If you provide Printer, this can print to a file:

    XMLPrinter printer( fp );
    doc.Print( &printer );

Or you can use a printer to print to memory:

    XMLPrinter printer;
    doc->Print( &printer );
    // printer.CStr() has a const char* to the XML

Definition at line 1761 of file tinyxml2_imp.h.

References Accept().

Referenced by SaveFile().

1762 {
1763  XMLPrinter stdStreamer( stdout );
1764  if ( !streamer )
1765  streamer = &stdStreamer;
1766  Accept( streamer );
1767 }
virtual bool Accept(XMLVisitor *visitor) const
Definition: tinyxml2_imp.h:582
void XMLDocument::PrintError ( ) const
inline

If there is an error, print it to stdout.

Definition at line 1780 of file tinyxml2_imp.h.

References errorID, errorStr1, errorStr2, and TIXML_SNPRINTF.

1781 {
1782  if ( errorID ) {
1783  static const int LEN = 20;
1784  char buf1[LEN] = { 0 };
1785  char buf2[LEN] = { 0 };
1786 
1787  if ( errorStr1 ) {
1788  TIXML_SNPRINTF( buf1, LEN, "%s", errorStr1 );
1789  }
1790  if ( errorStr2 ) {
1791  TIXML_SNPRINTF( buf2, LEN, "%s", errorStr2 );
1792  }
1793 
1794  printf( "XMLDocument error id=%d str1=%s str2=%s\n",
1795  errorID, buf1, buf2 );
1796  }
1797 }
const char * errorStr1
Definition: tinyxml2.h:1220
#define TIXML_SNPRINTF
Definition: tinyxml2.h:92
const char * errorStr2
Definition: tinyxml2.h:1221
bool tinyxml2::XMLDocument::ProcessEntities ( ) const
inline
XMLElement* tinyxml2::XMLDocument::RootElement ( )
inline

Return the root element of DOM. Equivalent to FirstChildElement(). To get the first node, use FirstChild().

Definition at line 1129 of file tinyxml2.h.

References tinyxml2::XMLNode::FirstChildElement().

1129 { return FirstChildElement(); }
const XMLElement * FirstChildElement(const char *value=0) const
Definition: tinyxml2_imp.h:740
const XMLElement* tinyxml2::XMLDocument::RootElement ( ) const
inline

Definition at line 1130 of file tinyxml2.h.

References tinyxml2::XMLNode::FirstChildElement().

1130 { return FirstChildElement(); }
const XMLElement * FirstChildElement(const char *value=0) const
Definition: tinyxml2_imp.h:740
int XMLDocument::SaveFile ( const char *  filename,
bool  compact = false 
)
inline

Save the XML file to disk. Returns XML_NO_ERROR (0) on success, or an errorID.

Definition at line 1703 of file tinyxml2_imp.h.

References errorID, SetError(), and tinyxml2::XML_ERROR_FILE_COULD_NOT_BE_OPENED.

1704 {
1705  FILE* fp = 0;
1706  #if defined(_MSC_VER) && (_MSC_VER >= 1400 )
1707  errno_t err = fopen_s(&fp, filename, "w" );
1708  if ( !fp || err) {
1709  #else
1710  fp = fopen( filename, "w" );
1711  if ( !fp) {
1712  #endif
1714  return errorID;
1715  }
1716  SaveFile(fp, compact);
1717  fclose( fp );
1718  return errorID;
1719 }
void SetError(int error, const char *str1, const char *str2)
int SaveFile(const char *filename, bool compact=false)
int XMLDocument::SaveFile ( FILE *  fp,
bool  compact = false 
)
inline

Save the XML file to disk. You are responsible for providing and closing the FILE*.

Returns XML_NO_ERROR (0) on success, or an errorID.

Definition at line 1723 of file tinyxml2_imp.h.

References errorID, and Print().

1724 {
1725  XMLPrinter stream( fp, compact );
1726  Print( &stream );
1727  return errorID;
1728 }
void Print(XMLPrinter *streamer=0)
void tinyxml2::XMLDocument::SetBOM ( bool  useBOM)
inline

Sets whether to write the BOM when writing the file.

Definition at line 1124 of file tinyxml2.h.

References writeBOM.

1124 { writeBOM = useBOM; }
void XMLDocument::SetError ( int  error,
const char *  str1,
const char *  str2 
)
inline
void XMLNode::SetValue ( const char *  val,
bool  staticMem = false 
)
inlineinherited

Set the Value of an XML node.

See also
Value()

Definition at line 619 of file tinyxml2_imp.h.

References tinyxml2::StrPair::SetInternedStr(), tinyxml2::StrPair::SetStr(), and tinyxml2::XMLNode::value.

Referenced by NewComment(), NewDeclaration(), NewText(), NewUnknown(), and tinyxml2::XMLElement::SetName().

620 {
621  if ( staticMem )
622  value.SetInternedStr( str );
623  else
624  value.SetStr( str );
625 }
void SetStr(const char *str, int flags=0)
Definition: tinyxml2_imp.h:108
void SetInternedStr(const char *str)
Definition: tinyxml2.h:145
virtual XMLNode* tinyxml2::XMLDocument::ShallowClone ( XMLDocument document) const
inlinevirtual

Make a copy of this node, but not its children. You may pass in a Document pointer that will be the owner of the new Node. If the 'document' is null, then the node returned will be allocated from the current Document. (this->GetDocument())

Note: if called on a XMLDocument, this will return null.

Implements tinyxml2::XMLNode.

Definition at line 1208 of file tinyxml2.h.

1208 { return 0; }
virtual bool tinyxml2::XMLDocument::ShallowEqual ( const XMLNode compare) const
inlinevirtual

Test if 2 nodes are the same, but don't test children. The 2 nodes do not need to be in the same Document.

Note: if called on a XMLDocument, this will return false.

Implements tinyxml2::XMLNode.

Definition at line 1209 of file tinyxml2.h.

1209 { return false; }
virtual XMLComment* tinyxml2::XMLNode::ToComment ( )
inlinevirtualinherited

Safely cast to a Comment, or null.

Reimplemented in tinyxml2::XMLComment.

Definition at line 461 of file tinyxml2.h.

Referenced by tinyxml2::XMLComment::ShallowEqual().

virtual const XMLComment* tinyxml2::XMLNode::ToComment ( ) const
inlinevirtualinherited

Reimplemented in tinyxml2::XMLComment.

Definition at line 468 of file tinyxml2.h.

468 { return 0; }
virtual XMLDeclaration* tinyxml2::XMLNode::ToDeclaration ( )
inlinevirtualinherited

Safely cast to a Declaration, or null.

Reimplemented in tinyxml2::XMLDeclaration.

Definition at line 463 of file tinyxml2.h.

Referenced by tinyxml2::XMLDeclaration::ShallowEqual(), tinyxml2::XMLHandle::ToDeclaration(), and tinyxml2::XMLConstHandle::ToDeclaration().

virtual const XMLDeclaration* tinyxml2::XMLNode::ToDeclaration ( ) const
inlinevirtualinherited

Reimplemented in tinyxml2::XMLDeclaration.

Definition at line 470 of file tinyxml2.h.

470 { return 0; }
virtual XMLDocument* tinyxml2::XMLDocument::ToDocument ( )
inlinevirtual

Safely cast to a Document, or null.

Reimplemented from tinyxml2::XMLNode.

Definition at line 1068 of file tinyxml2.h.

1068 { return this; }
virtual const XMLDocument* tinyxml2::XMLDocument::ToDocument ( ) const
inlinevirtual

Reimplemented from tinyxml2::XMLNode.

Definition at line 1069 of file tinyxml2.h.

1069 { return this; }
virtual XMLElement* tinyxml2::XMLNode::ToElement ( )
inlinevirtualinherited

Safely cast to an Element, or null.

Reimplemented in tinyxml2::XMLElement.

Definition at line 459 of file tinyxml2.h.

Referenced by tinyxml2::XMLNode::ParseDeep(), tinyxml2::XMLElement::ShallowEqual(), tinyxml2::XMLHandle::ToElement(), and tinyxml2::XMLConstHandle::ToElement().

virtual const XMLElement* tinyxml2::XMLNode::ToElement ( ) const
inlinevirtualinherited

Reimplemented in tinyxml2::XMLElement.

Definition at line 466 of file tinyxml2.h.

466 { return 0; }
virtual XMLText* tinyxml2::XMLNode::ToText ( )
inlinevirtualinherited
virtual const XMLText* tinyxml2::XMLNode::ToText ( ) const
inlinevirtualinherited

Reimplemented in tinyxml2::XMLText.

Definition at line 467 of file tinyxml2.h.

467 { return 0; }
virtual XMLUnknown* tinyxml2::XMLNode::ToUnknown ( )
inlinevirtualinherited

Safely cast to an Unknown, or null.

Reimplemented in tinyxml2::XMLUnknown.

Definition at line 464 of file tinyxml2.h.

Referenced by tinyxml2::XMLUnknown::ShallowEqual(), tinyxml2::XMLHandle::ToUnknown(), and tinyxml2::XMLConstHandle::ToUnknown().

virtual const XMLUnknown* tinyxml2::XMLNode::ToUnknown ( ) const
inlinevirtualinherited

Reimplemented in tinyxml2::XMLUnknown.

Definition at line 471 of file tinyxml2.h.

471 { return 0; }
const char* tinyxml2::XMLNode::Value ( ) const
inlineinherited
Whitespace tinyxml2::XMLDocument::WhitespaceMode ( ) const
inline

Definition at line 1116 of file tinyxml2.h.

References whitespace.

Referenced by tinyxml2::XMLText::ParseDeep().

1116 { return whitespace; }
Whitespace whitespace
Definition: tinyxml2.h:1219

Friends And Related Function Documentation

friend class XMLElement
friend

Definition at line 1062 of file tinyxml2.h.

Referenced by Identify(), and NewElement().

Member Data Documentation

MemPoolT< sizeof(XMLAttribute) > tinyxml2::XMLDocument::attributePool
private
char* tinyxml2::XMLDocument::charBuffer
private

Definition at line 1222 of file tinyxml2.h.

Referenced by InitDocument(), LoadFile(), Parse(), and ~XMLDocument().

MemPoolT< sizeof(XMLComment) > tinyxml2::XMLDocument::commentPool
private

Definition at line 1227 of file tinyxml2.h.

Referenced by Identify(), NewComment(), NewDeclaration(), NewUnknown(), and ~XMLDocument().

XMLDocument* tinyxml2::XMLNode::document
protectedinherited
MemPoolT< sizeof(XMLElement) > tinyxml2::XMLDocument::elementPool
private

Definition at line 1224 of file tinyxml2.h.

Referenced by Identify(), NewElement(), and ~XMLDocument().

int tinyxml2::XMLDocument::errorID
private

Definition at line 1218 of file tinyxml2.h.

Referenced by Error(), ErrorID(), InitDocument(), LoadFile(), Parse(), PrintError(), SaveFile(), and SetError().

const char* tinyxml2::XMLDocument::errorStr1
private

Definition at line 1220 of file tinyxml2.h.

Referenced by GetErrorStr1(), InitDocument(), PrintError(), and SetError().

const char* tinyxml2::XMLDocument::errorStr2
private

Definition at line 1221 of file tinyxml2.h.

Referenced by GetErrorStr2(), InitDocument(), PrintError(), and SetError().

XMLNode* tinyxml2::XMLNode::firstChild
protectedinherited
XMLNode* tinyxml2::XMLNode::lastChild
protectedinherited
XMLNode* tinyxml2::XMLNode::next
protectedinherited
XMLNode* tinyxml2::XMLNode::parent
protectedinherited
XMLNode* tinyxml2::XMLNode::prev
protectedinherited
bool tinyxml2::XMLDocument::processEntities
private

Definition at line 1217 of file tinyxml2.h.

Referenced by ProcessEntities().

MemPoolT< sizeof(XMLText) > tinyxml2::XMLDocument::textPool
private

Definition at line 1226 of file tinyxml2.h.

Referenced by Identify(), NewText(), and ~XMLDocument().

StrPair tinyxml2::XMLNode::value
mutableprotectedinherited
Whitespace tinyxml2::XMLDocument::whitespace
private

Definition at line 1219 of file tinyxml2.h.

Referenced by WhitespaceMode().

bool tinyxml2::XMLDocument::writeBOM
private

Definition at line 1216 of file tinyxml2.h.

Referenced by HasBOM(), LoadFile(), Parse(), and SetBOM().


The documentation for this class was generated from the following files:

Generated on Thu Jul 7 2016 11:09:52 for antioch-0.4.0 by  doxygen 1.8.8