aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
TiXmlDocument Class Reference

Always the top level node. More...

#include <tinyxml.h>

Inheritance diagram for TiXmlDocument:
Collaboration diagram for TiXmlDocument:

Public Types

enum  NodeType {
  DOCUMENT , ELEMENT , COMMENT , UNKNOWN ,
  TEXT , DECLARATION , STYLESHEETREFERENCE , TYPECOUNT
}
 The types of XML nodes supported by TinyXml. More...
enum  {
  TIXML_NO_ERROR = 0 , TIXML_ERROR , TIXML_ERROR_OPENING_FILE , TIXML_ERROR_OUT_OF_MEMORY ,
  TIXML_ERROR_PARSING_ELEMENT , TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME , TIXML_ERROR_READING_ELEMENT_VALUE , TIXML_ERROR_READING_ATTRIBUTES ,
  TIXML_ERROR_PARSING_EMPTY , TIXML_ERROR_READING_END_TAG , TIXML_ERROR_PARSING_UNKNOWN , TIXML_ERROR_PARSING_COMMENT ,
  TIXML_ERROR_PARSING_DECLARATION , TIXML_ERROR_DOCUMENT_EMPTY , TIXML_ERROR_EMBEDDED_nullptr , TIXML_ERROR_PARSING_CDATA ,
  TIXML_ERROR_DOCUMENT_TOP_ONLY , TIXML_ERROR_STRING_COUNT
}

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
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 TiXmlDocumentToDocument () 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.
const char * Value () const
 The meaning of 'value' changes for the specific type of TiXmlNode.
const std::string & ValueStr () const
 Return Value() as a std::string.
const TIXML_STRINGValueTStr () const
void SetValue (const char *_value)
 Changes the value of the node.
void SetValue (const std::string &_value)
 STL std::string form.
void Clear ()
 Delete all the children of this node. Does not affect 'this'.
TiXmlNodeParent ()
 One step up the DOM.
const TiXmlNodeParent () const
const TiXmlNodeFirstChild () const
 The first child of this node. Will be null if there are no children.
TiXmlNodeFirstChild ()
const TiXmlNodeFirstChild (const char *value) const
 The first child of this node with the matching 'value'. Will be null if none found. The first child of this node with the matching 'value'. Will be null if none found.
TiXmlNodeFirstChild (const char *_value)
const TiXmlNodeFirstChild (const std::string &_value) const
 STL std::string form.
TiXmlNodeFirstChild (const std::string &_value)
 STL std::string form.
const TiXmlNodeLastChild () const
TiXmlNodeLastChild ()
 The last child of this node. Will be null if there are no children.
const TiXmlNodeLastChild (const char *value) const
TiXmlNodeLastChild (const char *_value)
 The last child of this node matching 'value'. Will be null if there are no children.
const TiXmlNodeLastChild (const std::string &_value) const
 STL std::string form.
TiXmlNodeLastChild (const std::string &_value)
 STL std::string form.
const TiXmlNodeIterateChildren (const TiXmlNode *previous) const
 An alternate way to walk the children of a node.
TiXmlNodeIterateChildren (const TiXmlNode *previous)
const TiXmlNodeIterateChildren (const char *value, const TiXmlNode *previous) const
 This flavor of IterateChildren searches for children with a particular 'value'.
TiXmlNodeIterateChildren (const char *_value, const TiXmlNode *previous)
const TiXmlNodeIterateChildren (const std::string &_value, const TiXmlNode *previous) const
 STL std::string form.
TiXmlNodeIterateChildren (const std::string &_value, const TiXmlNode *previous)
 STL std::string form.
TiXmlNodeInsertEndChild (const TiXmlNode &addThis)
 Add a new node related to this.
TiXmlNodeLinkEndChild (TiXmlNode *addThis)
 Add a new node related to this.
TiXmlNodeInsertBeforeChild (TiXmlNode *beforeThis, const TiXmlNode &addThis)
 Add a new node related to this.
TiXmlNodeInsertAfterChild (TiXmlNode *afterThis, const TiXmlNode &addThis)
 Add a new node related to this.
TiXmlNodeReplaceChild (TiXmlNode *replaceThis, const TiXmlNode &withThis)
 Replace a child of this node.
bool RemoveChild (TiXmlNode *removeThis)
 Delete a child of this node.
const TiXmlNodePreviousSibling () const
 Navigate to a sibling node.
TiXmlNodePreviousSibling ()
const TiXmlNodePreviousSibling (const char *) const
 Navigate to a sibling node.
TiXmlNodePreviousSibling (const char *_prev)
const TiXmlNodePreviousSibling (const std::string &_value) const
 STL std::string form.
TiXmlNodePreviousSibling (const std::string &_value)
 STL std::string form.
const TiXmlNodeNextSibling (const std::string &_value) const
 STL std::string form.
TiXmlNodeNextSibling (const std::string &_value)
 STL std::string form.
const TiXmlNodeNextSibling () const
 Navigate to a sibling node.
TiXmlNodeNextSibling ()
const TiXmlNodeNextSibling (const char *) const
 Navigate to a sibling node with the given 'value'.
TiXmlNodeNextSibling (const char *_next)
const TiXmlElementNextSiblingElement () const
 Convenience function to get through elements.
TiXmlElementNextSiblingElement ()
const TiXmlElementNextSiblingElement (const char *) const
 Convenience function to get through elements.
TiXmlElementNextSiblingElement (const char *_next)
const TiXmlElementNextSiblingElement (const std::string &_value) const
 STL std::string form.
TiXmlElementNextSiblingElement (const std::string &_value)
 STL std::string form.
const TiXmlElementFirstChildElement () const
 Convenience function to get through elements.
TiXmlElementFirstChildElement ()
const TiXmlElementFirstChildElement (const char *_value) const
 Convenience function to get through elements.
TiXmlElementFirstChildElement (const char *_value)
const TiXmlElementFirstChildElement (const std::string &_value) const
 STL std::string form.
TiXmlElementFirstChildElement (const std::string &_value)
 STL std::string form.
int Type () const
 Query the type (as an enumerated value, above) of this node.
const TiXmlDocumentGetDocument () const
 Return a pointer to the Document this node lives in.
TiXmlDocumentGetDocument ()
bool NoChildren () const
 Returns true if this node has no children.
virtual const TiXmlElementToElement () const
 Cast to a more defined type. Will return null if not of the requested type.
virtual TiXmlElementToElement ()
 Cast to a more defined type. Will return null if not of the requested type.
virtual const TiXmlCommentToComment () const
 Cast to a more defined type. Will return null if not of the requested type.
virtual TiXmlCommentToComment ()
 Cast to a more defined type. Will return null if not of the requested type.
virtual const TiXmlUnknownToUnknown () const
 Cast to a more defined type. Will return null if not of the requested type.
virtual TiXmlUnknownToUnknown ()
 Cast to a more defined type. Will return null if not of the requested type.
virtual const TiXmlTextToText () const
 Cast to a more defined type. Will return null if not of the requested type.
virtual TiXmlTextToText ()
 Cast to a more defined type. Will return null if not of the requested type.
virtual const TiXmlDeclarationToDeclaration () const
 Cast to a more defined type. Will return null if not of the requested type.
virtual TiXmlDeclarationToDeclaration ()
 Cast to a more defined type. Will return null if not of the requested type.
virtual const TiXmlStylesheetReferenceToStylesheetReference () const
 Cast to a more defined type. Will return null if not of the requested type.
virtual TiXmlStylesheetReferenceToStylesheetReference ()
 Cast to a more defined type. Will return null if not of the requested type.
int Row () const
 Return the position, in the original source file, of this node or attribute.
int Column () const
 See Row().
void SetUserData (void *user)
 Set a pointer to arbitrary user data.
void * GetUserData ()
 Get a pointer to arbitrary user data.
const void * GetUserData () const
 Get a pointer to arbitrary user data.
void DeleteSpawnedWrappers ()
 Delete all container objects we've spawned with 'new'.

Static Public Member Functions

static void SetCondenseWhiteSpace (bool condense)
 The world does not agree on whether white space should be kept or not.
static bool IsWhiteSpaceCondensed ()
 Return the current white space setting.
static void EncodeString (const TIXML_STRING &str, TIXML_STRING *out)
 Expands entities in a string.

Public Attributes

std::vector< ticpp::Base * > m_spawnedWrappers
 Remember all wrappers that we've created with 'new' - ( e.g.

Static Public Attributes

static const int utf8ByteTable [256]

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)
void CopyTo (TiXmlNode *target) const
TiXmlNodeIdentify (const char *start, TiXmlEncoding encoding)

Static Protected Member Functions

static const char * SkipWhiteSpace (const char *, TiXmlEncoding encoding)
static bool IsWhiteSpace (char c)
static bool IsWhiteSpace (int c)
static bool StreamWhiteSpace (std::istream *in, TIXML_STRING *tag)
static bool StreamTo (std::istream *in, int character, TIXML_STRING *tag)
static const char * ReadName (const char *p, TIXML_STRING *name, TiXmlEncoding encoding)
static const char * ReadText (const char *in, TIXML_STRING *text, bool ignoreWhiteSpace, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
static const char * GetEntity (const char *in, char *value, int *length, TiXmlEncoding encoding)
static const char * GetChar (const char *p, char *_value, int *length, TiXmlEncoding encoding)
static bool StringEqual (const char *p, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
static int IsAlpha (unsigned char anyByte, TiXmlEncoding encoding)
static int IsAlphaNum (unsigned char anyByte, TiXmlEncoding encoding)
static int ToLower (int v, TiXmlEncoding encoding)
static void ConvertUTF32ToUTF8 (unsigned long input, char *output, int *length)

Protected Attributes

TiXmlNodeparent
NodeType type
TiXmlNodefirstChild
TiXmlNodelastChild
TIXML_STRING value
TiXmlNodeprev
TiXmlNodenext
TiXmlCursor location
void * userData
 Field containing a generic user pointer.

Static Protected Attributes

static const char * errorString [TIXML_ERROR_STRING_COUNT]

Private Types

enum  { NUM_ENTITY = 5 , MAX_ENTITY_LENGTH = 6 }

Private Member Functions

void CopyTo (TiXmlDocument *target) const

Private Attributes

bool error
int errorId
TIXML_STRING errorDesc
int tabsize
TiXmlCursor errorLocation
bool useMicrosoftBOM
TiCppRCImpm_tiRC
 Pointer to reference counter.

Static Private Attributes

static Entity entity [NUM_ENTITY]
static bool condenseWhiteSpace = true

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 1655 of file tinyxml.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
inherited
Enumerator
TIXML_NO_ERROR 
TIXML_ERROR 
TIXML_ERROR_OPENING_FILE 
TIXML_ERROR_OUT_OF_MEMORY 
TIXML_ERROR_PARSING_ELEMENT 
TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME 
TIXML_ERROR_READING_ELEMENT_VALUE 
TIXML_ERROR_READING_ATTRIBUTES 
TIXML_ERROR_PARSING_EMPTY 
TIXML_ERROR_READING_END_TAG 
TIXML_ERROR_PARSING_UNKNOWN 
TIXML_ERROR_PARSING_COMMENT 
TIXML_ERROR_PARSING_DECLARATION 
TIXML_ERROR_DOCUMENT_EMPTY 
TIXML_ERROR_EMBEDDED_nullptr 
TIXML_ERROR_PARSING_CDATA 
TIXML_ERROR_DOCUMENT_TOP_ONLY 
TIXML_ERROR_STRING_COUNT 

Definition at line 304 of file tinyxml.h.

304 {
305 TIXML_NO_ERROR = 0,
322
324 };
@ TIXML_ERROR_STRING_COUNT
Definition tinyxml.h:323
@ TIXML_ERROR_READING_END_TAG
Definition tinyxml.h:314
@ TIXML_ERROR_PARSING_UNKNOWN
Definition tinyxml.h:315
@ TIXML_ERROR_PARSING_DECLARATION
Definition tinyxml.h:317
@ TIXML_ERROR_PARSING_ELEMENT
Definition tinyxml.h:309
@ TIXML_ERROR_PARSING_EMPTY
Definition tinyxml.h:313
@ TIXML_ERROR_READING_ATTRIBUTES
Definition tinyxml.h:312
@ TIXML_ERROR_DOCUMENT_TOP_ONLY
Definition tinyxml.h:321
@ TIXML_ERROR_PARSING_COMMENT
Definition tinyxml.h:316
@ TIXML_NO_ERROR
Definition tinyxml.h:305
@ TIXML_ERROR_OUT_OF_MEMORY
Definition tinyxml.h:308
@ TIXML_ERROR_PARSING_CDATA
Definition tinyxml.h:320
@ TIXML_ERROR_DOCUMENT_EMPTY
Definition tinyxml.h:318
@ TIXML_ERROR_OPENING_FILE
Definition tinyxml.h:307
@ TIXML_ERROR
Definition tinyxml.h:306
@ TIXML_ERROR_EMBEDDED_nullptr
Definition tinyxml.h:319
@ TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME
Definition tinyxml.h:310
@ TIXML_ERROR_READING_ELEMENT_VALUE
Definition tinyxml.h:311

◆ anonymous enum

anonymous enum
privateinherited
Enumerator
NUM_ENTITY 
MAX_ENTITY_LENGTH 

Definition at line 439 of file tinyxml.h.

439 {
440 NUM_ENTITY = 5,
442
443 };
@ NUM_ENTITY
Definition tinyxml.h:440
@ MAX_ENTITY_LENGTH
Definition tinyxml.h:441

◆ NodeType

enum TiXmlNode::NodeType
inherited

The types of XML nodes supported by TinyXml.

(All the unsupported types are picked up by UNKNOWN.)

Enumerator
DOCUMENT 
ELEMENT 
COMMENT 
UNKNOWN 
TEXT 
DECLARATION 
STYLESHEETREFERENCE 
TYPECOUNT 

Definition at line 492 of file tinyxml.h.

492 {
493 DOCUMENT,
494 ELEMENT,
495 COMMENT,
496 UNKNOWN,
497 TEXT,
501 };
@ TYPECOUNT
Definition tinyxml.h:500
@ STYLESHEETREFERENCE
Definition tinyxml.h:499
@ DECLARATION
Definition tinyxml.h:498

Constructor & Destructor Documentation

◆ TiXmlDocument() [1/4]

TiXmlDocument::TiXmlDocument ( )

Create an empty document, that has no name.

Definition at line 769 of file tinyxml.cpp.

771 tabsize = 4;
772 useMicrosoftBOM = false;
773 ClearError();
774}
friend class TiXmlNode
Definition tinyxml.h:216
bool useMicrosoftBOM
Definition tinyxml.h:1855
void ClearError()
If you have handled the error, it can be reset with this call.
Definition tinyxml.h:1799

References TiXmlNode::TiXmlNode(), ClearError(), TiXmlNode::DOCUMENT, tabsize, and useMicrosoftBOM.

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TiXmlDocument() [2/4]

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 776 of file tinyxml.cpp.

778 tabsize = 4;
779 useMicrosoftBOM = false;
780 value = documentName;
781 ClearError();
782}
TIXML_STRING value
Definition tinyxml.h:898

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

