Changeset 4491 in orxonox.OLD for orxonox/trunk
- Timestamp:
- Jun 3, 2005, 1:40:28 AM (19 years ago)
- Location:
- orxonox/trunk/src/lib/tinyxml
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/tinyxml/tinystr.cc
r4261 r4491 37 37 TiXmlString::TiXmlString (const char* instring) 38 38 { 39 unsignednewlen;39 size_t newlen; 40 40 char * newstring; 41 41 … … 47 47 return; 48 48 } 49 //*ME: warning C4267: convert 'size_t' to 'unsigned int' 50 //*ME: Use Cast: (unsigned) 51 newlen = (unsigned)strlen (instring) + 1; 49 newlen = strlen (instring) + 1; 52 50 newstring = new char [newlen]; 53 51 memcpy (newstring, instring, newlen); … … 61 59 TiXmlString::TiXmlString (const TiXmlString& copy) 62 60 { 63 unsignednewlen;61 size_t newlen; 64 62 char * newstring; 65 63 … … 87 85 void TiXmlString ::operator = (const char * content) 88 86 { 89 unsignednewlen;87 size_t newlen; 90 88 char * newstring; 91 89 … … 95 93 return; 96 94 } 97 newlen = (unsigned)strlen (content) + 1;95 newlen = strlen (content) + 1; 98 96 newstring = new char [newlen]; 99 97 // strcpy (newstring, content); … … 108 106 void TiXmlString ::operator = (const TiXmlString & copy) 109 107 { 110 unsignednewlen;108 size_t newlen; 111 109 char * newstring; 112 110 … … 128 126 129 127 // append a const char * to an existing TiXmlString 130 void TiXmlString::append( const char* str, int len )128 void TiXmlString::append( const char* str, size_t len ) 131 129 { 132 130 char * new_string; 133 unsignednew_alloc, new_size, size_suffix;131 size_t new_alloc, new_size, size_suffix; 134 132 135 133 // don't use strlen - it can overrun the len passed in! … … 192 190 { 193 191 char * new_string; 194 unsignednew_alloc, new_size;192 size_t new_alloc, new_size; 195 193 196 194 new_size = length () + strlen (suffix) + 1; … … 252 250 unsigned TiXmlString::find (char tofind, unsigned offset) const 253 251 { 254 //*ME: warning C4244: convert '__w64 int' to 'unsigned' 255 //*ME: Use Array-Arithmetic instead of Pointer 256 // char * lookup; 252 char * lookup; 257 253 258 254 if (offset >= length ()) 259 255 return (unsigned) notfound; 260 // for (lookup = cstring + offset; * lookup; lookup++) 261 // if (* lookup == tofind) 262 // return lookup - cstring; 263 for( unsigned n=offset ; cstring[n] != '\0' ; n++ ) 264 if( cstring[n] == tofind ) 265 return n ; 256 for (lookup = cstring + offset; * lookup; lookup++) 257 if (* lookup == tofind) 258 return (unsigned)(lookup - cstring); 266 259 return (unsigned) notfound; 267 260 } … … 276 269 return ( strcmp( cstring, compare.cstring ) == 0 ); 277 270 } 271 else if ( length() == 0 && compare.length() == 0 ) 272 { 273 return true; 274 } 278 275 return false; 276 } 277 278 279 bool TiXmlString::operator == (const char* compare) const 280 { 281 if ( allocated && compare && *compare ) 282 { 283 assert( cstring ); 284 return ( strcmp( cstring, compare ) == 0 ); 285 } 286 else if ( length() == 0 && (!compare || !*compare ) ) // this is a little dubious, but try to duplicate behavior in other operator== 287 { 288 return true; 289 } 290 return false; 279 291 } 280 292 -
orxonox/trunk/src/lib/tinyxml/tinystr.h
r4261 r4491 32 32 33 33 #ifdef _MSC_VER 34 #pragma warning( disable : 4786 ) // Debugger truncating names. 34 #pragma warning( disable : 4530 ) 35 #pragma warning( disable : 4786 ) 35 36 #endif 36 37 … … 47 48 { 48 49 public : 49 // TiXmlString constructor, based on a string 50 TiXmlString (const char * instring); 50 // TiXmlString constructor, based on a string, mark explicit to force 51 // us to find unnecessary casting. 52 explicit TiXmlString (const char * instring); 51 53 52 54 // TiXmlString empty constructor … … 59 61 60 62 // TiXmlString copy constructor 61 TiXmlString (const TiXmlString& copy);63 explicit TiXmlString (const TiXmlString& copy); 62 64 63 65 // TiXmlString destructor … … 76 78 77 79 // Return the length of a TiXmlString 78 unsignedlength () const80 size_t length () const 79 81 { 80 82 return ( allocated ) ? current_length : 0; … … 108 110 } 109 111 bool operator == (const TiXmlString & compare) const; 112 bool operator == (const char* compare) const; 110 113 bool operator < (const TiXmlString & compare) const; 111 114 bool operator > (const TiXmlString & compare) const; … … 159 162 npos = notfound }; 160 163 161 void append (const char *str, int len );164 void append (const char *str, size_t len ); 162 165 163 166 protected : … … 166 169 char * cstring; 167 170 // Number of chars allocated 168 unsignedallocated;171 size_t allocated; 169 172 // Current string size 170 unsignedcurrent_length;173 size_t current_length; 171 174 172 175 // New size computation. It is simplistic right now : it returns twice the amount 173 176 // we need 174 unsigned assign_new_size (unsignedminimum_to_allocate)177 size_t assign_new_size (size_t minimum_to_allocate) 175 178 { 176 179 return minimum_to_allocate * 2; … … 239 242 } ; 240 243 244 #ifdef _MSC_VER 245 #pragma warning( default : 4530 ) 246 #pragma warning( default : 4786 ) 247 #endif 248 241 249 #endif // TIXML_STRING_INCLUDED 242 250 #endif // TIXML_USE_STL -
orxonox/trunk/src/lib/tinyxml/tinyxml.cc
r4261 r4491 319 319 for ( node = firstChild; node; node = node->next ) 320 320 { 321 if ( node->SValue() == TIXML_STRING( _value ))321 if ( node->SValue() == _value ) 322 322 return node; 323 323 } … … 331 331 for ( node = firstChild; node; node = node->next ) 332 332 { 333 if ( node->SValue() == TIXML_STRING( _value ))333 if ( node->SValue() == _value ) 334 334 return node; 335 335 } … … 343 343 for ( node = lastChild; node; node = node->prev ) 344 344 { 345 if ( node->SValue() == TIXML_STRING (_value))345 if ( node->SValue() == _value ) 346 346 return node; 347 347 } … … 354 354 for ( node = lastChild; node; node = node->prev ) 355 355 { 356 if ( node->SValue() == TIXML_STRING (_value))356 if ( node->SValue() == _value ) 357 357 return node; 358 358 } … … 360 360 } 361 361 362 const TiXmlNode* TiXmlNode::IterateChildren( TiXmlNode* previous ) const362 const TiXmlNode* TiXmlNode::IterateChildren( const TiXmlNode* previous ) const 363 363 { 364 364 if ( !previous ) … … 386 386 } 387 387 388 const TiXmlNode* TiXmlNode::IterateChildren( const char * val, TiXmlNode* previous ) const388 const TiXmlNode* TiXmlNode::IterateChildren( const char * val, const TiXmlNode* previous ) const 389 389 { 390 390 if ( !previous ) … … 417 417 for ( node = next; node; node = node->next ) 418 418 { 419 if ( node->SValue() == TIXML_STRING (_value))419 if ( node->SValue() == _value ) 420 420 return node; 421 421 } … … 428 428 for ( node = next; node; node = node->next ) 429 429 { 430 if ( node->SValue() == TIXML_STRING (_value))430 if ( node->SValue() == _value ) 431 431 return node; 432 432 } … … 439 439 for ( node = prev; node; node = node->prev ) 440 440 { 441 if ( node->SValue() == TIXML_STRING (_value))441 if ( node->SValue() == _value ) 442 442 return node; 443 443 } … … 450 450 for ( node = prev; node; node = node->prev ) 451 451 { 452 if ( node->SValue() == TIXML_STRING (_value))452 if ( node->SValue() == _value ) 453 453 return node; 454 454 } … … 723 723 void TiXmlElement::SetDoubleAttribute( const char * name, double val ) 724 724 { 725 char buf[ 128];725 char buf[256]; 726 726 sprintf( buf, "%f", val ); 727 727 SetAttribute( name, buf ); … … 1141 1141 void TiXmlAttribute::SetDoubleValue( double _value ) 1142 1142 { 1143 char buf [ 64];1143 char buf [256]; 1144 1144 sprintf (buf, "%lf", _value); 1145 1145 SetValue (buf); … … 1413 1413 } 1414 1414 1415 const TiXmlAttribute* 1415 const TiXmlAttribute* TiXmlAttributeSet::Find( const char * name ) const 1416 1416 { 1417 1417 const TiXmlAttribute* node; -
orxonox/trunk/src/lib/tinyxml/tinyxml.h
r4261 r4491 73 73 const int TIXML_MAJOR_VERSION = 2; 74 74 const int TIXML_MINOR_VERSION = 3; 75 const int TIXML_PATCH_VERSION = 3;75 const int TIXML_PATCH_VERSION = 4; 76 76 77 77 /* Internal structure for tracking location of items … … 483 483 first. IterateChildren will return null when done. 484 484 */ 485 const TiXmlNode* IterateChildren( TiXmlNode* previous ) const;485 const TiXmlNode* IterateChildren( const TiXmlNode* previous ) const; 486 486 TiXmlNode* IterateChildren( TiXmlNode* previous ); 487 487 488 488 /// This flavor of IterateChildren searches for children with a particular 'value' 489 const TiXmlNode* IterateChildren( const char * value, TiXmlNode* previous ) const;489 const TiXmlNode* IterateChildren( const char * value, const TiXmlNode* previous ) const; 490 490 TiXmlNode* IterateChildren( const char * value, TiXmlNode* previous ); 491 491 492 492 #ifdef TIXML_USE_STL 493 const TiXmlNode* IterateChildren( const std::string& _value, TiXmlNode* previous ) const { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form.493 const TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) const { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form. 494 494 TiXmlNode* IterateChildren( const std::string& _value, TiXmlNode* previous ) { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form. 495 495 #endif … … 1418 1418 }; 1419 1419 1420 1420 #ifdef _MSC_VER 1421 #pragma warning( default : 4530 ) 1422 #pragma warning( default : 4786 ) 1421 1423 #endif 1422 1424 1425 #endif 1426 -
orxonox/trunk/src/lib/tinyxml/tinyxmlparser.cc
r4261 r4491 25 25 #include "tinyxml.h" 26 26 #include <ctype.h> 27 #include <stddef.h> 27 28 28 29 //#define DEBUG_PARSER … … 50 51 // ef bf bf 51 52 52 const char TIXML_UTF_LEAD_0 = (const char)0xef;53 const char TIXML_UTF_LEAD_1 = (const char)0xbb;54 const char TIXML_UTF_LEAD_2 = (const char)0xbf;53 const unsigned char TIXML_UTF_LEAD_0 = 0xefU; 54 const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; 55 const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; 55 56 56 57 const int TiXmlBase::utf8ByteTable[256] = … … 117 118 118 119 119 /*static*/ int TiXmlBase::IsAlpha( unsigned char anyByte, TiXmlEncoding )120 /*static*/ int TiXmlBase::IsAlpha( unsigned char anyByte, TiXmlEncoding /*encoding*/ ) 120 121 { 121 122 // This will only work for low-ascii, everything else is assumed to be a valid … … 138 139 139 140 140 /*static*/ int TiXmlBase::IsAlphaNum( unsigned char anyByte, TiXmlEncoding )141 /*static*/ int TiXmlBase::IsAlphaNum( unsigned char anyByte, TiXmlEncoding /*encoding*/ ) 141 142 { 142 143 // This will only work for low-ascii, everything else is assumed to be a valid … … 202 203 while ( p < now ) 203 204 { 205 // Treat p as unsigned, so we have a happy compiler. 206 const unsigned char* pU = (const unsigned char*)p; 207 204 208 // Code contributed by Fletcher Dunn: (modified by lee) 205 switch (*p ) {209 switch (*pU) { 206 210 case 0: 207 211 // We *should* never get here, but in case we do, don't … … 253 257 // In these cases, don't advance the column. These are 254 258 // 0-width spaces. 255 if ( *(p +1)==TIXML_UTF_LEAD_1 && *(p+2)==TIXML_UTF_LEAD_2 )259 if ( *(pU+1)==TIXML_UTF_LEAD_1 && *(pU+2)==TIXML_UTF_LEAD_2 ) 256 260 p += 3; 257 else if ( *(p +1)==(char)(0xbf) && *(p+2)==(char)(0xbe))261 else if ( *(pU+1)==0xbfU && *(pU+2)==0xbeU ) 258 262 p += 3; 259 else if ( *(p +1)==(char)(0xbf) && *(p+2)==(char)(0xbf))263 else if ( *(pU+1)==0xbfU && *(pU+2)==0xbfU ) 260 264 p += 3; 261 265 else … … 309 313 while ( *p ) 310 314 { 315 const unsigned char* pU = (const unsigned char*)p; 316 311 317 // Skip the stupid Microsoft UTF-8 Byte order marks 312 if ( *(p +0)==TIXML_UTF_LEAD_0313 && *(p +1)==TIXML_UTF_LEAD_1314 && *(p +2)==TIXML_UTF_LEAD_2 )318 if ( *(pU+0)==TIXML_UTF_LEAD_0 319 && *(pU+1)==TIXML_UTF_LEAD_1 320 && *(pU+2)==TIXML_UTF_LEAD_2 ) 315 321 { 316 322 p += 3; 317 323 continue; 318 324 } 319 else if(*(p +0)==TIXML_UTF_LEAD_0320 && *(p +1)==(const char) 0xbf321 && *(p +2)==(const char) 0xbe)325 else if(*(pU+0)==TIXML_UTF_LEAD_0 326 && *(pU+1)==0xbfU 327 && *(pU+2)==0xbeU ) 322 328 { 323 329 p += 3; 324 330 continue; 325 331 } 326 else if(*(p +0)==TIXML_UTF_LEAD_0327 && *(p +1)==(const char) 0xbf328 && *(p +2)==(const char) 0xbf)332 else if(*(pU+0)==TIXML_UTF_LEAD_0 333 && *(pU+1)==0xbfU 334 && *(pU+2)==0xbfU ) 329 335 { 330 336 p += 3; … … 421 427 { 422 428 unsigned long ucs = 0; 423 //*ME: warning C4244: convert '__w64 int' to 'unsigned' 424 //*ME: Use size_t instead of unsigned (pointer-arithmetic) 425 size_t delta = 0; 429 ptrdiff_t delta = 0; 426 430 unsigned mult = 1; 427 431 … … 708 712 { 709 713 // Check for the Microsoft UTF-8 lead bytes. 710 if ( *(p+0) && *(p+0) == TIXML_UTF_LEAD_0 711 && *(p+1) && *(p+1) == TIXML_UTF_LEAD_1 712 && *(p+2) && *(p+2) == TIXML_UTF_LEAD_2 ) 714 const unsigned char* pU = (const unsigned char*)p; 715 if ( *(pU+0) && *(pU+0) == TIXML_UTF_LEAD_0 716 && *(pU+1) && *(pU+1) == TIXML_UTF_LEAD_1 717 && *(pU+2) && *(pU+2) == TIXML_UTF_LEAD_2 ) 713 718 { 714 719 encoding = TIXML_ENCODING_UTF8;
Note: See TracChangeset
for help on using the changeset viewer.