XMLDocument Class Reference
Inheritance diagram for XMLDocument:
XMLNode

Public Member Functions

 XMLDocument (bool processEntities=true, Whitespace whitespaceMode=PRESERVE_WHITESPACE)
 constructor More...
 
virtual XMLDocumentToDocument ()
 Safely cast to a Document, or null. More...
 
virtual const XMLDocumentToDocument () const
 
XMLError Parse (const char *xml, int nBytes=static_cast< int >(-1))
 
XMLError LoadFile (const char *filename)
 
XMLError LoadFile (FILE *)
 
XMLError SaveFile (const char *filename, bool compact=false)
 
XMLError 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=nullptr) const
 
virtual bool Accept (XMLVisitor *visitor) const
 
XMLElementNewElement (const char *name)
 
XMLCommentNewComment (const char *comment)
 
XMLTextNewText (const char *text)
 
XMLDeclarationNewDeclaration (const char *text=nullptr)
 
XMLUnknownNewUnknown (const char *text)
 
void DeleteNode (XMLNode *node)
 
void ClearError ()
 
bool Error () const
 Return true if there was an error parsing the document. More...
 
XMLError ErrorID () const
 Return the errorID. More...
 
const char * ErrorName () const
 
const char * ErrorStr () const
 
void PrintError () const
 A(trivial) utility function that prints the ErrorStr() to stdout. More...
 
int ErrorLineNum () const
 Return the line where the error occured, or zero if unknown. More...
 
void Clear ()
 Clear the document, resetting it to the initial state. More...
 
void DeepCopy (XMLDocument *target) const
 
char * Identify (char *p, XMLNode **node)
 
void MarkInUse (XMLNode *)
 
virtual XMLNodeShallowClone (XMLDocument *) const
 
virtual bool ShallowEqual (const XMLNode *) const
 
- Public Member Functions inherited from XMLNode
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 XMLTextToText ()
 Safely cast to Text, or null. More...
 
virtual XMLCommentToComment ()
 Safely cast to a Comment, or null. More...
 
virtual XMLDeclarationToDeclaration ()
 Safely cast to a Declaration, or null. More...
 
virtual XMLUnknownToUnknown ()
 Safely cast to an Unknown, or null. More...
 
virtual const XMLElementToElement () const
 
virtual const XMLTextToText () const
 
virtual const XMLCommentToComment () const
 
virtual const XMLDeclarationToDeclaration () const
 
virtual const XMLUnknownToUnknown () const
 
const char * Value () const
 
void SetValue (const char *val, bool staticMem=false)
 
int GetLineNum () const
 Gets the line number the node is in, if the document was parsed from a file. More...
 
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 *name=nullptr) const
 
XMLElementFirstChildElement (const char *name=nullptr)
 
const XMLNodeLastChild () const
 Get the last child node, or null if none exists. More...
 
XMLNodeLastChild ()
 
const XMLElementLastChildElement (const char *name=nullptr) const
 
XMLElementLastChildElement (const char *name=nullptr)
 
const XMLNodePreviousSibling () const
 Get the previous(left) sibling node of this node. More...
 
XMLNodePreviousSibling ()
 
const XMLElementPreviousSiblingElement (const char *name=nullptr) const
 Get the previous(left) sibling element of this node, with an optionally supplied name. More...
 
XMLElementPreviousSiblingElement (const char *name=nullptr)
 
const XMLNodeNextSibling () const
 Get the next(right) sibling node of this node. More...
 
XMLNodeNextSibling ()
 
const XMLElementNextSiblingElement (const char *name=nullptr) const
 Get the next(right) sibling element of this node, with an optionally supplied name. More...
 
XMLElementNextSiblingElement (const char *name=nullptr)
 
XMLNodeInsertEndChild (XMLNode *addThis)
 
XMLNodeLinkEndChild (XMLNode *addThis)
 
XMLNodeInsertFirstChild (XMLNode *addThis)
 