Here is the call graph for this function:

◆ TiXmlDocument() [3/4]

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

Constructor.

Definition at line 785 of file tinyxml.cpp.

787 tabsize = 4;
788 useMicrosoftBOM = false;
789 value = documentName;
790 ClearError();
791}

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

Here is the call graph for this function:

◆ TiXmlDocument() [4/4]

TiXmlDocument::TiXmlDocument ( const TiXmlDocument & copy)

Definition at line 794 of file tinyxml.cpp.

796 copy.CopyTo(this);
797}
void CopyTo(TiXmlDocument *target) const
Definition tinyxml.cpp:998

References TiXmlDocument(), TiXmlNode::TiXmlNode(), CopyTo(), and TiXmlNode::DOCUMENT.

Here is the call graph for this function:

◆ ~TiXmlDocument()

virtual TiXmlDocument::~TiXmlDocument ( )
inlinevirtual

Definition at line 1672 of file tinyxml.h.

1672{}

Member Function Documentation

◆ Accept()

bool TiXmlDocument::Accept ( TiXmlVisitor * content) const
virtual

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

Implements TiXmlNode.

Definition at line 1033 of file tinyxml.cpp.

1033 {
1034 if (visitor->VisitEnter(*this)) {
1035 for (const TiXmlNode* node = FirstChild(); node; node = node->NextSibling()) {
1036 if (!node->Accept(visitor)) break;
1037 }
1038 }
1039
1040 return visitor->VisitExit(*this);
1041}
const TiXmlNode * NextSibling(const std::string &_value) const
STL std::string form.
Definition tinyxml.h:695
const TiXmlNode * FirstChild() const
The first child of this node. Will be null if there are no children.
Definition tinyxml.h:552

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

Here is the call graph for this function:

◆ Clear()

void TiXmlNode::Clear ( )
inherited

Delete all the children of this node. Does not affect 'this'.

Definition at line 139 of file tinyxml.cpp.

139 {
140 TiXmlNode* node = firstChild;
141 TiXmlNode* temp = 0;
142
143 while (node) {
144 temp = node;
145 node = node->next;
146 delete temp;
147 }
148
149 firstChild = 0;
150 lastChild = 0;
151}
TiXmlNode * next
Definition tinyxml.h:901
TiXmlNode(NodeType _type)
Definition tinyxml.cpp:113
TiXmlNode * lastChild
Definition tinyxml.h:896
TiXmlNode * firstChild
Definition tinyxml.h:895

References TiXmlNode(), firstChild, lastChild, and next.

Referenced by ticpp::Node::Clear(), TiXmlElement::ClearThis(), TiXmlDocument::LoadFile(), TiXmlComment::operator=(), TiXmlDeclaration::operator=(), TiXmlDocument::operator=(), and TiXmlStylesheetReference::operator=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClearError()

void 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 1799 of file tinyxml.h.

1799 {
1800 error = false;
1801 errorId = 0;
1802 errorDesc = "";
1803 errorLocation.row = errorLocation.col = 0;
1804 // errorLocation.last = 0;
1805 }
TIXML_STRING errorDesc
Definition tinyxml.h:1852
TiXmlCursor errorLocation
Definition tinyxml.h:1854

References error, errorDesc, errorId, and errorLocation.

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

Here is the caller graph for this function:

◆ Clone()

TiXmlNode * TiXmlDocument::Clone ( ) const
protectedvirtual

Create an exact duplicate of this node and return it.

The memory must be deleted by the caller.

Implements TiXmlNode.

Definition at line 1015 of file tinyxml.cpp.

1015 {
1016 TiXmlDocument* clone = new TiXmlDocument();
1017
1018 if (!clone) return 0;
1019
1020 CopyTo(clone);
1021 return clone;
1022}
TiXmlDocument()
Create an empty document, that has no name.
Definition tinyxml.cpp:769

References TiXmlDocument(), TiXmlNode::TiXmlNode(), and CopyTo().

Here is the call graph for this function:

◆ Column()

int TiXmlBase::Column ( ) const
inlineinherited

See Row().

Definition at line 276 of file tinyxml.h.

References location.

Referenced by ticpp::Base::Column().

Here is the caller graph for this function:

◆ ConvertUTF32ToUTF8()

void TiXmlBase::ConvertUTF32ToUTF8 ( unsigned long input,
char * output,
int * length )
staticprotectedinherited

Definition at line 100 of file tinyxmlparser.cpp.

102 {
103 const unsigned long BYTE_MASK = 0xBF;
104 const unsigned long BYTE_MARK = 0x80;
105 const unsigned long FIRST_BYTE_MARK[7] = {
106 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC};
107
108 if (input < 0x80)
109 *length = 1;
110 else if (input < 0x800)
111 *length = 2;
112 else if (input < 0x10000)
113 *length = 3;
114 else if (input < 0x200000)
115 *length = 4;
116 else {
117 *length = 0;
118 return;
119 } // This code won't covert this correctly anyway.
120
121 output += *length;
122
123 // Scary scary fall throughs.
124 switch (*length) {
125 case 4:
126 --output;
127 *output = (char)((input | BYTE_MARK) & BYTE_MASK);
128 input >>= 6;
129
130 case 3:
131 --output;
132 *output = (char)((input | BYTE_MARK) & BYTE_MASK);
133 input >>= 6;
134
135 case 2:
136 --output;
137 *output = (char)((input | BYTE_MARK) & BYTE_MASK);
138 input >>= 6;
139
140 case 1:
141 --output;
142 *output = (char)(input | FIRST_BYTE_MARK[*length]);
143 }
144}

Referenced by GetEntity().

Here is the caller graph for this function:

◆ CopyTo() [1/2]

void TiXmlDocument::CopyTo ( TiXmlDocument * target) const
private

Definition at line 998 of file tinyxml.cpp.

998 {
999 TiXmlNode::CopyTo(target);
1000
1001 target->error = error;
1002 target->errorId = errorId;
1003 target->errorDesc = errorDesc;
1004 target->tabsize = tabsize;
1005 target->errorLocation = errorLocation;
1007
1008 TiXmlNode* node = 0;
1009
1010 for (node = firstChild; node; node = node->NextSibling()) {
1011 target->LinkEndChild(node->Clone());
1012 }
1013}
TiXmlNode * LinkEndChild(TiXmlNode *addThis)
Add a new node related to this.
Definition tinyxml.cpp:153
virtual TiXmlNode * Clone() const =0
Create an exact duplicate of this node and return it.
void CopyTo(TiXmlNode *target) const
Definition tinyxml.cpp:134

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CopyTo() [2/2]

void TiXmlNode::CopyTo ( TiXmlNode * target) const
protectedinherited

Definition at line 134 of file tinyxml.cpp.

134 {
135 target->SetValue(value.c_str());
136 target->userData = userData;
137}
void * userData
Field containing a generic user pointer.
Definition tinyxml.h:413
void SetValue(const char *_value)
Changes the value of the node.
Definition tinyxml.h:538

References TiXmlNode(), SetValue(), TiXmlBase::userData, and value.

Referenced by TiXmlComment::CopyTo(), TiXmlDeclaration::CopyTo(), TiXmlDocument::CopyTo(), TiXmlElement::CopyTo(), TiXmlStylesheetReference::CopyTo(), TiXmlText::CopyTo(), and TiXmlUnknown::CopyTo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DeleteSpawnedWrappers()

void TiCppRC::DeleteSpawnedWrappers ( )
inherited

Delete all container objects we've spawned with 'new'.

Definition at line 929 of file ticpp.cpp.

929 {
930 std::vector< Base* >::reverse_iterator wrapper;
931
932 for (wrapper = m_spawnedWrappers.rbegin(); wrapper != m_spawnedWrappers.rend();
933 ++wrapper) {
934 delete *wrapper;
935 }
936
937 m_spawnedWrappers.clear();
938}
std::vector< ticpp::Base * > m_spawnedWrappers
Remember all wrappers that we've created with 'new' - ( e.g.
Definition ticpprc.h:63

References m_spawnedWrappers.

◆ EncodeString()

void TiXmlBase::EncodeString ( const TIXML_STRING & str,
TIXML_STRING * out )
staticinherited

Expands entities in a string.

Note this should not contian the tag's '<', '>', etc, or they will be transformed into entities!

Definition at line 50 of file tinyxml.cpp.

50 {
51 int i = 0;
52
53 while (i < (int)str.length()) {
54 unsigned char c = (unsigned char)str[i];
55
56 if (c == '&' && i < ((int)str.length() - 2) && str[i + 1] == '#' &&
57 str[i + 2] == 'x') {
58 // Hexadecimal character reference.
59 // Pass through unchanged.
60 // &#xA9; -- copyright symbol, for example.
61 //
62 // The -1 is a bug fix from Rob Laveaux. It keeps
63 // an overflow from happening if there is no ';'.
64 // There are actually 2 ways to exit this loop -
65 // while fails (error case) and break (semicolon found).
66 // However, there is no mechanism (currently) for
67 // this function to return an error.
68 while (i < (int)str.length() - 1) {
69 outString->append(str.c_str() + i, 1);
70 ++i;
71
72 if (str[i] == ';') break;
73 }
74 } else if (c == '&') {
75 outString->append(entity[0].str, entity[0].strLength);
76 ++i;
77 } else if (c == '<') {
78 outString->append(entity[1].str, entity[1].strLength);
79 ++i;
80 } else if (c == '>') {
81 outString->append(entity[2].str, entity[2].strLength);
82 ++i;
83 } else if (c == '\"') {
84 outString->append(entity[3].str, entity[3].strLength);
85 ++i;
86 } else if (c == '\'') {
87 outString->append(entity[4].str, entity[4].strLength);
88 ++i;
89 } else if (c < 32) {
90 // Easy pass at non-alpha/numeric/symbol
91 // Below 32 is symbolic.
92 char buf[32];
93
94#if defined(TIXML_SNPRINTF)
95 TIXML_SNPRINTF(buf, sizeof(buf), "&#x%02X;", (unsigned)(c & 0xff));
96#else
97 snprintf(buf, 32, "&#x%02X;", (unsigned)(c & 0xff));
98#endif
99
100 //*ME: warning C4267: convert 'size_t' to 'int'
101 //*ME: Int-Cast to make compiler happy ...
102 outString->append(buf, (int)strlen(buf));
103 ++i;
104 } else {
105 // char realc = (char) c;
106 // outString->append( &realc, 1 );
107 *outString += (char)c; // somewhat more efficient function call.
108 ++i;
109 }
110 }
111}
static Entity entity[NUM_ENTITY]
Definition tinyxml.h:44

References entity, and TIXML_STRING.

Referenced by TiXmlAttribute::Print(), TiXmlText::Print(), and TiXmlPrinter::Visit().

Here is the caller graph for this function:

◆ Error()

bool TiXmlDocument::Error ( ) const
inline

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

