26 #ifndef TINYXML_INCLUDED 27 #define TINYXML_INCLUDED 29 #define TIXML_USE_TICPP 33 #pragma warning(disable : 4530) 34 #pragma warning(disable : 4786) 46 #if defined(_DEBUG) && !defined(DEBUG) 50 #ifdef TIXML_USE_TICPP 60 #define TIXML_STRING std::string 63 #define TIXML_STRING TiXmlString 73 #if defined(_MSC_VER) && (_MSC_VER >= 1400) 75 #define TIXML_SNPRINTF _snprintf_s 76 #define TIXML_SNSCANF _snscanf_s 77 #define TIXML_SSCANF sscanf_s 78 #elif defined(_MSC_VER) && (_MSC_VER >= 1200) 81 #define TIXML_SNPRINTF _snprintf 82 #define TIXML_SNSCANF _snscanf 83 #define TIXML_SSCANF sscanf 84 #elif defined(__GNUC__) && (__GNUC__ >= 3) 87 #define TIXML_SNPRINTF snprintf 88 #define TIXML_SNSCANF snscanf 89 #define TIXML_SSCANF sscanf 91 #define TIXML_SSCANF sscanf 209 #ifdef TIXML_USE_TICPP 234 virtual void Print(FILE* cfile,
int depth)
const = 0;
329 return (std::isspace((
unsigned char)c) || c ==
'\n' || c ==
'\r');
356 bool ignoreWhiteSpace,
367 inline static const char*
372 *length = utf8ByteTable[*((
const unsigned char*)p)];
373 assert(*length >= 0 && *length < 5);
379 if (*p ==
'&')
return GetEntity(p, _value, length, encoding);
383 }
else if (*length) {
387 for (
int i = 0; p[i] && i < *length; ++i) {
391 return p + (*length);
421 if (v < 128)
return std::tolower(v);
425 return std::tolower(v);
441 MAX_ENTITY_LENGTH = 6
570 (
const_cast< const TiXmlNode*
>(
this))->FirstChild(_value));
583 (
const_cast< const TiXmlNode*
>(
this))->LastChild(_value));
620 (
const_cast< const TiXmlNode*
>(
this))->IterateChildren(previous));
629 (
const_cast< const TiXmlNode*
>(
this))->IterateChildren(_value, previous));
685 (
const_cast< const TiXmlNode*
>(
this))->PreviousSibling(_prev));
711 (
const_cast< const TiXmlNode*
>(
this))->NextSibling(_next));
721 (
const_cast< const TiXmlNode*
>(
this))->NextSiblingElement());
731 (
const_cast< const TiXmlNode*
>(
this))->NextSiblingElement(_next));
747 (
const_cast< const TiXmlNode*
>(
this))->FirstChildElement());
754 (
const_cast< const TiXmlNode*
>(
this))->FirstChildElement(_value));
778 (
const_cast< const TiXmlNode*
>(
this))->GetDocument());
927 TiXmlAttribute(
const std::string& _name,
const std::string& _value) {
948 return value.c_str();
972 int QueryIntValue(
int* _value)
const;
974 int QueryDoubleValue(
double* _value)
const;
979 void SetValue(
const char* _value) { value = _value; }
981 void SetIntValue(
int _value);
982 void SetDoubleValue(
double _value);
985 void SetName(
const std::string& _name) { name = _name; }
988 void SetValue(
const std::string& _value) { value = _value; }
1016 virtual void Print(FILE* cfile,
int depth)
const {
Print(cfile, depth, 0); }
1017 void Print(FILE* cfile,
int depth,
TIXML_STRING* str)
const;
1055 return (sentinel.next == &sentinel) ? 0 : sentinel.
next;
1058 return (sentinel.next == &sentinel) ? 0 : sentinel.
next;
1061 return (sentinel.prev == &sentinel) ? 0 : sentinel.
prev;
1064 return (sentinel.prev == &sentinel) ? 0 : sentinel.
prev;
1072 #ifdef TIXML_USE_STL 1100 #ifdef TIXML_USE_STL 1114 const char* Attribute(
const char* name)
const;
1122 const char* Attribute(
const char* name,
int* i)
const;
1130 const char* Attribute(
const char* name,
double* d)
const;
1139 int QueryIntAttribute(
const char* name,
int* _value)
const;
1141 int QueryDoubleAttribute(
const char* name,
double* _value)
const;
1145 int result = QueryDoubleAttribute(name, &d);
1154 #ifdef TIXML_USE_STL 1163 template <
typename T >
1169 std::stringstream sstream(node->
ValueStr());
1170 sstream >> *outValue;
1203 void SetAttribute(
const char* name,
const char* _value);
1205 #ifdef TIXML_USE_STL 1206 const std::string* Attribute(
const std::string& name)
const;
1207 const std::string* Attribute(
const std::string& name,
int* i)
const;
1208 const std::string* Attribute(
const std::string& name,
double* d)
const;
1209 int QueryIntAttribute(
const std::string& name,
int* _value)
const;
1210 int QueryDoubleAttribute(
const std::string& name,
double* _value)
const;
1213 void SetAttribute(
const std::string& name,
const std::string& _value);
1215 void SetAttribute(
const std::string& name,
int _value);
1221 void SetAttribute(
const char* name,
int value);
1226 void SetDoubleAttribute(
const char* name,
double value);
1230 void RemoveAttribute(
const char* name);
1231 #ifdef TIXML_USE_STL 1233 RemoveAttribute(name.c_str());
1238 return attributeSet.First();
1242 return attributeSet.Last();
1283 const char* GetText()
const;
1288 virtual void Print(FILE* cfile,
int depth)
const;
1314 #ifdef TIXML_USE_STL 1315 virtual void StreamIn(std::istream* in,
TIXML_STRING* tag);
1348 virtual void Print(FILE* cfile,
int depth)
const;
1373 #ifdef TIXML_USE_STL 1374 virtual void StreamIn(std::istream* in,
TIXML_STRING* tag);
1401 #ifdef TIXML_USE_STL 1417 virtual void Print(FILE* cfile,
int depth)
const;
1447 #ifdef TIXML_USE_STL 1475 #ifdef TIXML_USE_STL 1478 const std::string& _encoding,
1479 const std::string& _standalone);
1484 const char* _encoding,
1485 const char* _standalone);
1493 const char*
Version()
const {
return version.c_str(); }
1495 const char*
Encoding()
const {
return encoding.c_str(); }
1502 virtual void Print(FILE* cfile,
int depth,
TIXML_STRING* str)
const;
1503 virtual void Print(FILE* cfile,
int depth)
const {
Print(cfile, depth, 0); }
1524 #ifdef TIXML_USE_STL 1525 virtual void StreamIn(std::istream* in,
TIXML_STRING* tag);
1549 #ifdef TIXML_USE_STL 1563 const char*
Type()
const {
return type.c_str(); }
1565 const char*
Href()
const {
return href.c_str(); }
1570 virtual void Print(FILE* cfile,
int depth,
TIXML_STRING* str)
const;
1571 virtual void Print(FILE* cfile,
int depth)
const {
Print(cfile, depth, 0); }
1592 #ifdef TIXML_USE_STL 1593 virtual void StreamIn(std::istream* in,
TIXML_STRING* tag);
1623 virtual void Print(FILE* cfile,
int depth)
const;
1644 #ifdef TIXML_USE_STL 1645 virtual void StreamIn(std::istream* in,
TIXML_STRING* tag);
1664 #ifdef TIXML_USE_STL 1680 bool SaveFile()
const;
1682 bool LoadFile(
const char* filename,
1685 bool SaveFile(
const char* filename)
const;
1696 bool SaveFile(FILE*)
const;
1698 #ifdef TIXML_USE_STL 1704 return LoadFile(filename.c_str(), encoding);
1709 return SaveFile(filename.c_str());
1721 virtual const char* Parse(
const char* p,
1763 return errorLocation.col + 1;
1803 errorLocation.row = errorLocation.col = 0;
1820 virtual void Print(FILE* cfile,
int depth = 0)
const;
1822 void SetError(
int err,
1823 const char* errorLocation,
1843 #ifdef TIXML_USE_STL 1844 virtual void StreamIn(std::istream* in,
TIXML_STRING* tag);
1960 this->node = ref.
node;
1971 TiXmlHandle FirstChildElement(
const char* value)
const;
1976 TiXmlHandle Child(
const char* value,
int index)
const;
1986 TiXmlHandle ChildElement(
const char* value,
int index)
const;
1994 #ifdef TIXML_USE_STL 1996 return FirstChild(_value.c_str());
1999 return FirstChildElement(_value.c_str());
2003 return Child(_value.c_str(), index);
2006 return ChildElement(_value.c_str(), index);
2016 return ((node && node->ToElement()) ? node->ToElement() : 0);
2021 return ((node && node->ToText()) ? node->ToText() : 0);
2026 return ((node && node->ToUnknown()) ? node->ToUnknown() : 0);
2074 , simpleTextPrint(false)
2077 , lineBreak(
"\n") {}
2087 virtual bool Visit(
const TiXmlText& text);
2095 void SetIndent(
const char* _indent) { indent = _indent ? _indent :
""; }
2097 const char*
Indent() {
return indent.c_str(); }
2103 lineBreak = _lineBreak ? _lineBreak :
"";
2117 const char*
CStr() {
return buffer.c_str(); }
2119 size_t Size() {
return buffer.size(); }
2121 #ifdef TIXML_USE_STL 2122 const std::string& Str() {
return buffer; }
2128 for (
int i = 0; i < depth; ++i)
2141 #pragma warning(pop)
static const int utf8ByteTable[256]
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
int ErrorCol() const
The column where the error occured. See ErrorRow()
An attribute is a name-value pair.
TiXmlHandle(TiXmlNode *_node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
TiXmlNode * FirstChild(const std::string &_value)
STL std::string form.
void SetUserData(void *user)
Set a pointer to arbitrary user data.
If you call the Accept() method, it requires being passed a TiXmlVisitor class to handle callbacks...
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null not of the requested type.
TiXmlUnknown(const TiXmlUnknown ©)
virtual ~TiXmlStylesheetReference()
const char * Type() const
Type. Will return an empty string if none was found.
void SetLineBreak(const char *_lineBreak)
Set the line breaking string.
TiXmlElement * NextSiblingElement()
TiXmlHandle(const TiXmlHandle &ref)
Copy constructor.
TiXmlNode * PreviousSibling(const char *_prev)
TiXmlNode * LastChild()
The last child of this node. Will be null if there are no children.
const char * LineBreak()
Query the current line breaking string.
const TiXmlNode * LastChild() const
virtual bool Visit(const TiXmlUnknown &)
Visit an unknow node.
bool operator==(const TiXmlAttribute &rhs) const
TiXmlAttribute(const char *_name, const char *_value)
Construct an attribute with a name and value.
virtual const TiXmlDocument * ToDocument() const
Cast to a more defined type. Will return null not of the requested type.
const char * Name() const
Return the name of this attribute.
const char * ErrorDesc() const
Contains a textual (english) description of the error if one occurs.
bool operator<(const TiXmlAttribute &rhs) const
void Print() const
Write the document to standard out using formatted printing ("pretty print").
static int ToLower(int v, TiXmlEncoding encoding)
TiXmlNode * IterateChildren(const std::string &_value, const TiXmlNode *previous)
STL std::string form.
TiXmlElement * Element() const
TiXmlNode * IterateChildren(const char *_value, const TiXmlNode *previous)
static int IsAlphaNum(unsigned char anyByte, TiXmlEncoding encoding)
const TiXmlNode * IterateChildren(const std::string &_value, const TiXmlNode *previous) const
STL std::string form.
void operator=(const TiXmlUnknown ©)
TiXmlHandle FirstChildElement(const std::string &_value) const
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null if not of the requested type.
TiXmlElement * NextSiblingElement(const std::string &_value)
STL std::string form.
TiXmlAttribute * FirstAttribute()
bool Error() const
If an error occurs, Error will be set to true.
int Column() const
See Row()
void operator=(const TiXmlAttributeSet &)
TiXmlElement * FirstChildElement(const char *_value)
void operator=(const TiXmlDocument ©)
void SetValue(const std::string &_value)
STL std::string form.
static const char * ReadName(const char *p, TIXML_STRING *name, TiXmlEncoding encoding)
virtual void StreamIn(std::istream *in, TIXML_STRING *tag)
TiXmlNode * ReplaceChild(TiXmlNode *replaceThis, const TiXmlNode &withThis)
Replace a child of this node.
const std::string & ValueStr() const
Return Value() as a std::string.
virtual bool VisitExit(const TiXmlElement &)
Visit an element.
bool CDATA() const
Queries whether this represents text using a CDATA section.
void SetName(const char *_name)
Set the name of this attribute.
TiXmlNode * NextSibling()
void SetTabSize(int _tabsize)
SetTabSize() allows the error reporting functions (ErrorRow() and ErrorCol()) to report the correct v...
TiXmlAttribute()
Construct an empty attribute.
const int TIXML_PATCH_VERSION
const char * Standalone() const
Is this a standalone document?
void CopyTo(TiXmlElement *target) const
TiXmlElement * NextSiblingElement(const char *_next)
const TIXML_STRING & NameTStr() const
TiXmlElement * FirstChildElement()
virtual TiXmlDocument * ToDocument()
Cast to a more defined type. Will return null if not of the requested type.
void ClearError()
If you have handled the error, it can be reset with this call.
void CopyTo(TiXmlUnknown *target) const
const TiXmlElement * NextSiblingElement(const std::string &_value) const
STL std::string form.
virtual void Print(FILE *cfile, int depth) const
All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL ...
const char * Href() const
Href. Will return an empty string if none was found.
static const char * errorString[TIXML_ERROR_STRING_COUNT]
void SetValue(const char *_value)
Changes the value of the node.
TiXmlNode * InsertEndChild(const TiXmlNode &addThis)
Add a new node related to this.
static void ConvertUTF32ToUTF8(unsigned long input, char *output, int *length)
TiXmlNode * ToNode() const
Return the handle as a TiXmlNode.
const TIXML_STRING & ValueTStr() const
TiXmlNode * InsertBeforeChild(TiXmlNode *beforeThis, const TiXmlNode &addThis)
Add a new node related to this.
static bool condenseWhiteSpace
const std::string & ValueStr() const
Return the value of this attribute.
TiXmlNode * PreviousSibling()
NodeType
The types of XML nodes supported by TinyXml.
TiXmlAttribute * Find(const char *_name)
virtual bool VisitEnter(const TiXmlDocument &)
Visit a document.
TiXmlNode * LinkEndChild(TiXmlNode *addThis)
Add a new node related to this.
const TiXmlElement * RootElement() const
Get the root element – the only top level element – of the document.
const TiXmlElement * FirstChildElement() const
Convenience function to get through elements.
const TiXmlNode * PreviousSibling(const std::string &_value) const
STL std::string form.
const char * Encoding() const
Encoding. Will return an empty string if none was found.
void * userData
Field containing a generic user pointer.
A stylesheet reference looks like this:
TiXmlDocument * GetDocument()
In correct XML the declaration is the first entry in the file.
const TiXmlNode * PreviousSibling() const
Navigate to a sibling node.
virtual const TiXmlDocument * ToDocument() const
Cast to a more defined type. Will return null if not of the requested type.
const char * Value() const
Return the value of this attribute.
static bool IsWhiteSpace(char c)
std::istream & operator>>(std::istream &in, TiXmlNode &base)
TiXmlAttributeSet attributeSet
Any tag that tinyXml doesn't recognize is saved as an unknown.
virtual bool Visit(const TiXmlText &)
Visit a text node.
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null not of the requested type.
const TiXmlEncoding TIXML_DEFAULT_ENCODING
virtual const TiXmlComment * ToComment() const
Cast to a more defined type. Will return null if not of the requested type.
TiXmlNode * NextSibling(const char *_next)
TiXmlStylesheetReference()
Construct an empty declaration.
const char * Version() const
Version. Will return an empty string if none was found.
static bool IsWhiteSpaceCondensed()
Return the current white space setting.
TiXmlText(const TiXmlText ©)
static const char * ReadText(const char *in, TIXML_STRING *text, bool ignoreWhiteSpace, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
const char * Value() const
The meaning of 'value' changes for the specific type of TiXmlNode.
const int TIXML_MAJOR_VERSION
const TiXmlNode * LastChild(const std::string &_value) const
STL std::string form.
void SetIndent(const char *_indent)
Set the indent characters for printing.
const TiXmlAttribute * LastAttribute() const
Access the last attribute in this element.
std::ostream & operator<<(std::ostream &output, const BayesNet< GUM_SCALAR > &bn)
Prints map's DAG in output using the Graphviz-dot format.
int QueryValueAttribute(const std::string &name, T *outValue) const
Template form of the attribute query which will try to read the attribute into the specified type...
void CopyTo(TiXmlText *target) const
bool LoadFile(const std::string &filename, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
void SetCDATA(bool _cdata)
Turns on or off a CDATA representation of text.
const char * Indent()
Query the indention string.
virtual void Print(FILE *cfile, int depth) const
All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL ...
virtual bool Visit(const TiXmlStylesheetReference &)
Visit a stylesheet reference.
TiXmlElement * FirstChildElement(const std::string &_value)
STL std::string form.
const TiXmlElement * NextSiblingElement() const
Convenience function to get through elements.
Always the top level node.
const TiXmlAttribute * Last() const
virtual void Print(FILE *cfile, int depth) const
All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL ...
TiXmlElement * ToElement() const
Return the handle as a TiXmlElement.
static const char * SkipWhiteSpace(const char *, TiXmlEncoding encoding)
TiXmlNode * Identify(const char *start, TiXmlEncoding encoding)
TiXmlNode * InsertAfterChild(TiXmlNode *afterThis, const TiXmlNode &addThis)
Add a new node related to this.
int ErrorRow() const
Returns the location (if known) of the error.
TiXmlUnknown * Unknown() const
static bool StreamTo(std::istream *in, int character, TIXML_STRING *tag)
int Row() const
Return the position, in the original source file, of this node or attribute.
A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly useful thi...
static bool IsWhiteSpace(int c)
const TiXmlDocument * GetDocument() const
Return a pointer to the Document this node lives in.
TiXmlUnknown * ToUnknown() const
Return the handle as a TiXmlUnknown.
static const char * GetEntity(const char *in, char *value, int *length, TiXmlEncoding encoding)
static void SetCondenseWhiteSpace(bool condense)
The world does not agree on whether white space should be kept or not.
bool operator>(const TiXmlAttribute &rhs) const
TiXmlBase is a base class for every class in TinyXml.
TiXmlNode * Parent()
One step up the DOM.
int Type() const
Query the type (as an enumerated value, above) of this node.
virtual const TiXmlUnknown * ToUnknown() const
Cast to a more defined type. Will return null not of the requested type.
static bool StringEqual(const char *p, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
const void * GetUserData() const
Get a pointer to arbitrary user data.
const TiXmlNode * FirstChild() const
The first child of this node. Will be null if there are no children.
virtual const char * Parse(const char *p, TiXmlParsingData *data=0, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
Parse the given null terminated block of xml data.
void operator=(const TiXmlElement &base)
virtual TiXmlNode * Clone() const
Creates a new Element and returns it - the returned element is a copy.
TiXmlHandle operator=(const TiXmlHandle &ref)
TiXmlNode * IterateChildren(const TiXmlNode *previous)
virtual const TiXmlDeclaration * ToDeclaration() const
Cast to a more defined type. Will return null if not of the requested type.
Base class for reference counting functionality.
TiXmlAttribute * Previous()
TiXmlNode(NodeType _type)
TiXmlElement * RootElement()
static void EncodeString(const TIXML_STRING &str, TIXML_STRING *out)
Expands entities in a string.
TiXmlHandle ChildElement(const std::string &_value, int index) const
void * GetUserData()
Get a pointer to arbitrary user data.
The parent class for everything in the Document Object Model.
const TiXmlAttribute * First() const
TiXmlNode * LastChild(const std::string &_value)
STL std::string form.
size_t Size()
Return the length of the result string.
Print to memory functionality.
TiXmlNode * PreviousSibling(const std::string &_value)
STL std::string form.
TiXmlHandle Child(const std::string &_value, int index) const
bool NoChildren() const
Returns true if this node has no children.
virtual const TiXmlUnknown * ToUnknown() const
Cast to a more defined type. Will return null if not of the requested type.
virtual bool VisitExit(const TiXmlDocument &)
Visit a document.
virtual bool Visit(const TiXmlComment &)
Visit a comment node.
static const char * GetChar(const char *p, char *_value, int *length, TiXmlEncoding encoding)
void operator=(const TiXmlText &base)
TiXmlText(const char *initValue)
Constructor for text element.
virtual const TiXmlStylesheetReference * ToStylesheetReference() const
Cast to a more defined type. Will return null if not of the requested type.
virtual const TiXmlDeclaration * ToDeclaration() const
Cast to a more defined type. Will return null not of the requested type.
TiXmlNode * NextSibling(const std::string &_value)
STL std::string form.
virtual const TiXmlStylesheetReference * ToStylesheetReference() const
Cast to a more defined type. Will return null not of the requested type.
virtual void Print(FILE *cfile, int depth) const
All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL ...
const TiXmlElement * FirstChildElement(const std::string &_value) const
STL std::string form.
bool SaveFile(const std::string &filename) const
int QueryFloatAttribute(const char *name, float *_value) const
QueryFloatAttribute examines the attribute - see QueryIntAttribute().
const TiXmlNode * Parent() const
bool RemoveChild(TiXmlNode *removeThis)
Delete a child of this node.
void RemoveAttribute(const std::string &name)
STL std::string form.
void SetDocument(TiXmlDocument *doc)
void SetValue(const char *_value)
Set the value.
virtual ~TiXmlDeclaration()
const TiXmlNode * IterateChildren(const TiXmlNode *previous) const
An alternate way to walk the children of a node.
virtual bool Accept(TiXmlVisitor *visitor) const
Walk the XML tree visiting this node and all of its children.
TiXmlAttribute * LastAttribute()
TiXmlDeclaration()
Construct an empty declaration.
void SetStreamPrinting()
Switch over to "stream printing" which is the most dense formatting without linebreaks.
static int IsAlpha(unsigned char anyByte, TiXmlEncoding encoding)
const TiXmlNode * FirstChild(const std::string &_value) const
STL std::string form.
TiXmlHandle FirstChild(const std::string &_value) const
const TiXmlNode * NextSibling() const
Navigate to a sibling node.
TiXmlText * ToText() const
Return the handle as a TiXmlText.
static bool StreamWhiteSpace(std::istream *in, TIXML_STRING *tag)
const char * CStr()
Return the result.
const TiXmlNode * NextSibling(const std::string &_value) const
STL std::string form.
const int TIXML_MINOR_VERSION
int ErrorId() const
Generally, you probably want the error string ( ErrorDesc() ).
The element is a container class.
TiXmlCursor errorLocation
virtual bool VisitEnter(const TiXmlElement &, const TiXmlAttribute *)
Visit an element.
virtual bool Visit(const TiXmlDeclaration &)
Visit a declaration.
const TiXmlAttribute * FirstAttribute() const
Access the first attribute in this element.
TiXmlAttribute * Find(const std::string &_name)