aGrUM  0.16.0
tinyxml.h
Go to the documentation of this file.
1 /*
2 www.sourceforge.net/projects/tinyxml
3 Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason
4 (www.grinninglizard.com)
5 
6 This software is provided 'as-is', without any express or implied
7 warranty. In no event will the authors be held liable for any
8 damages arising from the use of this software.
9 
10 Permission is granted to anyone to use this software for any
11 purpose, including commercial applications, and to alter it and
12 redistribute it freely, subject to the following restrictions:
13 
14 1. The origin of this software must not be misrepresented; you must
15 not claim that you wrote the original software. If you use this
16 software in a product, an acknowledgment in the product documentation
17 would be appreciated but is not required.
18 
19 2. Altered source versions must be plainly marked as such, and
20 must not be misrepresented as being the original software.
21 
22 3. This notice may not be removed or altered from any source
23 distribution.
24 */
25 
26 #ifndef TINYXML_INCLUDED
27 #define TINYXML_INCLUDED
28 
29 #define TIXML_USE_TICPP
30 
31 #ifdef _MSC_VER
32 #pragma warning(push)
33 #pragma warning(disable : 4530)
34 #pragma warning(disable : 4786)
35 #endif
36 
37 #include <cctype>
38 
39 #include <assert.h>
40 #include <ctype.h>
41 #include <stdio.h>
42 #include <stdlib.h>
43 #include <string.h>
44 
45 // Help out windows:
46 #if defined(_DEBUG) && !defined(DEBUG)
47 #define DEBUG
48 #endif
49 
50 #ifdef TIXML_USE_TICPP
51 #ifndef TIXML_USE_STL
52 #define TIXML_USE_STL
53 #endif
54 #endif
55 
56 #ifdef TIXML_USE_STL
57 #include <iostream>
58 #include <sstream>
59 #include <string>
60 #define TIXML_STRING std::string
61 #else
62 #include "tinystr.h"
63 #define TIXML_STRING TiXmlString
64 #endif
65 
66 // Deprecated library function hell. Compilers want to use the
67 // new safe versions. This probably doesn't fully address the problem,
68 // but it gets closer. There are too many compilers for me to fully
69 // test. If you get compilation troubles, undefine TIXML_SAFE
70 #define TIXML_SAFE
71 
72 #ifdef TIXML_SAFE
73 #if defined(_MSC_VER) && (_MSC_VER >= 1400)
74 // Microsoft visual studio, version 2005 and higher.
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)
79 // Microsoft visual studio, version 6 and higher.
80 //#pragma message( "Using _sn* functions." )
81 #define TIXML_SNPRINTF _snprintf
82 #define TIXML_SNSCANF _snscanf
83 #define TIXML_SSCANF sscanf
84 #elif defined(__GNUC__) && (__GNUC__ >= 3)
85 // GCC version 3 and higher.s
86 //#warning( "Using sn* functions." )
87 #define TIXML_SNPRINTF snprintf
88 #define TIXML_SNSCANF snscanf
89 #define TIXML_SSCANF sscanf
90 #else
91 #define TIXML_SSCANF sscanf
92 #endif
93 #endif
94 
95 class TiXmlDocument;
96 class TiXmlElement;
97 class TiXmlComment;
98 class TiXmlUnknown;
99 class TiXmlAttribute;
100 class TiXmlText;
101 class TiXmlDeclaration;
103 class TiXmlParsingData;
104 
105 const int TIXML_MAJOR_VERSION = 2;
106 const int TIXML_MINOR_VERSION = 5;
107 const int TIXML_PATCH_VERSION = 3;
108 
109 /* Internal structure for tracking location of items
110  in the XML file.
111 */
112 struct TiXmlCursor {
114  void Clear() { row = col = -1; }
115 
116  int row; // 0 based.
117  int col; // 0 based.
118 };
119 
145  public:
146  virtual ~TiXmlVisitor() {}
147 
149  virtual bool VisitEnter(const TiXmlDocument& /*doc*/) { return true; }
151  virtual bool VisitExit(const TiXmlDocument& /*doc*/) { return true; }
152 
154  virtual bool VisitEnter(const TiXmlElement& /*element*/,
155  const TiXmlAttribute* /*firstAttribute*/) {
156  return true;
157  }
159  virtual bool VisitExit(const TiXmlElement& /*element*/) { return true; }
160 
162  virtual bool Visit(const TiXmlDeclaration& /*declaration*/) { return true; }
164  virtual bool Visit(const TiXmlStylesheetReference& /*stylesheet*/) {
165  return true;
166  }
168  virtual bool Visit(const TiXmlText& /*text*/) { return true; }
170  virtual bool Visit(const TiXmlComment& /*comment*/) { return true; }
172  virtual bool Visit(const TiXmlUnknown& /*unknown*/) { return true; }
173 };
174 
175 // Only used by Attribute::Query functions
177 
178 // Used by the parsing routines.
183 };
184 
186 
209 #ifdef TIXML_USE_TICPP
210 #include "ticpprc.h"
211 class TiXmlBase : public TiCppRC
212 #else
213 class TiXmlBase
214 #endif
215 {
216  friend class TiXmlNode;
217  friend class TiXmlElement;
218  friend class TiXmlDocument;
219 
220  public:
222  : userData(0) {}
223  virtual ~TiXmlBase() {}
224 
234  virtual void Print(FILE* cfile, int depth) const = 0;
235 
242  static void SetCondenseWhiteSpace(bool condense) {
243  condenseWhiteSpace = condense;
244  }
245 
247  static bool IsWhiteSpaceCondensed() { return condenseWhiteSpace; }
248 
275  int Row() const { return location.row + 1; }
276  int Column() const { return location.col + 1; }
277 
278  void SetUserData(void* user) {
279  userData = user;
280  }
281  void* GetUserData() {
282  return userData;
283  }
284  const void* GetUserData() const {
285  return userData;
286  }
287 
288  // Table that returs, for a given lead byte, the total number of bytes
289  // in the UTF-8 sequence.
290  static const int utf8ByteTable[256];
291 
292  virtual const char*
293  Parse(const char* p,
294  TiXmlParsingData* data,
295  TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */) = 0;
296 
302  static void EncodeString(const TIXML_STRING& str, TIXML_STRING* out);
303 
304  enum {
322 
324  };
325 
326  protected:
327  static const char* SkipWhiteSpace(const char*, TiXmlEncoding encoding);
328  inline static bool IsWhiteSpace(char c) {
329  return (std::isspace((unsigned char)c) || c == '\n' || c == '\r');
330  }
331  inline static bool IsWhiteSpace(int c) {
332  if (c < 256) return IsWhiteSpace((char)c);
333 
334  return false; // Again, only truly correct for English/Latin...but usually
335  // works.
336  }
337 
338 #ifdef TIXML_USE_STL
339  static bool StreamWhiteSpace(std::istream* in, TIXML_STRING* tag);
340  static bool StreamTo(std::istream* in, int character, TIXML_STRING* tag);
341 #endif
342 
343  /* Reads an XML name into the string provided. Returns
344  a pointer just past the last character of the name,
345  or 0 if the function has an error.
346  */
347  static const char*
348  ReadName(const char* p, TIXML_STRING* name, TiXmlEncoding encoding);
349 
350  /* Reads text. Returns a pointer past the given end tag.
351  Wickedly complex options, but it keeps the (sensitive) code in one place.
352  */
353  static const char*
354  ReadText(const char* in, // where to start
355  TIXML_STRING* text, // the string read
356  bool ignoreWhiteSpace, // whether to keep the white space
357  const char* endTag, // what ends this text
358  bool ignoreCase, // whether to ignore case in the end tag
359  TiXmlEncoding encoding); // the current encoding
360 
361  // If an entity has been found, transform it into a character.
362  static const char*
363  GetEntity(const char* in, char* value, int* length, TiXmlEncoding encoding);
364 
365  // Get a character, while interpreting entities.
366  // The length can be from 0 to 4 bytes.
367  inline static const char*
368  GetChar(const char* p, char* _value, int* length, TiXmlEncoding encoding) {
369  assert(p);
370 
371  if (encoding == TIXML_ENCODING_UTF8) {
372  *length = utf8ByteTable[*((const unsigned char*)p)];
373  assert(*length >= 0 && *length < 5);
374  } else {
375  *length = 1;
376  }
377 
378  if (*length == 1) {
379  if (*p == '&') return GetEntity(p, _value, length, encoding);
380 
381  *_value = *p;
382  return p + 1;
383  } else if (*length) {
384  // strncpy( _value, p, *length ); // lots of compilers don't like this
385  // function (unsafe),
386  // and the null terminator isn't needed
387  for (int i = 0; p[i] && i < *length; ++i) {
388  _value[i] = p[i];
389  }
390 
391  return p + (*length);
392  } else {
393  // Not valid text.
394  return 0;
395  }
396  }
397 
398  // Return true if the next characters in the stream are any of the endTag
399  // sequences.
400  // Ignore case only works for english, and should only be relied on when
401  // comparing
402  // to English words: StringEqual( p, "version", true ) is fine.
403  static bool StringEqual(const char* p,
404  const char* endTag,
405  bool ignoreCase,
406  TiXmlEncoding encoding);
407 
409 
411 
413  void* userData;
414 
415  // None of these methods are reliable for any language except English.
416  // Good for approximation, not great for accuracy.
417  static int IsAlpha(unsigned char anyByte, TiXmlEncoding encoding);
418  static int IsAlphaNum(unsigned char anyByte, TiXmlEncoding encoding);
419  inline static int ToLower(int v, TiXmlEncoding encoding) {
420  if (encoding == TIXML_ENCODING_UTF8) {
421  if (v < 128) return std::tolower(v);
422 
423  return v;
424  } else {
425  return std::tolower(v);
426  }
427  }
428  static void ConvertUTF32ToUTF8(unsigned long input, char* output, int* length);
429 
430  private:
431  TiXmlBase(const TiXmlBase&); // not implemented.
432  void operator=(const TiXmlBase& base); // not allowed.
433 
434  struct Entity {
435  const char* str;
436  unsigned int strLength;
437  char chr;
438  };
439  enum {
440  NUM_ENTITY = 5,
441  MAX_ENTITY_LENGTH = 6
442 
443  };
444  static Entity entity[NUM_ENTITY];
445  static bool condenseWhiteSpace;
446 };
447 
454 class TiXmlNode : public TiXmlBase {
455  friend class TiXmlDocument;
456  friend class TiXmlElement;
457 
458  public:
459 #ifdef TIXML_USE_STL
460 
464  friend std::istream& operator>>(std::istream& in, TiXmlNode& base);
465 
482  friend std::ostream& operator<<(std::ostream& out, const TiXmlNode& base);
483 
485  friend std::string& operator<<(std::string& out, const TiXmlNode& base);
486 
487 #endif
488 
492  enum NodeType {
501  };
502 
503  virtual ~TiXmlNode();
504 
517  const char* Value() const { return value.c_str(); }
518 
519 #ifdef TIXML_USE_STL
520 
524  const std::string& ValueStr() const { return value; }
525 #endif
526 
527  const TIXML_STRING& ValueTStr() const { return value; }
528 
538  void SetValue(const char* _value) { value = _value; }
539 
540 #ifdef TIXML_USE_STL
541  void SetValue(const std::string& _value) { value = _value; }
543 #endif
544 
546  void Clear();
547 
549  TiXmlNode* Parent() { return parent; }
550  const TiXmlNode* Parent() const { return parent; }
551 
552  const TiXmlNode* FirstChild() const {
553  return firstChild;
554  }
556  const TiXmlNode*
557  FirstChild(const char* value) const;
558  TiXmlNode* FirstChild(const char* _value) {
565  // Call through to the const version - safe since nothing is changed.
566  // Exiting
567  // syntax: cast this to a const (always safe)
568  // call the method, cast the return back to non-const.
569  return const_cast< TiXmlNode* >(
570  (const_cast< const TiXmlNode* >(this))->FirstChild(_value));
571  }
572  const TiXmlNode* LastChild() const {
573  return lastChild;
574  }
576 
577  const TiXmlNode* LastChild(const char* value) const;
578  TiXmlNode* LastChild(const char* _value) {
582  return const_cast< TiXmlNode* >(
583  (const_cast< const TiXmlNode* >(this))->LastChild(_value));
584  }
585 
586 #ifdef TIXML_USE_STL
587  const TiXmlNode* FirstChild(const std::string& _value) const {
588  return FirstChild(_value.c_str());
589  }
590  TiXmlNode* FirstChild(const std::string& _value) {
591  return FirstChild(_value.c_str());
592  }
593  const TiXmlNode* LastChild(const std::string& _value) const {
594  return LastChild(_value.c_str());
595  }
596  TiXmlNode* LastChild(const std::string& _value) {
597  return LastChild(_value.c_str());
598  }
599 #endif
600 
617  const TiXmlNode* IterateChildren(const TiXmlNode* previous) const;
618  TiXmlNode* IterateChildren(const TiXmlNode* previous) {
619  return const_cast< TiXmlNode* >(
620  (const_cast< const TiXmlNode* >(this))->IterateChildren(previous));
621  }
622 
625  const TiXmlNode* IterateChildren(const char* value,
626  const TiXmlNode* previous) const;
627  TiXmlNode* IterateChildren(const char* _value, const TiXmlNode* previous) {
628  return const_cast< TiXmlNode* >(
629  (const_cast< const TiXmlNode* >(this))->IterateChildren(_value, previous));
630  }
631 
632 #ifdef TIXML_USE_STL
633  const TiXmlNode* IterateChildren(const std::string& _value,
634  const TiXmlNode* previous) const {
635  return IterateChildren(_value.c_str(), previous);
636  }
637  TiXmlNode* IterateChildren(const std::string& _value,
638  const TiXmlNode* previous) {
639  return IterateChildren(_value.c_str(), previous);
640  }
641 #endif
642 
646  TiXmlNode* InsertEndChild(const TiXmlNode& addThis);
647 
657  TiXmlNode* LinkEndChild(TiXmlNode* addThis);
658 
662  TiXmlNode* InsertBeforeChild(TiXmlNode* beforeThis, const TiXmlNode& addThis);
663 
667  TiXmlNode* InsertAfterChild(TiXmlNode* afterThis, const TiXmlNode& addThis);
668 
672  TiXmlNode* ReplaceChild(TiXmlNode* replaceThis, const TiXmlNode& withThis);
673 
675  bool RemoveChild(TiXmlNode* removeThis);
676 
678  const TiXmlNode* PreviousSibling() const { return prev; }
680 
682  const TiXmlNode* PreviousSibling(const char*) const;
683  TiXmlNode* PreviousSibling(const char* _prev) {
684  return const_cast< TiXmlNode* >(
685  (const_cast< const TiXmlNode* >(this))->PreviousSibling(_prev));
686  }
687 
688 #ifdef TIXML_USE_STL
689  const TiXmlNode* PreviousSibling(const std::string& _value) const {
690  return PreviousSibling(_value.c_str());
691  }
692  TiXmlNode* PreviousSibling(const std::string& _value) {
693  return PreviousSibling(_value.c_str());
694  }
695  const TiXmlNode* NextSibling(const std::string& _value) const {
696  return NextSibling(_value.c_str());
697  }
698  TiXmlNode* NextSibling(const std::string& _value) {
699  return NextSibling(_value.c_str());
700  }
701 #endif
702 
704  const TiXmlNode* NextSibling() const { return next; }
705  TiXmlNode* NextSibling() { return next; }
706 
708  const TiXmlNode* NextSibling(const char*) const;
709  TiXmlNode* NextSibling(const char* _next) {
710  return const_cast< TiXmlNode* >(
711  (const_cast< const TiXmlNode* >(this))->NextSibling(_next));
712  }
713 
718  const TiXmlElement* NextSiblingElement() const;
720  return const_cast< TiXmlElement* >(
721  (const_cast< const TiXmlNode* >(this))->NextSiblingElement());
722  }
723 
728  const TiXmlElement* NextSiblingElement(const char*) const;
729  TiXmlElement* NextSiblingElement(const char* _next) {
730  return const_cast< TiXmlElement* >(
731  (const_cast< const TiXmlNode* >(this))->NextSiblingElement(_next));
732  }
733 
734 #ifdef TIXML_USE_STL
735  const TiXmlElement* NextSiblingElement(const std::string& _value) const {
736  return NextSiblingElement(_value.c_str());
737  }
738  TiXmlElement* NextSiblingElement(const std::string& _value) {
739  return NextSiblingElement(_value.c_str());
740  }
741 #endif
742 
744  const TiXmlElement* FirstChildElement() const;
746  return const_cast< TiXmlElement* >(
747  (const_cast< const TiXmlNode* >(this))->FirstChildElement());
748  }
749 
751  const TiXmlElement* FirstChildElement(const char* _value) const;
752  TiXmlElement* FirstChildElement(const char* _value) {
753  return const_cast< TiXmlElement* >(
754  (const_cast< const TiXmlNode* >(this))->FirstChildElement(_value));
755  }
756 
757 #ifdef TIXML_USE_STL
758  const TiXmlElement* FirstChildElement(const std::string& _value) const {
759  return FirstChildElement(_value.c_str());
760  }
761  TiXmlElement* FirstChildElement(const std::string& _value) {
762  return FirstChildElement(_value.c_str());
763  }
764 #endif
765 
770  int Type() const { return type; }
771 
775  const TiXmlDocument* GetDocument() const;
777  return const_cast< TiXmlDocument* >(
778  (const_cast< const TiXmlNode* >(this))->GetDocument());
779  }
780 
782  bool NoChildren() const { return !firstChild; }
783 
784  virtual const TiXmlDocument* ToDocument() const {
785  return 0;
786  }
787  virtual const TiXmlElement* ToElement() const {
789  return 0;
790  }
791  virtual const TiXmlComment* ToComment() const {
793  return 0;
794  }
795  virtual const TiXmlUnknown* ToUnknown() const {
797  return 0;
798  }
799  virtual const TiXmlText* ToText() const {
801  return 0;
802  }
803  virtual const TiXmlDeclaration* ToDeclaration() const {
805  return 0;
806  }
807  virtual const TiXmlStylesheetReference* ToStylesheetReference() const {
809  return 0;
810  }
811 
814  return 0;
815  }
816  virtual TiXmlElement* ToElement() {
818  return 0;
819  }
820  virtual TiXmlComment* ToComment() {
822  return 0;
823  }
824  virtual TiXmlUnknown* ToUnknown() {
826  return 0;
827  }
828  virtual TiXmlText* ToText() {
830  return 0;
831  }
832  virtual TiXmlDeclaration* ToDeclaration() {
834  return 0;
835  }
838  return 0;
839  }
840 
846  virtual TiXmlNode* Clone() const = 0;
847 
873  virtual bool Accept(TiXmlVisitor* visitor) const = 0;
874 
875  protected:
876  TiXmlNode(NodeType _type);
877 
878  // Copy to the allocated object. Shared functionality between Clone, Copy
879  // constructor,
880  // and the assignment operator.
881  void CopyTo(TiXmlNode* target) const;
882 
883 #ifdef TIXML_USE_STL
884  // The real work of the input operator.
885  virtual void StreamIn(std::istream* in, TIXML_STRING* tag) = 0;
886 #endif
887 
888  // Figure out what is at *p, and parse it. Returns null if it is not an xml
889  // node.
890  TiXmlNode* Identify(const char* start, TiXmlEncoding encoding);
891 
894 
897 
899 
902 
903  private:
904  TiXmlNode(const TiXmlNode&); // not implemented.
905  void operator=(const TiXmlNode& base); // not allowed.
906 };
907 
915 class TiXmlAttribute : public TiXmlBase {
916  friend class TiXmlAttributeSet;
917 
918  public:
921  : TiXmlBase() {
922  document = 0;
923  prev = next = 0;
924  }
925 
926 #ifdef TIXML_USE_STL
927  TiXmlAttribute(const std::string& _name, const std::string& _value) {
929  name = _name;
930  value = _value;
931  document = 0;
932  prev = next = 0;
933  }
934 #endif
935 
937  TiXmlAttribute(const char* _name, const char* _value) {
938  name = _name;
939  value = _value;
940  document = 0;
941  prev = next = 0;
942  }
943 
944  const char* Name() const {
945  return name.c_str();
946  }
947  const char* Value() const {
948  return value.c_str();
949  }
950 #ifdef TIXML_USE_STL
951  const std::string& ValueStr() const {
952  return value;
953  }
954 #endif
955  int IntValue()
956  const;
957  double DoubleValue()
958  const;
959 
960  // Get the tinyxml string representation
961  const TIXML_STRING& NameTStr() const { return name; }
962 
972  int QueryIntValue(int* _value) const;
974  int QueryDoubleValue(double* _value) const;
975 
976  void SetName(const char* _name) {
977  name = _name;
978  }
979  void SetValue(const char* _value) { value = _value; }
980 
981  void SetIntValue(int _value);
982  void SetDoubleValue(double _value);
983 
984 #ifdef TIXML_USE_STL
985  void SetName(const std::string& _name) { name = _name; }
988  void SetValue(const std::string& _value) { value = _value; }
989 #endif
990 
992  const TiXmlAttribute* Next() const;
994  return const_cast< TiXmlAttribute* >(
995  (const_cast< const TiXmlAttribute* >(this))->Next());
996  }
997 
999  const TiXmlAttribute* Previous() const;
1001  return const_cast< TiXmlAttribute* >(
1002  (const_cast< const TiXmlAttribute* >(this))->Previous());
1003  }
1004 
1005  bool operator==(const TiXmlAttribute& rhs) const { return rhs.name == name; }
1006  bool operator<(const TiXmlAttribute& rhs) const { return name < rhs.name; }
1007  bool operator>(const TiXmlAttribute& rhs) const { return name > rhs.name; }
1008 
1009  /* Attribute parsing starts: first letter of the name
1010  returns: the next char after the value end quote
1011  */
1012  virtual const char*
1013  Parse(const char* p, TiXmlParsingData* data, TiXmlEncoding encoding);
1014 
1015  // Prints this Attribute to a FILE stream.
1016  virtual void Print(FILE* cfile, int depth) const { Print(cfile, depth, 0); }
1017  void Print(FILE* cfile, int depth, TIXML_STRING* str) const;
1018 
1019  // [internal use]
1020  // Set the document pointer so the attribute can report errors.
1021  void SetDocument(TiXmlDocument* doc) { document = doc; }
1022 
1023  private:
1024  TiXmlAttribute(const TiXmlAttribute&); // not implemented.
1025  void operator=(const TiXmlAttribute& base); // not allowed.
1026 
1027  TiXmlDocument* document; // A pointer back to a document, for error reporting.
1032 };
1033 
1034 /* A class used to manage a group of attributes.
1035  It is only used internally, both by the ELEMENT and the DECLARATION.
1036 
1037  The set can be changed transparent to the Element and Declaration
1038  classes that use it, but NOT transparent to the Attribute
1039  which has to implement a next() and previous() method. Which makes
1040  it a bit problematic and prevents the use of STL.
1041 
1042  This version is implemented with circular lists because:
1043  - I like circular lists
1044  - it demonstrates some independence from the (typical) doubly linked list.
1045 */
1047  public:
1049  ~TiXmlAttributeSet();
1050 
1051  void Add(TiXmlAttribute* attribute);
1052  void Remove(TiXmlAttribute* attribute);
1053 
1054  const TiXmlAttribute* First() const {
1055  return (sentinel.next == &sentinel) ? 0 : sentinel.next;
1056  }
1058  return (sentinel.next == &sentinel) ? 0 : sentinel.next;
1059  }
1060  const TiXmlAttribute* Last() const {
1061  return (sentinel.prev == &sentinel) ? 0 : sentinel.prev;
1062  }
1064  return (sentinel.prev == &sentinel) ? 0 : sentinel.prev;
1065  }
1066 
1067  const TiXmlAttribute* Find(const char* _name) const;
1068  TiXmlAttribute* Find(const char* _name) {
1069  return const_cast< TiXmlAttribute* >(
1070  (const_cast< const TiXmlAttributeSet* >(this))->Find(_name));
1071  }
1072 #ifdef TIXML_USE_STL
1073  const TiXmlAttribute* Find(const std::string& _name) const;
1074  TiXmlAttribute* Find(const std::string& _name) {
1075  return const_cast< TiXmlAttribute* >(
1076  (const_cast< const TiXmlAttributeSet* >(this))->Find(_name));
1077  }
1078 
1079 #endif
1080 
1081  private:
1082  //*ME: Because of hidden/disabled copy-construktor in TiXmlAttribute
1083  //(sentinel-element),
1084  //*ME: this class must be also use a hidden/disabled copy-constructor !!!
1085  TiXmlAttributeSet(const TiXmlAttributeSet&); // not allowed
1086  void operator=(const TiXmlAttributeSet&); // not allowed (as TiXmlAttribute)
1087 
1089 };
1090 
1095 class TiXmlElement : public TiXmlNode {
1096  public:
1098  TiXmlElement(const char* in_value);
1099 
1100 #ifdef TIXML_USE_STL
1101  TiXmlElement(const std::string& _value);
1103 #endif
1104 
1105  TiXmlElement(const TiXmlElement&);
1106 
1107  void operator=(const TiXmlElement& base);
1108 
1109  virtual ~TiXmlElement();
1110 
1114  const char* Attribute(const char* name) const;
1115 
1122  const char* Attribute(const char* name, int* i) const;
1123 
1130  const char* Attribute(const char* name, double* d) const;
1131 
1139  int QueryIntAttribute(const char* name, int* _value) const;
1141  int QueryDoubleAttribute(const char* name, double* _value) const;
1143  int QueryFloatAttribute(const char* name, float* _value) const {
1144  double d;
1145  int result = QueryDoubleAttribute(name, &d);
1146 
1147  if (result == TIXML_SUCCESS) {
1148  *_value = (float)d;
1149  }
1150 
1151  return result;
1152  }
1153 
1154 #ifdef TIXML_USE_STL
1155 
1163  template < typename T >
1164  int QueryValueAttribute(const std::string& name, T* outValue) const {
1165  const TiXmlAttribute* node = attributeSet.Find(name);
1166 
1167  if (!node) return TIXML_NO_ATTRIBUTE;
1168 
1169  std::stringstream sstream(node->ValueStr());
1170  sstream >> *outValue;
1171 
1172  if (!sstream.fail()) return TIXML_SUCCESS;
1173 
1174  return TIXML_WRONG_TYPE;
1175  }
1176 /*
1177  This is - in theory - a bug fix for "QueryValueAtribute returns truncated
1178 std::string"
1179  but template specialization is hard to get working cross-compiler. Leaving the
1180 bug
1181 for now.
1182 
1183 // The above will fail for std::string because the space character is used as a
1184 seperator.
1185 // Specialize for strings. Bug [ 1695429 ] QueryValueAtribute returns truncated
1186 std::string
1187 template<> int QueryValueAttribute( const std::string& name, std::string*
1188 outValue )
1189 const
1190 {
1191  const TiXmlAttribute* node = attributeSet.Find( name );
1192  if ( !node )
1193  return TIXML_NO_ATTRIBUTE;
1194  *outValue = node->ValueStr();
1195  return TIXML_SUCCESS;
1196 }
1197 */
1198 #endif
1199 
1203  void SetAttribute(const char* name, const char* _value);
1204 
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;
1211 
1213  void SetAttribute(const std::string& name, const std::string& _value);
1215  void SetAttribute(const std::string& name, int _value);
1216 #endif
1217 
1221  void SetAttribute(const char* name, int value);
1222 
1226  void SetDoubleAttribute(const char* name, double value);
1227 
1230  void RemoveAttribute(const char* name);
1231 #ifdef TIXML_USE_STL
1232  void RemoveAttribute(const std::string& name) {
1233  RemoveAttribute(name.c_str());
1234  }
1235 #endif
1236 
1238  return attributeSet.First();
1239  }
1240  TiXmlAttribute* FirstAttribute() { return attributeSet.First(); }
1242  return attributeSet.Last();
1243  }
1244  TiXmlAttribute* LastAttribute() { return attributeSet.Last(); }
1245 
1283  const char* GetText() const;
1284 
1286  virtual TiXmlNode* Clone() const;
1287  // Print the Element to a FILE stream.
1288  virtual void Print(FILE* cfile, int depth) const;
1289 
1290  /* Attribtue parsing starts: next char past '<'
1291  returns: next char past '>'
1292  */
1293  virtual const char*
1294  Parse(const char* p, TiXmlParsingData* data, TiXmlEncoding encoding);
1295 
1296  virtual const TiXmlElement* ToElement() const {
1297  return this;
1298  }
1299  virtual TiXmlElement* ToElement() {
1301  return this;
1302  }
1303 
1307  virtual bool Accept(TiXmlVisitor* visitor) const;
1308 
1309  protected:
1310  void CopyTo(TiXmlElement* target) const;
1311  void ClearThis(); // like clear, but initializes 'this' object as well
1312 
1313 // Used to be public [internal use]
1314 #ifdef TIXML_USE_STL
1315  virtual void StreamIn(std::istream* in, TIXML_STRING* tag);
1316 #endif
1317  /* [internal use]
1318  Reads the "value" of the element -- another element, or text.
1319  This should terminate with the current end tag.
1320  */
1321  const char*
1322  ReadValue(const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding);
1323 
1324  private:
1326 };
1327 
1330 class TiXmlComment : public TiXmlNode {
1331  public:
1334  : TiXmlNode(TiXmlNode::COMMENT) {}
1336  TiXmlComment(const char* _value)
1337  : TiXmlNode(TiXmlNode::COMMENT) {
1338  SetValue(_value);
1339  }
1340  TiXmlComment(const TiXmlComment&);
1341  void operator=(const TiXmlComment& base);
1342 
1343  virtual ~TiXmlComment() {}
1344 
1346  virtual TiXmlNode* Clone() const;
1347  // Write this Comment to a FILE stream.
1348  virtual void Print(FILE* cfile, int depth) const;
1349 
1350  /* Attribtue parsing starts: at the ! of the !--
1351  returns: next char past '>'
1352  */
1353  virtual const char*
1354  Parse(const char* p, TiXmlParsingData* data, TiXmlEncoding encoding);
1355 
1356  virtual const TiXmlComment* ToComment() const {
1357  return this;
1358  }
1359  virtual TiXmlComment* ToComment() {
1361  return this;
1362  }
1363 
1367  virtual bool Accept(TiXmlVisitor* visitor) const;
1368 
1369  protected:
1370  void CopyTo(TiXmlComment* target) const;
1371 
1372 // used to be public
1373 #ifdef TIXML_USE_STL
1374  virtual void StreamIn(std::istream* in, TIXML_STRING* tag);
1375 #endif
1376  // virtual void StreamOut( TIXML_OSTREAM * out ) const;
1377 
1378  private:
1379 };
1380 
1386 class TiXmlText : public TiXmlNode {
1387  friend class TiXmlElement;
1388 
1389  public:
1394  TiXmlText(const char* initValue)
1395  : TiXmlNode(TiXmlNode::TEXT) {
1396  SetValue(initValue);
1397  cdata = false;
1398  }
1399  virtual ~TiXmlText() {}
1400 
1401 #ifdef TIXML_USE_STL
1402  TiXmlText(const std::string& initValue)
1405  SetValue(initValue);
1406  cdata = false;
1407  }
1408 #endif
1409 
1410  TiXmlText(const TiXmlText& copy)
1411  : TiXmlNode(TiXmlNode::TEXT) {
1412  copy.CopyTo(this);
1413  }
1414  void operator=(const TiXmlText& base) { base.CopyTo(this); }
1415 
1416  // Write this text object to a FILE stream.
1417  virtual void Print(FILE* cfile, int depth) const;
1418 
1420  bool CDATA() const { return cdata; }
1422  void SetCDATA(bool _cdata) { cdata = _cdata; }
1423 
1424  virtual const char*
1425  Parse(const char* p, TiXmlParsingData* data, TiXmlEncoding encoding);
1426 
1427  virtual const TiXmlText* ToText() const {
1428  return this;
1429  }
1430  virtual TiXmlText* ToText() {
1432  return this;
1433  }
1434 
1438  virtual bool Accept(TiXmlVisitor* content) const;
1439 
1440  protected:
1442  virtual TiXmlNode* Clone() const;
1443  void CopyTo(TiXmlText* target) const;
1444 
1445  bool Blank() const; // returns true if all white space and new lines
1446  // [internal use]
1447 #ifdef TIXML_USE_STL
1448  virtual void StreamIn(std::istream* in, TIXML_STRING* tag);
1449 #endif
1450 
1451  private:
1452  bool cdata; // true if this should be input and output as a CDATA style text
1453  // element
1454 };
1455 
1469 class TiXmlDeclaration : public TiXmlNode {
1470  public:
1473  : TiXmlNode(TiXmlNode::DECLARATION) {}
1474 
1475 #ifdef TIXML_USE_STL
1476  TiXmlDeclaration(const std::string& _version,
1478  const std::string& _encoding,
1479  const std::string& _standalone);
1480 #endif
1481 
1483  TiXmlDeclaration(const char* _version,
1484  const char* _encoding,
1485  const char* _standalone);
1486 
1487  TiXmlDeclaration(const TiXmlDeclaration& copy);
1488  void operator=(const TiXmlDeclaration& copy);
1489 
1490  virtual ~TiXmlDeclaration() {}
1491 
1493  const char* Version() const { return version.c_str(); }
1495  const char* Encoding() const { return encoding.c_str(); }
1497  const char* Standalone() const { return standalone.c_str(); }
1498 
1500  virtual TiXmlNode* Clone() const;
1501  // Print this declaration to a FILE stream.
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); }
1504 
1505  virtual const char*
1506  Parse(const char* p, TiXmlParsingData* data, TiXmlEncoding encoding);
1507 
1508  virtual const TiXmlDeclaration* ToDeclaration() const {
1509  return this;
1510  }
1511  virtual TiXmlDeclaration* ToDeclaration() {
1513  return this;
1514  }
1515 
1519  virtual bool Accept(TiXmlVisitor* visitor) const;
1520 
1521  protected:
1522  void CopyTo(TiXmlDeclaration* target) const;
1523 // used to be public
1524 #ifdef TIXML_USE_STL
1525  virtual void StreamIn(std::istream* in, TIXML_STRING* tag);
1526 #endif
1527 
1528  private:
1532 };
1533 
1544  public:
1547  : TiXmlNode(TiXmlNode::STYLESHEETREFERENCE) {}
1548 
1549 #ifdef TIXML_USE_STL
1550  TiXmlStylesheetReference(const std::string& _type, const std::string& _href);
1552 #endif
1553 
1555  TiXmlStylesheetReference(const char* _type, const char* _href);
1556 
1558  void operator=(const TiXmlStylesheetReference& copy);
1559 
1561 
1563  const char* Type() const { return type.c_str(); }
1565  const char* Href() const { return href.c_str(); }
1566 
1568  virtual TiXmlNode* Clone() const;
1569  // Print this declaration to a FILE stream.
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); }
1572 
1573  virtual const char*
1574  Parse(const char* p, TiXmlParsingData* data, TiXmlEncoding encoding);
1575 
1577  return this;
1578  }
1579  virtual TiXmlStylesheetReference* ToStylesheetReference() {
1581  return this;
1582  }
1583 
1587  virtual bool Accept(TiXmlVisitor* visitor) const;
1588 
1589  protected:
1590  void CopyTo(TiXmlStylesheetReference* target) const;
1591 // used to be public
1592 #ifdef TIXML_USE_STL
1593  virtual void StreamIn(std::istream* in, TIXML_STRING* tag);
1594 #endif
1595 
1596  private:
1599 };
1600 
1608 class TiXmlUnknown : public TiXmlNode {
1609  public:
1611  : TiXmlNode(TiXmlNode::UNKNOWN) {}
1612  virtual ~TiXmlUnknown() {}
1613 
1615  : TiXmlNode(TiXmlNode::UNKNOWN) {
1616  copy.CopyTo(this);
1617  }
1618  void operator=(const TiXmlUnknown& copy) { copy.CopyTo(this); }
1619 
1621  virtual TiXmlNode* Clone() const;
1622  // Print this Unknown to a FILE stream.
1623  virtual void Print(FILE* cfile, int depth) const;
1624 
1625  virtual const char*
1626  Parse(const char* p, TiXmlParsingData* data, TiXmlEncoding encoding);
1627 
1628  virtual const TiXmlUnknown* ToUnknown() const {
1629  return this;
1630  }
1631  virtual TiXmlUnknown* ToUnknown() {
1633  return this;
1634  }
1635 
1639  virtual bool Accept(TiXmlVisitor* content) const;
1640 
1641  protected:
1642  void CopyTo(TiXmlUnknown* target) const;
1643 
1644 #ifdef TIXML_USE_STL
1645  virtual void StreamIn(std::istream* in, TIXML_STRING* tag);
1646 #endif
1647 
1648  private:
1649 };
1650 
1655 class TiXmlDocument : public TiXmlNode {
1656  public:
1658  TiXmlDocument();
1662  TiXmlDocument(const char* documentName);
1663 
1664 #ifdef TIXML_USE_STL
1665  TiXmlDocument(const std::string& documentName);
1667 #endif
1668 
1669  TiXmlDocument(const TiXmlDocument& copy);
1670  void operator=(const TiXmlDocument& copy);
1671 
1672  virtual ~TiXmlDocument() {}
1673 
1678  bool LoadFile(TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING);
1680  bool SaveFile() const;
1682  bool LoadFile(const char* filename,
1685  bool SaveFile(const char* filename) const;
1694  bool LoadFile(FILE*, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING);
1696  bool SaveFile(FILE*) const;
1697 
1698 #ifdef TIXML_USE_STL
1699  bool LoadFile(const std::string& filename,
1700  TiXmlEncoding encoding =
1702  // StringToBuffer f( filename );
1703  // return ( f.buffer && LoadFile( f.buffer, encoding ));
1704  return LoadFile(filename.c_str(), encoding);
1705  }
1706  bool SaveFile(const std::string& filename) const {
1707  // StringToBuffer f( filename );
1708  // return ( f.buffer && SaveFile( f.buffer ));
1709  return SaveFile(filename.c_str());
1710  }
1711 #endif
1712 
1721  virtual const char* Parse(const char* p,
1722  TiXmlParsingData* data = 0,
1724 
1729  const TiXmlElement* RootElement() const { return FirstChildElement(); }
1730  TiXmlElement* RootElement() { return FirstChildElement(); }
1731 
1740  bool Error() const { return error; }
1741 
1743  const char* ErrorDesc() const { return errorDesc.c_str(); }
1744 
1748  int ErrorId() const { return errorId; }
1749 
1761  int ErrorRow() const { return errorLocation.row + 1; }
1762  int ErrorCol() const {
1763  return errorLocation.col + 1;
1764  }
1765 
1792  void SetTabSize(int _tabsize) { tabsize = _tabsize; }
1793 
1794  int TabSize() const { return tabsize; }
1795 
1799  void ClearError() {
1800  error = false;
1801  errorId = 0;
1802  errorDesc = "";
1803  errorLocation.row = errorLocation.col = 0;
1804  // errorLocation.last = 0;
1805  }
1806 
1810  void Print() const { Print(stdout, 0); }
1811 
1812  /* Write the document to a string using formatted printing ("pretty print").
1813  This
1814  will allocate a character array (new char[]) and return it as a pointer. The
1815  calling code pust call delete[] on the return char* to avoid a memory leak.
1816  */
1817  // char* PrintToMemory() const;
1818 
1820  virtual void Print(FILE* cfile, int depth = 0) const;
1821  // [internal use]
1822  void SetError(int err,
1823  const char* errorLocation,
1824  TiXmlParsingData* prevData,
1825  TiXmlEncoding encoding);
1826 
1827  virtual const TiXmlDocument* ToDocument() const {
1828  return this;
1829  }
1830  virtual TiXmlDocument* ToDocument() {
1832  return this;
1833  }
1834 
1838  virtual bool Accept(TiXmlVisitor* content) const;
1839 
1840  protected:
1841  // [internal use]
1842  virtual TiXmlNode* Clone() const;
1843 #ifdef TIXML_USE_STL
1844  virtual void StreamIn(std::istream* in, TIXML_STRING* tag);
1845 #endif
1846 
1847  private:
1848  void CopyTo(TiXmlDocument* target) const;
1849 
1850  bool error;
1851  int errorId;
1853  int tabsize;
1855  bool useMicrosoftBOM; // the UTF-8 BOM were found when read. Note this, and
1856  // try to
1857  // write.
1858 };
1859 
1952  public:
1956  TiXmlHandle(TiXmlNode* _node) { this->node = _node; }
1958  TiXmlHandle(const TiXmlHandle& ref) { this->node = ref.node; }
1960  this->node = ref.node;
1961  return *this;
1962  }
1963 
1965  TiXmlHandle FirstChild() const;
1967  TiXmlHandle FirstChild(const char* value) const;
1969  TiXmlHandle FirstChildElement() const;
1971  TiXmlHandle FirstChildElement(const char* value) const;
1972 
1976  TiXmlHandle Child(const char* value, int index) const;
1980  TiXmlHandle Child(int index) const;
1986  TiXmlHandle ChildElement(const char* value, int index) const;
1992  TiXmlHandle ChildElement(int index) const;
1993 
1994 #ifdef TIXML_USE_STL
1995  TiXmlHandle FirstChild(const std::string& _value) const {
1996  return FirstChild(_value.c_str());
1997  }
1998  TiXmlHandle FirstChildElement(const std::string& _value) const {
1999  return FirstChildElement(_value.c_str());
2000  }
2001 
2002  TiXmlHandle Child(const std::string& _value, int index) const {
2003  return Child(_value.c_str(), index);
2004  }
2005  TiXmlHandle ChildElement(const std::string& _value, int index) const {
2006  return ChildElement(_value.c_str(), index);
2007  }
2008 #endif
2009 
2012  TiXmlNode* ToNode() const { return node; }
2016  return ((node && node->ToElement()) ? node->ToElement() : 0);
2017  }
2020  TiXmlText* ToText() const {
2021  return ((node && node->ToText()) ? node->ToText() : 0);
2022  }
2026  return ((node && node->ToUnknown()) ? node->ToUnknown() : 0);
2027  }
2028 
2032  TiXmlNode* Node() const { return ToNode(); }
2036  TiXmlElement* Element() const { return ToElement(); }
2040  TiXmlText* Text() const { return ToText(); }
2044  TiXmlUnknown* Unknown() const { return ToUnknown(); }
2045 
2046  private:
2048 };
2049 
2070 class TiXmlPrinter : public TiXmlVisitor {
2071  public:
2073  : depth(0)
2074  , simpleTextPrint(false)
2075  , buffer()
2076  , indent(" ")
2077  , lineBreak("\n") {}
2078 
2079  virtual bool VisitEnter(const TiXmlDocument& doc);
2080  virtual bool VisitExit(const TiXmlDocument& doc);
2081 
2082  virtual bool VisitEnter(const TiXmlElement& element,
2083  const TiXmlAttribute* firstAttribute);
2084  virtual bool VisitExit(const TiXmlElement& element);
2085 
2086  virtual bool Visit(const TiXmlDeclaration& declaration);
2087  virtual bool Visit(const TiXmlText& text);
2088  virtual bool Visit(const TiXmlComment& comment);
2089  virtual bool Visit(const TiXmlUnknown& unknown);
2090  virtual bool Visit(const TiXmlStylesheetReference& stylesheet);
2091 
2095  void SetIndent(const char* _indent) { indent = _indent ? _indent : ""; }
2097  const char* Indent() { return indent.c_str(); }
2102  void SetLineBreak(const char* _lineBreak) {
2103  lineBreak = _lineBreak ? _lineBreak : "";
2104  }
2106  const char* LineBreak() { return lineBreak.c_str(); }
2107 
2113  indent = "";
2114  lineBreak = "";
2115  }
2117  const char* CStr() { return buffer.c_str(); }
2119  size_t Size() { return buffer.size(); }
2120 
2121 #ifdef TIXML_USE_STL
2122  const std::string& Str() { return buffer; }
2124 #endif
2125 
2126  private:
2127  void DoIndent() {
2128  for (int i = 0; i < depth; ++i)
2129  buffer += indent;
2130  }
2131  void DoLineBreak() { buffer += lineBreak; }
2132 
2133  int depth;
2138 };
2139 
2140 #ifdef _MSC_VER
2141 #pragma warning(pop)
2142 #endif
2143 
2144 #endif
TIXML_STRING standalone
Definition: tinyxml.h:1531
virtual ~TiXmlVisitor()
Definition: tinyxml.h:146
static const int utf8ByteTable[256]
Definition: tinyxml.h:290
TiXmlAttribute sentinel
Definition: tinyxml.h:1088
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
int ErrorCol() const
The column where the error occured. See ErrorRow()
Definition: tinyxml.h:1762
TIXML_STRING errorDesc
Definition: tinyxml.h:1852
void DoLineBreak()
Definition: tinyxml.h:2131
An attribute is a name-value pair.
Definition: tinyxml.h:915
TiXmlHandle(TiXmlNode *_node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
Definition: tinyxml.h:1956
TiXmlNode * FirstChild(const std::string &_value)
STL std::string form.
Definition: tinyxml.h:590
void SetUserData(void *user)
Set a pointer to arbitrary user data.
Definition: tinyxml.h:278
If you call the Accept() method, it requires being passed a TiXmlVisitor class to handle callbacks...
Definition: tinyxml.h:144
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1296
TiXmlUnknown(const TiXmlUnknown &copy)
Definition: tinyxml.h:1614
TiXmlComment()
Constructs an empty comment.
Definition: tinyxml.h:1333
virtual ~TiXmlStylesheetReference()
Definition: tinyxml.h:1560
const char * Type() const
Type. Will return an empty string if none was found.
Definition: tinyxml.h:1563
void SetLineBreak(const char *_lineBreak)
Set the line breaking string.
Definition: tinyxml.h:2102
TiXmlElement * NextSiblingElement()
Definition: tinyxml.h:719
TiXmlHandle(const TiXmlHandle &ref)
Copy constructor.
Definition: tinyxml.h:1958
TiXmlNode * PreviousSibling(const char *_prev)
Definition: tinyxml.h:683
TiXmlNode * LastChild()
The last child of this node. Will be null if there are no children.
Definition: tinyxml.h:575
const char * LineBreak()
Query the current line breaking string.
Definition: tinyxml.h:2106
const TiXmlNode * LastChild() const
Definition: tinyxml.h:572
virtual bool Visit(const TiXmlUnknown &)
Visit an unknow node.
Definition: tinyxml.h:172
bool operator==(const TiXmlAttribute &rhs) const
Definition: tinyxml.h:1005
TIXML_STRING version
Definition: tinyxml.h:1529
TiXmlAttribute(const char *_name, const char *_value)
Construct an attribute with a name and value.
Definition: tinyxml.h:937
virtual const TiXmlDocument * ToDocument() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1827
const char * Name() const
Return the name of this attribute.
Definition: tinyxml.h:944
TiXmlNode * prev
Definition: tinyxml.h:900
const char * ErrorDesc() const
Contains a textual (english) description of the error if one occurs.
Definition: tinyxml.h:1743
bool operator<(const TiXmlAttribute &rhs) const
Definition: tinyxml.h:1006
void Print() const
Write the document to standard out using formatted printing ("pretty print").
Definition: tinyxml.h:1810
static int ToLower(int v, TiXmlEncoding encoding)
Definition: tinyxml.h:419
TiXmlNode * IterateChildren(const std::string &_value, const TiXmlNode *previous)
STL std::string form.
Definition: tinyxml.h:637
TiXmlElement * Element() const
Definition: tinyxml.h:2036
TiXmlNode * IterateChildren(const char *_value, const TiXmlNode *previous)
Definition: tinyxml.h:627
TiXmlNode * firstChild
Definition: tinyxml.h:895
static int IsAlphaNum(unsigned char anyByte, TiXmlEncoding encoding)
const TiXmlNode * IterateChildren(const std::string &_value, const TiXmlNode *previous) const
STL std::string form.
Definition: tinyxml.h:633
void operator=(const TiXmlUnknown &copy)
Definition: tinyxml.h:1618
TiXmlHandle FirstChildElement(const std::string &_value) const
Definition: tinyxml.h:1998
TIXML_STRING lineBreak
Definition: tinyxml.h:2137
TIXML_STRING name
Definition: tinyxml.h:1028
TiXmlDocument * document
Definition: tinyxml.h:1027
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:800
TiXmlElement * NextSiblingElement(const std::string &_value)
STL std::string form.
Definition: tinyxml.h:738
TiXmlAttribute * FirstAttribute()
Definition: tinyxml.h:1240
bool Error() const
If an error occurs, Error will be set to true.
Definition: tinyxml.h:1740
int Column() const
See Row()
Definition: tinyxml.h:276
void operator=(const TiXmlAttributeSet &)
TiXmlElement * FirstChildElement(const char *_value)
Definition: tinyxml.h:752
void operator=(const TiXmlDocument &copy)
Definition: tinyxml.cpp:799
void SetValue(const std::string &_value)
STL std::string form.
Definition: tinyxml.h:988
TiXmlAttribute * Next()
Definition: tinyxml.h:993
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.
Definition: tinyxml.cpp:265
const std::string & ValueStr() const
Return Value() as a std::string.
Definition: tinyxml.h:524
virtual bool VisitExit(const TiXmlElement &)
Visit an element.
Definition: tinyxml.h:159
bool CDATA() const
Queries whether this represents text using a CDATA section.
Definition: tinyxml.h:1420
void SetName(const char *_name)
Set the name of this attribute.
Definition: tinyxml.h:976
TiXmlNode * NextSibling()
Definition: tinyxml.h:705
void SetTabSize(int _tabsize)
SetTabSize() allows the error reporting functions (ErrorRow() and ErrorCol()) to report the correct v...
Definition: tinyxml.h:1792
void DoIndent()
Definition: tinyxml.h:2127
TiXmlAttribute()
Construct an empty attribute.
Definition: tinyxml.h:920
TIXML_STRING buffer
Definition: tinyxml.h:2135
const int TIXML_PATCH_VERSION
Definition: tinyxml.h:107
const char * Standalone() const
Is this a standalone document?
Definition: tinyxml.h:1497
void CopyTo(TiXmlElement *target) const
Definition: tinyxml.cpp:716
TiXmlElement * NextSiblingElement(const char *_next)
Definition: tinyxml.h:729
virtual ~TiXmlText()
Definition: tinyxml.h:1399
const TIXML_STRING & NameTStr() const
Definition: tinyxml.h:961
TiXmlElement * FirstChildElement()
Definition: tinyxml.h:745
virtual TiXmlDocument * ToDocument()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:813
void ClearError()
If you have handled the error, it can be reset with this call.
Definition: tinyxml.h:1799
void Clear()
Definition: tinyxml.h:114
void CopyTo(TiXmlUnknown *target) const
Definition: tinyxml.cpp:1400
const TiXmlElement * NextSiblingElement(const std::string &_value) const
STL std::string form.
Definition: tinyxml.h:735
virtual ~TiXmlComment()
Definition: tinyxml.h:1343
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 ...
Definition: tinyxml.h:1016
const char * Href() const
Href. Will return an empty string if none was found.
Definition: tinyxml.h:1565
static const char * errorString[TIXML_ERROR_STRING_COUNT]
Definition: tinyxml.h:408
void SetValue(const char *_value)
Changes the value of the node.
Definition: tinyxml.h:538
TiXmlNode * InsertEndChild(const TiXmlNode &addThis)
Add a new node related to this.
Definition: tinyxml.cpp:181
static void ConvertUTF32ToUTF8(unsigned long input, char *output, int *length)
TiXmlNode * ToNode() const
Return the handle as a TiXmlNode.
Definition: tinyxml.h:2012
const TIXML_STRING & ValueTStr() const
Definition: tinyxml.h:527
TiXmlNode * InsertBeforeChild(TiXmlNode *beforeThis, const TiXmlNode &addThis)
Add a new node related to this.
Definition: tinyxml.cpp:197
static bool condenseWhiteSpace
Definition: tinyxml.h:445
const std::string & ValueStr() const
Return the value of this attribute.
Definition: tinyxml.h:951
virtual ~TiXmlDocument()
Definition: tinyxml.h:1672
TiXmlNode * PreviousSibling()
Definition: tinyxml.h:679
NodeType
The types of XML nodes supported by TinyXml.
Definition: tinyxml.h:492
TiXmlAttribute * Find(const char *_name)
Definition: tinyxml.h:1068
virtual bool VisitEnter(const TiXmlDocument &)
Visit a document.
Definition: tinyxml.h:149
TiXmlNode * LinkEndChild(TiXmlNode *addThis)
Add a new node related to this.
Definition: tinyxml.cpp:153
const TiXmlElement * RootElement() const
Get the root element – the only top level element – of the document.
Definition: tinyxml.h:1729
const TiXmlElement * FirstChildElement() const
Convenience function to get through elements.
Definition: tinyxml.cpp:384
const TiXmlNode * PreviousSibling(const std::string &_value) const
STL std::string form.
Definition: tinyxml.h:689
const char * Encoding() const
Encoding. Will return an empty string if none was found.
Definition: tinyxml.h:1495
void * userData
Field containing a generic user pointer.
Definition: tinyxml.h:413
A stylesheet reference looks like this:
Definition: tinyxml.h:1543
TiXmlAttribute * prev
Definition: tinyxml.h:1030
TiXmlDocument * GetDocument()
Definition: tinyxml.h:776
const char * str
Definition: tinyxml.h:435
In correct XML the declaration is the first entry in the file.
Definition: tinyxml.h:1469
bool cdata
Definition: tinyxml.h:1452
const TiXmlNode * PreviousSibling() const
Navigate to a sibling node.
Definition: tinyxml.h:678
virtual const TiXmlDocument * ToDocument() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:784
const char * Value() const
Return the value of this attribute.
Definition: tinyxml.h:947
static bool IsWhiteSpace(char c)
Definition: tinyxml.h:328
std::istream & operator>>(std::istream &in, TiXmlNode &base)
Definition: tinyxml.cpp:1505
TiXmlCursor()
Definition: tinyxml.h:113
TiXmlAttributeSet attributeSet
Definition: tinyxml.h:1325
Any tag that tinyXml doesn&#39;t recognize is saved as an unknown.
Definition: tinyxml.h:1608
virtual bool Visit(const TiXmlText &)
Visit a text node.
Definition: tinyxml.h:168
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1427
const TiXmlEncoding TIXML_DEFAULT_ENCODING
Definition: tinyxml.h:185
virtual const TiXmlComment * ToComment() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:792
TiXmlNode * NextSibling(const char *_next)
Definition: tinyxml.h:709
TiXmlNode * FirstChild()
Definition: tinyxml.h:555
TiXmlStylesheetReference()
Construct an empty declaration.
Definition: tinyxml.h:1546
const char * Version() const
Version. Will return an empty string if none was found.
Definition: tinyxml.h:1493
TiXmlAttribute * next
Definition: tinyxml.h:1031
static bool IsWhiteSpaceCondensed()
Return the current white space setting.
Definition: tinyxml.h:247
TiXmlText(const TiXmlText &copy)
Definition: tinyxml.h:1410
static const char * ReadText(const char *in, TIXML_STRING *text, bool ignoreWhiteSpace, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
TiXmlCursor location
Definition: tinyxml.h:410
const char * Value() const
The meaning of &#39;value&#39; changes for the specific type of TiXmlNode.
Definition: tinyxml.h:517
const int TIXML_MAJOR_VERSION
Definition: tinyxml.h:105
const TiXmlNode * LastChild(const std::string &_value) const
STL std::string form.
Definition: tinyxml.h:593
void SetIndent(const char *_indent)
Set the indent characters for printing.
Definition: tinyxml.h:2095
virtual ~TiXmlUnknown()
Definition: tinyxml.h:1612
const TiXmlAttribute * LastAttribute() const
Access the last attribute in this element.
Definition: tinyxml.h:1241
std::ostream & operator<<(std::ostream &output, const BayesNet< GUM_SCALAR > &bn)
Prints map&#39;s DAG in output using the Graphviz-dot format.
Definition: BayesNet_tpl.h:605
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...
Definition: tinyxml.h:1164
void CopyTo(TiXmlText *target) const
Definition: tinyxml.cpp:1204
bool LoadFile(const std::string &filename, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
Definition: tinyxml.h:1699
TiXmlAttribute * Last()
Definition: tinyxml.h:1063
void SetCDATA(bool _cdata)
Turns on or off a CDATA representation of text.
Definition: tinyxml.h:1422
const char * Indent()
Query the indention string.
Definition: tinyxml.h:2097
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 ...
Definition: tinyxml.cpp:666
virtual bool Visit(const TiXmlStylesheetReference &)
Visit a stylesheet reference.
Definition: tinyxml.h:164
TiXmlElement * FirstChildElement(const std::string &_value)
STL std::string form.
Definition: tinyxml.h:761
const TiXmlElement * NextSiblingElement() const
Convenience function to get through elements.
Definition: tinyxml.cpp:404
Always the top level node.
Definition: tinyxml.h:1655
const TiXmlAttribute * Last() const
Definition: tinyxml.h:1060
TiXmlEncoding
Definition: tinyxml.h:179
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 ...
Definition: tinyxml.h:1571
TiXmlElement * ToElement() const
Return the handle as a TiXmlElement.
Definition: tinyxml.h:2015
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.
Definition: tinyxml.cpp:231
int ErrorRow() const
Returns the location (if known) of the error.
Definition: tinyxml.h:1761
TiXmlUnknown * Unknown() const
Definition: tinyxml.h:2044
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.
Definition: tinyxml.h:275
TiXmlNode * node
Definition: tinyxml.h:2047
A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly useful thi...
Definition: tinyxml.h:1951
static bool IsWhiteSpace(int c)
Definition: tinyxml.h:331
TIXML_STRING value
Definition: tinyxml.h:1029
const TiXmlDocument * GetDocument() const
Return a pointer to the Document this node lives in.
Definition: tinyxml.cpp:424
TiXmlUnknown * ToUnknown() const
Return the handle as a TiXmlUnknown.
Definition: tinyxml.h:2025
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.
Definition: tinyxml.h:242
bool operator>(const TiXmlAttribute &rhs) const
Definition: tinyxml.h:1007
TiXmlBase is a base class for every class in TinyXml.
Definition: tinyxml.h:211
TiXmlNode * Parent()
One step up the DOM.
Definition: tinyxml.h:549
int Type() const
Query the type (as an enumerated value, above) of this node.
Definition: tinyxml.h:770
virtual const TiXmlUnknown * ToUnknown() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1628
TiXmlComment(const char *_value)
Construct a comment from text.
Definition: tinyxml.h:1336
virtual ~TiXmlBase()
Definition: tinyxml.h:223
static bool StringEqual(const char *p, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
const void * GetUserData() const
Get a pointer to arbitrary user data.
Definition: tinyxml.h:284
const TiXmlNode * FirstChild() const
The first child of this node. Will be null if there are no children.
Definition: tinyxml.h:552
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)
Definition: tinyxml.cpp:454
virtual TiXmlNode * Clone() const
Creates a new Element and returns it - the returned element is a copy.
Definition: tinyxml.cpp:746
TiXmlHandle operator=(const TiXmlHandle &ref)
Definition: tinyxml.h:1959
TiXmlNode * parent
Definition: tinyxml.h:892
TiXmlNode * IterateChildren(const TiXmlNode *previous)
Definition: tinyxml.h:618
virtual const TiXmlDeclaration * ToDeclaration() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:804
Base class for reference counting functionality.
Definition: ticpprc.h:41
TiXmlAttribute * Previous()
Definition: tinyxml.h:1000
TIXML_STRING indent
Definition: tinyxml.h:2136
TiXmlNode(NodeType _type)
Definition: tinyxml.cpp:113
TiXmlElement * RootElement()
Definition: tinyxml.h:1730
static void EncodeString(const TIXML_STRING &str, TIXML_STRING *out)
Expands entities in a string.
Definition: tinyxml.cpp:50
TiXmlHandle ChildElement(const std::string &_value, int index) const
Definition: tinyxml.h:2005
void * GetUserData()
Get a pointer to arbitrary user data.
Definition: tinyxml.h:281
The parent class for everything in the Document Object Model.
Definition: tinyxml.h:454
const TiXmlAttribute * First() const
Definition: tinyxml.h:1054
TiXmlNode * LastChild(const std::string &_value)
STL std::string form.
Definition: tinyxml.h:596
size_t Size()
Return the length of the result string.
Definition: tinyxml.h:2119
Print to memory functionality.
Definition: tinyxml.h:2070
TiXmlNode * PreviousSibling(const std::string &_value)
STL std::string form.
Definition: tinyxml.h:692
TiXmlHandle Child(const std::string &_value, int index) const
Definition: tinyxml.h:2002
XML text.
Definition: tinyxml.h:1386
bool NoChildren() const
Returns true if this node has no children.
Definition: tinyxml.h:782
TiXmlNode * Node() const
Definition: tinyxml.h:2032
virtual const TiXmlUnknown * ToUnknown() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:796
TiXmlNode * next
Definition: tinyxml.h:901
int TabSize() const
Definition: tinyxml.h:1794
virtual bool VisitExit(const TiXmlDocument &)
Visit a document.
Definition: tinyxml.h:151
virtual const TiXmlComment * ToComment() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1356
virtual bool Visit(const TiXmlComment &)
Visit a comment node.
Definition: tinyxml.h:170
static const char * GetChar(const char *p, char *_value, int *length, TiXmlEncoding encoding)
Definition: tinyxml.h:368
void operator=(const TiXmlText &base)
Definition: tinyxml.h:1414
TiXmlText(const char *initValue)
Constructor for text element.
Definition: tinyxml.h:1394
bool useMicrosoftBOM
Definition: tinyxml.h:1855
virtual const TiXmlStylesheetReference * ToStylesheetReference() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:808
virtual const TiXmlDeclaration * ToDeclaration() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1508
TiXmlNode * NextSibling(const std::string &_value)
STL std::string form.
Definition: tinyxml.h:698
virtual const TiXmlStylesheetReference * ToStylesheetReference() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1576
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 ...
Definition: tinyxml.h:1503
const TiXmlElement * FirstChildElement(const std::string &_value) const
STL std::string form.
Definition: tinyxml.h:758
bool SaveFile(const std::string &filename) const
Definition: tinyxml.h:1706
unsigned int strLength
Definition: tinyxml.h:436
int QueryFloatAttribute(const char *name, float *_value) const
QueryFloatAttribute examines the attribute - see QueryIntAttribute().
Definition: tinyxml.h:1143
NodeType type
Definition: tinyxml.h:893
const TiXmlNode * Parent() const
Definition: tinyxml.h:550
bool RemoveChild(TiXmlNode *removeThis)
Delete a child of this node.
Definition: tinyxml.cpp:291
TIXML_STRING value
Definition: tinyxml.h:898
void RemoveAttribute(const std::string &name)
STL std::string form.
Definition: tinyxml.h:1232
An XML comment.
Definition: tinyxml.h:1330
void SetDocument(TiXmlDocument *doc)
Definition: tinyxml.h:1021
void SetValue(const char *_value)
Set the value.
Definition: tinyxml.h:979
virtual ~TiXmlDeclaration()
Definition: tinyxml.h:1490
const TiXmlNode * IterateChildren(const TiXmlNode *previous) const
An alternate way to walk the children of a node.
Definition: tinyxml.cpp:331
virtual bool Accept(TiXmlVisitor *visitor) const
Walk the XML tree visiting this node and all of its children.
Definition: tinyxml.cpp:736
TiXmlAttribute * LastAttribute()
Definition: tinyxml.h:1244
TiXmlNode * lastChild
Definition: tinyxml.h:896
TiXmlDeclaration()
Construct an empty declaration.
Definition: tinyxml.h:1472
void SetStreamPrinting()
Switch over to "stream printing" which is the most dense formatting without linebreaks.
Definition: tinyxml.h:2112
static int IsAlpha(unsigned char anyByte, TiXmlEncoding encoding)
TiXmlAttribute * First()
Definition: tinyxml.h:1057
const TiXmlNode * FirstChild(const std::string &_value) const
STL std::string form.
Definition: tinyxml.h:587
TiXmlHandle FirstChild(const std::string &_value) const
Definition: tinyxml.h:1995
virtual ~TiXmlNode()
Definition: tinyxml.cpp:123
const TiXmlNode * NextSibling() const
Navigate to a sibling node.
Definition: tinyxml.h:704
TiXmlText * ToText() const
Return the handle as a TiXmlText.
Definition: tinyxml.h:2020
static bool StreamWhiteSpace(std::istream *in, TIXML_STRING *tag)
const char * CStr()
Return the result.
Definition: tinyxml.h:2117
const TiXmlNode * NextSibling(const std::string &_value) const
STL std::string form.
Definition: tinyxml.h:695
#define TIXML_STRING
Definition: tinyxml.h:60
const int TIXML_MINOR_VERSION
Definition: tinyxml.h:106
int ErrorId() const
Generally, you probably want the error string ( ErrorDesc() ).
Definition: tinyxml.h:1748
TiXmlText * Text() const
Definition: tinyxml.h:2040
The element is a container class.
Definition: tinyxml.h:1095
bool simpleTextPrint
Definition: tinyxml.h:2134
TiXmlCursor errorLocation
Definition: tinyxml.h:1854
virtual bool VisitEnter(const TiXmlElement &, const TiXmlAttribute *)
Visit an element.
Definition: tinyxml.h:154
TIXML_STRING encoding
Definition: tinyxml.h:1530
TiXmlBase()
Definition: tinyxml.h:221
virtual bool Visit(const TiXmlDeclaration &)
Visit a declaration.
Definition: tinyxml.h:162
const TiXmlAttribute * FirstAttribute() const
Access the first attribute in this element.
Definition: tinyxml.h:1237
TiXmlAttribute * Find(const std::string &_name)
Definition: tinyxml.h:1074