27 #if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__) 35 #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE) 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. 76 char*
str =
new char[
len]();
79 if ( required != -1 ) {
92 #define TIXML_SNPRINTF snprintf 93 #define TIXML_VSNPRINTF vsnprintf 100 #define TIXML_SSCANF sscanf 146 if (
this ==
other ) {
196 char endChar = *endTag;
277 if ( *(
p+1) ==
LF ) {
286 if ( *(
p+1) ==
CR ) {
300 if ( *(
p+1) ==
'#' ) {
301 const int buflen = 10;
302 char buf[buflen] = { 0 };
305 if ( adjusted == 0 ) {
319 bool entityFound =
false;
323 && *(
p +
entity.length + 1 ) ==
';' ) {
332 if ( !entityFound ) {
368 const unsigned char* pu = reinterpret_cast<const unsigned char*>(
p);
383 const unsigned long BYTE_MASK = 0xBF;
384 const unsigned long BYTE_MARK = 0x80;
385 const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
390 else if (
input < 0x800 ) {
393 else if (
input < 0x10000 ) {
396 else if (
input < 0x200000 ) {
435 if ( *(
p+1) ==
'#' && *(
p+2) ) {
436 unsigned long ucs = 0;
440 static const char SEMICOLON =
';';
442 if ( *(
p+2) ==
'x' ) {
459 while ( *
q !=
'x' ) {
460 unsigned int digit = 0;
462 if ( *
q >=
'0' && *
q <=
'9' ) {
465 else if ( *
q >=
'a' && *
q <=
'f' ) {
466 digit = *
q -
'a' + 10;
468 else if ( *
q >=
'A' && *
q <=
'F' ) {
469 digit = *
q -
'A' + 10;
476 const unsigned int digitScaled = mult * digit;
501 while ( *
q !=
'#' ) {
502 if ( *
q >=
'0' && *
q <=
'9' ) {
503 const unsigned int digit = *
q -
'0';
506 const unsigned int digitScaled = mult * digit;
520 return p + delta + 1;
579 *
value = (ival==0) ?
false :
true;
624 static const char* xmlHeader = {
"<?" };
625 static const char* commentHeader = {
"<!--" };
626 static const char* cdataHeader = {
"<![CDATA[" };
627 static const char* dtdHeader = {
"<!" };
628 static const char* elementHeader = {
"<" };
630 static const int xmlHeaderLen = 2;
631 static const int commentHeaderLen = 4;
632 static const int cdataHeaderLen = 9;
633 static const int dtdHeaderLen = 2;
634 static const int elementHeaderLen = 1;
649 p += commentHeaderLen;
657 text->SetCData(
true );
669 p += elementHeaderLen;
690 if ( !
node->Accept( visitor ) ) {
704 _firstChild( 0 ), _lastChild( 0 ),
705 _prev( 0 ), _next( 0 ),
764 if (
child->_prev ) {
767 if (
child->_next ) {
855 if ( afterThis->
_parent !=
this ) {
860 if ( afterThis->
_next == 0 ) {
865 addThis->
_prev = afterThis;
868 afterThis->
_next = addThis;
958 p =
node->ParseDeep(
p, &endTag );
985 node->_memPool->SetTracked();
993 if ( endTag.
Empty() ) {
1042 if ( this->
CData() ) {
1088 return visitor->
Visit( *
this );
1137 return visitor->
Visit( *
this );
1188 return visitor->
Visit( *
this );
1237 return visitor->
Visit( *
this );
1268 if ( *
p !=
'\"' && *
p !=
'\'' ) {
1272 char endTag[2] = { *
p, 0 };
1549 last = attrib, attrib = attrib->
_next ) {
1559 last->_next = attrib;
1565 attrib->_memPool->SetTracked();
1608 attrib->_memPool->SetTracked();
1621 if ( prevAttribute ) {
1622 prevAttribute->
_next = attrib;
1627 prevAttribute = attrib;
1630 else if ( *
p ==
'>' ) {
1635 else if ( *
p ==
'/' && *(
p+1) ==
'>' ) {
1697 element->SetAttribute(
a->Name(),
a->Value() );
1734 if ( !
node->Accept( visitor ) ) {
1749 "XML_WRONG_ATTRIBUTE_TYPE",
1750 "XML_ERROR_FILE_NOT_FOUND",
1751 "XML_ERROR_FILE_COULD_NOT_BE_OPENED",
1752 "XML_ERROR_FILE_READ_ERROR",
1753 "XML_ERROR_ELEMENT_MISMATCH",
1754 "XML_ERROR_PARSING_ELEMENT",
1755 "XML_ERROR_PARSING_ATTRIBUTE",
1756 "XML_ERROR_IDENTIFYING_TAG",
1757 "XML_ERROR_PARSING_TEXT",
1758 "XML_ERROR_PARSING_CDATA",
1759 "XML_ERROR_PARSING_COMMENT",
1760 "XML_ERROR_PARSING_DECLARATION",
1761 "XML_ERROR_PARSING_UNKNOWN",
1762 "XML_ERROR_EMPTY_DOCUMENT",
1763 "XML_ERROR_MISMATCHED_ELEMENT",
1764 "XML_ERROR_PARSING",
1765 "XML_CAN_NOT_CONVERT_TEXT",
1773 _processEntities( processEntities ),
1796 const bool hadError =
Error();
1828 ele->SetName(
name );
1858 dec->SetValue(
str ?
str :
"xml version=\"1.0\" encoding=\"UTF-8\"" );
1868 unk->SetValue(
str );
1876 #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE) 1891 if (
node->_parent) {
1892 node->_parent->DeleteChild(
node );
1899 node->_memPool->SetTracked();
1926 <
bool = (
sizeof(
unsigned long) >=
sizeof(
size_t))>
2014 if (
len == 0 || !
p || !*
p ) {
2018 if (
len == (
size_t)(-1) ) {
2048 Accept( &stdoutStreamer );
2072 static const int LEN = 20;
2073 char buf1[
LEN] = { 0 };
2074 char buf2[
LEN] = { 0 };
2086 printf(
"XMLDocument error id=%d '%s' str1=%s str2=%s\n",
2106 _elementJustOpened(
false ),
2107 _firstElement(
true ),
2111 _processEntities(
true ),
2112 _compactMode( compact )
2174 if (
flag[(
unsigned char)(*
q)] ) {
2176 const size_t delta =
q -
p;
2179 Print(
"%.*s", toPrint,
p );
2182 bool entityPatternPrinted =
false;
2186 entityPatternPrinted =
true;
2190 if ( !entityPatternPrinted ) {
2230 if ( !compactMode ) {
2301 if (
_depth == 0 && !compactMode) {
2421 parentElem =
element.Parent()->ToElement();
XMLText * NewText(const char *text)
virtual bool Visit(const XMLText &text)
Visit a text node.
XMLError QueryDoubleValue(double *value) const
See QueryIntValue.
virtual bool Accept(XMLVisitor *visitor) const
void SetError(XMLError error, const char *str1, const char *str2)
virtual bool ShallowEqual(const XMLNode *compare) const
void CollapseWhitespace()
_Check_return_ _CRTIMP int __cdecl ferror(_In_ FILE *_File)
static const char LINE_FEED
void SetText(const char *inText)
void SealElementIfJustOpened()
static UCHAR ULONG UCHAR ULONG UCHAR * output
void InsertChildPreamble(XMLNode *insertThis) const
static void ToStr(int v, char *buffer, int bufferSize)
XMLAttribute * FindOrCreateAttribute(const char *name)
virtual bool Accept(XMLVisitor *visitor) const
const char * Name() const
Get the name of an element (which is the Value() of the node.)
static const char * GetCharacterRef(const char *p, char *value, int *length)
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
static const unsigned char TIXML_UTF_LEAD_0
ACPI_SIZE strlen(const char *String)
XMLError LoadFile(const char *filename)
void PushComment(const char *comment)
Add a comment.
char * ParseDeep(char *p, StrPair *endTag)
static const Entity entities[NUM_ENTITIES]
return static_cast< int >(global)
XMLAttribute * _rootAttribute
MemPoolT< sizeof(XMLAttribute) > _attributePool
static const char * SkipWhiteSpace(const char *p)
static bool ToFloat(const char *str, float *value)
const XMLAttribute * FirstAttribute() const
Return the first attribute in the list.
char * ParseDeep(char *, StrPair *endTag)
const XMLElement * PreviousSiblingElement(const char *name=0) const
Get the previous (left) sibling element of this node, with an optionally supplied name.
void PushHeader(bool writeBOM, bool writeDeclaration)
void Set(char *start, char *end, int flags)
bool Error() const
Return true if there was an error parsing the document.
void Unlink(XMLNode *child)
void PushDeclaration(const char *value)
Whitespace WhitespaceMode() const
const XMLDocument * GetDocument() const
Get the XMLDocument that owns this XMLNode.
ios_base &_STLP_CALL dec(ios_base &__s)
static bool IsNameChar(unsigned char ch)
static bool IsWhiteSpace(char p)
void Print(XMLPrinter *streamer=0) const
static const char * ReadBOM(const char *p, bool *hasBOM)
void TransferTo(StrPair *other)
#define comment(fmt, arg1)
char * ParseDeep(char *p, bool processEntities)
XMLError QueryFloatValue(float *value) const
See QueryIntValue.
static const char DOUBLE_QUOTE
virtual bool Accept(XMLVisitor *visitor) const
static const char * _errorNames[XML_ERROR_COUNT]
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
int CDECL fopen_s(FILE **pFile, const char *filename, const char *mode)
static bool ToBool(const char *str, bool *value)
virtual bool VisitExit(const XMLDocument &)
Visit a document.
char * ParseName(char *in)
void SetAttribute(const char *value)
Set the attribute to a string value.
_Check_return_ _CRTIMP long __cdecl filelength(_In_ int _FileHandle)
GLenum GLuint GLenum GLsizei const GLchar * buf
XMLError QueryFloatText(float *fval) const
See QueryIntText()
_Check_return_opt_ _CRTIMP size_t __cdecl fread(_Out_writes_bytes_(_ElementSize *_Count) void *_DstBuf, _In_ size_t _ElementSize, _In_ size_t _Count, _Inout_ FILE *_File)
void Print(const char *format,...)
XMLPrinter(FILE *file=0, bool compact=false, int depth=0)
_STLP_INLINE_LOOP _STLP_STD::pair< _InputIter1, _InputIter2 > mismatch(_InputIter1 __first1, _InputIter1 __last1, _InputIter2 __first2)
GLenum GLuint GLenum GLsizei length
void Clear()
Clear the document, resetting it to the initial state.
const XMLElement * NextSiblingElement(const char *name=0) const
Get the next (right) sibling element of this node, with an optionally supplied name.
virtual char * ParseDeep(char *, StrPair *)
XMLElement * NewElement(const char *name)
_Check_return_opt_ _CRTIMP int __cdecl fseek(_Inout_ FILE *_File, _In_ long _Offset, _In_ int _Origin)
DynArray< char, 20 > _buffer
static const unsigned char TIXML_UTF_LEAD_2
char * ParseDeep(char *, StrPair *endTag)
static bool ToInt(const char *str, int *value)
void SetName(const char *name)
XMLError SaveFile(const char *filename, bool compact=false)
XMLError QueryDoubleText(double *dval) const
See QueryIntText()
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
static bool ToUnsigned(const char *str, unsigned *value)
const char * GetText() const
void PushText(const char *text, bool cdata=false)
Add a text node.
static int TIXML_VSCPRINTF(const char *format, va_list va)
static const char CARRIAGE_RETURN
void PrintError() const
If there is an error, print it to stdout.
XMLComment * NewComment(const char *comment)
virtual void CloseElement(bool compactMode=false)
If streaming, close the Element.
virtual bool ShallowEqual(const XMLNode *compare) const
GLboolean GLboolean GLboolean b
virtual XMLNode * ShallowClone(XMLDocument *document) const
const char * Name() const
The name of the attribute.
void DeleteNode(XMLNode *node)
virtual void SetTracked()=0
virtual bool VisitEnter(const XMLDocument &)
Visit a document.
static bool ToDouble(const char *str, double *value)
MemPoolT< sizeof(XMLComment) > _commentPool
const char * Value() const
The value of the attribute.
virtual bool Accept(XMLVisitor *visitor) const
static bool Fits(unsigned long value)
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
static const char SINGLE_QUOTE
virtual bool ShallowEqual(const XMLNode *compare) const
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)
XMLDeclaration(XMLDocument *doc)
GLdouble GLdouble GLdouble GLdouble q
XMLNode * InsertFirstChild(XMLNode *addThis)
virtual XMLNode * ShallowClone(XMLDocument *document) const
XMLError QueryUnsignedText(unsigned *uval) const
See QueryIntText()
XMLElement(XMLDocument *doc)
const char * ErrorName() const
char * ParseAttributes(char *p)
GLint GLint GLsizei GLsizei GLsizei depth
XMLError QueryIntValue(int *value) const
XMLError QueryUnsignedValue(unsigned int *value) const
See QueryIntValue.
XMLDocument(bool processEntities=true, Whitespace=PRESERVE_WHITESPACE)
constructor
char * Identify(char *p, XMLNode **node)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean flag
XMLError QueryBoolText(bool *bval) const
See QueryIntText()
static bool StringEqual(const char *p, const char *q, int nChar=INT_MAX)
#define memcpy(s1, s2, n)
static void DeleteNode(XMLNode *node)
GLsizei const GLfloat * value
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
const char * Attribute(const char *name, const char *value=0) const
const XMLElement * FirstChildElement(const char *name=0) const
void SetValue(const char *val, bool staticMem=false)
const XMLAttribute * FindAttribute(const char *name) const
Query a specific attribute in the list.
static const int NUM_ENTITIES
void PushUnknown(const char *value)
void PushAttribute(const char *name, const char *value)
If streaming, add an attribute to an open element.
static unsigned __int64 next
DynArray< const char *, 10 > _stack
static void ConvertUTF32ToUTF8(unsigned long input, char *output, int *length)
GLenum GLenum GLenum input
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
void DeleteAttribute(const char *name)
void PrintString(const char *, bool restrictedEntitySet)
virtual XMLNode * ShallowClone(XMLDocument *document) const
virtual XMLNode * ShallowClone(XMLDocument *document) const
XMLUnknown(XMLDocument *doc)
static bool IsNameStartChar(unsigned char ch)
void DeleteChild(XMLNode *node)
virtual bool ShallowEqual(const XMLNode *compare) const
virtual XMLText * ToText()
Safely cast to Text, or null.
bool CData() const
Returns true if this is a CDATA text element.
__kernel_ptrdiff_t ptrdiff_t
XMLError QueryBoolValue(bool *value) const
See QueryIntValue.
virtual void PrintSpace(int depth)
char * strchr(const char *String, int ch)
XMLUnknown * NewUnknown(const char *text)
virtual bool CompactMode(const XMLElement &)
MemPoolT< sizeof(XMLText) > _textPool
char * ParseDeep(char *, StrPair *endTag)
XMLDeclaration * NewDeclaration(const char *text=0)
MemPoolT< sizeof(XMLElement) > _elementPool
const char * Value() const
_Check_return_ _CRTIMP long __cdecl ftell(_Inout_ FILE *_File)
bool NoChildren() const
Returns true if this node has no children.
virtual bool Visit(const XMLDeclaration &)
Visit a declaration.
bool _restrictedEntityFlag[ENTITY_RANGE]
virtual bool VisitEnter(const XMLDocument &)
Visit a document.
XMLError QueryIntText(int *ival) const
GLboolean GLboolean GLboolean GLboolean a
static const char whitespace[]
char * ParseText(char *in, const char *endTag, int strFlags)
bool ProcessEntities() const
XMLNode * InsertAfterChild(XMLNode *afterThis, XMLNode *addThis)
_Check_return_opt_ _CRTIMP int __cdecl vfprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
static const unsigned char TIXML_UTF_LEAD_1
static FILE * callfopen(const char *filepath, const char *mode)
XMLNode * InsertEndChild(XMLNode *addThis)
bool _entityFlag[ENTITY_RANGE]
virtual bool Accept(XMLVisitor *visitor) const
const XMLElement * LastChildElement(const char *name=0) const
_CRTIMP int __cdecl read(_In_ int _FileHandle, _Out_writes_bytes_(_MaxCharCount) void *_DstBuf, _In_ unsigned int _MaxCharCount)
_Check_return_opt_ _CRTIMP int __cdecl fgetc(_Inout_ FILE *_File)
void SetInternedStr(const char *str)
GLuint const GLchar * name