Changeset 5817 in orxonox.OLD for branches/world_entities/src/lib/tinyxml/tinyxml.h
- Timestamp:
- Nov 29, 2005, 10:52:08 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/world_entities/src/lib/tinyxml/tinyxml.h
r4491 r5817 28 28 29 29 #ifdef _MSC_VER 30 #pragma warning( push ) 30 31 #pragma warning( disable : 4530 ) 31 32 #pragma warning( disable : 4786 ) … … 62 63 #endif 63 64 65 // Deprecated library function hell. Compilers want to use the 66 // new safe versions. This probably doesn't fully address the problem, 67 // but it gets closer. There are too many compilers for me to fully 68 // test. If you get compilation troubles, undefine TIXML_SAFE 69 70 #define TIXML_SAFE // TinyXml isn't fully buffer overrun protected, safe code. This is work in progress. 71 #ifdef TIXML_SAFE 72 #if defined(_MSC_VER) && (_MSC_VER >= 1200 ) 73 // Microsoft visual studio, version 6 and higher. 74 //#pragma message( "Using _sn* functions." ) 75 #define TIXML_SNPRINTF _snprintf 76 #define TIXML_SNSCANF _snscanf 77 #elif defined(__GNUC__) && (__GNUC__ >= 3 ) 78 // GCC version 3 and higher.s 79 //#warning( "Using sn* functions." ) 80 #define TIXML_SNPRINTF snprintf 81 #define TIXML_SNSCANF snscanf 82 #endif 83 #endif 84 64 85 class TiXmlDocument; 65 86 class TiXmlElement; … … 72 93 73 94 const int TIXML_MAJOR_VERSION = 2; 74 const int TIXML_MINOR_VERSION = 3;75 const int TIXML_PATCH_VERSION = 4;95 const int TIXML_MINOR_VERSION = 4; 96 const int TIXML_PATCH_VERSION = 2; 76 97 77 98 /* Internal structure for tracking location of items … … 206 227 TIXML_ERROR_DOCUMENT_EMPTY, 207 228 TIXML_ERROR_EMBEDDED_NULL, 229 TIXML_ERROR_PARSING_CDATA, 208 230 209 231 TIXML_ERROR_STRING_COUNT … … 278 300 else if ( *length ) 279 301 { 280 strncpy( _value, p, *length ); 302 //strncpy( _value, p, *length ); // lots of compilers don't like this function (unsafe), 303 // and the null terminator isn't needed 304 for( int i=0; p[i] && i<*length; ++i ) { 305 _value[i] = p[i]; 306 } 281 307 return p + (*length); 282 308 } … … 296 322 // Return true if the next characters in the stream are any of the endTag sequences. 297 323 // Ignore case only works for english, and should only be relied on when comparing 298 // to Eng ilish words: StringEqual( p, "version", true ) is fine.324 // to English words: StringEqual( p, "version", true ) is fine. 299 325 static bool StringEqual( const char* p, 300 326 const char* endTag, … … 421 447 The subclasses will wrap this function. 422 448 */ 423 const char * Value() const { return value.c_str (); } 449 const char *Value() const { return value.c_str (); } 450 451 #ifdef TIXML_USE_STL 452 /** Return Value() as a std::string. If you only use STL, 453 this is more efficient than calling Value(). 454 Only available in STL mode. 455 */ 456 const std::string& ValueStr() const { return value; } 457 #endif 424 458 425 459 /** Changes the value of the node. Defined as: … … 589 623 UNKNOWN, TEXT, and DECLARATION. 590 624 */ 591 virtualint Type() const { return type; }625 int Type() const { return type; } 592 626 593 627 /** Return a pointer to the Document this node lives in. … … 633 667 // Figure out what is at *p, and parse it. Returns null if it is not an xml node. 634 668 TiXmlNode* Identify( const char* start, TiXmlEncoding encoding ); 635 636 // Internal Value function returning a TIXML_STRING637 const TIXML_STRING& SValue() const { return value ; }638 669 639 670 TiXmlNode* parent; … … 695 726 const char* Name() const { return name.c_str (); } ///< Return the name of this attribute. 696 727 const char* Value() const { return value.c_str (); } ///< Return the value of this attribute. 697 const intIntValue() const; ///< Return the value of this attribute, converted to an integer.698 const doubleDoubleValue() const; ///< Return the value of this attribute, converted to a double.728 int IntValue() const; ///< Return the value of this attribute, converted to an integer. 729 double DoubleValue() const; ///< Return the value of this attribute, converted to a double. 699 730 700 731 /** QueryIntValue examines the value string. It is an alternative to the … … 707 738 which is the opposite of almost all other TinyXml calls. 708 739 */ 709 int QueryIntValue( int* value ) const;740 int QueryIntValue( int* _value ) const; 710 741 /// QueryDoubleValue examines the value string. See QueryIntValue(). 711 int QueryDoubleValue( double* value ) const;742 int QueryDoubleValue( double* _value ) const; 712 743 713 744 void SetName( const char* _name ) { name = _name; } ///< Set the name of this attribute. 714 745 void SetValue( const char* _value ) { value = _value; } ///< Set the value. 715 746 716 void SetIntValue( int value ); ///< Set the value from an integer.717 void SetDoubleValue( double value ); ///< Set the value from a double.747 void SetIntValue( int _value ); ///< Set the value from an integer. 748 void SetDoubleValue( double _value ); ///< Set the value from a double. 718 749 719 750 #ifdef TIXML_USE_STL … … 856 887 does not exist, then TIXML_NO_ATTRIBUTE is returned. 857 888 */ 858 int QueryIntAttribute( const char* name, int* value ) const;889 int QueryIntAttribute( const char* name, int* _value ) const; 859 890 /// QueryDoubleAttribute examines the attribute - see QueryIntAttribute(). 860 int QueryDoubleAttribute( const char* name, double* value ) const;891 int QueryDoubleAttribute( const char* name, double* _value ) const; 861 892 /// QueryFloatAttribute examines the attribute - see QueryIntAttribute(). 862 int Query DoubleAttribute( const char* name, float*value ) const {893 int QueryFloatAttribute( const char* name, float* _value ) const { 863 894 double d; 864 895 int result = QueryDoubleAttribute( name, &d ); 865 *value = (float)d; 896 if ( result == TIXML_SUCCESS ) { 897 *_value = (float)d; 898 } 866 899 return result; 867 900 } … … 870 903 will be created if it does not exist, or changed if it does. 871 904 */ 872 void SetAttribute( const char* name, const char * value );905 void SetAttribute( const char* name, const char * _value ); 873 906 874 907 #ifdef TIXML_USE_STL … … 876 909 const char* Attribute( const std::string& name, int* i ) const { return Attribute( name.c_str(), i ); } 877 910 const char* Attribute( const std::string& name, double* d ) const { return Attribute( name.c_str(), d ); } 878 int QueryIntAttribute( const std::string& name, int* value ) const { return QueryIntAttribute( name.c_str(),value ); }879 int QueryDoubleAttribute( const std::string& name, double* value ) const { return QueryDoubleAttribute( name.c_str(),value ); }911 int QueryIntAttribute( const std::string& name, int* _value ) const { return QueryIntAttribute( name.c_str(), _value ); } 912 int QueryDoubleAttribute( const std::string& name, double* _value ) const { return QueryDoubleAttribute( name.c_str(), _value ); } 880 913 881 914 /// STL std::string form. … … 918 951 TiXmlAttribute* LastAttribute() { return attributeSet.Last(); } 919 952 953 /** Convenience function for easy access to the text inside an element. Although easy 954 and concise, GetText() is limited compared to getting the TiXmlText child 955 and accessing it directly. 956 957 If the first child of 'this' is a TiXmlText, the GetText() 958 returns the character string of the Text node, else null is returned. 959 960 This is a convenient method for getting the text of simple contained text: 961 @verbatim 962 <foo>This is text</foo> 963 const char* str = fooElement->GetText(); 964 @endverbatim 965 966 'str' will be a pointer to "This is text". 967 968 Note that this function can be misleading. If the element foo was created from 969 this XML: 970 @verbatim 971 <foo><b>This is text</b></foo> 972 @endverbatim 973 974 then the value of str would be null. The first child node isn't a text node, it is 975 another element. From this XML: 976 @verbatim 977 <foo>This is <b>text</b></foo> 978 @endverbatim 979 GetText() will return "This is ". 980 981 WARNING: GetText() accesses a child node - don't become confused with the 982 similarly named TiXmlHandle::Text() and TiXmlNode::ToText() which are 983 safe type casts on the referenced node. 984 */ 985 const char* GetText() const; 986 920 987 /// Creates a new Element and returns it - the returned element is a copy. 921 988 virtual TiXmlNode* Clone() const; … … 987 1054 988 1055 989 /** XML text. Contained in an element. 1056 /** XML text. A text node can have 2 ways to output the next. "normal" output 1057 and CDATA. It will default to the mode it was parsed from the XML file and 1058 you generally want to leave it alone, but you can change the output mode with 1059 SetCDATA() and query it with CDATA(). 990 1060 */ 991 1061 class TiXmlText : public TiXmlNode … … 993 1063 friend class TiXmlElement; 994 1064 public: 995 /// Constructor. 996 TiXmlText (const char * initValue) : TiXmlNode (TiXmlNode::TEXT) 1065 /** Constructor for text element. By default, it is treated as 1066 normal, encoded text. If you want it be output as a CDATA text 1067 element, set the parameter _cdata to 'true' 1068 */ 1069 TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TEXT) 997 1070 { 998 1071 SetValue( initValue ); 1072 cdata = false; 999 1073 } 1000 1074 virtual ~TiXmlText() {} … … 1005 1079 { 1006 1080 SetValue( initValue ); 1081 cdata = false; 1007 1082 } 1008 1083 #endif … … 1013 1088 /// Write this text object to a FILE stream. 1014 1089 virtual void Print( FILE* cfile, int depth ) const; 1090 1091 /// Queries whether this represents text using a CDATA section. 1092 bool CDATA() { return cdata; } 1093 /// Turns on or off a CDATA representation of text. 1094 void SetCDATA( bool _cdata ) { cdata = _cdata; } 1015 1095 1016 1096 virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); … … 1029 1109 1030 1110 private: 1111 bool cdata; // true if this should be input and output as a CDATA style text element 1031 1112 }; 1032 1113 … … 1207 1288 prefer the ErrorId, this function will fetch it. 1208 1289 */ 1209 constint ErrorId() const { return errorId; }1290 int ErrorId() const { return errorId; } 1210 1291 1211 1292 /** Returns the location (if known) of the error. The first column is column 1, … … 1219 1300 int ErrorCol() { return errorLocation.col+1; } ///< The column where the error occured. See ErrorRow() 1220 1301 1221 /** By calling this method, with a tab size 1302 /** SetTabSize() allows the error reporting functions (ErrorRow() and ErrorCol()) 1303 to report the correct values for row and column. It does not change the output 1304 or input in any way. 1305 1306 By calling this method, with a tab size 1222 1307 greater than 0, the row and column of each node and attribute is stored 1223 1308 when the file is loaded. Very useful for tracking the DOM back in to … … 1277 1362 int tabsize; 1278 1363 TiXmlCursor errorLocation; 1364 bool useMicrosoftBOM; // the UTF-8 BOM were found when read. Note this, and try to write. 1279 1365 }; 1280 1366 … … 1364 1450 public: 1365 1451 /// Create a handle from any node (at any depth of the tree.) This can be a null pointer. 1366 TiXmlHandle( TiXmlNode* node ) { this->node =node; }1452 TiXmlHandle( TiXmlNode* _node ) { this->node = _node; } 1367 1453 /// Copy constructor 1368 1454 TiXmlHandle( const TiXmlHandle& ref ) { this->node = ref.node; } … … 1419 1505 1420 1506 #ifdef _MSC_VER 1421 #pragma warning( default : 4530 ) 1422 #pragma warning( default : 4786 ) 1507 #pragma warning( pop ) 1423 1508 #endif 1424 1509
Note: See TracChangeset
for help on using the changeset viewer.