XMLNodeInsertAfterChild (XMLNode *afterThis, XMLNode *addThis)
 
void DeleteChildren ()
 
void DeleteChild (XMLNode *node)
 
XMLNodeDeepClone (XMLDocument *target) const
 
void SetUserData (void *userData)
 
void * GetUserData () const
 

Static Public Member Functions

static const char * ErrorIDToName (XMLError errorID)
 

Private Member Functions

 XMLDocument (const XMLDocument &)
 
void operator= (const XMLDocument &)
 
void Parse ()
 
void SetError (XMLError error, int lineNum, const char *format,...)
 
template<class NodeType , int PoolElementSize>
NodeType * CreateUnlinkedNode (MemPoolT< PoolElementSize > &pool)
 

Private Attributes

bool _writeBOM
 
bool _processEntities
 
XMLError _errorID
 
Whitespace _whitespaceMode
 
StrPair _errorStr
 
int _errorLineNum
 
char * _charBuffer
 
int _parseCurLineNum
 
DynArray< XMLNode *, 10 > _unlinked
 
MemPoolT< sizeof(XMLElement) > _elementPool
 
MemPoolT< sizeof(XMLAttribute) > _attributePool
 
MemPoolT< sizeof(XMLText) > _textPool
 
MemPoolT< sizeof(XMLComment) > _commentPool
 

Static Private Attributes

static const char * _errorNames [XML_ERROR_COUNT]
 

Friends

class XMLElement
 
class XMLNode
 
class XMLText
 
class XMLComment
 
class XMLDeclaration
 
class XMLUnknown
 

Additional Inherited Members

- Protected Member Functions inherited from XMLNode
 XMLNode (XMLDocument *)
 
virtual char * ParseDeep (char *p, StrPair *parentEndTag, int *curLineNumPtr)
 
- Protected Attributes inherited from XMLNode
XMLDocument_document
 
XMLNode_parent
 
StrPair _value
 
int _parseLineNum
 
XMLNode_firstChild
 
XMLNode_lastChild
 
XMLNode_prev
 
XMLNode_next
 
void * _userData
 

Detailed Description

Definition at line 1652 of file tinyxml2.h.

Constructor & Destructor Documentation

◆ XMLDocument()

XMLDocument ( bool  processEntities = true,
Whitespace  whitespaceMode = PRESERVE_WHITESPACE 
)

constructor

Definition at line 2190 of file tinyxml2.cpp.

◆ ~XMLDocument()

Definition at line 2211 of file tinyxml2.cpp.

Member Function Documentation

◆ Accept()

bool Accept ( XMLVisitor visitor) const
virtual

Implements XMLNode.

Definition at line 795 of file tinyxml2.cpp.

◆ Clear()

void Clear ( )

Clear the document, resetting it to the initial state.

Definition at line 2232 of file tinyxml2.cpp.

◆ ClearError()

void ClearError ( )
inline

Definition at line 1814 of file tinyxml2.h.

◆ CreateUnlinkedNode()

NodeType * CreateUnlinkedNode ( MemPoolT< PoolElementSize > &  pool)
inlineprivate

Definition at line 1903 of file tinyxml2.h.

◆ DeepCopy()

void DeepCopy ( XMLDocument target) const

Definition at line 2267 of file tinyxml2.cpp.

◆ DeleteNode()

void DeleteNode ( XMLNode node)

Definition at line 2338 of file tinyxml2.cpp.

◆ Error()

bool Error ( ) const
inline

Return true if there was an error parsing the document.

Definition at line 1819 of file tinyxml2.h.

◆ ErrorID()

XMLError ErrorID ( ) const
inline

Return the errorID.

Definition at line 1823 of file tinyxml2.h.

◆ ErrorIDToName()

const char * ErrorIDToName ( XMLError  errorID)
static

Definition at line 2550 of file tinyxml2.cpp.

◆ ErrorLineNum()

int ErrorLineNum ( ) const
inline