Also,

  • The ErrorId() will contain the integer identifier of the error (not generally useful)
  • The ErrorDesc() method will return the name of the error. (very useful)
  • The ErrorRow() and ErrorCol() will return the location of the error (if known)

Definition at line 1740 of file tinyxml.h.

1740{ return error; }

References error.

Referenced by ticpp::Base::BuildDetailedErrorString(), and LoadFile().

Here is the caller graph for this function:

◆ ErrorCol()

int TiXmlDocument::ErrorCol ( ) const
inline

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

Definition at line 1762 of file tinyxml.h.

References errorLocation.

Referenced by ticpp::Base::BuildDetailedErrorString().

Here is the caller graph for this function:

◆ ErrorDesc()

const char * TiXmlDocument::ErrorDesc ( ) const
inline

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

Definition at line 1743 of file tinyxml.h.

1743{ return errorDesc.c_str(); }

References errorDesc.

Referenced by ticpp::Base::BuildDetailedErrorString().

Here is the caller graph for this function:

◆ ErrorId()

int 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 1748 of file tinyxml.h.

1748{ return errorId; }

References errorId.

◆ ErrorRow()

int 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 1761 of file tinyxml.h.

1761{ return errorLocation.row + 1; }

References errorLocation.

Referenced by ticpp::Base::BuildDetailedErrorString().

Here is the caller graph for this function:

◆ FirstChild() [1/6]

TiXmlNode * TiXmlNode::FirstChild ( )
inlineinherited

Definition at line 555 of file tinyxml.h.

555{ return firstChild; }

References TiXmlNode(), and firstChild.

Here is the call graph for this function:

◆ FirstChild() [2/6]

const TiXmlNode * TiXmlNode::FirstChild ( ) const
inlineinherited

The first child of this node. Will be null if there are no children.

Definition at line 552 of file tinyxml.h.

References TiXmlNode(), and firstChild.

Referenced by TiXmlDocument::Accept(), TiXmlElement::Accept(), ticpp::Node::FirstChild(), FirstChild(), FirstChild(), FirstChildElement(), FirstChildElement(), TiXmlElement::GetText(), IterateChildren(), IterateChildren(), TiXmlDocument::Print(), TiXmlPrinter::VisitEnter(), and TiXmlPrinter::VisitExit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FirstChild() [3/6]

TiXmlNode * TiXmlNode::FirstChild ( const char * _value)
inlineinherited

Definition at line 564 of file tinyxml.h.

564 {
565 // Call through to the const version - safe since nothing is changed.
566 // Exiting
567 // syntax: cast this to a const (always safe)
568 // call the method, cast the return back to non-const.
569 return const_cast< TiXmlNode* >(
570 (const_cast< const TiXmlNode* >(this))->FirstChild(_value));
571 }

References TiXmlNode().

Here is the call graph for this function:

◆ FirstChild() [4/6]

const TiXmlNode * TiXmlNode::FirstChild ( const char * value) const
inherited

The first child of this node with the matching 'value'. Will be null if none found. The first child of this node with the matching 'value'. Will be null if none found.

Definition at line 311 of file tinyxml.cpp.

311 {
312 const TiXmlNode* node;
313
314 for (node = firstChild; node; node = node->next) {
315 if (strcmp(node->Value(), _value) == 0) return node;
316 }
317
318 return 0;
319}
const char * Value() const
The meaning of 'value' changes for the specific type of TiXmlNode.
Definition tinyxml.h:517

References TiXmlNode(), firstChild, next, and Value().

Here is the call graph for this function:

◆ FirstChild() [5/6]

TiXmlNode * TiXmlNode::FirstChild ( const std::string & _value)
inlineinherited

STL std::string form.

Definition at line 590 of file tinyxml.h.

References TiXmlNode(), and FirstChild().

Here is the call graph for this function:

◆ FirstChild() [6/6]

const TiXmlNode * TiXmlNode::FirstChild ( const std::string & _value) const
inlineinherited

STL std::string form.

Definition at line 587 of file tinyxml.h.

References TiXmlNode(), and FirstChild().

Here is the call graph for this function:

◆ FirstChildElement() [1/6]

TiXmlElement * TiXmlNode::FirstChildElement ( )
inlineinherited

Definition at line 745 of file tinyxml.h.

745 {
746 return const_cast< TiXmlElement* >(
747 (const_cast< const TiXmlNode* >(this))->FirstChildElement());
748 }
friend class TiXmlElement
Definition tinyxml.h:456

References TiXmlNode(), and TiXmlElement.

Here is the call graph for this function:

◆ FirstChildElement() [2/6]

const TiXmlElement * TiXmlNode::FirstChildElement ( ) const
inherited

Convenience function to get through elements.

Definition at line 384 of file tinyxml.cpp.

384 {
385 const TiXmlNode* node;
386
387 for (node = FirstChild(); node; node = node->NextSibling()) {
388 if (node->ToElement()) return node->ToElement();
389 }
390
391 return 0;
392}
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null if not of the requested type.
Definition tinyxml.h:788

References TiXmlNode(), FirstChild(), NextSibling(), TiXmlElement, and ToElement().

Referenced by ticpp::Node::FirstChildElement(), FirstChildElement(), FirstChildElement(), TiXmlDocument::RootElement(), and TiXmlDocument::RootElement().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FirstChildElement() [3/6]

TiXmlElement * TiXmlNode::FirstChildElement ( const char * _value)
inlineinherited

Definition at line 752 of file tinyxml.h.

752 {
753 return const_cast< TiXmlElement* >(
754 (const_cast< const TiXmlNode* >(this))->FirstChildElement(_value));
755 }

References TiXmlNode(), and TiXmlElement.

Here is the call graph for this function:

◆ FirstChildElement() [4/6]

const TiXmlElement * TiXmlNode::FirstChildElement ( const char * _value) const
inherited

Convenience function to get through elements.

Definition at line 394 of file tinyxml.cpp.

394 {
395 const TiXmlNode* node;
396
397 for (node = FirstChild(_value); node; node = node->NextSibling(_value)) {
398 if (node->ToElement()) return node->ToElement();
399 }
400
401 return 0;
402}

References TiXmlNode(), FirstChild(), NextSibling(), TiXmlElement, and ToElement().

Here is the call graph for this function:

◆ FirstChildElement() [5/6]

TiXmlElement * TiXmlNode::FirstChildElement ( const std::string & _value)
inlineinherited

STL std::string form.

Definition at line 761 of file tinyxml.h.

References FirstChildElement(), and TiXmlElement.

Here is the call graph for this function:

◆ FirstChildElement() [6/6]

const TiXmlElement * TiXmlNode::FirstChildElement ( const std::string & _value) const
inlineinherited

STL std::string form.

Definition at line 758 of file tinyxml.h.

References FirstChildElement(), and TiXmlElement.

Here is the call graph for this function:

◆ GetChar()

const char * TiXmlBase::GetChar ( const char * p,
char * _value,
int * length,
TiXmlEncoding encoding )
inlinestaticprotectedinherited

Definition at line 368 of file tinyxml.h.

368 {
369 assert(p);
370
371 if (encoding == TIXML_ENCODING_UTF8) {
372 *length = utf8ByteTable[*((const unsigned char*)p)];
373 assert(*length >= 0 && *length < 5);
374 } else {
375 *length = 1;
376 }
377
378 if (*length == 1) {
379 if (*p == '&') return GetEntity(p, _value, length, encoding);
380
381 *_value = *p;
382 return p + 1;
383 } else if (*length) {
384 // strncpy( _value, p, *length ); // lots of compilers don't like this
385 // function (unsafe),
386 // and the null terminator isn't needed
387 for (int i = 0; p[i] && i < *length; ++i) {
388 _value[i] = p[i];
389 }
390
391 return p + (*length);
392 } else {
393 // Not valid text.
394 return 0;
395 }
396 }
static const char * GetEntity(const char *in, char *value, int *length, TiXmlEncoding encoding)
static const int utf8ByteTable[256]
Definition tinyxml.h:64
@ TIXML_ENCODING_UTF8
Definition tinyxml.h:181

References GetEntity(), TIXML_ENCODING_UTF8, and utf8ByteTable.

Referenced by ReadText().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDocument() [1/2]

TiXmlDocument * TiXmlNode::GetDocument ( )
inlineinherited

Definition at line 776 of file tinyxml.h.

776 {
777 return const_cast< TiXmlDocument* >(
778 (const_cast< const TiXmlNode* >(this))->GetDocument());
779 }
friend class TiXmlDocument
Definition tinyxml.h:455

References TiXmlNode(), and TiXmlDocument.

Here is the call graph for this function:

◆ GetDocument() [2/2]

const TiXmlDocument * TiXmlNode::GetDocument ( ) const
inherited

Return a pointer to the Document this node lives in.

Returns null if not in a document.

Definition at line 424 of file tinyxml.cpp.

424 {
425 const TiXmlNode* node;
426
427 for (node = this; node; node = node->parent) {
428 if (node->ToDocument()) return node->ToDocument();
429 }
430
431 return 0;
432}
TiXmlNode * parent
Definition tinyxml.h:892
virtual const TiXmlDocument * ToDocument() const
Cast to a more defined type. Will return null if not of the requested type.
Definition tinyxml.h:784

References TiXmlNode(), parent, TiXmlDocument, and ToDocument().

Referenced by ticpp::Base::BuildDetailedErrorString(), Identify(), InsertAfterChild(), InsertBeforeChild(), InsertEndChild(), LinkEndChild(), TiXmlComment::Parse(), TiXmlDeclaration::Parse(), TiXmlElement::Parse(), TiXmlStylesheetReference::Parse(), TiXmlText::Parse(), TiXmlUnknown::Parse(), TiXmlElement::ReadValue(), TiXmlElement::SetAttribute(), TiXmlElement::SetAttribute(), TiXmlComment::StreamIn(), TiXmlDeclaration::StreamIn(), TiXmlElement::StreamIn(), TiXmlStylesheetReference::StreamIn(), TiXmlText::StreamIn(), and TiXmlUnknown::StreamIn().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetEntity()

const char * TiXmlBase::GetEntity ( const char * in,
char * value,
int * length,
TiXmlEncoding encoding )
staticprotectedinherited

Definition at line 442 of file tinyxmlparser.cpp.

445 {
446 // Presume an entity, and pull it out.
447 TIXML_STRING ent;
448 int i;
449 *length = 0;
450
451 if (*(p + 1) && *(p + 1) == '#' && *(p + 2)) {
452 unsigned long ucs = 0;
453 ptrdiff_t delta = 0;
454 unsigned mult = 1;
455
456 if (*(p + 2) == 'x') {
457 // Hexadecimal.
458 if (!*(p + 3)) return 0;
459
460 const char* q = p + 3;
461 q = strchr(q, ';');
462
463 if (!q || !*q) return 0;
464
465 delta = q - p;
466 --q;
467
468 while (*q != 'x') {
469 if (*q >= '0' && *q <= '9')
470 ucs += mult * (*q - '0');
471 else if (*q >= 'a' && *q <= 'f')
472 ucs += mult * (*q - 'a' + 10);
473 else if (*q >= 'A' && *q <= 'F')
474 ucs += mult * (*q - 'A' + 10);
475 else
476 return 0;
477
478 mult *= 16;
479 --q;
480 }
481 } else {
482 // Decimal.
483 if (!*(p + 2)) return 0;
484
485 const char* q = p + 2;
486 q = strchr(q, ';');
487
488 if (!q || !*q) return 0;
489
490 delta = q - p;
491 --q;
492
493 while (*q != '#') {
494 if (*q >= '0' && *q <= '9')
495 ucs += mult * (*q - '0');
496 else
497 return 0;
498
499 mult *= 10;
500 --q;
501 }
502 }
503
504 if (encoding == TIXML_ENCODING_UTF8) {
505 // convert the UCS to UTF-8
506 ConvertUTF32ToUTF8(ucs, value, length);
507 } else {
508 *value = (char)ucs;
509 *length = 1;
510 }
511
512 return p + delta + 1;
513 }
514
515 // Now try to match it.
516 for (i = 0; i < NUM_ENTITY; ++i) {
517 if (strncmp(entity[i].str, p, entity[i].strLength) == 0) {
518 assert(strlen(entity[i].str) == entity[i].strLength);
519 *value = entity[i].chr;
520 *length = 1;
521 return (p + entity[i].strLength);
522 }
523 }
524
525 // So it wasn't an entity, its unrecognized, or something like that.
526 *value = *p; // Don't put back the last one, since we return it!
527 //*length = 1; // Leave unrecognized entities - this doesn't really work.
528 // Just writes strange XML.
529 return p + 1;
530}
static void ConvertUTF32ToUTF8(unsigned long input, char *output, int *length)
#define TIXML_STRING
Definition tinyxml.h:60

References ConvertUTF32ToUTF8(), entity, NUM_ENTITY, TIXML_ENCODING_UTF8, and TIXML_STRING.

Referenced by GetChar().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetUserData() [1/2]

void * TiXmlBase::GetUserData ( )
inlineinherited

Get a pointer to arbitrary user data.

