27 #if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__) 35 #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE) 44 static inline int TIXML_SNPRINTF(
char* buffer,
size_t size,
const char* format, ... )
47 va_start( va, format );
48 int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );
53 static inline int TIXML_VSNPRINTF(
char* buffer,
size_t size,
const char* format, va_list va )
55 int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );
59 #define TIXML_VSCPRINTF _vscprintf 60 #define TIXML_SSCANF sscanf_s 61 #elif defined _MSC_VER 63 #define TIXML_SNPRINTF _snprintf 64 #define TIXML_VSNPRINTF _vsnprintf 65 #define TIXML_SSCANF sscanf 66 #if (_MSC_VER < 1400 ) && (!defined WINCE) 68 #define TIXML_VSCPRINTF _vscprintf // VS2003's C runtime has this, but VC6 C runtime or WinCE SDK doesn't have. 71 static inline int TIXML_VSCPRINTF(
const char* format, va_list va )
76 char* str =
new char[len]();
77 const int required = _vsnprintf(str, len, format, va);
79 if ( required != -1 ) {
92 #define TIXML_SNPRINTF snprintf 93 #define TIXML_VSNPRINTF vsnprintf 94 static inline int TIXML_VSCPRINTF(
const char* format, va_list va )
96 int len = vsnprintf( 0, 0, format, va );
100 #define TIXML_SSCANF sscanf 104 static const char LINE_FEED = (char)0x0a;
105 static const char LF = LINE_FEED;
106 static const char CARRIAGE_RETURN = (char)0x0d;
107 static const char CR = CARRIAGE_RETURN;
108 static const char SINGLE_QUOTE =
'\'';
109 static const char DOUBLE_QUOTE =
'\"';
115 static const unsigned char TIXML_UTF_LEAD_0 = 0xefU;
116 static const unsigned char TIXML_UTF_LEAD_1 = 0xbbU;
117 static const unsigned char TIXML_UTF_LEAD_2 = 0xbfU;
128 static const int NUM_ENTITIES = 5;
129 static const Entity entities[NUM_ENTITIES] = {
130 {
"quot", 4, DOUBLE_QUOTE },
132 {
"apos", 4, SINGLE_QUOTE },
146 if (
this == other ) {
159 other->_flags = _flags;
160 other->_start = _start;
171 if ( _flags & NEEDS_DELETE ) {
184 size_t len = strlen( str );
186 _start =
new char[ len+1 ];
187 memcpy( _start, str, len+1 );
189 _flags = flags | NEEDS_DELETE;
200 char endChar = *endTag;
201 size_t length = strlen( endTag );
205 if ( *p == endChar && strncmp( p, endTag, length ) == 0 ) {
206 Set( start, p, strFlags );
208 }
else if (*p ==
'\n') {
227 char*
const start = p;
238 void StrPair::CollapseWhitespace()
246 const char* p = _start;
271 if ( _flags & NEEDS_FLUSH ) {
273 _flags ^= NEEDS_FLUSH;
276 const char* p = _start;
284 if ( *(p+1) == LF ) {
294 if ( *(p+1) == CR ) {
309 if ( *(p+1) ==
'#' ) {
310 const int buflen = 10;
311 char buf[buflen] = { 0 };
314 if ( adjusted == 0 ) {
323 memcpy( q, buf, len );
328 bool entityFound =
false;
329 for(
int i = 0; i < NUM_ENTITIES; ++i ) {
330 const Entity& entity = entities[i];
332 && *( p + entity.
length + 1 ) ==
';' ) {
341 if ( !entityFound ) {
359 CollapseWhitespace();
361 _flags = (_flags & NEEDS_DELETE);
372 const char* XMLUtil::writeBoolTrue =
"true";
373 const char* XMLUtil::writeBoolFalse =
"false";
377 static const char* defTrue =
"true";
378 static const char* defFalse =
"false";
380 writeBoolTrue = (writeTrue) ? writeTrue : defTrue;
381 writeBoolFalse = (writeFalse) ? writeFalse : defFalse;
390 const unsigned char* pu =
reinterpret_cast<const unsigned char*
>(p);
392 if ( *(pu+0) == TIXML_UTF_LEAD_0
393 && *(pu+1) == TIXML_UTF_LEAD_1
394 && *(pu+2) == TIXML_UTF_LEAD_2 ) {
405 const unsigned long BYTE_MASK = 0xBF;
406 const unsigned long BYTE_MARK = 0x80;
407 const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
412 else if ( input < 0x800 ) {
415 else if ( input < 0x10000 ) {
418 else if ( input < 0x200000 ) {
433 *output = (char)((input | BYTE_MARK) & BYTE_MASK);
438 *output = (char)((input | BYTE_MARK) & BYTE_MASK);
443 *output = (char)((input | BYTE_MARK) & BYTE_MASK);
448 *output = (char)(input | FIRST_BYTE_MARK[*length]);
461 if ( *(p+1) ==
'#' && *(p+2) ) {
462 unsigned long ucs = 0;
466 static const char SEMICOLON =
';';
468 if ( *(p+2) ==
'x' ) {
475 q = strchr( q, SEMICOLON );
485 while ( *q !=
'x' ) {
486 unsigned int digit = 0;
488 if ( *q >=
'0' && *q <=
'9' ) {
491 else if ( *q >=
'a' && *q <=
'f' ) {
492 digit = *q -
'a' + 10;
494 else if ( *q >=
'A' && *q <=
'F' ) {
495 digit = *q -
'A' + 10;
501 TIXMLASSERT( digit == 0 || mult <= UINT_MAX / digit );
502 const unsigned int digitScaled = mult * digit;
517 q = strchr( q, SEMICOLON );
527 while ( *q !=
'#' ) {
528 if ( *q >=
'0' && *q <=
'9' ) {
529 const unsigned int digit = *q -
'0';
531 TIXMLASSERT( digit == 0 || mult <= UINT_MAX / digit );
532 const unsigned int digitScaled = mult * digit;
546 return p + delta + 1;
566 TIXML_SNPRINTF( buffer, bufferSize,
"%s", v ? writeBoolTrue : writeBoolFalse);
611 if (
ToInt( str, &ival )) {
612 *value = (ival==0) ?
false :
true;
660 char*
const start = p;
661 int const startLine = _parseCurLineNum;
670 static const char* xmlHeader = {
"<?" };
671 static const char* commentHeader = {
"<!--" };
672 static const char* cdataHeader = {
"<![CDATA[" };
673 static const char* dtdHeader = {
"<!" };
674 static const char* elementHeader = {
"<" };
676 static const int xmlHeaderLen = 2;
677 static const int commentHeaderLen = 4;
678 static const int cdataHeaderLen = 9;
679 static const int dtdHeaderLen = 2;
680 static const int elementHeaderLen = 1;
686 returnNode = CreateUnlinkedNode<XMLDeclaration>( _commentPool );
691 returnNode = CreateUnlinkedNode<XMLComment>( _commentPool );
693 p += commentHeaderLen;
696 XMLText* text = CreateUnlinkedNode<XMLText>( _textPool );
703 returnNode = CreateUnlinkedNode<XMLUnknown>( _commentPool );
708 returnNode = CreateUnlinkedNode<XMLElement>( _elementPool );
710 p += elementHeaderLen;
713 returnNode = CreateUnlinkedNode<XMLText>( _textPool );
716 _parseCurLineNum = startLine;
731 if ( !node->Accept( visitor ) ) {
747 _firstChild( 0 ), _lastChild( 0 ),
748 _prev( 0 ), _next( 0 ),
784 if (!clone)
return 0;
804 void XMLNode::Unlink(
XMLNode* child )
816 if ( child->
_prev ) {
819 if ( child->
_next ) {
848 InsertChildPreamble( addThis );
878 InsertChildPreamble( addThis );
912 if ( afterThis->
_parent !=
this ) {
916 if ( afterThis == addThis ) {
924 if ( afterThis->
_next == 0 ) {
928 InsertChildPreamble( addThis );
929 addThis->
_prev = afterThis;
932 afterThis->
_next = addThis;
943 const XMLElement* element = node->ToElementWithName( name );
955 const XMLElement* element = node->ToElementWithName( name );
967 const XMLElement* element = node->ToElementWithName( name );
979 const XMLElement* element = node->ToElementWithName( name );
1007 XMLDocument::DepthTracker tracker(
_document);
1023 p = node->
ParseDeep( p, &endTag, curLineNumPtr );
1036 if ( wellLocated ) {
1040 if ( !existingNode->ToDeclaration() ) {
1041 wellLocated =
false;
1046 if ( !wellLocated ) {
1057 if ( parentEndTag ) {
1067 bool mismatch =
false;
1068 if ( endTag.
Empty() ) {
1092 void XMLNode::DeleteNode(
XMLNode* node )
1102 MemPool* pool = node->_memPool;
1107 void XMLNode::InsertChildPreamble( XMLNode* insertThis )
const 1112 if (insertThis->_parent) {
1113 insertThis->_parent->Unlink( insertThis );
1116 insertThis->_document->MarkInUse(insertThis);
1117 insertThis->_memPool->SetTracked();
1121 const XMLElement* XMLNode::ToElementWithName(
const char* name )
const 1124 if ( element == 0 ) {
1139 if ( this->
CData() ) {
1186 return visitor->
Visit( *
this );
1234 return visitor->
Visit( *
this );
1284 return visitor->
Visit( *
this );
1331 return visitor->
Visit( *
this );
1346 char* XMLAttribute::ParseDeep(
char* p,
bool processEntities,
int* curLineNumPtr )
1362 if ( *p !=
'\"' && *p !=
'\'' ) {
1366 char endTag[2] = { *p, 0 };
1374 void XMLAttribute::SetName(
const char* n )
1489 _closingType( OPEN ),
1495 XMLElement::~XMLElement()
1497 while( _rootAttribute ) {
1498 XMLAttribute* next = _rootAttribute->_next;
1500 _rootAttribute = next;
1507 for(
XMLAttribute* a = _rootAttribute; a; a = a->_next ) {
1530 int i = defaultValue;
1537 unsigned i = defaultValue;
1544 int64_t i = defaultValue;
1551 bool b = defaultValue;
1558 double d = defaultValue;
1565 float f = defaultValue;
1717 int i = defaultValue;
1724 unsigned i = defaultValue;
1731 int64_t i = defaultValue;
1738 bool b = defaultValue;
1745 double d = defaultValue;
1752 float f = defaultValue;
1758 XMLAttribute* XMLElement::FindOrCreateAttribute(
const char* name )
1762 for( attrib = _rootAttribute;
1764 last = attrib, attrib = attrib->_next ) {
1770 attrib = CreateAttribute();
1774 last->_next = attrib;
1778 _rootAttribute = attrib;
1780 attrib->SetName( name );
1792 prev->_next = a->_next;
1795 _rootAttribute = a->_next;
1805 char* XMLElement::ParseAttributes(
char* p,
int* curLineNumPtr )
1819 XMLAttribute* attrib = CreateAttribute();
1821 attrib->_parseLineNum =
_document->_parseCurLineNum;
1823 int attrLineNum = attrib->_parseLineNum;
1826 if ( !p ||
Attribute( attrib->Name() ) ) {
1836 if ( prevAttribute ) {
1838 prevAttribute->_next = attrib;
1842 _rootAttribute = attrib;
1844 prevAttribute = attrib;
1847 else if ( *p ==
'>' ) {
1852 else if ( *p ==
'/' && *(p+1) ==
'>' ) {
1866 if ( attribute == 0 ) {
1869 MemPool* pool = attribute->_memPool;
1870 attribute->~XMLAttribute();
1871 pool->Free( attribute );
1874 XMLAttribute* XMLElement::CreateAttribute()
1877 XMLAttribute* attrib =
new (
_document->_attributePool.Alloc() ) XMLAttribute();
1879 attrib->_memPool = &
_document->_attributePool;
1880 attrib->_memPool->SetTracked();
1906 p = ParseAttributes( p, curLineNumPtr );
1907 if ( !p || !*p || _closingType !=
OPEN ) {
1959 if ( visitor->
VisitEnter( *
this, _rootAttribute ) ) {
1961 if ( !node->
Accept( visitor ) ) {
1976 "XML_WRONG_ATTRIBUTE_TYPE",
1977 "XML_ERROR_FILE_NOT_FOUND",
1978 "XML_ERROR_FILE_COULD_NOT_BE_OPENED",
1979 "XML_ERROR_FILE_READ_ERROR",
1980 "XML_ERROR_PARSING_ELEMENT",
1981 "XML_ERROR_PARSING_ATTRIBUTE",
1982 "XML_ERROR_PARSING_TEXT",
1983 "XML_ERROR_PARSING_CDATA",
1984 "XML_ERROR_PARSING_COMMENT",
1985 "XML_ERROR_PARSING_DECLARATION",
1986 "XML_ERROR_PARSING_UNKNOWN",
1987 "XML_ERROR_EMPTY_DOCUMENT",
1988 "XML_ERROR_MISMATCHED_ELEMENT",
1989 "XML_ERROR_PARSING",
1990 "XML_CAN_NOT_CONVERT_TEXT",
1992 "XML_ELEMENT_DEPTH_EXCEEDED" 1999 _processEntities( processEntities ),
2001 _whitespaceMode( whitespaceMode ),
2005 _parseCurLineNum( 0 ),
2029 for (
int i = 0; i < _unlinked.Size(); ++i) {
2030 if (node == _unlinked[i]) {
2031 _unlinked.SwapRemove(i);
2040 while( _unlinked.Size()) {
2044 #ifdef TINYXML2_DEBUG 2045 const bool hadError =
Error();
2049 delete [] _charBuffer;
2053 #ifdef TINYXML2_DEBUG 2055 TIXMLASSERT( _elementPool.CurrentAllocs() == _elementPool.Untracked() );
2056 TIXMLASSERT( _attributePool.CurrentAllocs() == _attributePool.Untracked() );
2057 TIXMLASSERT( _textPool.CurrentAllocs() == _textPool.Untracked() );
2058 TIXMLASSERT( _commentPool.CurrentAllocs() == _commentPool.Untracked() );
2067 if (target ==
this) {
2079 XMLElement* ele = CreateUnlinkedNode<XMLElement>( _elementPool );
2087 XMLComment* comment = CreateUnlinkedNode<XMLComment>( _commentPool );
2095 XMLText* text = CreateUnlinkedNode<XMLText>( _textPool );
2103 XMLDeclaration* dec = CreateUnlinkedNode<XMLDeclaration>( _commentPool );
2104 dec->
SetValue( str ? str :
"xml version=\"1.0\" encoding=\"UTF-8\"" );
2111 XMLUnknown* unk = CreateUnlinkedNode<XMLUnknown>( _commentPool );
2116 static FILE* callfopen(
const char* filepath,
const char* mode )
2120 #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE) 2122 errno_t err = fopen_s( &fp, filepath, mode );
2127 FILE* fp = fopen( filepath, mode );
2145 XMLNode::DeleteNode(node);
2159 FILE* fp = callfopen( filename,
"rb" );
2176 <
bool = (
sizeof(
unsigned long) >=
sizeof(
size_t))>
2178 static bool Fits(
unsigned long value )
2180 return value < (size_t)-1;
2196 fseek( fp, 0, SEEK_SET );
2197 if ( fgetc( fp ) == EOF && ferror( fp ) != 0 ) {
2202 fseek( fp, 0, SEEK_END );
2203 const long filelength = ftell( fp );
2204 fseek( fp, 0, SEEK_SET );
2205 if ( filelength == -1L ) {
2217 if ( filelength == 0 ) {
2222 const size_t size = filelength;
2224 _charBuffer =
new char[size+1];
2225 size_t read = fread( _charBuffer, 1, size, fp );
2226 if ( read != size ) {
2231 _charBuffer[size] = 0;
2246 FILE* fp = callfopen( filename,
"w" );
2268 XMLError XMLDocument::Parse(
const char* p,
size_t len )
2272 if ( len == 0 || !p || !*p ) {
2276 if ( len == (
size_t)(-1) ) {
2280 _charBuffer =
new char[ len+1 ];
2281 memcpy( _charBuffer, p, len );
2282 _charBuffer[len] = 0;
2290 _elementPool.Clear();
2291 _attributePool.Clear();
2293 _commentPool.Clear();
2306 Accept( &stdoutStreamer );
2311 void XMLDocument::SetError(
XMLError error,
int lineNum,
const char* format, ... )
2315 _errorLineNum = lineNum;
2318 size_t BUFFER_SIZE = 1000;
2319 char* buffer =
new char[BUFFER_SIZE];
2322 TIXML_SNPRINTF(buffer, BUFFER_SIZE,
"Error=%s ErrorID=%d (0x%x) Line number=%d",
ErrorIDToName(error),
int(error),
int(error), lineNum);
2325 size_t len = strlen(buffer);
2327 len = strlen(buffer);
2330 va_start(va, format);
2334 _errorStr.
SetStr(buffer);
2342 const char* errorName = _errorNames[errorID];
2349 return _errorStr.
Empty() ?
"" : _errorStr.
GetStr();
2363 void XMLDocument::Parse()
2367 _parseCurLineNum = 1;
2369 char* p = _charBuffer;
2379 void XMLDocument::PushDepth()
2382 if (_parsingDepth == TINYXML2_MAX_ELEMENT_DEPTH) {
2387 void XMLDocument::PopDepth()
2394 _elementJustOpened( false ),
2396 _firstElement(
true ),
2400 _processEntities(
true ),
2401 _compactMode( compact ),
2404 for(
int i=0; i<ENTITY_RANGE; ++i ) {
2405 _entityFlag[i] =
false;
2406 _restrictedEntityFlag[i] =
false;
2408 for(
int i=0; i<NUM_ENTITIES; ++i ) {
2409 const char entityValue = entities[i].
value;
2410 const unsigned char flagIndex = (
unsigned char)entityValue;
2412 _entityFlag[flagIndex] =
true;
2414 _restrictedEntityFlag[(
unsigned char)
'&'] =
true;
2415 _restrictedEntityFlag[(
unsigned char)
'<'] =
true;
2416 _restrictedEntityFlag[(
unsigned char)
'>'] =
true;
2424 va_start( va, format );
2427 vfprintf( _fp, format, va );
2430 const int len = TIXML_VSCPRINTF( format, va );
2434 va_start( va, format );
2436 char* p = _buffer.
PushArr( len ) - 1;
2446 fwrite ( data ,
sizeof(
char), size, _fp);
2449 char* p = _buffer.
PushArr( static_cast<int>(size) ) - 1;
2450 memcpy( p, data, size );
2462 char* p = _buffer.
PushArr(
sizeof(
char) ) - 1;
2471 for(
int i=0; i<depth; ++i ) {
2477 void XMLPrinter::PrintString(
const char* p,
bool restricted )
2482 if ( _processEntities ) {
2483 const bool* flag = restricted ? _restrictedEntityFlag : _entityFlag;
2487 if ( *q > 0 && *q < ENTITY_RANGE ) {
2491 if ( flag[(
unsigned char)(*q)] ) {
2493 const size_t delta = q - p;
2494 const int toPrint = ( INT_MAX < delta ) ? INT_MAX : (
int)delta;
2495 Write( p, toPrint );
2498 bool entityPatternPrinted =
false;
2499 for(
int i=0; i<NUM_ENTITIES; ++i ) {
2500 if ( entities[i].value == *q ) {
2502 Write( entities[i].pattern, entities[i].length );
2504 entityPatternPrinted =
true;
2508 if ( !entityPatternPrinted ) {
2521 const size_t delta = q - p;
2522 const int toPrint = ( INT_MAX < delta ) ? INT_MAX : (
int)delta;
2523 Write( p, toPrint );
2535 static const unsigned char bom[] = { TIXML_UTF_LEAD_0, TIXML_UTF_LEAD_1, TIXML_UTF_LEAD_2, 0 };
2536 Write( reinterpret_cast< const char* >( bom ) );
2549 if ( _textDepth < 0 && !_firstElement && !compactMode ) {
2552 if ( !compactMode ) {
2560 _firstElement =
false;
2571 PrintString( value,
false );
2625 if ( _textDepth < 0 && !compactMode) {
2634 if ( _textDepth == _depth ) {
2637 if ( _depth == 0 && !compactMode) {
2656 _textDepth = _depth-1;
2660 Write(
"<![CDATA[" );
2665 PrintString( text,
true );
2719 if ( _textDepth < 0 && !_firstElement && !_compactMode) {
2723 _firstElement =
false;
2734 if ( _textDepth < 0 && !_firstElement && !_compactMode) {
2738 _firstElement =
false;
2749 if ( _textDepth < 0 && !_firstElement && !_compactMode) {
2753 _firstElement =
false;
2774 if ( element.
Parent() ) {
2777 const bool compactMode = parentElem ?
CompactMode( *parentElem ) : _compactMode;
2779 while ( attribute ) {
2781 attribute = attribute->
Next();
void SetValue(const char *val, bool staticMem=false)
XMLError QueryInt64Attribute(const char *name, int64_t *value) const
See QueryIntAttribute()
XMLError QueryIntValue(int *value) const
static const char * GetCharacterRef(const char *p, char *value, int *length)
char * ParseDeep(char *p, StrPair *parentEndTag, int *curLineNumPtr)
XMLError QueryBoolAttribute(const char *name, bool *value) const
See QueryIntAttribute()
virtual bool VisitExit(const XMLDocument &)
Visit a document.
void PushAttribute(const char *name, const char *value)
If streaming, add an attribute to an open element.
unsigned UnsignedAttribute(const char *name, unsigned defaultValue=0) const
See IntAttribute()
void SetInternedStr(const char *str)
XMLNode * InsertEndChild(XMLNode *addThis)
XMLError QueryFloatValue(float *value) const
See QueryIntValue.
int IntAttribute(const char *name, int defaultValue=0) const
virtual void CloseElement(bool compactMode=false)
If streaming, close the Element.
static bool ToInt(const char *str, int *value)
virtual bool Accept(XMLVisitor *visitor) const
virtual bool Visit(const XMLText &text)
Visit a text node.
virtual bool CompactMode(const XMLElement &)
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
virtual XMLText * ToText()
Safely cast to Text, or null.
Whitespace WhitespaceMode() const
const char * Attribute(const char *name, const char *value=0) const
XMLText * NewText(const char *text)
void PushHeader(bool writeBOM, bool writeDeclaration)
static const char * SkipWhiteSpace(const char *p, int *curLineNumPtr)
virtual XMLNode * ShallowClone(XMLDocument *document) const
XMLError QueryUnsignedAttribute(const char *name, unsigned int *value) const
See QueryIntAttribute()
static bool ToInt64(const char *str, int64_t *value)
XMLComment * NewComment(const char *comment)
int64_t Int64Text(int64_t defaultValue=0) const
See QueryIntText()
virtual bool ShallowEqual(const XMLNode *compare) const
const char * Name() const
Get the name of an element (which is the Value() of the node.)
ElementClosingType ClosingType() const
void SetCData(bool isCData)
Declare whether this should be CDATA or standard text.
const XMLNode * NextSibling() const
Get the next (right) sibling node of this node.
XMLError QueryIntText(int *ival) const
static bool Fits(unsigned long)
static bool StringEqual(const char *p, const char *q, int nChar=INT_MAX)
static bool ToUnsigned(const char *str, unsigned *value)
const char * ErrorName() const
XMLError QueryBoolText(bool *bval) const
See QueryIntText()
virtual bool Accept(XMLVisitor *visitor) const
virtual void SetTracked()=0
static void SetBoolSerialization(const char *writeTrue, const char *writeFalse)
static void ToStr(int v, char *buffer, int bufferSize)
void Write(const char *data, size_t size)
void SetName(const char *str, bool staticMem=false)
Set the name of the element.
static const char * ReadBOM(const char *p, bool *hasBOM)
XMLError QueryUnsignedText(unsigned *uval) const
See QueryIntText()
XMLUnknown(XMLDocument *doc)
void OpenElement(const char *name, bool compactMode=false)
static bool IsNameChar(unsigned char ch)
XMLError QueryFloatAttribute(const char *name, float *value) const
See QueryIntAttribute()
XMLError QueryUnsignedValue(unsigned int *value) const
See QueryIntValue.
void DeleteNode(XMLNode *node)
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
virtual bool Accept(XMLVisitor *visitor) const
static const char * ErrorIDToName(XMLError errorID)
virtual XMLNode * ShallowClone(XMLDocument *document) const
void DeleteChild(XMLNode *node)
void PushComment(const char *comment)
Add a comment.
virtual bool Visit(const XMLDeclaration &)
Visit a declaration.
virtual void PrintSpace(int depth)
int IntText(int defaultValue=0) const
XMLError QueryDoubleAttribute(const char *name, double *value) const
See QueryIntAttribute()
virtual bool VisitEnter(const XMLDocument &)
Visit a document.
XMLError QueryInt64Value(int64_t *value) const
See QueryIntValue.
float FloatText(float defaultValue=0) const
See QueryIntText()
char * Identify(char *p, XMLNode **node)
XMLNode * DeepClone(XMLDocument *target) const
void Set(char *start, char *end, int flags)
XMLError QueryInt64Text(int64_t *uval) const
See QueryIntText()
const XMLElement * NextSiblingElement(const char *name=0) const
Get the next (right) sibling element of this node, with an optionally supplied name.
bool CData() const
Returns true if this is a CDATA text element.
bool BoolText(bool defaultValue=false) const
See QueryIntText()
const char * Name() const
The name of the attribute.
virtual bool ShallowEqual(const XMLNode *compare) const
virtual bool VisitExit(const XMLDocument &)
Visit a document.
char * ParseDeep(char *p, StrPair *parentEndTag, int *curLineNumPtr)
virtual bool ShallowEqual(const XMLNode *compare) const
char * ParseName(char *in)
void MarkInUse(XMLNode *)
char * ParseDeep(char *p, StrPair *parentEndTag, int *curLineNumPtr)
const char * Value() const
bool Error() const
Return true if there was an error parsing the document.
static bool ToFloat(const char *str, float *value)
const XMLElement * LastChildElement(const char *name=0) const
virtual ~XMLDeclaration()
void PushText(const char *text, bool cdata=false)
Add a text node.
virtual bool VisitEnter(const XMLDocument &)
Visit a document.
double DoubleText(double defaultValue=0) const
See QueryIntText()
static bool Fits(unsigned long value)
virtual bool Accept(XMLVisitor *visitor) const
void SealElementIfJustOpened()
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
static bool ToDouble(const char *str, double *value)
double DoubleAttribute(const char *name, double defaultValue=0) const
See IntAttribute()
XMLElement * NewElement(const char *name)
void PushUnknown(const char *value)
int64_t Int64Attribute(const char *name, int64_t defaultValue=0) const
See IntAttribute()
const char * GetText() const
void SetAttribute(const char *value)
Set the attribute to a string value.
void SetAttribute(const char *name, const char *value)
Sets the named attribute to value.
static bool IsWhiteSpace(char p)
XMLError SaveFile(const char *filename, bool compact=false)
virtual bool ShallowEqual(const XMLNode *compare) const
unsigned UnsignedText(unsigned defaultValue=0) const
See QueryIntText()
char * ParseDeep(char *p, StrPair *parentEndTag, int *curLineNumPtr)
virtual char * ParseDeep(char *p, StrPair *parentEndTag, int *curLineNumPtr)
static void ConvertUTF32ToUTF8(unsigned long input, char *output, int *length)
XMLError QueryDoubleValue(double *value) const
See QueryIntValue.
void TransferTo(StrPair *other)
const XMLNode * Parent() const
Get the parent of this node on the DOM.
void Clear()
Clear the document, resetting it to the initial state.
virtual bool Accept(XMLVisitor *visitor) const =0
void PrintError() const
A (trivial) utility function that prints the ErrorStr() to stdout.
static bool IsNameStartChar(unsigned char ch)
XMLError QueryBoolValue(bool *value) const
See QueryIntValue.
XMLDeclaration * NewDeclaration(const char *text=0)
XMLError LoadFile(const char *filename)
const char * ErrorStr() const
XMLUnknown * NewUnknown(const char *text)
float FloatAttribute(const char *name, float defaultValue=0) const
See IntAttribute()
XMLError QueryDoubleText(double *dval) const
See QueryIntText()
void Print(XMLPrinter *streamer=0) const
virtual XMLNode * ShallowClone(XMLDocument *document) const
const char * Value() const
The value of the attribute.
XMLError Parse(const char *xml, size_t nBytes=(size_t)(-1))
XMLDeclaration(XMLDocument *doc)
const XMLAttribute * FindAttribute(const char *name) const
Query a specific attribute in the list.
void Print(const char *format,...)
XMLError QueryIntAttribute(const char *name, int *value) const
XMLNode * InsertAfterChild(XMLNode *afterThis, XMLNode *addThis)
virtual XMLNode * ShallowClone(XMLDocument *document) const
void DeleteAttribute(const char *name)
char * ParseText(char *in, const char *endTag, int strFlags, int *curLineNumPtr)
static bool ToBool(const char *str, bool *value)
DynArray< const char *, 10 > _stack
void DeepCopy(XMLDocument *target) const
XMLPrinter(FILE *file=0, bool compact=false, int depth=0)
void SetText(const char *inText)
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
bool BoolAttribute(const char *name, bool defaultValue=false) const
See IntAttribute()
const XMLAttribute * Next() const
The next attribute in the list.
void PushDeclaration(const char *value)
bool NoChildren() const
Returns true if this node has no children.
virtual bool Accept(XMLVisitor *visitor) const
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
const XMLDocument * GetDocument() const
Get the XMLDocument that owns this XMLNode.
bool ProcessEntities() const
const XMLElement * FirstChildElement(const char *name=0) const
void SetStr(const char *str, int flags=0)
XMLError QueryFloatText(float *fval) const
See QueryIntText()
XMLDocument(bool processEntities=true, Whitespace whitespaceMode=PRESERVE_WHITESPACE)
constructor
const XMLElement * PreviousSiblingElement(const char *name=0) const
Get the previous (left) sibling element of this node, with an optionally supplied name...
virtual XMLNode * ShallowClone(XMLDocument *document) const =0
XMLNode * InsertFirstChild(XMLNode *addThis)
const XMLAttribute * FirstAttribute() const
Return the first attribute in the list.
virtual XMLComment * ToComment()
Safely cast to a Comment, or null.