Return the line where the error occured, or zero if unknown.

Definition at line 1838 of file tinyxml2.h.

◆ ErrorName()

const char * ErrorName ( ) const

Definition at line 2569 of file tinyxml2.cpp.

◆ ErrorStr()

const char * ErrorStr ( ) const

Definition at line 2558 of file tinyxml2.cpp.

◆ HasBOM()

bool HasBOM ( ) const
inline

Definition at line 1734 of file tinyxml2.h.

◆ Identify()

char * Identify ( char *  p,
XMLNode **  node 
)

Definition at line 718 of file tinyxml2.cpp.

◆ LoadFile() [1/2]

XMLError LoadFile ( const char *  filename)

Definition at line 2359 of file tinyxml2.cpp.

◆ LoadFile() [2/2]

XMLError LoadFile ( FILE *  fp)

Definition at line 2398 of file tinyxml2.cpp.

◆ MarkInUse()

void MarkInUse ( XMLNode node)

Definition at line 2217 of file tinyxml2.cpp.

◆ NewComment()

XMLComment * NewComment ( const char *  comment)

Definition at line 2290 of file tinyxml2.cpp.

◆ NewDeclaration()

XMLDeclaration * NewDeclaration ( const char *  text = nullptr)

Definition at line 2306 of file tinyxml2.cpp.

◆ NewElement()

XMLElement * NewElement ( const char *  name)

Definition at line 2282 of file tinyxml2.cpp.

◆ NewText()

XMLText * NewText ( const char *  text)

Definition at line 2298 of file tinyxml2.cpp.

◆ NewUnknown()

XMLUnknown * NewUnknown ( const char *  text)

Definition at line 2314 of file tinyxml2.cpp.

◆ Parse() [1/2]

void Parse ( )
private

Definition at line 2574 of file tinyxml2.cpp.

◆ Parse() [2/2]

XMLError Parse ( const char *  xml,
int  nBytes = static_cast<int>(-1) 
)

Definition at line 2474 of file tinyxml2.cpp.

◆ Print()

void Print ( XMLPrinter streamer = nullptr) const

Definition at line 2508 of file tinyxml2.cpp.

◆ PrintError()

void PrintError ( ) const

A(trivial) utility function that prints the ErrorStr() to stdout.

Definition at line 2564 of file tinyxml2.cpp.

◆ ProcessEntities()

bool ProcessEntities ( ) const
inline

Definition at line 1724 of file tinyxml2.h.

◆ RootElement() [1/2]

XMLElement * RootElement ( )
inline

Definition at line 1747 of file tinyxml2.h.

◆ RootElement() [2/2]

const XMLElement * RootElement ( ) const
inline

Definition at line 1750 of file tinyxml2.h.

◆ SaveFile() [1/2]

XMLError SaveFile ( const char *  filename,
bool  compact = false 
)

Definition at line 2449 of file tinyxml2.cpp.

◆ SaveFile() [2/2]

XMLError SaveFile ( FILE *  fp,
bool  compact = false 
)

Definition at line 2463 of file tinyxml2.cpp.

◆ SetBOM()

void SetBOM ( bool  useBOM)
inline

Definition at line 1740 of file tinyxml2.h.

◆ SetError()

void SetError ( XMLError  error,
int  lineNum,
const char *  format,
  ... 
)
private

Definition at line 2522 of file tinyxml2.cpp.

◆ ShallowClone()

virtual XMLNode * ShallowClone ( XMLDocument ) const
inlinevirtual

Implements XMLNode.

Definition at line 1860 of file tinyxml2.h.

◆ ShallowEqual()

virtual bool ShallowEqual ( const XMLNode ) const
inlinevirtual

Implements XMLNode.

Definition at line 1863 of file tinyxml2.h.

◆ ToDocument() [1/2]

virtual XMLDocument * ToDocument ( )
inlinevirtual

Safely cast to a Document, or null.

Reimplemented from XMLNode.

Definition at line 1667 of file tinyxml2.h.