Definition at line 281 of file tinyxml.h.

References userData.

◆ GetUserData() [2/2]

const void * TiXmlBase::GetUserData ( ) const
inlineinherited

Get a pointer to arbitrary user data.

Definition at line 284 of file tinyxml.h.

References userData.

◆ Identify()

TiXmlNode * TiXmlNode::Identify ( const char * start,
TiXmlEncoding encoding )
protectedinherited

Definition at line 788 of file tinyxmlparser.cpp.

788 {
789 TiXmlNode* returnNode = 0;
790
791 p = SkipWhiteSpace(p, encoding);
792
793 if (!p || !*p || *p != '<') {
794 return 0;
795 }
796
797 TiXmlDocument* doc = GetDocument();
798 p = SkipWhiteSpace(p, encoding);
799
800 if (!p || !*p) {
801 return 0;
802 }
803
804 // What is this thing?
805 // - Elements start with a letter or underscore, but xml is reserved.
806 // - Comments: <!--
807 // - Decleration: <?xml
808 // - StylesheetReference <?xml-stylesheet
809 // - Everthing else is unknown to tinyxml.
810 //
811
812 const char* xmlHeader = {"<?xml"};
813 const char* xmlSSHeader = {"<?xml-stylesheet"};
814 const char* commentHeader = {"<!--"};
815 const char* dtdHeader = {"<!"};
816 const char* cdataHeader = {"<![CDATA["};
817
818 if (StringEqual(p, xmlSSHeader, true, encoding)) {
819#ifdef DEBUG_PARSER
820 TIXML_LOG("XML parsing Stylesheet Reference\n");
821#endif
822 returnNode = new TiXmlStylesheetReference();
823 } else if (StringEqual(p, xmlHeader, true, encoding)) {
824#ifdef DEBUG_PARSER
825 TIXML_LOG("XML parsing Declaration\n");
826#endif
827 returnNode = new TiXmlDeclaration();
828 } else if (StringEqual(p, commentHeader, false, encoding)) {
829#ifdef DEBUG_PARSER
830 TIXML_LOG("XML parsing Comment\n");
831#endif
832 returnNode = new TiXmlComment();
833 } else if (StringEqual(p, cdataHeader, false, encoding)) {
834#ifdef DEBUG_PARSER
835 TIXML_LOG("XML parsing CDATA\n");
836#endif
837 TiXmlText* text = new TiXmlText("");
838 text->SetCDATA(true);
839 returnNode = text;
840 } else if (StringEqual(p, dtdHeader, false, encoding)) {
841#ifdef DEBUG_PARSER
842 TIXML_LOG("XML parsing Unknown(1)\n");
843#endif
844 returnNode = new TiXmlUnknown();
845 } else if (IsAlpha(*(p + 1), encoding) || *(p + 1) == '_') {
846#ifdef DEBUG_PARSER
847 TIXML_LOG("XML parsing Element\n");
848#endif
849 returnNode = new TiXmlElement("");
850 } else {
851#ifdef DEBUG_PARSER
852 TIXML_LOG("XML parsing Unknown(2)\n");
853#endif
854 returnNode = new TiXmlUnknown();
855 }
856
857 if (returnNode) {
858 // Set the parent, so it can report errors
859 returnNode->parent = this;
860 } else {
861 if (doc)
863 }
864
865 return returnNode;
866}
static bool StringEqual(const char *p, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
static const char * SkipWhiteSpace(const char *, TiXmlEncoding encoding)
static int IsAlpha(unsigned char anyByte, TiXmlEncoding encoding)
void SetError(int err, const char *errorLocation, TiXmlParsingData *prevData, TiXmlEncoding encoding)
const TiXmlDocument * GetDocument() const
Return a pointer to the Document this node lives in.
Definition tinyxml.cpp:424
void SetCDATA(bool _cdata)
Turns on or off a CDATA representation of text.
Definition tinyxml.h:1422
@ TIXML_ENCODING_UNKNOWN
Definition tinyxml.h:180

References TiXmlNode(), GetDocument(), TiXmlBase::IsAlpha(), parent, TiXmlText::SetCDATA(), TiXmlDocument::SetError(), TiXmlBase::SkipWhiteSpace(), TiXmlBase::StringEqual(), TIXML_ENCODING_UNKNOWN, TiXmlBase::TIXML_ERROR_OUT_OF_MEMORY, TiXmlDocument, and TiXmlElement.

Referenced by TiXmlDocument::Parse(), TiXmlElement::ReadValue(), TiXmlDocument::StreamIn(), and TiXmlElement::StreamIn().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InsertAfterChild()

TiXmlNode * TiXmlNode::InsertAfterChild ( TiXmlNode * afterThis,
const TiXmlNode & addThis )
inherited

Add a new node related to this.

Adds a child after the specified child. Returns a pointer to the new object or nullptr if an error occured.

Definition at line 231 of file tinyxml.cpp.

232 {
233 if (!afterThis || afterThis->parent != this) {
234 return 0;
235 }
236
237 if (addThis.Type() == TiXmlNode::DOCUMENT) {
238 if (GetDocument())
241
242 return 0;
243 }
244
245 TiXmlNode* node = addThis.Clone();
246
247 if (!node) return 0;
248
249 node->parent = this;
250
251 node->prev = afterThis;
252 node->next = afterThis->next;
253
254 if (afterThis->next) {
255 afterThis->next->prev = node;
256 } else {
257 assert(lastChild == afterThis);
258 lastChild = node;
259 }
260
261 afterThis->next = node;
262 return node;
263}
int Type() const
Query the type (as an enumerated value, above) of this node.
Definition tinyxml.h:770
TiXmlNode * prev
Definition tinyxml.h:900

References TiXmlNode(), Clone(), DOCUMENT, GetDocument(), lastChild, next, parent, prev, TiXmlDocument::SetError(), TIXML_ENCODING_UNKNOWN, TiXmlBase::TIXML_ERROR_DOCUMENT_TOP_ONLY, and Type().

Referenced by ticpp::Node::InsertAfterChild().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InsertBeforeChild()

TiXmlNode * TiXmlNode::InsertBeforeChild ( TiXmlNode * beforeThis,
const TiXmlNode & addThis )
inherited

Add a new node related to this.

Adds a child before the specified child. Returns a pointer to the new object or nullptr if an error occured.

Definition at line 197 of file tinyxml.cpp.

198 {
199 if (!beforeThis || beforeThis->parent != this) {
200 return 0;
201 }
202
203 if (addThis.Type() == TiXmlNode::DOCUMENT) {
204 if (GetDocument())
207
208 return 0;
209 }
210
211 TiXmlNode* node = addThis.Clone();
212
213 if (!node) return 0;
214
215 node->parent = this;
216
217 node->next = beforeThis;
218 node->prev = beforeThis->prev;
219
220 if (beforeThis->prev) {
221 beforeThis->prev->next = node;
222 } else {
223 assert(firstChild == beforeThis);
224 firstChild = node;
225 }
226
227 beforeThis->prev = node;
228 return node;
229}

References TiXmlNode(), Clone(), DOCUMENT, firstChild, GetDocument(), next, parent, prev, TiXmlDocument::SetError(), TIXML_ENCODING_UNKNOWN, TiXmlBase::TIXML_ERROR_DOCUMENT_TOP_ONLY, and Type().

Referenced by ticpp::Node::InsertBeforeChild().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InsertEndChild()

TiXmlNode * TiXmlNode::InsertEndChild ( const TiXmlNode & addThis)
inherited

Add a new node related to this.

Adds a child past the LastChild. Returns a pointer to the new object or nullptr if an error occured.

Definition at line 181 of file tinyxml.cpp.

181 {
182 if (addThis.Type() == TiXmlNode::DOCUMENT) {
183 if (GetDocument())
186
187 return 0;
188 }
189
190 TiXmlNode* node = addThis.Clone();
191
192 if (!node) return 0;
193
194 return LinkEndChild(node);
195}

References TiXmlNode(), Clone(), DOCUMENT, GetDocument(), LinkEndChild(), TiXmlDocument::SetError(), TIXML_ENCODING_UNKNOWN, TiXmlBase::TIXML_ERROR_DOCUMENT_TOP_ONLY, and Type().

Referenced by ticpp::Node::InsertEndChild().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsAlpha()

int TiXmlBase::IsAlpha ( unsigned char anyByte,
TiXmlEncoding encoding )
staticprotectedinherited

Definition at line 146 of file tinyxmlparser.cpp.

147 {
148 // This will only work for low-ascii, everything else is assumed to be a valid
149 // letter. I'm not sure this is the best approach, but it is quite tricky
150 // trying
151 // to figure out alhabetical vs. not across encoding. So take a very
152 // conservative approach.
153
154 // if ( encoding == TIXML_ENCODING_UTF8 )
155 // {
156 if (anyByte < 127)
157 return isalpha(anyByte);
158 else
159 return 1; // What else to do? The unicode set is huge...get the english
160 // ones
161 // right.
162
163 // }
164 // else
165 // {
166 // return isalpha( anyByte );
167 // }
168}

Referenced by TiXmlNode::Identify(), and ReadName().

Here is the caller graph for this function:

◆ IsAlphaNum()

int TiXmlBase::IsAlphaNum ( unsigned char anyByte,
TiXmlEncoding encoding )
staticprotectedinherited

Definition at line 170 of file tinyxmlparser.cpp.

171 {
172 // This will only work for low-ascii, everything else is assumed to be a valid
173 // letter. I'm not sure this is the best approach, but it is quite tricky
174 // trying
175 // to figure out alhabetical vs. not across encoding. So take a very
176 // conservative approach.
177
178 // if ( encoding == TIXML_ENCODING_UTF8 )
179 // {
180 if (anyByte < 127)
181 return isalnum(anyByte);
182 else
183 return 1; // What else to do? The unicode set is huge...get the english
184 // ones
185 // right.
186
187 // }
188 // else
189 // {
190 // return isalnum( anyByte );
191 // }
192}

Referenced by ReadName().

Here is the caller graph for this function:

◆ IsWhiteSpace() [1/2]

bool TiXmlBase::IsWhiteSpace ( char c)
inlinestaticprotectedinherited

Definition at line 328 of file tinyxml.h.

328 {
329 return (std::isspace((unsigned char)c) || c == '\n' || c == '\r');
330 }

Referenced by TiXmlText::Blank(), IsWhiteSpace(), TiXmlAttribute::Parse(), TiXmlDeclaration::Parse(), TiXmlStylesheetReference::Parse(), ReadText(), SkipWhiteSpace(), TiXmlElement::StreamIn(), and StreamWhiteSpace().

Here is the caller graph for this function:

◆ IsWhiteSpace() [2/2]

bool TiXmlBase::IsWhiteSpace ( int c)
inlinestaticprotectedinherited

Definition at line 331 of file tinyxml.h.

331 {
332 if (c < 256) return IsWhiteSpace((char)c);
333
334 return false; // Again, only truly correct for English/Latin...but usually
335 // works.
336 }
static bool IsWhiteSpace(char c)
Definition tinyxml.h:328

References IsWhiteSpace().

Here is the call graph for this function:

◆ IsWhiteSpaceCondensed()

bool TiXmlBase::IsWhiteSpaceCondensed ( )
inlinestaticinherited

Return the current white space setting.

Definition at line 247 of file tinyxml.h.

247{ return condenseWhiteSpace; }
static bool condenseWhiteSpace
Definition tinyxml.h:445

References condenseWhiteSpace.

Referenced by TiXmlElement::ReadValue().

Here is the caller graph for this function:

◆ IterateChildren() [1/6]

TiXmlNode * TiXmlNode::IterateChildren ( const char * _value,
const TiXmlNode * previous )
inlineinherited

Definition at line 627 of file tinyxml.h.

627 {
628 return const_cast< TiXmlNode* >(
629 (const_cast< const TiXmlNode* >(this))->IterateChildren(_value, previous));
630 }

References TiXmlNode().

Here is the call graph for this function:

◆ IterateChildren() [2/6]

const TiXmlNode * TiXmlNode::IterateChildren ( const char * value,
const TiXmlNode * previous ) const
inherited

This flavor of IterateChildren searches for children with a particular 'value'.

Definition at line 340 of file tinyxml.cpp.

341 {
342 if (!previous) {
343 return FirstChild(val);
344 } else {
345 assert(previous->parent == this);
346 return previous->NextSibling(val);
347 }
348}

References TiXmlNode(), FirstChild(), NextSibling(), and parent.

Here is the call graph for this function:

◆ IterateChildren() [3/6]

TiXmlNode * TiXmlNode::IterateChildren ( const std::string & _value,
const TiXmlNode * previous )
inlineinherited

STL std::string form.

Definition at line 637 of file tinyxml.h.

References TiXmlNode(), and IterateChildren().

Here is the call graph for this function:

◆ IterateChildren() [4/6]

const TiXmlNode * TiXmlNode::IterateChildren ( const std::string & _value,
const TiXmlNode * previous ) const
inlineinherited

STL std::string form.

Definition at line 633 of file tinyxml.h.

References TiXmlNode(), and IterateChildren().

Here is the call graph for this function:

◆ IterateChildren() [5/6]

TiXmlNode * TiXmlNode::IterateChildren ( const TiXmlNode * previous)
inlineinherited

Definition at line 618 of file tinyxml.h.

618 {
619 return const_cast< TiXmlNode* >(
620 (const_cast< const TiXmlNode* >(this))->IterateChildren(previous));
621 }

References TiXmlNode().

Here is the call graph for this function:

◆ IterateChildren() [6/6]

const TiXmlNode * TiXmlNode::IterateChildren ( const TiXmlNode * previous) const
inherited

An alternate way to walk the children of a node.

One way to iterate over nodes is:

  for( child = parent->FirstChild(); child; child = child->NextSibling() )

IterateChildren does the same thing with the syntax:

  child = 0;
  while( child = parent->IterateChildren( child ) )

IterateChildren takes the previous child as input and finds the next one. If the previous child is null, it returns the first. IterateChildren will return null when done.

Definition at line 331 of file tinyxml.cpp.

331 {
332 if (!previous) {
333 return FirstChild();
334 } else {
335 assert(previous->parent == this);
336 return previous->NextSibling();
337 }
338}

References TiXmlNode(), FirstChild(), NextSibling(), and parent.

Referenced by ticpp::Node::IterateChildren(), ticpp::Node::IterateChildren(), IterateChildren(), and IterateChildren().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LastChild() [1/6]

TiXmlNode * TiXmlNode::LastChild ( )
inlineinherited

The last child of this node. Will be null if there are no children.

Definition at line 575 of file tinyxml.h.

575{ return lastChild; }

References TiXmlNode(), and lastChild.

Here is the call graph for this function:

◆ LastChild() [2/6]

const TiXmlNode * TiXmlNode::LastChild ( ) const
inlineinherited

Definition at line 572 of file tinyxml.h.

572 {
573 return lastChild;
574 }

References TiXmlNode(), and lastChild.

Referenced by ticpp::Node::LastChild(), LastChild(), LastChild(), and TiXmlPrinter::VisitEnter().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LastChild() [3/6]

TiXmlNode * TiXmlNode::LastChild ( const char * _value)
inlineinherited

The last child of this node matching 'value'. Will be null if there are no children.

Definition at line 581 of file tinyxml.h.

581 {
582 return const_cast< TiXmlNode* >(
583 (const_cast< const TiXmlNode* >(this))->LastChild(_value));
584 }

References TiXmlNode().

Here is the call graph for this function:

◆ LastChild() [4/6]

const TiXmlNode * TiXmlNode::LastChild ( const char * value) const
inherited

Definition at line 321 of file tinyxml.cpp.

321 {
322 const TiXmlNode* node;
323
324 for (node = lastChild; node; node = node->prev) {
325 if (strcmp(node->Value(), _value) == 0) return node;
326 }
327
328 return 0;
329}

References TiXmlNode(), lastChild, prev, and Value().

Here is the call graph for this function:

◆ LastChild() [5/6]

TiXmlNode * TiXmlNode::LastChild ( const std::string & _value)
inlineinherited

STL std::string form.

Definition at line 596 of file tinyxml.h.

References TiXmlNode(), and LastChild().

Here is the call graph for this function:

◆ LastChild() [6/6]

const TiXmlNode * TiXmlNode::LastChild ( const std::string & _value) const
inlineinherited

STL std::string form.

Definition at line 593 of file tinyxml.h.

References TiXmlNode(), and LastChild().

Here is the call graph for this function:

◆ LinkEndChild()

TiXmlNode * TiXmlNode::LinkEndChild ( TiXmlNode * addThis)
inherited

Add a new node related to this.

Adds a child past the LastChild.

NOTE: the node to be added is passed by pointer, and will be henceforth owned (and deleted) by tinyXml. This method is efficient and avoids an extra copy, but should be used with care as it uses a different memory model than the other insert functions.

See also
InsertEndChild

Definition at line 153 of file tinyxml.cpp.

153 {
154 assert(node->parent == 0 || node->parent == this);
155 assert(node->GetDocument() == 0 || node->GetDocument() == this->GetDocument());
156
157 if (node->Type() == TiXmlNode::DOCUMENT) {
158 delete node;
159
160 if (GetDocument())
163
164 return 0;
165 }
166
167 node->parent = this;
168
169 node->prev = lastChild;
170 node->next = 0;
171
172 if (lastChild)
173 lastChild->next = node;
174 else
175 firstChild = node; // it was an empty list.
176
177 lastChild = node;
178 return node;
179}

References TiXmlNode(), DOCUMENT, firstChild, GetDocument(), lastChild, next, parent, prev, TiXmlDocument::SetError(), TIXML_ENCODING_UNKNOWN, TiXmlBase::TIXML_ERROR_DOCUMENT_TOP_ONLY, and Type().

Referenced by TiXmlDocument::CopyTo(), TiXmlElement::CopyTo(), InsertEndChild(), TiXmlDocument::Parse(), and TiXmlElement::ReadValue().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LoadFile() [1/4]

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

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

Definition at line 822 of file tinyxml.cpp.

822 {
823 // There was a really terrifying little bug here. The code:
824 // value = filename
825 // in the STL case, cause the assignment method of the std::string to
826 // be called. What is strange, is that the std::string had the same
827 // address as it's c_str() method, and so bad things happen. Looks
828 // like a bug in the Microsoft STL implementation.
829 // Add an extra string to avoid the crash.
830 TIXML_STRING filename(_filename);
831 value = filename;
832
833 // reading in binary mode so that tinyxml can normalize the EOL
834 FILE* file = TiXmlFOpen(value.c_str(), "rb");
835
836 if (file) {
837 bool result = LoadFile(file, encoding);
838 fclose(file);
839 return result;
840 } else {
842 return false;
843 }
844}
bool LoadFile(TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
Load a file using the current document value.
Definition tinyxml.cpp:804
FILE * TiXmlFOpen(const char *filename, const char *mode)
Definition tinyxml.cpp:37

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

Here is the call graph for this function:

◆ LoadFile() [2/4]

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

Definition at line 1699 of file tinyxml.h.

1700 {
1701 // StringToBuffer f( filename );
1702 // return ( f.buffer && LoadFile( f.buffer, encoding ));
1703 return LoadFile(filename.c_str(), encoding);
1704 }

References LoadFile(), and TIXML_DEFAULT_ENCODING.

Here is the call graph for this function:

◆ LoadFile() [3/4]

bool 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 846 of file tinyxml.cpp.

846 {
847 if (!file) {
849 return false;
850 }
851
852 // Delete the existing data:
853 Clear();
854 location.Clear();
855
856 // Get the file size, so we can pre-allocate the string. HUGE speed impact.
857 long length = 0;
858 fseek(file, 0, SEEK_END);
859 length = ftell(file);
860 fseek(file, 0, SEEK_SET);
861
862 // Strange case, but good to handle up front.
863 if (length <= 0) {
865 return false;
866 }
867
868 // If we have a file, assume it is all one big XML file, and read it in.
869 // The document parser may decide the document ends sooner than the entire
870 // file,
871 // however.
872 TIXML_STRING data;
873 data.reserve(length);
874
875 // Subtle bug here. TinyXml did use fgets. But from the XML spec:
876 // 2.11 End-of-Line Handling
877 // <snip>
878 // <quote>
879 // ...the XML processor MUST behave as if it normalized all line breaks in
880 // external
881 // parsed entities (including the document entity) on input, before parsing,
882 // by
883 // translating
884 // both the two-character sequence #xD #xA and any #xD that is not followed by
885 // #xA
886 // to
887 // a single #xA character.
888 // </quote>
889 //
890 // It is not clear fgets does that, and certainly isn't clear it works cross
891 // platform.
892 // Generally, you expect fgets to translate from the convention of the OS to
893 // the
894 // c/unix
895 // convention, and not work generally.
896
897 /*
898 while( fgets( buf, sizeof(buf), file ) )
899 {
900 data += buf;
901 }
902 */
903
904 char* buf = new char[length + 1];
905 buf[0] = 0;
906
907 if (fread(buf, length, 1, file) != 1) {
908 delete[] buf;
910 return false;
911 }
912
913 const char* lastPos = buf;
914 const char* p = buf;
915
916 buf[length] = 0;
917
918 while (*p) {
919 assert(p < (buf + length));
920
921 if (*p == 0xa) {
922 // Newline character. No special rules for this. Append all the characters
923 // since the last string, and include the newline.
924 data.append(lastPos, (p - lastPos + 1)); // append, include the newline
925 ++p; // move past the newline
926 lastPos = p; // and point to the new buffer (may be 0)
927 assert(p <= (buf + length));
928 } else if (*p == 0xd) {
929 // Carriage return. Append what we have so far, then
930 // handle moving forward in the buffer.
931 if ((p - lastPos) > 0) {
932 data.append(lastPos, p - lastPos); // do not add the CR
933 }
934
935 data += (char)0xa; // a proper newline
936
937 if (*(p + 1) == 0xa) {
938 // Carriage return - new line sequence
939 p += 2;
940 lastPos = p;
941 assert(p <= (buf + length));
942 } else {
943 // it was followed by something else...that is presumably characters
944 // again.
945 ++p;
946 lastPos = p;
947 assert(p <= (buf + length));
948 }
949 } else {
950 ++p;
951 }
952 }
953
954 // Handle any left over characters.
955 if (p - lastPos) {
956 data.append(lastPos, p - lastPos);
957 }
958
959 delete[] buf;
960 buf = 0;
961
962 Parse(data.c_str(), 0, encoding);
963
964 if (Error())
965 return false;
966 else
967 return true;
968}
TiXmlCursor location
Definition tinyxml.h:410
bool Error() const
If an error occurs, Error will be set to true.
Definition tinyxml.h:1740
virtual const char * Parse(const char *p, TiXmlParsingData *data=0, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
Parse the given null terminated block of xml data.
void Clear()
Delete all the children of this node. Does not affect 'this'.
Definition tinyxml.cpp:139

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

Here is the call graph for this function:

◆ LoadFile() [4/4]

bool 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 804 of file tinyxml.cpp.

804 {
805 // See STL_STRING_BUG below.
806 // StringToBuffer buf( value );
807
808 return LoadFile(Value(), encoding);
809}

References LoadFile(), and TiXmlNode::Value().

Referenced by LoadFile(), LoadFile(), and LoadFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NextSibling() [1/6]

TiXmlNode * TiXmlNode::NextSibling ( )
inlineinherited

Definition at line 705 of file tinyxml.h.

705{ return next; }

References TiXmlNode(), and next.

Here is the call graph for this function:

◆ NextSibling() [2/6]

const TiXmlNode * TiXmlNode::NextSibling ( ) const
inlineinherited

Navigate to a sibling node.

Definition at line 704 of file tinyxml.h.

704{ return next; }

References TiXmlNode(), and next.

Referenced by NextSibling(), NextSibling(), NextSiblingElement(), and NextSiblingElement().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NextSibling() [3/6]

const TiXmlNode * TiXmlNode::NextSibling ( const char * _value) const
inherited

Navigate to a sibling node with the given 'value'.

Definition at line 350 of file tinyxml.cpp.

350 {
351 const TiXmlNode* node;
352
353 for (node = next; node; node = node->next) {
354 if (strcmp(node->Value(), _value) == 0) return node;
355 }
356
357 return 0;
358}

References TiXmlNode(), next, and Value().

Here is the call graph for this function:

◆ NextSibling() [4/6]

TiXmlNode * TiXmlNode::NextSibling ( const char * _next)
inlineinherited

Definition at line 709 of file tinyxml.h.

709 {
710 return const_cast< TiXmlNode* >(
711 (const_cast< const TiXmlNode* >(this))->NextSibling(_next));
712 }

References TiXmlNode().

Here is the call graph for this function:

◆ NextSibling() [5/6]

TiXmlNode * TiXmlNode::NextSibling ( const std::string & _value)
inlineinherited

STL std::string form.

Definition at line 698 of file tinyxml.h.

References TiXmlNode(), and NextSibling().

Here is the call graph for this function:

◆ NextSibling() [6/6]

const TiXmlNode * TiXmlNode::NextSibling ( const std::string & _value) const
inlineinherited

STL std::string form.

Definition at line 695 of file tinyxml.h.

References TiXmlNode(), and NextSibling().

Referenced by TiXmlDocument::Accept(), TiXmlElement::Accept(), TiXmlHandle::Child(), TiXmlHandle::Child(), TiXmlDocument::CopyTo(), TiXmlElement::CopyTo(), FirstChildElement(), FirstChildElement(), IterateChildren(), IterateChildren(), ticpp::Node::NextSibling(), NextSiblingElement(), NextSiblingElement(), TiXmlDocument::Print(), and TiXmlElement::Print().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NextSiblingElement() [1/6]

TiXmlElement * TiXmlNode::NextSiblingElement ( )
inlineinherited

Definition at line 719 of file tinyxml.h.

719 {
720 return const_cast< TiXmlElement* >(
721 (const_cast< const TiXmlNode* >(this))->NextSiblingElement());
722 }

References TiXmlNode(), and TiXmlElement.

Here is the call graph for this function:

◆ NextSiblingElement() [2/6]

const TiXmlElement * TiXmlNode::NextSiblingElement ( ) const
inherited

Convenience function to get through elements.

Calls NextSibling and ToElement. Will skip all non-Element nodes. Returns 0 if there is not another element.

Definition at line 404 of file tinyxml.cpp.

404 {
405 const TiXmlNode* node;
406
407 for (node = NextSibling(); node; node = node->NextSibling()) {
408 if (node->ToElement()) return node->ToElement();
409 }
410
411 return 0;
412}
const TiXmlNode * NextSibling() const
Navigate to a sibling node.
Definition tinyxml.h:704

References TiXmlNode(), NextSibling(), NextSibling(), TiXmlElement, and ToElement().

Referenced by TiXmlHandle::ChildElement(), TiXmlHandle::ChildElement(), ticpp::Node::NextSiblingElement(), NextSiblingElement(), and NextSiblingElement().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NextSiblingElement() [3/6]

const TiXmlElement * TiXmlNode::NextSiblingElement ( const char * _value) const
inherited

Convenience function to get through elements.

Calls NextSibling and ToElement. Will skip all non-Element nodes. Returns 0 if there is not another element.

Definition at line 414 of file tinyxml.cpp.

414 {
415 const TiXmlNode* node;
416
417 for (node = NextSibling(_value); node; node = node->NextSibling(_value)) {
418 if (node->ToElement()) return node->ToElement();
419 }
420
421 return 0;
422}

References TiXmlNode(), NextSibling(), NextSibling(), TiXmlElement, and ToElement().

Here is the call graph for this function:

◆ NextSiblingElement() [4/6]

TiXmlElement * TiXmlNode::NextSiblingElement ( const char * _next)
inlineinherited

Definition at line 729 of file tinyxml.h.

729 {
730 return const_cast< TiXmlElement* >(
731 (const_cast< const TiXmlNode* >(this))->NextSiblingElement(_next));
732 }

References TiXmlNode(), and TiXmlElement.

Here is the call graph for this function:

◆ NextSiblingElement() [5/6]

TiXmlElement * TiXmlNode::NextSiblingElement ( const std::string & _value)
inlineinherited

STL std::string form.

Definition at line 738 of file tinyxml.h.

References NextSiblingElement(), and TiXmlElement.

Here is the call graph for this function:

◆ NextSiblingElement() [6/6]

const TiXmlElement * TiXmlNode::NextSiblingElement ( const std::string & _value) const
inlineinherited

STL std::string form.

Definition at line 735 of file tinyxml.h.

References NextSiblingElement(), and TiXmlElement.

Here is the call graph for this function:

◆ NoChildren()

bool TiXmlNode::NoChildren ( ) const
inlineinherited

Returns true if this node has no children.

Definition at line 782 of file tinyxml.h.

782{ return !firstChild; }

References firstChild.

Referenced by ticpp::Node::NoChildren().

Here is the caller graph for this function:

◆ operator=()

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

Definition at line 799 of file tinyxml.cpp.

799 {
800 Clear();
801 copy.CopyTo(this);
802}

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

Here is the call graph for this function:

◆ Parent() [1/2]

TiXmlNode * TiXmlNode::Parent ( )
inlineinherited

One step up the DOM.

Definition at line 549 of file tinyxml.h.

549{ return parent; }

References TiXmlNode(), and parent.

Referenced by ticpp::Node::Parent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Parent() [2/2]

const TiXmlNode * TiXmlNode::Parent ( ) const
inlineinherited

Definition at line 550 of file tinyxml.h.

550{ return parent; }

References TiXmlNode(), and parent.

Here is the call graph for this function:

◆ Parse()

const char * 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 TiXmlBase.

Definition at line 681 of file tinyxmlparser.cpp.

683 {
684 ClearError();
685
686 // Parse away, at the document level. Since a document
687 // contains nothing but other tags, most of what happens
688 // here is skipping white space.
689 if (!p || !*p) {
691 return 0;
692 }
693
694 // Note that, for a document, this needs to come
695 // before the while space skip, so that parsing
696 // starts from the pointer we are given.
697 location.Clear();
698
699 if (prevData) {
700 location.row = prevData->cursor.row;
701 location.col = prevData->cursor.col;
702 } else {
703 location.row = 0;
704 location.col = 0;
705 }
706
707 TiXmlParsingData data(p, TabSize(), location.row, location.col);
708 location = data.Cursor();
709
710 if (encoding == TIXML_ENCODING_UNKNOWN) {
711 // Check for the Microsoft UTF-8 lead bytes.
712 const unsigned char* pU = (const unsigned char*)p;
713
714 if (*(pU + 0) && *(pU + 0) == TIXML_UTF_LEAD_0 && *(pU + 1) &&
715 *(pU + 1) == TIXML_UTF_LEAD_1 && *(pU + 2) &&
716 *(pU + 2) == TIXML_UTF_LEAD_2) {
717 encoding = TIXML_ENCODING_UTF8;
718 useMicrosoftBOM = true;
719 }
720 }
721
722 p = SkipWhiteSpace(p, encoding);
723
724 if (!p) {
726 return 0;
727 }
728
729 while (p && *p) {
730 TiXmlNode* node = Identify(p, encoding);
731
732 if (node) {
733 p = node->Parse(p, &data, encoding);
734 LinkEndChild(node);
735 } else {
736 break;
737 }
738
739 // Did we get encoding info?
740 if (encoding == TIXML_ENCODING_UNKNOWN && node->ToDeclaration()) {
741 TiXmlDeclaration* dec = node->ToDeclaration();
742 const char* enc = dec->Encoding();
743 assert(enc);
744
745 if (*enc == 0)
746 encoding = TIXML_ENCODING_UTF8;
747 else if (StringEqual(enc, "UTF-8", true, TIXML_ENCODING_UNKNOWN))
748 encoding = TIXML_ENCODING_UTF8;
749 else if (StringEqual(enc, "UTF8", true, TIXML_ENCODING_UNKNOWN))
750 encoding = TIXML_ENCODING_UTF8; // incorrect, but be nice
751 else
752 encoding = TIXML_ENCODING_LEGACY;
753 }
754
755 p = SkipWhiteSpace(p, encoding);
756 }
757
758 // Was this empty?
759 if (!firstChild) {
760 SetError(TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, encoding);
761 return 0;
762 }
763
764 // All is well.
765 return p;
766}
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)=0
const char * Encoding() const
Encoding. Will return an empty string if none was found.
Definition tinyxml.h:1495
int TabSize() const
Definition tinyxml.h:1794
virtual const TiXmlDeclaration * ToDeclaration() const
Cast to a more defined type. Will return null if not of the requested type.
Definition tinyxml.h:804
TiXmlNode * Identify(const char *start, TiXmlEncoding encoding)
const TiXmlCursor & Cursor()
@ TIXML_ENCODING_LEGACY
Definition tinyxml.h:182
const unsigned char TIXML_UTF_LEAD_0
const unsigned char TIXML_UTF_LEAD_1
const unsigned char TIXML_UTF_LEAD_2

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

Referenced by LoadFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PreviousSibling() [1/6]

TiXmlNode * TiXmlNode::PreviousSibling ( )
inlineinherited

Definition at line 679 of file tinyxml.h.

679{ return prev; }

References TiXmlNode(), and prev.

Here is the call graph for this function:

◆ PreviousSibling() [2/6]

const TiXmlNode * TiXmlNode::PreviousSibling ( ) const
inlineinherited

Navigate to a sibling node.

Definition at line 678 of file tinyxml.h.

678{ return prev; }

References TiXmlNode(), and prev.

Referenced by ticpp::Node::PreviousSibling(), PreviousSibling(), and PreviousSibling().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PreviousSibling() [3/6]

const TiXmlNode * TiXmlNode::PreviousSibling ( const char * _value) const
inherited

Navigate to a sibling node.

Definition at line 360 of file tinyxml.cpp.

360 {
361 const TiXmlNode* node;
362
363 for (node = prev; node; node = node->prev) {
364 if (strcmp(node->Value(), _value) == 0) return node;
365 }
366
367 return 0;
368}

References TiXmlNode(), prev, and Value().

Here is the call graph for this function:

◆ PreviousSibling() [4/6]

TiXmlNode * TiXmlNode::PreviousSibling ( const char * _prev)
inlineinherited

Definition at line 683 of file tinyxml.h.

683 {
684 return const_cast< TiXmlNode* >(
685 (const_cast< const TiXmlNode* >(this))->PreviousSibling(_prev));
686 }

References TiXmlNode().

Here is the call graph for this function:

◆ PreviousSibling() [5/6]

TiXmlNode * TiXmlNode::PreviousSibling ( const std::string & _value)
inlineinherited

STL std::string form.

Definition at line 692 of file tinyxml.h.

References TiXmlNode(), and PreviousSibling().

Here is the call graph for this function:

◆ PreviousSibling() [6/6]

const TiXmlNode * TiXmlNode::PreviousSibling ( const std::string & _value) const
inlineinherited

STL std::string form.

Definition at line 689 of file tinyxml.h.

References TiXmlNode(), and PreviousSibling().

Here is the call graph for this function:

◆ Print() [1/2]

void TiXmlDocument::Print ( ) const
inline

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

Definition at line 1810 of file tinyxml.h.

1810{ Print(stdout, 0); }
void Print() const
Write the document to standard out using formatted printing ("prettyprint").
Definition tinyxml.h:1810

References Print().

Referenced by Print(), and SaveFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Print() [2/2]

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

Print this Document to a FILE stream.

Implements TiXmlBase.

Definition at line 1024 of file tinyxml.cpp.

1024 {
1025 assert(cfile);
1026
1027 for (const TiXmlNode* node = FirstChild(); node; node = node->NextSibling()) {
1028 node->Print(cfile, depth);
1029 fprintf(cfile, "\n");
1030 }
1031}

References TiXmlNode::TiXmlNode(), TiXmlNode::FirstChild(), and TiXmlNode::NextSibling().

Here is the call graph for this function:

◆ ReadName()

const char * TiXmlBase::ReadName ( const char * p,
TIXML_STRING * name,
TiXmlEncoding encoding )
staticprotectedinherited

Definition at line 409 of file tinyxmlparser.cpp.

409 {
410 // Oddly, not supported on some comilers,
411 // name->clear();
412 // So use this:
413 *name = "";
414 assert(p);
415
416 // Names start with letters or underscores.
417 // Of course, in unicode, tinyxml has no idea what a letter *is*. The
418 // algorithm is generous.
419 //
420 // After that, they can be letters, underscores, numbers,
421 // hyphens, or colons. (Colons are valid ony for namespaces,
422 // but tinyxml can't tell namespaces from names.)
423 if (p && *p && (IsAlpha((unsigned char)*p, encoding) || *p == '_')) {
424 const char* start = p;
425
426 while (p && *p && (IsAlphaNum((unsigned char)*p, encoding) || *p == '_' ||
427 *p == '-' || *p == '.' || *p == ':')) {
428 //(*name) += *p; // expensive
429 ++p;
430 }
431
432 if (p - start > 0) {
433 name->assign(start, p - start);
434 }
435
436 return p;
437 }
438
439 return 0;
440}
static int IsAlphaNum(unsigned char anyByte, TiXmlEncoding encoding)

References IsAlpha(), IsAlphaNum(), and TIXML_STRING.

Referenced by TiXmlAttribute::Parse(), and TiXmlElement::Parse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadText()

const char * TiXmlBase::ReadText ( const char * in,
TIXML_STRING * text,
bool ignoreWhiteSpace,
const char * endTag,
bool ignoreCase,
TiXmlEncoding encoding )
staticprotectedinherited

Definition at line 566 of file tinyxmlparser.cpp.

571 {
572 *text = "";
573
574 if (!trimWhiteSpace // certain tags always keep whitespace
575 ||
576 !condenseWhiteSpace) { // if true, whitespace is always kept
577 // Keep all the white space.
578 while (p && *p && !StringEqual(p, endTag, caseInsensitive, encoding)) {
579 int len;
580 char cArr[4] = {0, 0, 0, 0};
581 p = GetChar(p, cArr, &len, encoding);
582 text->append(cArr, len);
583 }
584 } else {
585 bool whitespace = false;
586
587 // Remove leading white space:
588 p = SkipWhiteSpace(p, encoding);
589
590 while (p && *p && !StringEqual(p, endTag, caseInsensitive, encoding)) {
591 if (*p == '\r' || *p == '\n') {
592 whitespace = true;
593 ++p;
594 } else if (IsWhiteSpace(*p)) {
595 whitespace = true;
596 ++p;
597 } else {
598 // If we've found whitespace, add it before the
599 // new character. Any whitespace just becomes a space.
600 if (whitespace) {
601 (*text) += ' ';
602 whitespace = false;
603 }
604
605 int len;
606 char cArr[4] = {0, 0, 0, 0};
607 p = GetChar(p, cArr, &len, encoding);
608
609 if (len == 1)
610 (*text) += cArr[0]; // more efficient
611 else
612 text->append(cArr, len);
613 }
614 }
615 }
616
617 if (p) p += strlen(endTag);
618
619 return p;
620}
static const char * GetChar(const char *p, char *_value, int *length, TiXmlEncoding encoding)
Definition tinyxml.h:368

References condenseWhiteSpace, GetChar(), IsWhiteSpace(), SkipWhiteSpace(), StringEqual(), and TIXML_STRING.

Referenced by TiXmlAttribute::Parse(), and TiXmlText::Parse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RemoveChild()

bool TiXmlNode::RemoveChild ( TiXmlNode * removeThis)
inherited

Delete a child of this node.

Definition at line 291 of file tinyxml.cpp.

291 {
292 if (removeThis->parent != this) {
293 assert(0);
294 return false;
295 }
296
297 if (removeThis->next)
298 removeThis->next->prev = removeThis->prev;
299 else
300 lastChild = removeThis->prev;
301
302 if (removeThis->prev)
303 removeThis->prev->next = removeThis->next;
304 else
305 firstChild = removeThis->next;
306
307 delete removeThis;
308 return true;
309}

References TiXmlNode(), firstChild, lastChild, next, parent, and prev.

Here is the call graph for this function:

◆ ReplaceChild()

TiXmlNode * TiXmlNode::ReplaceChild ( TiXmlNode * replaceThis,
const TiXmlNode & withThis )
inherited

Replace a child of this node.

Returns a pointer to the new object or nullptr if an error occured.

Definition at line 265 of file tinyxml.cpp.

266 {
267 if (replaceThis->parent != this) return 0;
268
269 TiXmlNode* node = withThis.Clone();
270
271 if (!node) return 0;
272
273 node->next = replaceThis->next;
274 node->prev = replaceThis->prev;
275
276 if (replaceThis->next)
277 replaceThis->next->prev = node;
278 else
279 lastChild = node;
280
281 if (replaceThis->prev)
282 replaceThis->prev->next = node;
283 else
284 firstChild = node;
285
286 delete replaceThis;
287 node->parent = this;
288 return node;
289}

References TiXmlNode(), Clone(), firstChild, lastChild, next, parent, and prev.

Referenced by ticpp::Node::ReplaceChild().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RootElement() [1/2]

TiXmlElement * TiXmlDocument::RootElement ( )
inline

Definition at line 1730 of file tinyxml.h.

1730{ return FirstChildElement(); }
const TiXmlElement * FirstChildElement() const
Convenience function to get through elements.
Definition tinyxml.cpp:384

References TiXmlNode::FirstChildElement(), and TiXmlNode::TiXmlElement.

Here is the call graph for this function:

◆ RootElement() [2/2]

const TiXmlElement * 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 1729 of file tinyxml.h.

1729{ return FirstChildElement(); }

References TiXmlNode::FirstChildElement(), and TiXmlNode::TiXmlElement.

Here is the call graph for this function:

◆ Row()

int TiXmlBase::Row ( ) const
inlineinherited

Return the position, in the original source file, of this node or attribute.

The row and column are 1-based. (That is the first row and first column is 1,1). If the returns values are 0 or less, then the parser does not have a row and column value.

Generally, the row and column value will be set when the TiXmlDocument::Load(), TiXmlDocument::LoadFile(), or any TiXmlNode::Parse() is called. It will NOT be set when the DOM was created from operator>>.

The values reflect the initial load. Once the DOM is modified programmatically (by adding or changing nodes and attributes) the new values will NOT update to reflect changes in the document.

There is a minor performance cost to computing the row and column. Computation can be disabled if TiXmlDocument::SetTabSize() is called with 0 as the value.

See also
TiXmlDocument::SetTabSize()

Definition at line 275 of file tinyxml.h.

275{ return location.row + 1; }

References location.

Referenced by ticpp::Base::Row().

Here is the caller graph for this function:

◆ SaveFile() [1/4]

bool TiXmlDocument::SaveFile ( ) const

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

Definition at line 811 of file tinyxml.cpp.

811 {
812 // See STL_STRING_BUG below.
813 // StringToBuffer buf( value );
814 //
815 // if ( buf.buffer && SaveFile( buf.buffer ) )
816 // return true;
817 //
818 // return false;
819 return SaveFile(Value());
820}
bool SaveFile() const
Save a file using the current document value. Returns true if successful.
Definition tinyxml.cpp:811

References SaveFile(), and TiXmlNode::Value().

Referenced by SaveFile(), SaveFile(), and SaveFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SaveFile() [2/4]

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

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

Definition at line 970 of file tinyxml.cpp.

970 {
971 // The old c stuff lives on...
972 FILE* fp = TiXmlFOpen(filename, "w");
973
974 if (fp) {
975 bool result = SaveFile(fp);
976 fclose(fp);
977 return result;
978 }
979
980 return false;
981}

References SaveFile(), and TiXmlFOpen().

Here is the call graph for this function:

◆ SaveFile() [3/4]

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

Definition at line 1706 of file tinyxml.h.

1706 {
1707 // StringToBuffer f( filename );
1708 // return ( f.buffer && SaveFile( f.buffer ));
1709 return SaveFile(filename.c_str());
1710 }

References SaveFile().

Here is the call graph for this function:

◆ SaveFile() [4/4]

bool TiXmlDocument::SaveFile ( FILE * fp) const

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

Definition at line 983 of file tinyxml.cpp.

983 {
984 if (useMicrosoftBOM) {
985 const unsigned char TIXML_UTF_LEAD_0 = 0xefU;
986 const unsigned char TIXML_UTF_LEAD_1 = 0xbbU;
987 const unsigned char TIXML_UTF_LEAD_2 = 0xbfU;
988
989 fputc(TIXML_UTF_LEAD_0, fp);
990 fputc(TIXML_UTF_LEAD_1, fp);
991 fputc(TIXML_UTF_LEAD_2, fp);
992 }
993
994 Print(fp, 0);
995 return (ferror(fp) == 0);
996}

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

Here is the call graph for this function:

◆ SetCondenseWhiteSpace()

void TiXmlBase::SetCondenseWhiteSpace ( bool condense)
inlinestaticinherited

The world does not agree on whether white space should be kept or not.

In order to make everyone happy, these global, static functions are provided to set whether or not TinyXml will condense all white space into a single space or not. The default is to condense. Note changing this value is not thread safe.

Definition at line 242 of file tinyxml.h.

242 {
243 condenseWhiteSpace = condense;
244 }

References condenseWhiteSpace.

◆ SetError()

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

Definition at line 768 of file tinyxmlparser.cpp.

771 {
772 // The first error in a chain is more accurate - don't set again!
773 if (error) return;
774
775 assert(err > 0 && err < TIXML_ERROR_STRING_COUNT);
776 error = true;
777 errorId = err;
779
780 errorLocation.Clear();
781
782 if (pError && data) {
783 data->Stamp(pError, encoding);
784 errorLocation = data->Cursor();
785 }
786}
static const char * errorString[TIXML_ERROR_STRING_COUNT]
Definition tinyxml.h:35

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetTabSize()

void 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 1792 of file tinyxml.h.

1792{ tabsize = _tabsize; }

References tabsize.

◆ SetUserData()

void TiXmlBase::SetUserData ( void * user)
inlineinherited

Set a pointer to arbitrary user data.

Definition at line 278 of file tinyxml.h.

References userData.

◆ SetValue() [1/2]

void TiXmlNode::SetValue ( const char * _value)
inlineinherited

Changes the value of the node.

Defined as:

Document: filename of the xml file
Element:  name of the element
Comment:  the comment text
Unknown:  the tag contents
Text:   the text string

Definition at line 538 of file tinyxml.h.

538{ value = _value; }

References value.

Referenced by TiXmlComment::TiXmlComment(), TiXmlText::TiXmlText(), TiXmlText::TiXmlText(), CopyTo(), and ticpp::Node::SetValue().

Here is the caller graph for this function:

◆ SetValue() [2/2]

void TiXmlNode::SetValue ( const std::string & _value)
inlineinherited

STL std::string form.

Definition at line 542 of file tinyxml.h.

542{ value = _value; }

References value.

◆ SkipWhiteSpace()

const char * TiXmlBase::SkipWhiteSpace ( const char * p,
TiXmlEncoding encoding )
staticprotectedinherited

Definition at line 333 of file tinyxmlparser.cpp.

333 {
334 if (!p || !*p) {
335 return 0;
336 }
337
338 if (encoding == TIXML_ENCODING_UTF8) {
339 while (*p) {
340 const unsigned char* pU = (const unsigned char*)p;
341
342 // Skip the stupid Microsoft UTF-8 Byte order marks
343 if (*(pU + 0) == TIXML_UTF_LEAD_0 && *(pU + 1) == TIXML_UTF_LEAD_1 &&
344 *(pU + 2) == TIXML_UTF_LEAD_2) {
345 p += 3;
346 continue;
347 } else if (*(pU + 0) == TIXML_UTF_LEAD_0 && *(pU + 1) == 0xbfU &&
348 *(pU + 2) == 0xbeU) {
349 p += 3;
350 continue;
351 } else if (*(pU + 0) == TIXML_UTF_LEAD_0 && *(pU + 1) == 0xbfU &&
352 *(pU + 2) == 0xbfU) {
353 p += 3;
354 continue;
355 }
356
357 if (IsWhiteSpace(*p) || *p == '\n' ||
358 *p == '\r') // Still using old rules for white space.
359 ++p;
360 else
361 break;
362 }
363 } else {
364 while ((*p && IsWhiteSpace(*p)) || *p == '\n' || *p == '\r')
365 ++p;
366 }
367
368 return p;
369}

References IsWhiteSpace(), TIXML_ENCODING_UTF8, TIXML_UTF_LEAD_0, TIXML_UTF_LEAD_1, and TIXML_UTF_LEAD_2.

Referenced by TiXmlNode::Identify(), TiXmlAttribute::Parse(), TiXmlComment::Parse(), TiXmlDeclaration::Parse(), TiXmlDocument::Parse(), TiXmlElement::Parse(), TiXmlStylesheetReference::Parse(), TiXmlUnknown::Parse(), ReadText(), and TiXmlElement::ReadValue().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StreamIn()

void TiXmlDocument::StreamIn ( std::istream * in,
TIXML_STRING * tag )
protectedvirtual

Implements TiXmlNode.

Definition at line 624 of file tinyxmlparser.cpp.

624 {
625 // The basic issue with a document is that we don't know what we're
626 // streaming. Read something presumed to be a tag (and hope), then
627 // identify it, and call the appropriate stream method on the tag.
628 //
629 // This "pre-streaming" will never read the closing ">" so the
630 // sub-tag can orient itself.
631
632 if (!StreamTo(in, '<', tag)) {
634 return;
635 }
636
637 while (in->good()) {
638 int tagIndex = (int)tag->length();
639
640 while (in->good() && in->peek() != '>') {
641 int c = in->get();
642
643 if (c <= 0) {
645 break;
646 }
647
648 (*tag) += (char)c;
649 }
650
651 if (in->good()) {
652 // We now have something we presume to be a node of
653 // some sort. Identify it, and call the node to
654 // continue streaming.
655 TiXmlNode* node = Identify(tag->c_str() + tagIndex, TIXML_DEFAULT_ENCODING);
656
657 if (node) {
658 node->StreamIn(in, tag);
659 bool isElement = node->ToElement() != 0;
660 delete node;
661 node = 0;
662
663 // If this is the root element, we're done. Parsing will be
664 // done by the >> operator.
665 if (isElement) {
666 return;
667 }
668 } else {
670 return;
671 }
672 }
673 }
674
675 // We should have returned sooner.
677}
static bool StreamTo(std::istream *in, int character, TIXML_STRING *tag)
virtual void StreamIn(std::istream *in, TIXML_STRING *tag)=0
const TiXmlEncoding TIXML_DEFAULT_ENCODING
Definition tinyxml.h:185

References TiXmlNode::TiXmlNode(), TiXmlNode::Identify(), SetError(), TiXmlNode::StreamIn(), TiXmlBase::StreamTo(), TIXML_DEFAULT_ENCODING, TIXML_ENCODING_UNKNOWN, TiXmlBase::TIXML_ERROR, TiXmlBase::TIXML_ERROR_EMBEDDED_nullptr, TiXmlBase::TIXML_ERROR_PARSING_EMPTY, TIXML_STRING, and TiXmlNode::ToElement().

Here is the call graph for this function:

◆ StreamTo()

bool TiXmlBase::StreamTo ( std::istream * in,
int character,
TIXML_STRING * tag )
staticprotectedinherited

Definition at line 386 of file tinyxmlparser.cpp.

386 {
387 // assert( character > 0 && character < 128 ); // else it won't work in utf-8
388 while (in->good()) {
389 int c = in->peek();
390
391 if (c == character) return true;
392
393 if (c <= 0) // Silent failure: can't get document at this scope
394 return false;
395
396 in->get();
397 *tag += (char)c;
398 }
399
400 return false;
401}

References TIXML_STRING.

Referenced by TiXmlDocument::StreamIn().

Here is the caller graph for this function:

◆ StreamWhiteSpace()

bool TiXmlBase::StreamWhiteSpace ( std::istream * in,
TIXML_STRING * tag )
staticprotectedinherited

Definition at line 372 of file tinyxmlparser.cpp.

372 {
373 for (;;) {
374 if (!in->good()) return false;
375
376 int c = in->peek();
377
378 // At this scope, we can't get to a document. So fail silently.
379 if (!IsWhiteSpace(c) || c <= 0) return true;
380
381 *tag += (char)in->get();
382 }
383}

References IsWhiteSpace(), and TIXML_STRING.

Referenced by TiXmlElement::StreamIn().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StringEqual()

bool TiXmlBase::StringEqual ( const char * p,
const char * endTag,
bool ignoreCase,
TiXmlEncoding encoding )
staticprotectedinherited

Definition at line 532 of file tinyxmlparser.cpp.

535 {
536 assert(p);
537 assert(tag);
538
539 if (!p || !*p) {
540 assert(0);
541 return false;
542 }
543
544 const char* q = p;
545
546 if (ignoreCase) {
547 while (*q && *tag && ToLower(*q, encoding) == ToLower(*tag, encoding)) {
548 ++q;
549 ++tag;
550 }
551
552 if (*tag == 0) return true;
553 } else {
554 while (*q && *tag && *q == *tag) {
555 ++q;
556 ++tag;
557 }
558
559 if (*tag == 0) // Have we found the end of the tag, and everything equal?
560 return true;
561 }
562
563 return false;
564}
static int ToLower(int v, TiXmlEncoding encoding)
Definition tinyxml.h:419

References ToLower().

Referenced by TiXmlNode::Identify(), TiXmlComment::Parse(), TiXmlDeclaration::Parse(), TiXmlDocument::Parse(), TiXmlElement::Parse(), TiXmlStylesheetReference::Parse(), TiXmlText::Parse(), ReadText(), and TiXmlElement::ReadValue().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TabSize()

int TiXmlDocument::TabSize ( ) const
inline

Definition at line 1794 of file tinyxml.h.

1794{ return tabsize; }

References tabsize.

Referenced by Parse().

Here is the caller graph for this function:

◆ ToComment() [1/2]

virtual TiXmlComment * TiXmlNode::ToComment ( )
inlinevirtualinherited

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

Reimplemented in TiXmlComment.

Definition at line 821 of file tinyxml.h.

◆ ToComment() [2/2]

virtual const TiXmlComment * TiXmlNode::ToComment ( ) const
inlinevirtualinherited

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

Reimplemented in TiXmlComment.

Definition at line 792 of file tinyxml.h.

Referenced by ticpp::Node::NodeFactory(), and ticpp::Node::ToComment().

Here is the caller graph for this function:

◆ ToDeclaration() [1/2]

virtual TiXmlDeclaration * TiXmlNode::ToDeclaration ( )
inlinevirtualinherited

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

Reimplemented in TiXmlDeclaration.

Definition at line 833 of file tinyxml.h.

◆ ToDeclaration() [2/2]

virtual const TiXmlDeclaration * TiXmlNode::ToDeclaration ( ) const
inlinevirtualinherited

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

Reimplemented in TiXmlDeclaration.

Definition at line 804 of file tinyxml.h.

Referenced by ticpp::Node::NodeFactory(), TiXmlDocument::Parse(), and ticpp::Node::ToDeclaration().

Here is the caller graph for this function:

◆ ToDocument() [1/2]

virtual TiXmlDocument * TiXmlDocument::ToDocument ( )
inlinevirtual

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

Reimplemented from TiXmlNode.

Definition at line 1831 of file tinyxml.h.

References TiXmlDocument().

Here is the call graph for this function:

◆ ToDocument() [2/2]

virtual const TiXmlDocument * TiXmlDocument::ToDocument ( ) const
inlinevirtual

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

Reimplemented from TiXmlNode.

Definition at line 1827 of file tinyxml.h.

References TiXmlDocument().

Here is the call graph for this function:

◆ ToElement() [1/2]

virtual TiXmlElement * TiXmlNode::ToElement ( )
inlinevirtualinherited

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

Reimplemented in TiXmlElement.

Definition at line 817 of file tinyxml.h.

References TiXmlElement.

Here is the call graph for this function:

◆ ToElement() [2/2]

virtual const TiXmlElement * TiXmlNode::ToElement ( ) const
inlinevirtualinherited

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

Reimplemented in TiXmlElement.

Definition at line 788 of file tinyxml.h.

References TiXmlElement.

Referenced by FirstChildElement(), FirstChildElement(), NextSiblingElement(), NextSiblingElement(), ticpp::Node::NodeFactory(), TiXmlDocument::StreamIn(), and ticpp::Node::ToElement().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ToLower()

int TiXmlBase::ToLower ( int v,
TiXmlEncoding encoding )
inlinestaticprotectedinherited

Definition at line 419 of file tinyxml.h.

419 {
420 if (encoding == TIXML_ENCODING_UTF8) {
421 if (v < 128) return std::tolower(v);
422
423 return v;
424 } else {
425 return std::tolower(v);
426 }
427 }

References TIXML_ENCODING_UTF8.

Referenced by StringEqual().

Here is the caller graph for this function:

◆ ToStylesheetReference() [1/2]

virtual TiXmlStylesheetReference * TiXmlNode::ToStylesheetReference ( )
inlinevirtualinherited

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

Reimplemented in TiXmlStylesheetReference.

Definition at line 837 of file tinyxml.h.

◆ ToStylesheetReference() [2/2]

virtual const TiXmlStylesheetReference * TiXmlNode::ToStylesheetReference ( ) const
inlinevirtualinherited

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

Reimplemented in TiXmlStylesheetReference.

Definition at line 808 of file tinyxml.h.

Referenced by ticpp::Node::NodeFactory(), and ticpp::Node::ToStylesheetReference().

Here is the caller graph for this function:

◆ ToText() [1/2]

virtual TiXmlText * TiXmlNode::ToText ( )
inlinevirtualinherited

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

Reimplemented in TiXmlText.

Definition at line 829 of file tinyxml.h.

◆ ToText() [2/2]

virtual const TiXmlText * TiXmlNode::ToText ( ) const
inlinevirtualinherited

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

Reimplemented in TiXmlText.

Definition at line 800 of file tinyxml.h.

Referenced by TiXmlElement::GetText(), ticpp::Node::NodeFactory(), TiXmlElement::Print(), ticpp::Node::ToText(), and TiXmlPrinter::VisitEnter().

Here is the caller graph for this function:

◆ ToUnknown() [1/2]

virtual TiXmlUnknown * TiXmlNode::ToUnknown ( )
inlinevirtualinherited

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

Reimplemented in TiXmlUnknown.

Definition at line 825 of file tinyxml.h.

◆ ToUnknown() [2/2]

virtual const TiXmlUnknown * TiXmlNode::ToUnknown ( ) const
inlinevirtualinherited

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

Reimplemented in TiXmlUnknown.

Definition at line 796 of file tinyxml.h.

◆ Type()

int TiXmlNode::Type ( ) const
inlineinherited

Query the type (as an enumerated value, above) of this node.

The possible types are: DOCUMENT, ELEMENT, COMMENT, UNKNOWN, TEXT, and DECLARATION.

Definition at line 770 of file tinyxml.h.

770{ return type; }
NodeType type
Definition tinyxml.h:893

References type.

Referenced by InsertAfterChild(), InsertBeforeChild(), InsertEndChild(), LinkEndChild(), ticpp::Node::NodeFactory(), and ticpp::Node::Type().

Here is the caller graph for this function:

◆ Value()

const char * TiXmlNode::Value ( ) const
inlineinherited

The meaning of 'value' changes for the specific type of TiXmlNode.

Document: filename of the xml file
Element:  name of the element
Comment:  the comment text
Unknown:  the tag contents
Text:   the text string

The subclasses will wrap this function.

Definition at line 517 of file tinyxml.h.

517{ return value.c_str(); }

References value.

Referenced by ticpp::Base::BuildDetailedErrorString(), TiXmlElement::Clone(), FirstChild(), TiXmlElement::GetText(), LastChild(), TiXmlDocument::LoadFile(), NextSibling(), PreviousSibling(), TiXmlDocument::SaveFile(), TiXmlPrinter::Visit(), TiXmlPrinter::Visit(), TiXmlPrinter::Visit(), TiXmlPrinter::VisitEnter(), and TiXmlPrinter::VisitExit().

Here is the caller graph for this function:

◆ ValueStr()

const std::string & TiXmlNode::ValueStr ( ) const
inlineinherited

Return Value() as a std::string.

If you only use STL, this is more efficient than calling Value(). Only available in STL mode.

Definition at line 524 of file tinyxml.h.

524{ return value; }

References value.

Referenced by ticpp::Node::Value().

Here is the caller graph for this function:

◆ ValueTStr()

const TIXML_STRING & TiXmlNode::ValueTStr ( ) const
inlineinherited

Definition at line 527 of file tinyxml.h.

527{ return value; }

References TIXML_STRING, and value.

Referenced by TiXmlPrinter::Visit().

Here is the caller graph for this function:

Member Data Documentation

◆ condenseWhiteSpace

bool TiXmlBase::condenseWhiteSpace = true
staticprivateinherited

Definition at line 445 of file tinyxml.h.

Referenced by IsWhiteSpaceCondensed(), ReadText(), and SetCondenseWhiteSpace().

◆ entity

TiXmlBase::Entity TiXmlBase::entity
staticprivateinherited
Initial value:
= {{"&amp;", 5, '&'},
{"&lt;", 4, '<'},
{"&gt;", 4, '>'},
{"&quot;", 6, '\"'},
{"&apos;", 6, '\''}}

Definition at line 44 of file tinyxml.h.

Referenced by EncodeString(), and GetEntity().

◆ error

bool TiXmlDocument::error
private

Definition at line 1850 of file tinyxml.h.

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

◆ errorDesc

TIXML_STRING TiXmlDocument::errorDesc
private

Definition at line 1852 of file tinyxml.h.

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

◆ errorId

int TiXmlDocument::errorId
private

Definition at line 1851 of file tinyxml.h.

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

◆ errorLocation

TiXmlCursor TiXmlDocument::errorLocation
private

Definition at line 1854 of file tinyxml.h.

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

◆ errorString

const char * TiXmlBase::errorString
staticprotectedinherited
Initial value:
= {
"No error",
"Error",
"Failed to open file",
"Memory allocation failed.",
"Error parsing Element.",
"Failed to read Element name",
"Error reading Element value.",
"Error reading Attributes.",
"Error: empty tag.",
"Error reading end tag.",
"Error parsing Unknown.",
"Error parsing Comment.",
"Error parsing Declaration.",
"Error document empty.",
"Error null (0) or unexpected EOF found in input stream.",
"Error parsing CDATA.",
"Error when TiXmlDocument added to document, because "
"TiXmlDocument can only be at the root.",
}

Definition at line 35 of file tinyxml.h.

Referenced by TiXmlDocument::SetError().

◆ firstChild

◆ lastChild

◆ location

◆ m_spawnedWrappers

std::vector< ticpp::Base* > TiCppRC::m_spawnedWrappers
inherited

Remember all wrappers that we've created with 'new' - ( e.g.

NodeFactory, FirstChildElement, etc. )

Definition at line 63 of file ticpprc.h.

Referenced by DeleteSpawnedWrappers(), ticpp::Element::LastAttribute(), ticpp::Attribute::Next(), ticpp::Node::NodeFactory(), ticpp::Attribute::Previous(), ticpp::Node::ToComment(), ticpp::Node::ToDocument(), and ticpp::Node::ToElement().

◆ m_tiRC

TiCppRCImp* TiCppRC::m_tiRC
privateinherited

Pointer to reference counter.

Definition at line 46 of file ticpprc.h.

Referenced by ticpp::Base::SetImpRC().

◆ next

◆ parent

◆ prev

◆ tabsize

int TiXmlDocument::tabsize
private

Definition at line 1853 of file tinyxml.h.

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

◆ type

NodeType TiXmlNode::type
protectedinherited

Definition at line 893 of file tinyxml.h.

Referenced by TiXmlNode(), and Type().

◆ useMicrosoftBOM

bool TiXmlDocument::useMicrosoftBOM
private

Definition at line 1855 of file tinyxml.h.

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

◆ userData

void* TiXmlBase::userData
protectedinherited

Field containing a generic user pointer.

Definition at line 413 of file tinyxml.h.

Referenced by TiXmlBase(), TiXmlNode::CopyTo(), GetUserData(), GetUserData(), and SetUserData().

◆ utf8ByteTable

const int TiXmlBase::utf8ByteTable
staticinherited

Definition at line 64 of file tinyxml.h.

Referenced by GetChar(), and TiXmlParsingData::Stamp().

◆ value


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