36 #if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__) 44 #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE) 53 static inline int TIXML_SNPRINTF(
char* buffer,
size_t size,
const char* format, ... )
56 va_start( va, format );
57 int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );
62 static inline int TIXML_VSNPRINTF(
char* buffer,
size_t size,
const char* format, va_list va )
64 int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );
68 #define TIXML_VSCPRINTF _vscprintf 69 #define TIXML_SSCANF sscanf_s 70 #elif defined _MSC_VER 72 #define TIXML_SNPRINTF _snprintf 73 #define TIXML_VSNPRINTF _vsnprintf 74 #define TIXML_SSCANF sscanf 75 #if (_MSC_VER < 1400 ) && (!defined WINCE) 77 #define TIXML_VSCPRINTF _vscprintf // VS2003's C runtime has this, but VC6 C runtime or WinCE SDK doesn't have. 80 static inline int TIXML_VSCPRINTF(
const char* format, va_list va )
85 char* str =
new char[len]();
86 const int required = _vsnprintf(str, len, format, va);
88 if ( required != -1 ) {
101 #define TIXML_SNPRINTF snprintf 102 #define TIXML_VSNPRINTF vsnprintf 103 static inline int TIXML_VSCPRINTF(
const char* format, va_list va )
105 int len = vsnprintf( 0, 0, format, va );
109 #define TIXML_SSCANF sscanf 113 static const char LINE_FEED = (char)0x0a;
114 static const char LF = LINE_FEED;
115 static const char CARRIAGE_RETURN = (char)0x0d;
116 static const char CR = CARRIAGE_RETURN;
117 static const char SINGLE_QUOTE =
'\'';
118 static const char DOUBLE_QUOTE =
'\"';
137 static const int NUM_ENTITIES = 5;
138 static const Entity entities[NUM_ENTITIES] = {
139 {
"quot", 4, DOUBLE_QUOTE },
141 {
"apos", 4, SINGLE_QUOTE },
155 if (
this == other ) {
168 other->_flags = _flags;
169 other->_start = _start;
179 if ( _flags & NEEDS_DELETE ) {
192 size_t len = strlen( str );
194 _start =
new char[ len+1 ];
195 memcpy( _start, str, len+1 );
197 _flags = flags | NEEDS_DELETE;
207 char endChar = *endTag;
208 size_t length = strlen( endTag );
212 if ( *p == endChar && strncmp( p, endTag, length ) == 0 ) {
213 Set( start, p, strFlags );
232 char*
const start = p;
243 void StrPair::CollapseWhitespace()
251 const char* p = _start;
276 if ( _flags & NEEDS_FLUSH ) {
278 _flags ^= NEEDS_FLUSH;
281 const char* p = _start;
285 if ( (_flags & NEEDS_NEWLINE_NORMALIZATION) && *p == CR ) {
289 if ( *(p+1) == LF ) {
298 else if ( (_flags & NEEDS_NEWLINE_NORMALIZATION) && *p == LF ) {
299 if ( *(p+1) == CR ) {
308 else if ( (_flags & NEEDS_ENTITY_PROCESSING) && *p ==
'&' ) {
314 if ( *(p+1) ==
'#' ) {
315 const int buflen = 10;
316 char buf[buflen] = { 0 };
319 if ( adjusted == 0 ) {
328 memcpy( q, buf, len );
333 bool entityFound =
false;
334 for(
int i = 0;
i < NUM_ENTITIES; ++
i ) {
335 const Entity& entity = entities[
i];
337 && *( p + entity.
length + 1 ) ==
';' ) {
346 if ( !entityFound ) {
363 if ( _flags & NEEDS_WHITESPACE_COLLAPSING ) {
364 CollapseWhitespace();
366 _flags = (_flags & NEEDS_DELETE);
382 const unsigned char* pu =
reinterpret_cast<const unsigned char*
>(p);
384 if ( *(pu+0) == TIXML_UTF_LEAD_0
385 && *(pu+1) == TIXML_UTF_LEAD_1
397 const unsigned long BYTE_MASK = 0xBF;
398 const unsigned long BYTE_MARK = 0x80;
399 const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
404 else if ( input < 0x800 ) {
407 else if ( input < 0x10000 ) {
410 else if ( input < 0x200000 ) {
424 *output = (char)((input | BYTE_MARK) & BYTE_MASK);
428 *output = (char)((input | BYTE_MARK) & BYTE_MASK);
432 *output = (char)((input | BYTE_MARK) & BYTE_MASK);
436 *output = (char)(input | FIRST_BYTE_MARK[*length]);
449 if ( *(p+1) ==
'#' && *(p+2) ) {
450 unsigned long ucs = 0;
454 static const char SEMICOLON =
';';
456 if ( *(p+2) ==
'x' ) {
463 q = strchr( q, SEMICOLON );
473 while ( *q !=
'x' ) {
474 unsigned int digit = 0;
476 if ( *q >=
'0' && *q <=
'9' ) {
479 else if ( *q >=
'a' && *q <=
'f' ) {
480 digit = *q -
'a' + 10;
482 else if ( *q >=
'A' && *q <=
'F' ) {
483 digit = *q -
'A' + 10;
489 TIXMLASSERT( digit == 0 || mult <= UINT_MAX / digit );
490 const unsigned int digitScaled = mult * digit;
505 q = strchr( q, SEMICOLON );
515 while ( *q !=
'#' ) {
516 if ( *q >=
'0' && *q <=
'9' ) {
517 const unsigned int digit = *q -
'0';
519 TIXMLASSERT( digit == 0 || mult <= UINT_MAX / digit );
520 const unsigned int digitScaled = mult * digit;
533 ConvertUTF32ToUTF8( ucs, value, length );
534 return p + delta + 1;
599 if ( ToInt( str, &ival )) {
600 *value = (ival==0) ?
false :
true;
603 if ( StringEqual( str,
"true" ) ) {
607 else if ( StringEqual( str,
"false" ) ) {
648 char*
const start = p;
657 static const char* xmlHeader = {
"<?" };
658 static const char* commentHeader = {
"<!--" };
659 static const char* cdataHeader = {
"<![CDATA[" };
660 static const char* dtdHeader = {
"<!" };
661 static const char* elementHeader = {
"<" };
663 static const int xmlHeaderLen = 2;
664 static const int commentHeaderLen = 4;
665 static const int cdataHeaderLen = 9;
666 static const int dtdHeaderLen = 2;
667 static const int elementHeaderLen = 1;
675 returnNode->_memPool = &_commentPool;
680 returnNode =
new (_commentPool.Alloc())
XMLComment(
this );
681 returnNode->_memPool = &_commentPool;
682 p += commentHeaderLen;
688 returnNode->_memPool = &_textPool;
690 text->SetCData(
true );
694 returnNode =
new (_commentPool.Alloc())
XMLUnknown(
this );
695 returnNode->_memPool = &_commentPool;
700 returnNode =
new (_elementPool.Alloc())
XMLElement(
this );
701 returnNode->_memPool = &_elementPool;
702 p += elementHeaderLen;
706 returnNode =
new (_textPool.Alloc())
XMLText(
this );
707 returnNode->_memPool = &_textPool;
723 if ( !node->Accept( visitor ) ) {
737 _firstChild( 0 ), _lastChild( 0 ),
738 _prev( 0 ), _next( 0 ),
782 void XMLNode::Unlink(
XMLNode* child )
794 if ( child->
_prev ) {
797 if ( child->
_next ) {
821 InsertChildPreamble( addThis );
851 InsertChildPreamble( addThis );
885 if ( afterThis->
_parent !=
this ) {
890 if ( afterThis->
_next == 0 ) {
894 InsertChildPreamble( addThis );
895 addThis->
_prev = afterThis;
898 afterThis->
_next = addThis;
909 const XMLElement* element = node->ToElementWithName( name );
921 const XMLElement* element = node->ToElementWithName( name );
933 const XMLElement* element = node->ToElementWithName( name );
945 const XMLElement* element = node->ToElementWithName( name );
1000 if ( !existingNode->ToDeclaration() ) {
1001 wellLocated =
false;
1006 if ( !wellLocated ) {
1027 bool mismatch =
false;
1028 if ( endTag.
Empty() ) {
1052 void XMLNode::DeleteNode(
XMLNode* node )
1057 MemPool* pool = node->_memPool;
1062 void XMLNode::InsertChildPreamble(
XMLNode* insertThis )
const 1068 insertThis->
_parent->Unlink( insertThis );
1073 const XMLElement* XMLNode::ToElementWithName(
const char* name )
const 1076 if ( element == 0 ) {
1091 const char* start = p;
1092 if ( this->CData() ) {
1138 return visitor->
Visit( *
this );
1157 const char* start = p;
1187 return visitor->
Visit( *
this );
1207 const char* start = p;
1238 return visitor->
Visit( *
this );
1256 const char* start = p;
1287 return visitor->
Visit( *
this );
1294 return _name.GetStr();
1302 char* XMLAttribute::ParseDeep(
char* p,
bool processEntities )
1305 p = _name.ParseName( p );
1318 if ( *p !=
'\"' && *p !=
'\'' ) {
1322 char endTag[2] = { *p, 0 };
1330 void XMLAttribute::SetName(
const char* n )
1451 XMLElement::~XMLElement()
1453 while( _rootAttribute ) {
1455 DeleteAttribute( _rootAttribute );
1456 _rootAttribute = next;
1463 for(
XMLAttribute* a = _rootAttribute; a; a = a->_next ) {
1486 int i = defaultValue;
1487 QueryIntAttribute(name, &i);
1493 unsigned i = defaultValue;
1494 QueryUnsignedAttribute(name, &i);
1500 int64_t
i = defaultValue;
1501 QueryInt64Attribute(name, &i);
1507 bool b = defaultValue;
1508 QueryBoolAttribute(name, &b);
1514 double d = defaultValue;
1515 QueryDoubleAttribute(name, &d);
1521 float f = defaultValue;
1522 QueryFloatAttribute(name, &f);
1673 int i = defaultValue;
1680 unsigned i = defaultValue;
1681 QueryUnsignedText(&i);
1687 int64_t
i = defaultValue;
1694 bool b = defaultValue;
1701 double d = defaultValue;
1702 QueryDoubleText(&d);
1708 float f = defaultValue;
1714 XMLAttribute* XMLElement::FindOrCreateAttribute(
const char* name )
1718 for( attrib = _rootAttribute;
1720 last = attrib, attrib = attrib->_next ) {
1728 attrib->_memPool = &
_document->_attributePool;
1730 last->_next = attrib;
1733 _rootAttribute = attrib;
1735 attrib->SetName( name );
1736 attrib->_memPool->SetTracked();
1748 prev->_next = a->_next;
1751 _rootAttribute = a->_next;
1753 DeleteAttribute( a );
1761 char* XMLElement::ParseAttributes(
char* p )
1763 const char* start = p;
1778 attrib->_memPool = &
_document->_attributePool;
1779 attrib->_memPool->SetTracked();
1782 if ( !p || Attribute( attrib->Name() ) ) {
1783 DeleteAttribute( attrib );
1792 if ( prevAttribute ) {
1793 prevAttribute->_next = attrib;
1796 _rootAttribute = attrib;
1798 prevAttribute = attrib;
1801 else if ( *p ==
'>' ) {
1806 else if ( *p ==
'/' && *(p+1) ==
'>' ) {
1807 _closingType = CLOSED;
1820 if ( attribute == 0 ) {
1823 MemPool* pool = attribute->_memPool;
1824 attribute->~XMLAttribute();
1825 pool->
Free( attribute );
1841 _closingType = CLOSING;
1850 p = ParseAttributes( p );
1851 if ( !p || !*p || _closingType ) {
1903 if ( visitor->
VisitEnter( *
this, _rootAttribute ) ) {
1905 if ( !node->
Accept( visitor ) ) {
1920 "XML_WRONG_ATTRIBUTE_TYPE",
1921 "XML_ERROR_FILE_NOT_FOUND",
1922 "XML_ERROR_FILE_COULD_NOT_BE_OPENED",
1923 "XML_ERROR_FILE_READ_ERROR",
1924 "XML_ERROR_ELEMENT_MISMATCH",
1925 "XML_ERROR_PARSING_ELEMENT",
1926 "XML_ERROR_PARSING_ATTRIBUTE",
1927 "XML_ERROR_IDENTIFYING_TAG",
1928 "XML_ERROR_PARSING_TEXT",
1929 "XML_ERROR_PARSING_CDATA",
1930 "XML_ERROR_PARSING_COMMENT",
1931 "XML_ERROR_PARSING_DECLARATION",
1932 "XML_ERROR_PARSING_UNKNOWN",
1933 "XML_ERROR_EMPTY_DOCUMENT",
1934 "XML_ERROR_MISMATCHED_ELEMENT",
1935 "XML_ERROR_PARSING",
1936 "XML_CAN_NOT_CONVERT_TEXT",
1944 _processEntities( processEntities ),
1946 _whitespace( whitespace ),
1965 const bool hadError =
Error();
1971 delete [] _charBuffer;
1975 _textPool.Trace(
"text" );
1976 _elementPool.Trace(
"element" );
1977 _commentPool.Trace(
"comment" );
1978 _attributePool.Trace(
"attribute" );
1983 TIXMLASSERT( _elementPool.CurrentAllocs() == _elementPool.Untracked() );
1984 TIXMLASSERT( _attributePool.CurrentAllocs() == _attributePool.Untracked() );
1985 TIXMLASSERT( _textPool.CurrentAllocs() == _textPool.Untracked() );
1986 TIXMLASSERT( _commentPool.CurrentAllocs() == _commentPool.Untracked() );
1996 ele->_memPool = &_elementPool;
1997 ele->SetName( name );
2006 comment->_memPool = &_commentPool;
2007 comment->SetValue( str );
2016 text->_memPool = &_textPool;
2017 text->SetValue( str );
2026 dec->_memPool = &_commentPool;
2027 dec->SetValue( str ? str :
"xml version=\"1.0\" encoding=\"UTF-8\"" );
2036 unk->_memPool = &_commentPool;
2037 unk->SetValue( str );
2041 static FILE* callfopen(
const char* filepath,
const char* mode )
2045 #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE) 2047 errno_t err = fopen_s( &fp, filepath, mode );
2052 FILE* fp = fopen( filepath, mode );
2070 XMLNode::DeleteNode(node);
2078 FILE* fp = callfopen( filename,
"rb" );
2095 <
bool = (
sizeof(
unsigned long) >=
sizeof(
size_t))>
2097 static bool Fits(
unsigned long value )
2099 return value < (size_t)-1;
2115 fseek( fp, 0, SEEK_SET );
2116 if ( fgetc( fp ) == EOF && ferror( fp ) != 0 ) {
2121 fseek( fp, 0, SEEK_END );
2122 const long filelength = ftell( fp );
2123 fseek( fp, 0, SEEK_SET );
2124 if ( filelength == -1L ) {
2136 if ( filelength == 0 ) {
2141 const size_t size = filelength;
2143 _charBuffer =
new char[size+1];
2144 size_t read = fread( _charBuffer, 1, size, fp );
2145 if ( read != size ) {
2150 _charBuffer[size] = 0;
2159 FILE* fp = callfopen( filename,
"w" );
2181 XMLError XMLDocument::Parse(
const char* p,
size_t len )
2185 if ( len == 0 || !p || !*p ) {
2189 if ( len == (
size_t)(-1) ) {
2193 _charBuffer =
new char[ len+1 ];
2194 memcpy( _charBuffer, p, len );
2195 _charBuffer[len] = 0;
2203 _elementPool.Clear();
2204 _attributePool.Clear();
2206 _commentPool.Clear();
2219 Accept( &stdoutStreamer );
2241 const char* errorName = _errorNames[_errorID];
2249 static const int LEN = 20;
2250 char buf1[LEN] = { 0 };
2251 char buf2[LEN] = { 0 };
2253 if ( !_errorStr1.
Empty() ) {
2256 if ( !_errorStr2.
Empty() ) {
2263 printf(
"XMLDocument error id=%d '%s' str1=%s str2=%s\n",
2264 static_cast<int>( _errorID ),
ErrorName(), buf1, buf2 );
2268 void XMLDocument::Parse()
2272 char* p = _charBuffer;
2283 _elementJustOpened( false ),
2284 _firstElement( true ),
2288 _processEntities( true ),
2289 _compactMode( compact )
2291 for(
int i=0;
i<ENTITY_RANGE; ++
i ) {
2292 _entityFlag[
i] =
false;
2293 _restrictedEntityFlag[
i] =
false;
2295 for(
int i=0;
i<NUM_ENTITIES; ++
i ) {
2296 const char entityValue = entities[
i].
value;
2297 TIXMLASSERT( ((
unsigned char)entityValue) < ENTITY_RANGE );
2298 _entityFlag[ (
unsigned char)entityValue ] =
true;
2300 _restrictedEntityFlag[(
unsigned char)
'&'] =
true;
2301 _restrictedEntityFlag[(
unsigned char)
'<'] =
true;
2302 _restrictedEntityFlag[(
unsigned char)
'>'] =
true;
2310 va_start( va, format );
2313 vfprintf( _fp, format, va );
2316 const int len = TIXML_VSCPRINTF( format, va );
2320 va_start( va, format );
2322 char* p = _buffer.
PushArr( len ) - 1;
2331 for(
int i=0;
i<depth; ++
i ) {
2337 void XMLPrinter::PrintString(
const char* p,
bool restricted )
2342 if ( _processEntities ) {
2343 const bool* flag = restricted ? _restrictedEntityFlag : _entityFlag;
2347 if ( *q > 0 && *q < ENTITY_RANGE ) {
2351 if ( flag[(
unsigned char)(*q)] ) {
2353 const size_t delta = q - p;
2355 const int toPrint = ( INT_MAX < delta ) ? INT_MAX : (
int)delta;
2356 Print(
"%.*s", toPrint, p );
2359 bool entityPatternPrinted =
false;
2360 for(
int i=0;
i<NUM_ENTITIES; ++
i ) {
2361 if ( entities[
i].value == *q ) {
2362 Print(
"&%s;", entities[
i].pattern );
2363 entityPatternPrinted =
true;
2367 if ( !entityPatternPrinted ) {
2381 if ( !_processEntities || ( p < q ) ) {
2404 if ( _textDepth < 0 && !_firstElement && !compactMode ) {
2407 if ( !compactMode ) {
2411 Print(
"<%s", name );
2413 _firstElement =
false;
2421 Print(
" %s=\"", name );
2422 PrintString( value,
false );
2476 if ( _textDepth < 0 && !compactMode) {
2480 Print(
"</%s>", name );
2483 if ( _textDepth == _depth ) {
2486 if ( _depth == 0 && !compactMode) {
2505 _textDepth = _depth-1;
2509 Print(
"<![CDATA[%s]]>", text );
2512 PrintString( text,
true );
2566 if ( _textDepth < 0 && !_firstElement && !_compactMode) {
2570 _firstElement =
false;
2571 Print(
"<!--%s-->", comment );
2578 if ( _textDepth < 0 && !_firstElement && !_compactMode) {
2582 _firstElement =
false;
2583 Print(
"<?%s?>", value );
2590 if ( _textDepth < 0 && !_firstElement && !_compactMode) {
2594 _firstElement =
false;
2595 Print(
"<!%s>", value );
2612 if ( element.
Parent() ) {
2615 const bool compactMode = parentElem ?
CompactMode( *parentElem ) : _compactMode;
2617 while ( attribute ) {
2619 attribute = attribute->
Next();
XMLText * NewText(const char *text)
virtual bool Visit(const XMLText &text)
Visit a text node.
void SetError(XMLError error, const char *str1, const char *str2)
bool Error() const
Return true if there was an error parsing the document.
void SetText(const char *inText)
void SealElementIfJustOpened()
const XMLElement * FirstChildElement(const char *name=0) const
static void ToStr(int v, char *buffer, int bufferSize)
XMLError QueryIntValue(int *value) const
unsigned UnsignedAttribute(const char *name, unsigned defaultValue=0) const
See IntAttribute()
XMLError Parse(const char *xml, size_t nBytes=(size_t)(-1))
static const char * GetCharacterRef(const char *p, char *value, int *length)
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
XMLError LoadFile(const char *filename)
void PushComment(const char *comment)
Add a comment.
char * ParseDeep(char *p, StrPair *endTag)
XMLError QueryFloatValue(float *value) const
See QueryIntValue.
virtual bool Accept(XMLVisitor *visitor) const
static const char * SkipWhiteSpace(const char *p)
static bool ToFloat(const char *str, float *value)
const XMLElement * NextSiblingElement(const char *name=0) const
Get the next (right) sibling element of this node, with an optionally supplied name.
virtual XMLComment * ToComment()
Safely cast to a Comment, or null.
char * ParseDeep(char *, StrPair *endTag)
XMLError QueryBoolText(bool *bval) const
See QueryIntText()
XMLError QueryInt64Value(int64_t *value) const
See QueryIntValue.
void PushHeader(bool writeBOM, bool writeDeclaration)
bool CData() const
Returns true if this is a CDATA text element.
void PushDeclaration(const char *value)
virtual void Free(void *)=0
void PrintError() const
If there is an error, print it to stdout.
static bool IsNameChar(unsigned char ch)
static bool IsWhiteSpace(char p)
static const char * ReadBOM(const char *p, bool *hasBOM)
void TransferTo(StrPair *other)
const unsigned char TIXML_UTF_LEAD_2
const XMLElement * PreviousSiblingElement(const char *name=0) const
Get the previous (left) sibling element of this node, with an optionally supplied name...
const XMLAttribute * FindAttribute(const char *name) const
Query a specific attribute in the list.
int IntAttribute(const char *name, int defaultValue=0) const
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
static bool ToBool(const char *str, bool *value)
virtual bool VisitExit(const XMLDocument &)
Visit a document.
char * ParseName(char *in)
const char * Value() const
The value of the attribute.
double DoubleAttribute(const char *name, double defaultValue=0) const
See IntAttribute()
void SetAttribute(const char *value)
Set the attribute to a string value.
void Print(const char *format,...)
virtual bool ShallowEqual(const XMLNode *compare) const
XMLPrinter(FILE *file=0, bool compact=false, int depth=0)
int64_t Int64Text(int64_t defaultValue=0) const
See QueryIntText()
void Clear()
Clear the document, resetting it to the initial state.
void SetAttribute(const char *name, const char *value)
Sets the named attribute to value.
virtual char * ParseDeep(char *, StrPair *)
XMLError QueryDoubleText(double *dval) const
See QueryIntText()
int IntText(int defaultValue=0) const
XMLElement * NewElement(const char *name)
virtual XMLNode * ShallowClone(XMLDocument *document) const
XMLError QueryDoubleValue(double *value) const
See QueryIntValue.
bool ProcessEntities() const
char * ParseDeep(char *, StrPair *endTag)
static bool ToInt(const char *str, int *value)
double DoubleText(double defaultValue=0) const
See QueryIntText()
float FloatAttribute(const char *name, float defaultValue=0) const
See IntAttribute()
float FloatText(float defaultValue=0) const
See QueryIntText()
bool BoolText(bool defaultValue=false) const
See QueryIntText()
unsigned UnsignedText(unsigned defaultValue=0) const
See QueryIntText()
XMLError SaveFile(const char *filename, bool compact=false)
static bool ToUnsigned(const char *str, unsigned *value)
const XMLNode * Parent() const
Get the parent of this node on the DOM.
void PushText(const char *text, bool cdata=false)
Add a text node.
const XMLAttribute * Next() const
The next attribute in the list.
XMLComment * NewComment(const char *comment)
virtual void CloseElement(bool compactMode=false)
If streaming, close the Element.
const unsigned char TIXML_UTF_LEAD_1
static bool ToInt64(const char *str, int64_t *value)
void DeleteNode(XMLNode *node)
virtual void SetTracked()=0
const char * Attribute(const char *name, const char *value=0) const
virtual bool VisitEnter(const XMLDocument &)
Visit a document.
static bool ToDouble(const char *str, double *value)
const char * Name() const
The name of the attribute.
const char * GetText() const
XMLError QueryIntText(int *ival) const
static bool Fits(unsigned long value)
virtual bool VisitExit(const XMLDocument &)
Visit a document.
virtual ~XMLDeclaration()
void OpenElement(const char *name, bool compactMode=false)
void SetStr(const char *str, int flags=0)
virtual XMLNode * ShallowClone(XMLDocument *document) const
void SetCData(bool isCData)
Declare whether this should be CDATA or standard text.
virtual bool Accept(XMLVisitor *visitor) const
XMLDeclaration(XMLDocument *doc)
const unsigned char TIXML_UTF_LEAD_0
XMLNode * InsertFirstChild(XMLNode *addThis)
const XMLDocument * GetDocument() const
Get the XMLDocument that owns this XMLNode.
XMLError QueryInt64Text(int64_t *uval) const
See QueryIntText()
XMLDocument(bool processEntities=true, Whitespace=PRESERVE_WHITESPACE)
constructor
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
char * Identify(char *p, XMLNode **node)
static bool StringEqual(const char *p, const char *q, int nChar=INT_MAX)
virtual bool ShallowEqual(const XMLNode *compare) const
virtual XMLNode * ShallowClone(XMLDocument *document) const
const char * Value() const
XMLError QueryFloatText(float *fval) const
See QueryIntText()
void SetValue(const char *val, bool staticMem=false)
XMLError QueryUnsignedText(unsigned *uval) const
See QueryIntText()
void PushUnknown(const char *value)
virtual bool Accept(XMLVisitor *visitor) const
void PushAttribute(const char *name, const char *value)
If streaming, add an attribute to an open element.
DynArray< const char *, 10 > _stack
static void ConvertUTF32ToUTF8(unsigned long input, char *output, int *length)
bool BoolAttribute(const char *name, bool defaultValue=false) const
See IntAttribute()
void DeleteAttribute(const char *name)
const XMLElement * LastChildElement(const char *name=0) const
XMLUnknown(XMLDocument *doc)
XMLError QueryUnsignedValue(unsigned int *value) const
See QueryIntValue.
static bool IsNameStartChar(unsigned char ch)
virtual bool Accept(XMLVisitor *visitor) const =0
void DeleteChild(XMLNode *node)
virtual XMLText * ToText()
Safely cast to Text, or null.
virtual XMLNode * ShallowClone(XMLDocument *document) const
virtual bool Accept(XMLVisitor *visitor) const
virtual void PrintSpace(int depth)
XMLUnknown * NewUnknown(const char *text)
virtual bool CompactMode(const XMLElement &)
char * ParseDeep(char *, StrPair *endTag)
XMLDeclaration * NewDeclaration(const char *text=0)
bool NoChildren() const
Returns true if this node has no children.
const XMLAttribute * FirstAttribute() const
Return the first attribute in the list.
virtual bool ShallowEqual(const XMLNode *compare) const
virtual bool Visit(const XMLDeclaration &)
Visit a declaration.
virtual bool VisitEnter(const XMLDocument &)
Visit a document.
void Print(XMLPrinter *streamer=0) const
char * ParseText(char *in, const char *endTag, int strFlags)
XMLError QueryBoolValue(bool *value) const
See QueryIntValue.
Whitespace WhitespaceMode() const
XMLNode * InsertAfterChild(XMLNode *afterThis, XMLNode *addThis)
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
static bool Fits(unsigned long)
const char * ErrorName() const
virtual bool Accept(XMLVisitor *visitor) const
XMLNode * InsertEndChild(XMLNode *addThis)
const XMLNode * NextSibling() const
Get the next (right) sibling node of this node.
int64_t Int64Attribute(const char *name, int64_t defaultValue=0) const
See IntAttribute()
const char * Name() const
Get the name of an element (which is the Value() of the node.)
virtual bool ShallowEqual(const XMLNode *compare) const
void SetInternedStr(const char *str)