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
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
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 ) {
410 *output = (
char)((
input | BYTE_MARK) & BYTE_MASK);
414 *output = (
char)((
input | BYTE_MARK) & BYTE_MASK);
418 *output = (
char)((
input | BYTE_MARK) & BYTE_MASK);
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;
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();
1858 dec->SetValue(
str ?
str :
"xml version=\"1.0\" encoding=\"UTF-8\"" );
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();
_STLP_INLINE_LOOP _STLP_STD::pair< _InputIter1, _InputIter2 > mismatch(_InputIter1 __first1, _InputIter1 __last1, _InputIter2 __first2)
ios_base &_STLP_CALL dec(ios_base &__s)
ACPI_SIZE strlen(const char *String)
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
char * strchr(const char *String, int ch)
virtual void SetTracked()=0
void SetStr(const char *str, int flags=0)
void SetInternedStr(const char *str)
void TransferTo(StrPair *other)
@ NEEDS_WHITESPACE_COLLAPSING
@ ATTRIBUTE_VALUE_LEAVE_ENTITIES
@ NEEDS_ENTITY_PROCESSING
@ NEEDS_NEWLINE_NORMALIZATION
@ TEXT_ELEMENT_LEAVE_ENTITIES
char * ParseName(char *in)
char * ParseText(char *in, const char *endTag, int strFlags)
void CollapseWhitespace()
XMLError QueryFloatValue(float *value) const
See QueryIntValue.
XMLError QueryDoubleValue(double *value) const
See QueryIntValue.
char * ParseDeep(char *p, bool processEntities)
void SetAttribute(const char *value)
Set the attribute to a string value.
void SetName(const char *name)
XMLError QueryUnsignedValue(unsigned int *value) const
See QueryIntValue.
const char * Name() const
The name of the attribute.
XMLError QueryBoolValue(bool *value) const
See QueryIntValue.
XMLError QueryIntValue(int *value) const
const char * Value() const
The value of the attribute.
char * ParseDeep(char *, StrPair *endTag)
virtual ~XMLDeclaration()
virtual bool Accept(XMLVisitor *visitor) const
virtual XMLNode * ShallowClone(XMLDocument *document) const
virtual bool ShallowEqual(const XMLNode *compare) const
XMLDeclaration(XMLDocument *doc)
MemPoolT< sizeof(XMLAttribute) > _attributePool
const char * ErrorName() const
void PrintError() const
If there is an error, print it to stdout.
MemPoolT< sizeof(XMLElement) > _elementPool
char * Identify(char *p, XMLNode **node)
XMLError LoadFile(const char *filename)
bool Error() const
Return true if there was an error parsing the document.
XMLComment * NewComment(const char *comment)
XMLElement * NewElement(const char *name)
XMLUnknown * NewUnknown(const char *text)
bool ProcessEntities() const
void Clear()
Clear the document, resetting it to the initial state.
XMLError SaveFile(const char *filename, bool compact=false)
Whitespace WhitespaceMode() const
void Print(XMLPrinter *streamer=0) const
virtual bool Accept(XMLVisitor *visitor) const
void DeleteNode(XMLNode *node)
MemPoolT< sizeof(XMLComment) > _commentPool
XMLText * NewText(const char *text)
void SetError(XMLError error, const char *str1, const char *str2)
XMLDeclaration * NewDeclaration(const char *text=0)
static const char * _errorNames[XML_ERROR_COUNT]
MemPoolT< sizeof(XMLText) > _textPool
const char * GetText() const
XMLError QueryUnsignedText(unsigned *uval) const
See QueryIntText()
const XMLAttribute * FindAttribute(const char *name) const
Query a specific attribute in the list.
void SetText(const char *inText)
XMLError QueryBoolText(bool *bval) const
See QueryIntText()
const char * Attribute(const char *name, const char *value=0) const
const XMLAttribute * FirstAttribute() const
Return the first attribute in the list.
virtual bool ShallowEqual(const XMLNode *compare) const
XMLError QueryDoubleText(double *dval) const
See QueryIntText()
XMLError QueryIntText(int *ival) const
void SetName(const char *str, bool staticMem=false)
Set the name of the element.
virtual bool Accept(XMLVisitor *visitor) const
char * ParseAttributes(char *p)
char * ParseDeep(char *p, StrPair *endTag)
virtual XMLNode * ShallowClone(XMLDocument *document) const
const char * Name() const
Get the name of an element (which is the Value() of the node.)
XMLAttribute * FindOrCreateAttribute(const char *name)
XMLAttribute * _rootAttribute
void DeleteAttribute(const char *name)
XMLError QueryFloatText(float *fval) const
See QueryIntText()
const char * Value() const
void SetValue(const char *val, bool staticMem=false)
virtual XMLText * ToText()
Safely cast to Text, or null.
void InsertChildPreamble(XMLNode *insertThis) const
const XMLElement * NextSiblingElement(const char *name=0) const
Get the next (right) sibling element of this node, with an optionally supplied name.
const XMLElement * FirstChildElement(const char *name=0) const
void DeleteChild(XMLNode *node)
const XMLElement * LastChildElement(const char *name=0) const
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
const XMLDocument * GetDocument() const
Get the XMLDocument that owns this XMLNode.
virtual char * ParseDeep(char *, StrPair *)
XMLNode * InsertAfterChild(XMLNode *afterThis, XMLNode *addThis)
const XMLElement * PreviousSiblingElement(const char *name=0) const
Get the previous (left) sibling element of this node, with an optionally supplied name.
void Unlink(XMLNode *child)
static void DeleteNode(XMLNode *node)
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
bool NoChildren() const
Returns true if this node has no children.
XMLNode * InsertFirstChild(XMLNode *addThis)
XMLNode * InsertEndChild(XMLNode *addThis)
virtual bool VisitExit(const XMLDocument &)
Visit a document.
void PushHeader(bool writeBOM, bool writeDeclaration)
DynArray< char, 20 > _buffer
virtual void PrintSpace(int depth)
void PushText(const char *text, bool cdata=false)
Add a text node.
void OpenElement(const char *name, bool compactMode=false)
void PushDeclaration(const char *value)
bool _entityFlag[ENTITY_RANGE]
virtual bool CompactMode(const XMLElement &)
void PrintString(const char *, bool restrictedEntitySet)
bool _restrictedEntityFlag[ENTITY_RANGE]
DynArray< const char *, 10 > _stack
void PushAttribute(const char *name, const char *value)
If streaming, add an attribute to an open element.
virtual bool VisitEnter(const XMLDocument &)
Visit a document.
XMLPrinter(FILE *file=0, bool compact=false, int depth=0)
void PushUnknown(const char *value)
void Print(const char *format,...)
void SealElementIfJustOpened()
virtual bool Visit(const XMLText &text)
Visit a text node.
virtual void CloseElement(bool compactMode=false)
If streaming, close the Element.
void PushComment(const char *comment)
Add a comment.
virtual bool Accept(XMLVisitor *visitor) const
virtual XMLNode * ShallowClone(XMLDocument *document) const
virtual bool ShallowEqual(const XMLNode *compare) const
char * ParseDeep(char *, StrPair *endTag)
bool CData() const
Returns true if this is a CDATA text element.
char * ParseDeep(char *, StrPair *endTag)
virtual bool Accept(XMLVisitor *visitor) const
XMLUnknown(XMLDocument *doc)
virtual XMLNode * ShallowClone(XMLDocument *document) const
virtual bool ShallowEqual(const XMLNode *compare) const
static bool IsNameChar(unsigned char ch)
static const char * SkipWhiteSpace(const char *p)
static bool ToUnsigned(const char *str, unsigned *value)
static void ConvertUTF32ToUTF8(unsigned long input, char *output, int *length)
static bool IsWhiteSpace(char p)
static bool ToFloat(const char *str, float *value)
static void ToStr(int v, char *buffer, int bufferSize)
static const char * GetCharacterRef(const char *p, char *value, int *length)
static bool IsNameStartChar(unsigned char ch)
static bool StringEqual(const char *p, const char *q, int nChar=INT_MAX)
static bool ToInt(const char *str, int *value)
static bool ToDouble(const char *str, double *value)
static bool ToBool(const char *str, bool *value)
static const char * ReadBOM(const char *p, bool *hasBOM)
virtual bool VisitExit(const XMLDocument &)
Visit a document.
virtual bool VisitEnter(const XMLDocument &)
Visit a document.
virtual bool Visit(const XMLDeclaration &)
Visit a declaration.
static WCHAR unknown[MAX_STRING_RESOURCE_LEN]
__kernel_ptrdiff_t ptrdiff_t
GLint GLint GLsizei GLsizei GLsizei depth
GLdouble GLdouble GLdouble GLdouble q
GLboolean GLboolean GLboolean b
GLenum GLuint GLenum GLsizei const GLchar * buf
GLuint GLsizei GLsizei * length
GLboolean GLboolean GLboolean GLboolean a
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 flag
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
_Check_return_opt_ _CRTIMP int __cdecl fgetc(_Inout_ FILE *_File)
_Check_return_ _CRTIMP int __cdecl ferror(_In_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl vfprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
_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)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl fseek(_Inout_ FILE *_File, _In_ long _Offset, _In_ int _Origin)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP long __cdecl ftell(_Inout_ FILE *_File)
#define memcpy(s1, s2, n)
#define comment(fmt, arg1)
static const char whitespace[]
@ XML_ERROR_MISMATCHED_ELEMENT
@ XML_ERROR_EMPTY_DOCUMENT
@ XML_ERROR_PARSING_ATTRIBUTE
@ XML_ERROR_FILE_NOT_FOUND
@ XML_ERROR_PARSING_COMMENT
@ XML_ERROR_FILE_READ_ERROR
@ XML_ERROR_PARSING_UNKNOWN
@ XML_ERROR_PARSING_CDATA
@ XML_ERROR_PARSING_DECLARATION
@ XML_WRONG_ATTRIBUTE_TYPE
@ XML_ERROR_PARSING_ELEMENT
@ XML_ERROR_FILE_COULD_NOT_BE_OPENED
@ XML_CAN_NOT_CONVERT_TEXT
static FILE * callfopen(const char *filepath, const char *mode)
static const Entity entities[NUM_ENTITIES]
static const int NUM_ENTITIES
static unsigned __int64 next
_Check_return_ _CRTIMP long __cdecl filelength(_In_ int _FileHandle)
int CDECL fopen_s(FILE **pFile, const char *filename, const char *mode)
static bool Fits(unsigned long value)
static const char DOUBLE_QUOTE
static const unsigned char TIXML_UTF_LEAD_0
static const unsigned char TIXML_UTF_LEAD_1
static const char SINGLE_QUOTE
static int TIXML_VSCPRINTF(const char *format, va_list va)
static const unsigned char TIXML_UTF_LEAD_2
static const char LINE_FEED
static const char CARRIAGE_RETURN
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value