◆ ToDocument() [2/2]

virtual const XMLDocument * ToDocument ( ) const
inlinevirtual

Reimplemented from XMLNode.

Definition at line 1671 of file tinyxml2.h.

◆ WhitespaceMode()

Whitespace WhitespaceMode ( ) const
inline

Definition at line 1727 of file tinyxml2.h.

Friends And Related Function Documentation

◆ XMLComment

friend class XMLComment
friend

Definition at line 1659 of file tinyxml2.h.

◆ XMLDeclaration

friend class XMLDeclaration
friend

Definition at line 1660 of file tinyxml2.h.

◆ XMLElement

friend class XMLElement
friend

Definition at line 1654 of file tinyxml2.h.

◆ XMLNode

friend class XMLNode
friend

Definition at line 1657 of file tinyxml2.h.

◆ XMLText

friend class XMLText
friend

Definition at line 1658 of file tinyxml2.h.

◆ XMLUnknown

friend class XMLUnknown
friend

Definition at line 1661 of file tinyxml2.h.

Member Data Documentation

◆ _attributePool

MemPoolT< sizeof(XMLAttribute) > _attributePool
private

Definition at line 1888 of file tinyxml2.h.

◆ _charBuffer

char* _charBuffer
private

Definition at line 1877 of file tinyxml2.h.

◆ _commentPool

MemPoolT< sizeof(XMLComment) > _commentPool
private

Definition at line 1890 of file tinyxml2.h.

◆ _elementPool

MemPoolT< sizeof(XMLElement) > _elementPool
private

Definition at line 1887 of file tinyxml2.h.

◆ _errorID

XMLError _errorID
private

Definition at line 1873 of file tinyxml2.h.

◆ _errorLineNum

int _errorLineNum
private

Definition at line 1876 of file tinyxml2.h.

◆ _errorNames

const char * _errorNames
staticprivate
Initial value:
=
{
"XML_SUCCESS",
"XML_NO_ATTRIBUTE",
"XML_WRONG_ATTRIBUTE_TYPE",
"XML_ERROR_FILE_NOT_FOUND",
"XML_ERROR_FILE_COULD_NOT_BE_OPENED",
"XML_ERROR_FILE_READ_ERROR",
"UNUSED_XML_ERROR_ELEMENT_MISMATCH",
"XML_ERROR_PARSING_ELEMENT",
"XML_ERROR_PARSING_ATTRIBUTE",
"UNUSED_XML_ERROR_IDENTIFYING_TAG",
"XML_ERROR_PARSING_TEXT",
"XML_ERROR_PARSING_CDATA",
"XML_ERROR_PARSING_COMMENT",
"XML_ERROR_PARSING_DECLARATION",
"XML_ERROR_PARSING_UNKNOWN",
"XML_ERROR_EMPTY_DOCUMENT",
"XML_ERROR_MISMATCHED_ELEMENT",
"XML_ERROR_PARSING",
"XML_CAN_NOT_CONVERT_TEXT",
"XML_NO_TEXT_NODE"
}

Definition at line 1892 of file tinyxml2.h.

◆ _errorStr

StrPair _errorStr
mutableprivate

Definition at line 1875 of file tinyxml2.h.

◆ _parseCurLineNum

int _parseCurLineNum
private

Definition at line 1878 of file tinyxml2.h.

◆ _processEntities

bool _processEntities
private

Definition at line 1872 of file tinyxml2.h.

◆ _textPool

MemPoolT< sizeof(XMLText) > _textPool
private

Definition at line 1889 of file tinyxml2.h.

◆ _unlinked

DynArray<XMLNode*, 10> _unlinked
private

Definition at line 1885 of file tinyxml2.h.

◆ _whitespaceMode

Whitespace _whitespaceMode
private

Definition at line 1874 of file tinyxml2.h.

◆ _writeBOM

bool _writeBOM
private

Definition at line 1871 of file tinyxml2.h.


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