24 #ifndef TINYXML2_INCLUDED 25 #define TINYXML2_INCLUDED 27 #if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__) 52 #if defined( _DEBUG ) || defined( DEBUG ) || defined (__DEBUG__) 59 # pragma warning(push) 60 # pragma warning(disable: 4251) 64 # ifdef TINYXML2_EXPORT 65 # define TINYXML2_LIB __declspec(dllexport) 66 # elif defined(TINYXML2_IMPORT) 67 # define TINYXML2_LIB __declspec(dllimport) 77 # if defined(_MSC_VER) 78 # // "(void)0," is for suppressing C4127 warning in "assert(false)", "assert(true)" and the like 79 # define TIXMLASSERT( x ) if ( !((void)0,(x))) { __debugbreak(); } 80 # elif defined (ANDROID_NDK) 81 # include <android/log.h> 82 # define TIXMLASSERT( x ) if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); } 85 # define TIXMLASSERT assert 88 # define TIXMLASSERT( x ) {} 106 class XMLDeclaration;
155 char*
ParseText(
char*
in,
const char* endTag,
int strFlags );
183 template <
class T,
int INITIAL_SIZE>
275 int newAllocated =
cap * 2;
276 T* newMem =
new T[newAllocated];
304 virtual void*
Alloc() = 0;
305 virtual void Free(
void* ) = 0;
307 virtual void Clear() = 0;
346 Block*
block =
new Block();
372 Chunk*
chunk = static_cast<Chunk*>(
mem );
380 printf(
"Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n",
528 return const_cast<char*>(
SkipWhiteSpace( const_cast<const char*>(
p) ) );
545 return ch ==
':' || ch ==
'_';
563 return (
p & 0x80 ) != 0;
566 static const char*
ReadBOM(
const char*
p,
bool* hasBOM );
683 const char*
Value()
const;
688 void SetValue(
const char*
val,
bool staticMem=
false );
716 const XMLElement* FirstChildElement(
const char*
name = 0 )
const;
719 return const_cast<XMLElement*>(const_cast<const XMLNode*>(
this)->FirstChildElement(
name ));
737 return const_cast<XMLElement*>(const_cast<const XMLNode*>(
this)->LastChildElement(
name) );
750 const XMLElement* PreviousSiblingElement(
const char*
name = 0 )
const ;
753 return const_cast<XMLElement*>(const_cast<const XMLNode*>(
this)->PreviousSiblingElement(
name ) );
766 const XMLElement* NextSiblingElement(
const char*
name = 0 )
const;
769 return const_cast<XMLElement*>(const_cast<const XMLNode*>(
this)->NextSiblingElement(
name ) );
782 return InsertEndChild( addThis );
805 void DeleteChildren();
853 virtual bool Accept(
XMLVisitor* visitor )
const = 0;
859 virtual char* ParseDeep(
char*,
StrPair* );
875 void InsertChildPreamble(
XMLNode* insertThis )
const;
896 friend class XMLBase;
899 virtual bool Accept(
XMLVisitor* visitor )
const;
924 char* ParseDeep(
char*,
StrPair* endTag );
946 virtual bool Accept(
XMLVisitor* visitor )
const;
955 char* ParseDeep(
char*,
StrPair* endTag );
985 virtual bool Accept(
XMLVisitor* visitor )
const;
994 char* ParseDeep(
char*,
StrPair* endTag );
1020 virtual bool Accept(
XMLVisitor* visitor )
const;
1029 char* ParseDeep(
char*,
StrPair* endTag );
1049 const char*
Name()
const;
1052 const char*
Value()
const;
1065 QueryIntValue( &
i );
1071 QueryUnsignedValue( &
i );
1077 QueryBoolValue( &
b );
1083 QueryDoubleValue( &
d );
1089 QueryFloatValue( &
f );
1108 void SetAttribute(
const char*
value );
1110 void SetAttribute(
int value );
1112 void SetAttribute(
unsigned value );
1114 void SetAttribute(
bool value );
1116 void SetAttribute(
double value );
1118 void SetAttribute(
float value );
1128 void SetName(
const char*
name );
1130 char* ParseDeep(
char*
p,
bool processEntities );
1145 friend class XMLBase;
1163 virtual bool Accept(
XMLVisitor* visitor )
const;
1188 const char* Attribute(
const char*
name,
const char*
value=0 )
const;
1197 QueryIntAttribute(
name, &
i );
1203 QueryUnsignedAttribute(
name, &
i );
1209 QueryBoolAttribute(
name, &
b );
1215 QueryDoubleAttribute(
name, &
d );
1221 QueryFloatAttribute(
name, &
f );
1243 return a->QueryIntValue(
value );
1251 return a->QueryUnsignedValue(
value );
1259 return a->QueryBoolValue(
value );
1267 return a->QueryDoubleValue(
value );
1275 return a->QueryFloatValue(
value );
1297 return QueryIntAttribute(
name,
value );
1301 return QueryUnsignedAttribute(
name,
value );
1305 return QueryBoolAttribute(
name,
value );
1309 return QueryDoubleAttribute(
name,
value );
1313 return QueryFloatAttribute(
name,
value );
1319 a->SetAttribute(
value );
1324 a->SetAttribute(
value );
1329 a->SetAttribute(
value );
1334 a->SetAttribute(
value );
1339 a->SetAttribute(
value );
1344 a->SetAttribute(
value );
1350 void DeleteAttribute(
const char*
name );
1354 return _rootAttribute;
1387 const char* GetText()
const;
1423 void SetText(
const char* inText );
1425 void SetText(
int value );
1427 void SetText(
unsigned value );
1429 void SetText(
bool value );
1431 void SetText(
double value );
1433 void SetText(
float value );
1461 XMLError QueryIntText(
int* ival )
const;
1463 XMLError QueryUnsignedText(
unsigned* uval )
const;
1469 XMLError QueryFloatText(
float* fval )
const;
1478 return _closingType;
1484 char* ParseDeep(
char*
p,
StrPair* endTag );
1493 return const_cast<XMLAttribute*>(const_cast<const XMLElement*>(
this)->
FindAttribute(
name ));
1497 char* ParseAttributes(
char*
p );
1547 XMLError Parse(
const char* xml,
size_t nBytes=(
size_t)(-1) );
1586 return _processEntities;
1608 return FirstChildElement();
1611 return FirstChildElement();
1629 virtual bool Accept(
XMLVisitor* visitor )
const;
1674 void SetError(
XMLError error,
const char* str1,
const char* str2 );
1684 const char* ErrorName()
const;
1811 return XMLHandle( _node ? _node->FirstChild() : 0 );
1815 return XMLHandle( _node ? _node->FirstChildElement(
name ) : 0 );
1819 return XMLHandle( _node ? _node->LastChild() : 0 );
1823 return XMLHandle( _node ? _node->LastChildElement(
name ) : 0 );
1827 return XMLHandle( _node ? _node->PreviousSibling() : 0 );
1831 return XMLHandle( _node ? _node->PreviousSiblingElement(
name ) : 0 );
1835 return XMLHandle( _node ? _node->NextSibling() : 0 );
1839 return XMLHandle( _node ? _node->NextSiblingElement(
name ) : 0 );
1848 return ( ( _node == 0 ) ? 0 : _node->ToElement() );
1852 return ( ( _node == 0 ) ? 0 : _node->ToText() );
1856 return ( ( _node == 0 ) ? 0 : _node->ToUnknown() );
1860 return ( ( _node == 0 ) ? 0 : _node->ToDeclaration() );
1920 return ( ( _node == 0 ) ? 0 : _node->ToElement() );
1923 return ( ( _node == 0 ) ? 0 : _node->ToText() );
1926 return ( ( _node == 0 ) ? 0 : _node->ToUnknown() );
1929 return ( ( _node == 0 ) ? 0 : _node->ToDeclaration() );
1992 void PushHeader(
bool writeBOM,
bool writeDeclaration );
1996 void OpenElement(
const char*
name,
bool compactMode=
false );
1998 void PushAttribute(
const char*
name,
const char*
value );
1999 void PushAttribute(
const char*
name,
int value );
2000 void PushAttribute(
const char*
name,
unsigned value );
2001 void PushAttribute(
const char*
name,
bool value );
2002 void PushAttribute(
const char*
name,
double value );
2004 virtual void CloseElement(
bool compactMode=
false );
2007 void PushText(
const char*
text,
bool cdata=
false );
2009 void PushText(
int value );
2011 void PushText(
unsigned value );
2013 void PushText(
bool value );
2015 void PushText(
float value );
2017 void PushText(
double value );
2020 void PushComment(
const char*
comment );
2022 void PushDeclaration(
const char*
value );
2023 void PushUnknown(
const char*
value );
2043 return _buffer.Mem();
2051 return _buffer.Size();
2068 virtual void PrintSpace(
int depth );
2071 void SealElementIfJustOpened();
2076 void PrintString(
const char*,
bool restrictedEntitySet );
2089 bool _entityFlag[ENTITY_RANGE];
2090 bool _restrictedEntityFlag[ENTITY_RANGE];
2098 #if defined(_MSC_VER) 2099 # pragma warning(pop) 2102 #endif // TINYXML2_INCLUDED virtual XMLElement * ToElement()
Safely cast to an Element, or null.
static unsigned int block
void CollapseWhitespace()
static UCHAR ULONG UCHAR ULONG UCHAR * output
const XMLConstHandle NextSibling() const
static void ToStr(int v, char *buffer, int bufferSize)
virtual void Free(void *mem)
static const int TIXML2_PATCH_VERSION
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.
XMLHandle(XMLNode *node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
virtual const XMLElement * ToElement() const
XMLElement * PreviousSiblingElement(const char *name=0)
const XMLNode * ToNode() const
XMLError QueryFloatAttribute(const char *name, float *value) const
See QueryIntAttribute()
XMLElement * LastChildElement(const char *name=0)
XMLAttribute * _rootAttribute
GLuint GLuint GLsizei count
static const char * SkipWhiteSpace(const char *p)
double DoubleValue() const
Query as a double. See IntValue()
void SetAttribute(const char *name, unsigned value)
Sets the named attribute to value.
static bool ToFloat(const char *str, float *value)
const XMLAttribute * FirstAttribute() const
Return the first attribute in the list.
virtual XMLComment * ToComment()
Safely cast to a Comment, or null.
unsigned UnsignedValue() const
Query as an unsigned integer. See IntValue()
const char * GetErrorStr1() const
Return a possibly helpful diagnostic location or string.
XMLConstHandle & operator=(const XMLConstHandle &ref)
virtual const XMLDeclaration * ToDeclaration() const
static VOID PrintError(DWORD dwError)
virtual bool VisitEnter(const XMLElement &, const XMLAttribute *)
Visit an element.
void Set(char *start, char *end, int flags)
bool Error() const
Return true if there was an error parsing the document.
DynArray< Block *, 10 > _blockPtrs
virtual void Free(void *)=0
Whitespace WhitespaceMode() const
const XMLConstHandle LastChild() const
const XMLDocument * GetDocument() const
Get the XMLDocument that owns this XMLNode.
XMLError QueryDoubleAttribute(const char *name, double *value) const
See QueryIntAttribute()
static bool IsNameChar(unsigned char ch)
static bool IsWhiteSpace(char p)
const XMLConstHandle FirstChild() const
static const char * ReadBOM(const char *p, bool *hasBOM)
void TransferTo(StrPair *other)
NTSTATUS FindAttribute(PDEVICE_EXTENSION Vcb, PFILE_RECORD_HEADER MftRecord, ULONG Type, PCWSTR Name, ULONG NameLength, PNTFS_ATTR_CONTEXT *AttrCtx, PULONG Offset)
virtual const XMLComment * ToComment() const
#define comment(fmt, arg1)
static int Unlink(const char **args)
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
virtual bool Visit(const XMLText &)
Visit a text node.
const XMLUnknown * ToUnknown() const
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
static char * SkipWhiteSpace(char *p)
XMLError ErrorID() const
Return the errorID.
XMLConstHandle(const XMLNode *node)
XMLNode * PreviousSibling()
static bool ToBool(const char *str, bool *value)
void Print(USHORT Window, LPSTR p)
virtual bool VisitExit(const XMLDocument &)
Visit a document.
char * ParseName(char *in)
virtual bool ShallowEqual(const XMLNode *) const
bool BoolAttribute(const char *name) const
See IntAttribute()
const T & operator[](int i) const
XMLConstHandle(const XMLNode &node)
const char * CStr() const
bool BoolValue() const
Query as a boolean. See IntValue()
const XMLConstHandle PreviousSiblingElement(const char *name=0) const
virtual XMLText * ToText()
Safely cast to Text, or null.
const XMLConstHandle LastChildElement(const char *name=0) const
virtual bool Visit(const XMLComment &)
Visit a comment node.
XMLHandle LastChild()
Get the last child of this handle.
double DoubleAttribute(const char *name) const
See IntAttribute()
int QueryAttribute(const char *name, unsigned int *value) const
BOOL LoadFile(LPTSTR FileName)
static VOID PrintString(IN PCSTR fmt,...)
GLenum GLuint GLenum GLsizei length
const XMLText * ToText() const
virtual const XMLDocument * ToDocument() const
void SetAttribute(const char *name, const char *value)
Sets the named attribute to value.
const XMLNode * LastChild() const
Get the last child node, or null if none exists.
const XMLNode * Parent() const
Get the parent of this node on the DOM.
XMLHandle FirstChildElement(const char *name=0)
Get the first child element of this handle.
void operator=(const DynArray &)
static const int TIXML2_MINOR_VERSION
XMLHandle & operator=(const XMLHandle &ref)
Assignment.
DynArray< char, 20 > _buffer
virtual const XMLText * ToText() const
XMLElement * RootElement()
static bool ToInt(const char *str, int *value)
const XMLElement * RootElement() const
BOOL DeleteNode(HWND hwndTV, HTREEITEM hItem)
XMLHandle NextSiblingElement(const char *name=0)
Get the next sibling element of this handle.
static bool IsUTF8Continuation(char p)
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
static bool ToUnsigned(const char *str, unsigned *value)
virtual const XMLUnknown * ToUnknown() const
int QueryAttribute(const char *name, double *value) const
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
virtual const XMLText * ToText() const
void SetName(const char *str, bool staticMem=false)
Set the name of the element.
const XMLConstHandle PreviousSibling() const
void SetAttribute(const char *name, double value)
Sets the named attribute to value.
GLboolean GLboolean GLboolean b
void operator=(const MemPoolT &)
static const int TIXML2_MAJOR_VERSION
virtual void SetTracked()=0
const XMLNode * NextSibling() const
Get the next (right) sibling node of this node.
static bool ToDouble(const char *str, double *value)
const XMLConstHandle FirstChildElement(const char *name=0) const
XMLHandle LastChildElement(const char *name=0)
Get the last child element of this handle.
void EnsureCapacity(int cap)
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
virtual XMLNode * ShallowClone(XMLDocument *) const
virtual bool VisitExit(const XMLDocument &)
Visit a document.
float FloatAttribute(const char *name) const
See IntAttribute()
const char * GetErrorStr2() const
Return a possibly helpful secondary diagnostic location or string.
void SetStr(const char *str, int flags=0)
XMLHandle(XMLNode &node)
Create a handle from a node.
void SetCData(bool isCData)
Declare whether this should be CDATA or standard text.
GLdouble GLdouble GLdouble GLdouble q
XMLDocument * GetDocument()
Get the XMLDocument that owns this XMLNode.
const XMLConstHandle NextSiblingElement(const char *name=0) const
GLint GLint GLsizei GLsizei GLsizei depth
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
static bool StringEqual(const char *p, const char *q, int nChar=INT_MAX)
virtual bool VisitExit(const XMLElement &)
Visit an element.
#define memcpy(s1, s2, n)
virtual bool Visit(const XMLUnknown &)
Visit an unknown node.
virtual int ItemSize() const
XMLConstHandle(const XMLConstHandle &ref)
XMLError QueryIntAttribute(const char *name, int *value) const
XMLElement * NextSiblingElement(const char *name=0)
int QueryAttribute(const char *name, float *value) const
unsigned UnsignedAttribute(const char *name) const
See IntAttribute()
XMLNode * LinkEndChild(XMLNode *addThis)
const XMLAttribute * Next() const
The next attribute in the list.
XMLAttribute * FindAttribute(const char *name)
XMLElement * FirstChildElement(const char *name=0)
void SetAttribute(const char *name, bool value)
Sets the named attribute to value.
int IntAttribute(const char *name) const
void SetAttribute(const char *name, float value)
Sets the named attribute to value.
DynArray< const char *, 10 > _stack
static void ConvertUTF32ToUTF8(unsigned long input, char *output, int *length)
GLenum GLenum GLenum input
XMLNode * ToNode()
Safe cast to XMLNode. This can return null.
void Trace(const char *name)
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
XMLHandle NextSibling()
Get the next sibling of this handle.
float FloatValue() const
Query as a float. See IntValue()
XMLText(XMLDocument *doc)
static bool IsNameStartChar(unsigned char ch)
virtual XMLText * ToText()
Safely cast to Text, or null.
void SetAttribute(const char *name, int value)
Sets the named attribute to value.
bool CData() const
Returns true if this is a CDATA text element.
XMLText * ToText()
Safe cast to XMLText. This can return null.
void operator=(StrPair &other)
virtual const XMLDeclaration * ToDeclaration() const
XMLError QueryBoolAttribute(const char *name, bool *value) const
See QueryIntAttribute()
const T & PeekTop() const
virtual bool CompactMode(const XMLElement &)
XMLHandle PreviousSibling()
Get the previous sibling of this handle.
XMLDeclaration * ToDeclaration()
Safe cast to XMLDeclaration. This can return null.
XMLUnknown * ToUnknown()
Safe cast to XMLUnknown. This can return null.
int QueryAttribute(const char *name, int *value) const
int QueryAttribute(const char *name, bool *value) const
bool NoChildren() const
Returns true if this node has no children.
XMLHandle FirstChild()
Get the first child of this handle.
XMLElement * ToElement()
Safe cast to XMLElement. This can return null.
XMLHandle PreviousSiblingElement(const char *name=0)
Get the previous sibling element of this handle.
const XMLNode * PreviousSibling() const
Get the previous (left) sibling node of this node.
virtual bool Visit(const XMLDeclaration &)
Visit a declaration.
XMLError QueryUnsignedAttribute(const char *name, unsigned int *value) const
See QueryIntAttribute()
virtual bool VisitEnter(const XMLDocument &)
Visit a document.
void Clear(USHORT Window)
GLboolean GLboolean GLboolean GLboolean a
char * ParseText(char *in, const char *endTag, int strFlags)
bool ProcessEntities() const
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
virtual int ItemSize() const =0
virtual const XMLUnknown * ToUnknown() const
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
virtual const XMLElement * ToElement() const
virtual const XMLDocument * ToDocument() const
XMLHandle(const XMLHandle &ref)
Copy constructor.
int CurrentAllocs() const
const XMLElement * ToElement() const
void SetInternedStr(const char *str)
const XMLDeclaration * ToDeclaration() const