| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
#ifndef TINYXML_INCLUDED |
| 27 |
#define TINYXML_INCLUDED |
| 28 |
|
| 29 |
#ifdef _MSC_VER |
| 30 |
#pragma warning( push ) |
| 31 |
#pragma warning( disable : 4530 ) |
| 32 |
#pragma warning( disable : 4786 ) |
| 33 |
#endif |
| 34 |
|
| 35 |
#include <cctype> |
| 36 |
#include <cstdio> |
| 37 |
#include <cstdlib> |
| 38 |
#include <cassert> |
| 39 |
|
| 40 |
|
| 41 |
#if defined( _DEBUG ) && !defined( DEBUG ) |
| 42 |
#define DEBUG |
| 43 |
#endif |
| 44 |
|
| 45 |
#define TIXML_USE_STL |
| 46 |
|
| 47 |
#ifdef TIXML_USE_STL |
| 48 |
#include <string> |
| 49 |
#include <iostream> |
| 50 |
#include <sstream> |
| 51 |
#define TIXML_STRING std::string |
| 52 |
#else |
| 53 |
#include "tinystr.h" |
| 54 |
#define TIXML_STRING TiXmlString |
| 55 |
#endif |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
#define TIXML_SAFE |
| 62 |
|
| 63 |
#ifdef TIXML_SAFE |
| 64 |
#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) |
| 65 |
|
| 66 |
#define TIXML_SNPRINTF _snprintf_s |
| 67 |
#define TIXML_SNSCANF _snscanf_s |
| 68 |
#elif defined(_MSC_VER) && (_MSC_VER >= 1200 ) |
| 69 |
|
| 70 |
|
| 71 |
#define TIXML_SNPRINTF _snprintf |
| 72 |
#define TIXML_SNSCANF _snscanf |
| 73 |
#elif defined(__GNUC__) && (__GNUC__ >= 3 ) |
| 74 |
|
| 75 |
|
| 76 |
#define TIXML_SNPRINTF snprintf |
| 77 |
#define TIXML_SNSCANF snscanf |
| 78 |
#endif |
| 79 |
#endif |
| 80 |
|
| 81 |
class TiXmlDocument; |
| 82 |
class TiXmlElement; |
| 83 |
class TiXmlComment; |
| 84 |
class TiXmlUnknown; |
| 85 |
class TiXmlAttribute; |
| 86 |
class TiXmlText; |
| 87 |
class TiXmlDeclaration; |
| 88 |
class TiXmlParsingData; |
| 89 |
|
| 90 |
const int TIXML_MAJOR_VERSION = 2; |
| 91 |
const int TIXML_MINOR_VERSION = 5; |
| 92 |
const int TIXML_PATCH_VERSION = 2; |
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
struct TiXmlCursor |
| 98 |
{ |
| 99 |
TiXmlCursor() { Clear(); } |
| 100 |
void Clear() { row = col = -1; } |
| 101 |
|
| 102 |
int row; |
| 103 |
int col; |
| 104 |
}; |
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
class TiXmlVisitor |
| 126 |
{ |
| 127 |
public: |
| 128 |
virtual ~TiXmlVisitor() {} |
| 129 |
|
| 130 |
|
| 131 |
virtual bool VisitEnter( const TiXmlDocument& doc ) { return true; } |
| 132 |
|
| 133 |
virtual bool VisitExit( const TiXmlDocument& doc ) { return true; } |
| 134 |
|
| 135 |
|
| 136 |
virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ) { return true; } |
| 137 |
|
| 138 |
virtual bool VisitExit( const TiXmlElement& element ) { return true; } |
| 139 |
|
| 140 |
|
| 141 |
virtual bool Visit( const TiXmlDeclaration& declaration ) { return true; } |
| 142 |
|
| 143 |
virtual bool Visit( const TiXmlText& text ) { return true; } |
| 144 |
|
| 145 |
virtual bool Visit( const TiXmlComment& comment ) { return true; } |
| 146 |
|
| 147 |
virtual bool Visit( const TiXmlUnknown& unknown ) { return true; } |
| 148 |
}; |
| 149 |
|
| 150 |
|
| 151 |
enum |
| 152 |
{ |
| 153 |
TIXML_SUCCESS, |
| 154 |
TIXML_NO_ATTRIBUTE, |
| 155 |
TIXML_WRONG_TYPE |
| 156 |
}; |
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
enum TiXmlEncoding |
| 161 |
{ |
| 162 |
TIXML_ENCODING_UNKNOWN, |
| 163 |
TIXML_ENCODING_UTF8, |
| 164 |
TIXML_ENCODING_LEGACY |
| 165 |
}; |
| 166 |
|
| 167 |
const TiXmlEncoding TIXML_DEFAULT_ENCODING = TIXML_ENCODING_UNKNOWN; |
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
class TiXmlBase |
| 192 |
{ |
| 193 |
friend class TiXmlNode; |
| 194 |
friend class TiXmlElement; |
| 195 |
friend class TiXmlDocument; |
| 196 |
|
| 197 |
public: |
| 198 |
TiXmlBase() : userData(0) {} |
| 199 |
virtual ~TiXmlBase() {} |
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
virtual void Print( FILE* cfile, int depth ) const = 0; |
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
static void SetCondenseWhiteSpace( bool condense ) { condenseWhiteSpace = condense; } |
| 219 |
|
| 220 |
|
| 221 |
static bool IsWhiteSpaceCondensed() { return condenseWhiteSpace; } |
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
int Row() const { return location.row + 1; } |
| 242 |
int Column() const { return location.col + 1; } |
| 243 |
|
| 244 |
void SetUserData( void* user ) { userData = user; } |
| 245 |
void* GetUserData() { return userData; } |
| 246 |
const void* GetUserData() const { return userData; } |
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
static const int utf8ByteTable[256]; |
| 251 |
|
| 252 |
virtual const char* Parse( const char* p, |
| 253 |
TiXmlParsingData* data, |
| 254 |
TiXmlEncoding encoding ) = 0; |
| 255 |
|
| 256 |
enum |
| 257 |
{ |
| 258 |
TIXML_NO_ERROR = 0, |
| 259 |
TIXML_ERROR, |
| 260 |
TIXML_ERROR_OPENING_FILE, |
| 261 |
TIXML_ERROR_OUT_OF_MEMORY, |
| 262 |
TIXML_ERROR_PARSING_ELEMENT, |
| 263 |
TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, |
| 264 |
TIXML_ERROR_READING_ELEMENT_VALUE, |
| 265 |
TIXML_ERROR_READING_ATTRIBUTES, |
| 266 |
TIXML_ERROR_PARSING_EMPTY, |
| 267 |
TIXML_ERROR_READING_END_TAG, |
| 268 |
TIXML_ERROR_PARSING_UNKNOWN, |
| 269 |
TIXML_ERROR_PARSING_COMMENT, |
| 270 |
TIXML_ERROR_PARSING_DECLARATION, |
| 271 |
TIXML_ERROR_DOCUMENT_EMPTY, |
| 272 |
TIXML_ERROR_EMBEDDED_NULL, |
| 273 |
TIXML_ERROR_PARSING_CDATA, |
| 274 |
TIXML_ERROR_DOCUMENT_TOP_ONLY, |
| 275 |
|
| 276 |
TIXML_ERROR_STRING_COUNT |
| 277 |
}; |
| 278 |
|
| 279 |
protected: |
| 280 |
|
| 281 |
static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding ); |
| 282 |
inline static bool IsWhiteSpace( char c ) |
| 283 |
{ |
| 284 |
return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' ); |
| 285 |
} |
| 286 |
inline static bool IsWhiteSpace( int c ) |
| 287 |
{ |
| 288 |
if ( c < 256 ) |
| 289 |
return IsWhiteSpace( (char) c ); |
| 290 |
return false; |
| 291 |
} |
| 292 |
|
| 293 |
#ifdef TIXML_USE_STL |
| 294 |
static bool StreamWhiteSpace( std::istream * in, TIXML_STRING * tag ); |
| 295 |
static bool StreamTo( std::istream * in, int character, TIXML_STRING * tag ); |
| 296 |
#endif |
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
static const char* ReadName( const char* p, TIXML_STRING* name, TiXmlEncoding encoding ); |
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
static const char* ReadText( const char* in, |
| 308 |
TIXML_STRING* text, |
| 309 |
bool ignoreWhiteSpace, |
| 310 |
const char* endTag, |
| 311 |
bool ignoreCase, |
| 312 |
TiXmlEncoding encoding ); |
| 313 |
|
| 314 |
|
| 315 |
static const char* GetEntity( const char* in, char* value, int* length, TiXmlEncoding encoding ); |
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
inline static const char* GetChar( const char* p, char* _value, int* length, TiXmlEncoding encoding ) |
| 320 |
{ |
| 321 |
assert( p ); |
| 322 |
if ( encoding == TIXML_ENCODING_UTF8 ) |
| 323 |
{ |
| 324 |
*length = utf8ByteTable[ *((const unsigned char*)p) ]; |
| 325 |
assert( *length >= 0 && *length < 5 ); |
| 326 |
} |
| 327 |
else |
| 328 |
{ |
| 329 |
*length = 1; |
| 330 |
} |
| 331 |
|
| 332 |
if ( *length == 1 ) |
| 333 |
{ |
| 334 |
if ( *p == '&' ) |
| 335 |
return GetEntity( p, _value, length, encoding ); |
| 336 |
*_value = *p; |
| 337 |
return p+1; |
| 338 |
} |
| 339 |
else if ( *length ) |
| 340 |
{ |
| 341 |
|
| 342 |
|
| 343 |
for( int i=0; p[i] && i<*length; ++i ) { |
| 344 |
_value[i] = p[i]; |
| 345 |
} |
| 346 |
return p + (*length); |
| 347 |
} |
| 348 |
else |
| 349 |
{ |
| 350 |
|
| 351 |
return 0; |
| 352 |
} |
| 353 |
} |
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
static void PutString( const TIXML_STRING& str, TIXML_STRING* out ); |
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
static bool StringEqual( const char* p, |
| 363 |
const char* endTag, |
| 364 |
bool ignoreCase, |
| 365 |
TiXmlEncoding encoding ); |
| 366 |
|
| 367 |
static const char* errorString[ TIXML_ERROR_STRING_COUNT ]; |
| 368 |
|
| 369 |
TiXmlCursor location; |
| 370 |
|
| 371 |
|
| 372 |
void* userData; |
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
static int IsAlpha( unsigned char anyByte, TiXmlEncoding encoding ); |
| 377 |
static int IsAlphaNum( unsigned char anyByte, TiXmlEncoding encoding ); |
| 378 |
inline static int ToLower( int v, TiXmlEncoding encoding ) |
| 379 |
{ |
| 380 |
if ( encoding == TIXML_ENCODING_UTF8 ) |
| 381 |
{ |
| 382 |
if ( v < 128 ) return tolower( v ); |
| 383 |
return v; |
| 384 |
} |
| 385 |
else |
| 386 |
{ |
| 387 |
return tolower( v ); |
| 388 |
} |
| 389 |
} |
| 390 |
static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ); |
| 391 |
|
| 392 |
private: |
| 393 |
TiXmlBase( const TiXmlBase& ); |
| 394 |
void operator=( const TiXmlBase& base ); |
| 395 |
|
| 396 |
struct Entity |
| 397 |
{ |
| 398 |
const char* str; |
| 399 |
unsigned int strLength; |
| 400 |
char chr; |
| 401 |
}; |
| 402 |
enum |
| 403 |
{ |
| 404 |
NUM_ENTITY = 5, |
| 405 |
MAX_ENTITY_LENGTH = 6 |
| 406 |
|
| 407 |
}; |
| 408 |
static Entity entity[ NUM_ENTITY ]; |
| 409 |
static bool condenseWhiteSpace; |
| 410 |
}; |
| 411 |
|
| 412 |
|
| 413 |
|
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
|
| 419 |
class TiXmlNode : public TiXmlBase |
| 420 |
{ |
| 421 |
friend class TiXmlDocument; |
| 422 |
friend class TiXmlElement; |
| 423 |
|
| 424 |
public: |
| 425 |
#ifdef TIXML_USE_STL |
| 426 |
|
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
friend std::istream& operator >> (std::istream& in, TiXmlNode& base); |
| 431 |
|
| 432 |
|
| 433 |
|
| 434 |
|
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
|
| 445 |
|
| 446 |
|
| 447 |
|
| 448 |
friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base); |
| 449 |
|
| 450 |
|
| 451 |
friend std::string& operator<< (std::string& out, const TiXmlNode& base ); |
| 452 |
|
| 453 |
#endif |
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
enum NodeType |
| 459 |
{ |
| 460 |
DOCUMENT, |
| 461 |
ELEMENT, |
| 462 |
COMMENT, |
| 463 |
UNKNOWN, |
| 464 |
TEXT, |
| 465 |
DECLARATION, |
| 466 |
TYPECOUNT |
| 467 |
}; |
| 468 |
|
| 469 |
virtual ~TiXmlNode(); |
| 470 |
|
| 471 |
|
| 472 |
|
| 473 |
|
| 474 |
|
| 475 |
|
| 476 |
|
| 477 |
|
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
|
| 482 |
|
| 483 |
const char *Value() const { return value.c_str (); } |
| 484 |
|
| 485 |
#ifdef TIXML_USE_STL |
| 486 |
|
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
const std::string& ValueStr() const { return value; } |
| 491 |
#endif |
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
|
| 502 |
void SetValue(const char * _value) { value = _value;} |
| 503 |
|
| 504 |
#ifdef TIXML_USE_STL |
| 505 |
|
| 506 |
void SetValue( const std::string& _value ) { value = _value; } |
| 507 |
#endif |
| 508 |
|
| 509 |
|
| 510 |
void Clear(); |
| 511 |
|
| 512 |
|
| 513 |
TiXmlNode* Parent() { return parent; } |
| 514 |
const TiXmlNode* Parent() const { return parent; } |
| 515 |
|
| 516 |
const TiXmlNode* FirstChild() const { return firstChild; } |
| 517 |
TiXmlNode* FirstChild() { return firstChild; } |
| 518 |
const TiXmlNode* FirstChild( const char * value ) const; |
| 519 |
|
| 520 |
TiXmlNode* FirstChild( const char * _value ) { |
| 521 |
|
| 522 |
|
| 523 |
return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->FirstChild( _value )); |
| 524 |
} |
| 525 |
const TiXmlNode* LastChild() const { return lastChild; } |
| 526 |
TiXmlNode* LastChild() { return lastChild; } |
| 527 |
|
| 528 |
const TiXmlNode* LastChild( const char * value ) const; |
| 529 |
TiXmlNode* LastChild( const char * _value ) { |
| 530 |
return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->LastChild( _value )); |
| 531 |
} |
| 532 |
|
| 533 |
#ifdef TIXML_USE_STL |
| 534 |
const TiXmlNode* FirstChild( const std::string& _value ) const { return FirstChild (_value.c_str ()); } |
| 535 |
TiXmlNode* FirstChild( const std::string& _value ) { return FirstChild (_value.c_str ()); } |
| 536 |
const TiXmlNode* LastChild( const std::string& _value ) const { return LastChild (_value.c_str ()); } |
| 537 |
TiXmlNode* LastChild( const std::string& _value ) { return LastChild (_value.c_str ()); } |
| 538 |
#endif |
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
|
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
|
| 556 |
const TiXmlNode* IterateChildren( const TiXmlNode* previous ) const; |
| 557 |
TiXmlNode* IterateChildren( const TiXmlNode* previous ) { |
| 558 |
return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( previous ) ); |
| 559 |
} |
| 560 |
|
| 561 |
|
| 562 |
const TiXmlNode* IterateChildren( const char * value, const TiXmlNode* previous ) const; |
| 563 |
TiXmlNode* IterateChildren( const char * _value, const TiXmlNode* previous ) { |
| 564 |
return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( _value, previous ) ); |
| 565 |
} |
| 566 |
|
| 567 |
#ifdef TIXML_USE_STL |
| 568 |
const TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) const { return IterateChildren (_value.c_str (), previous); } |
| 569 |
TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) { return IterateChildren (_value.c_str (), previous); } |
| 570 |
#endif |
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
|
| 575 |
TiXmlNode* InsertEndChild( const TiXmlNode& addThis ); |
| 576 |
|
| 577 |
|
| 578 |
|
| 579 |
|
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
|
| 584 |
|
| 585 |
|
| 586 |
|
| 587 |
TiXmlNode* LinkEndChild( TiXmlNode* addThis ); |
| 588 |
|
| 589 |
|
| 590 |
|
| 591 |
|
| 592 |
TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ); |
| 593 |
|
| 594 |
|
| 595 |
|
| 596 |
|
| 597 |
TiXmlNode* InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ); |
| 598 |
|
| 599 |
|
| 600 |
|
| 601 |
|
| 602 |
TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ); |
| 603 |
|
| 604 |
|
| 605 |
bool RemoveChild( TiXmlNode* removeThis ); |
| 606 |
|
| 607 |
|
| 608 |
const TiXmlNode* PreviousSibling() const { return prev; } |
| 609 |
TiXmlNode* PreviousSibling() { return prev; } |
| 610 |
|
| 611 |
|
| 612 |
const TiXmlNode* PreviousSibling( const char * ) const; |
| 613 |
TiXmlNode* PreviousSibling( const char *_prev ) { |
| 614 |
return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->PreviousSibling( _prev ) ); |
| 615 |
} |
| 616 |
|
| 617 |
#ifdef TIXML_USE_STL |
| 618 |
const TiXmlNode* PreviousSibling( const std::string& _value ) const { return PreviousSibling (_value.c_str ()); } |
| 619 |
TiXmlNode* PreviousSibling( const std::string& _value ) { return PreviousSibling (_value.c_str ()); } |
| 620 |
const TiXmlNode* NextSibling( const std::string& _value) const { return NextSibling (_value.c_str ()); } |
| 621 |
TiXmlNode* NextSibling( const std::string& _value) { return NextSibling (_value.c_str ()); } |
| 622 |
#endif |
| 623 |
|
| 624 |
|
| 625 |
const TiXmlNode* NextSibling() const { return next; } |
| 626 |
TiXmlNode* NextSibling() { return next; } |
| 627 |
|
| 628 |
|
| 629 |
const TiXmlNode* NextSibling( const char * ) const; |
| 630 |
TiXmlNode* NextSibling( const char* _next ) { |
| 631 |
return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->NextSibling( _next ) ); |
| 632 |
} |
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
|
| 638 |
const TiXmlElement* NextSiblingElement() const; |
| 639 |
TiXmlElement* NextSiblingElement() { |
| 640 |
return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement() ); |
| 641 |
} |
| 642 |
|
| 643 |
|
| 644 |
|
| 645 |
|
| 646 |
|
| 647 |
const TiXmlElement* NextSiblingElement( const char * ) const; |
| 648 |
TiXmlElement* NextSiblingElement( const char *_next ) { |
| 649 |
return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement( _next ) ); |
| 650 |
} |
| 651 |
|
| 652 |
#ifdef TIXML_USE_STL |
| 653 |
const TiXmlElement* NextSiblingElement( const std::string& _value) const { return NextSiblingElement (_value.c_str ()); } |
| 654 |
TiXmlElement* NextSiblingElement( const std::string& _value) { return NextSiblingElement (_value.c_str ()); } |
| 655 |
#endif |
| 656 |
|
| 657 |
|
| 658 |
const TiXmlElement* FirstChildElement() const; |
| 659 |
TiXmlElement* FirstChildElement() { |
| 660 |
return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement() ); |
| 661 |
} |
| 662 |
|
| 663 |
|
| 664 |
const TiXmlElement* FirstChildElement( const char * _value ) const; |
| 665 |
TiXmlElement* FirstChildElement( const char * _value ) { |
| 666 |
return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement( _value ) ); |
| 667 |
} |
| 668 |
|
| 669 |
#ifdef TIXML_USE_STL |
| 670 |
const TiXmlElement* FirstChildElement( const std::string& _value ) const { return FirstChildElement (_value.c_str ()); } |
| 671 |
TiXmlElement* FirstChildElement( const std::string& _value ) { return FirstChildElement (_value.c_str ()); } |
| 672 |
#endif |
| 673 |
|
| 674 |
|
| 675 |
|
| 676 |
|
| 677 |
|
| 678 |
int Type() const { return type; } |
| 679 |
|
| 680 |
|
| 681 |
|
| 682 |
|
| 683 |
const TiXmlDocument* GetDocument() const; |
| 684 |
TiXmlDocument* GetDocument() { |
| 685 |
return const_cast< TiXmlDocument* >( (const_cast< const TiXmlNode* >(this))->GetDocument() ); |
| 686 |
} |
| 687 |
|
| 688 |
|
| 689 |
bool NoChildren() const { return !firstChild; } |
| 690 |
|
| 691 |
virtual const TiXmlDocument* ToDocument() const { return 0; } |
| 692 |
virtual const TiXmlElement* ToElement() const { return 0; } |
| 693 |
virtual const TiXmlComment* ToComment() const { return 0; } |
| 694 |
virtual const TiXmlUnknown* ToUnknown() const { return 0; } |
| 695 |
virtual const TiXmlText* ToText() const { return 0; } |
| 696 |
virtual const TiXmlDeclaration* ToDeclaration() const { return 0; } |
| 697 |
|
| 698 |
virtual TiXmlDocument* ToDocument() { return 0; } |
| 699 |
virtual TiXmlElement* ToElement() { return 0; } |
| 700 |
virtual TiXmlComment* ToComment() { return 0; } |
| 701 |
virtual TiXmlUnknown* ToUnknown() { return 0; } |
| 702 |
virtual TiXmlText* ToText() { return 0; } |
| 703 |
virtual TiXmlDeclaration* ToDeclaration() { return 0; } |
| 704 |
|
| 705 |
|
| 706 |
|
| 707 |
|
| 708 |
virtual TiXmlNode* Clone() const = 0; |
| 709 |
|
| 710 |
|
| 711 |
|
| 712 |
|
| 713 |
|
| 714 |
|
| 715 |
|
| 716 |
|
| 717 |
|
| 718 |
|
| 719 |
|
| 720 |
|
| 721 |
|
| 722 |
|
| 723 |
|
| 724 |
|
| 725 |
|
| 726 |
|
| 727 |
|
| 728 |
|
| 729 |
|
| 730 |
|
| 731 |
|
| 732 |
virtual bool Accept( TiXmlVisitor* visitor ) const = 0; |
| 733 |
|
| 734 |
protected: |
| 735 |
TiXmlNode( NodeType _type ); |
| 736 |
|
| 737 |
|
| 738 |
|
| 739 |
void CopyTo( TiXmlNode* target ) const; |
| 740 |
|
| 741 |
#ifdef TIXML_USE_STL |
| 742 |
|
| 743 |
virtual void StreamIn( std::istream* in, TIXML_STRING* tag ) = 0; |
| 744 |
#endif |
| 745 |
|
| 746 |
|
| 747 |
TiXmlNode* Identify( const char* start, TiXmlEncoding encoding ); |
| 748 |
|
| 749 |
TiXmlNode* parent; |
| 750 |
NodeType type; |
| 751 |
|
| 752 |
TiXmlNode* firstChild; |
| 753 |
TiXmlNode* lastChild; |
| 754 |
|
| 755 |
TIXML_STRING value; |
| 756 |
|
| 757 |
TiXmlNode* prev; |
| 758 |
TiXmlNode* next; |
| 759 |
|
| 760 |
private: |
| 761 |
TiXmlNode( const TiXmlNode& ); |
| 762 |
void operator=( const TiXmlNode& base ); |
| 763 |
}; |
| 764 |
|
| 765 |
|
| 766 |
|
| 767 |
|
| 768 |
|
| 769 |
|
| 770 |
|
| 771 |
|
| 772 |
|
| 773 |
class TiXmlAttribute : public TiXmlBase |
| 774 |
{ |
| 775 |
friend class TiXmlAttributeSet; |
| 776 |
|
| 777 |
public: |
| 778 |
|
| 779 |
TiXmlAttribute() : TiXmlBase() |
| 780 |
{ |
| 781 |
document = 0; |
| 782 |
prev = next = 0; |
| 783 |
} |
| 784 |
|
| 785 |
#ifdef TIXML_USE_STL |
| 786 |
|
| 787 |
TiXmlAttribute( const std::string& _name, const std::string& _value ) |
| 788 |
{ |
| 789 |
name = _name; |
| 790 |
value = _value; |
| 791 |
document = 0; |
| 792 |
prev = next = 0; |
| 793 |
} |
| 794 |
#endif |
| 795 |
|
| 796 |
|
| 797 |
TiXmlAttribute( const char * _name, const char * _value ) |
| 798 |
{ |
| 799 |
name = _name; |
| 800 |
value = _value; |
| 801 |
document = 0; |
| 802 |
prev = next = 0; |
| 803 |
} |
| 804 |
|
| 805 |
const char* Name() const { return name.c_str(); } |
| 806 |
const char* Value() const { return value.c_str(); } |
| 807 |
#ifdef TIXML_USE_STL |
| 808 |
const std::string& ValueStr() const { return value; } |
| 809 |
#endif |
| 810 |
int IntValue() const; |
| 811 |
double DoubleValue() const; |
| 812 |
|
| 813 |
|
| 814 |
const TIXML_STRING& NameTStr() const { return name; } |
| 815 |
|
| 816 |
|
| 817 |
|
| 818 |
|
| 819 |
|
| 820 |
|
| 821 |
|
| 822 |
|
| 823 |
|
| 824 |
|
| 825 |
int QueryIntValue( int* _value ) const; |
| 826 |
|
| 827 |
int QueryDoubleValue( double* _value ) const; |
| 828 |
|
| 829 |
void SetName( const char* _name ) { name = _name; } |
| 830 |
void SetValue( const char* _value ) { value = _value; } |
| 831 |
|
| 832 |
void SetIntValue( int _value ); |
| 833 |
void SetDoubleValue( double _value ); |
| 834 |
|
| 835 |
#ifdef TIXML_USE_STL |
| 836 |
|
| 837 |
void SetName( const std::string& _name ) { name = _name; } |
| 838 |
|
| 839 |
void SetValue( const std::string& _value ) { value = _value; } |
| 840 |
#endif |
| 841 |
|
| 842 |
|
| 843 |
const TiXmlAttribute* Next() const; |
| 844 |
TiXmlAttribute* Next() { |
| 845 |
return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() ); |
| 846 |
} |
| 847 |
|
| 848 |
|
| 849 |
const TiXmlAttribute* Previous() const; |
| 850 |
TiXmlAttribute* Previous() { |
| 851 |
return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() ); |
| 852 |
} |
| 853 |
|
| 854 |
bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; } |
| 855 |
bool operator<( const TiXmlAttribute& rhs ) const { return name < rhs.name; } |
| 856 |
bool operator>( const TiXmlAttribute& rhs ) const { return name > rhs.name; } |
| 857 |
|
| 858 |
|
| 859 |
|
| 860 |
|
| 861 |
virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); |
| 862 |
|
| 863 |
|
| 864 |
virtual void Print( FILE* cfile, int depth ) const { |
| 865 |
Print( cfile, depth, 0 ); |
| 866 |
} |
| 867 |
void Print( FILE* cfile, int depth, TIXML_STRING* str ) const; |
| 868 |
|
| 869 |
|
| 870 |
|
| 871 |
void SetDocument( TiXmlDocument* doc ) { document = doc; } |
| 872 |
|
| 873 |
private: |
| 874 |
TiXmlAttribute( const TiXmlAttribute& ); |
| 875 |
void operator=( const TiXmlAttribute& base ); |
| 876 |
|
| 877 |
TiXmlDocument* document; |
| 878 |
TIXML_STRING name; |
| 879 |
TIXML_STRING value; |
| 880 |
TiXmlAttribute* prev; |
| 881 |
TiXmlAttribute* next; |
| 882 |
}; |
| 883 |
|
| 884 |
|
| 885 |
|
| 886 |
|
| 887 |
|
| 888 |
|
| 889 |
|
| 890 |
|
| 891 |
|
| 892 |
|
| 893 |
|
| 894 |
|
| 895 |
|
| 896 |
|
| 897 |
class TiXmlAttributeSet |
| 898 |
{ |
| 899 |
public: |
| 900 |
TiXmlAttributeSet(); |
| 901 |
~TiXmlAttributeSet(); |
| 902 |
|
| 903 |
void Add( TiXmlAttribute* attribute ); |
| 904 |
void Remove( TiXmlAttribute* attribute ); |
| 905 |
|
| 906 |
const TiXmlAttribute* First() const { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } |
| 907 |
TiXmlAttribute* First() { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } |
| 908 |
const TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } |
| 909 |
TiXmlAttribute* Last() { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } |
| 910 |
|
| 911 |
const TiXmlAttribute* Find( const char* _name ) const; |
| 912 |
TiXmlAttribute* Find( const char* _name ) { |
| 913 |
return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) ); |
| 914 |
} |
| 915 |
#ifdef TIXML_USE_STL |
| 916 |
const TiXmlAttribute* Find( const std::string& _name ) const; |
| 917 |
TiXmlAttribute* Find( const std::string& _name ) { |
| 918 |
return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) ); |
| 919 |
} |
| 920 |
|
| 921 |
#endif |
| 922 |
|
| 923 |
private: |
| 924 |
|
| 925 |
|
| 926 |
TiXmlAttributeSet( const TiXmlAttributeSet& ); |
| 927 |
void operator=( const TiXmlAttributeSet& ); |
| 928 |
|
| 929 |
TiXmlAttribute sentinel; |
| 930 |
}; |
| 931 |
|
| 932 |
|
| 933 |
|
| 934 |
|
| 935 |
|
| 936 |
|
| 937 |
class TiXmlElement : public TiXmlNode |
| 938 |
{ |
| 939 |
public: |
| 940 |
|
| 941 |
TiXmlElement (const char * in_value); |
| 942 |
|
| 943 |
#ifdef TIXML_USE_STL |
| 944 |
|
| 945 |
TiXmlElement( const std::string& _value ); |
| 946 |
#endif |
| 947 |
|
| 948 |
TiXmlElement( const TiXmlElement& ); |
| 949 |
|
| 950 |
void operator=( const TiXmlElement& base ); |
| 951 |
|
| 952 |
virtual ~TiXmlElement(); |
| 953 |
|
| 954 |
|
| 955 |
|
| 956 |
|
| 957 |
const char* Attribute( const char* name ) const; |
| 958 |
|
| 959 |
|
| 960 |
|
| 961 |
|
| 962 |
|
| 963 |
|
| 964 |
|
| 965 |
const char* Attribute( const char* name, int* i ) const; |
| 966 |
|
| 967 |
|
| 968 |
|
| 969 |
|
| 970 |
|
| 971 |
|
| 972 |
|
| 973 |
const char* Attribute( const char* name, double* d ) const; |
| 974 |
|
| 975 |
|
| 976 |
|
| 977 |
|
| 978 |
|
| 979 |
|
| 980 |
|
| 981 |
|
| 982 |
int QueryIntAttribute( const char* name, int* _value ) const; |
| 983 |
|
| 984 |
int QueryDoubleAttribute( const char* name, double* _value ) const; |
| 985 |
|
| 986 |
int QueryFloatAttribute( const char* name, float* _value ) const { |
| 987 |
double d; |
| 988 |
int result = QueryDoubleAttribute( name, &d ); |
| 989 |
if ( result == TIXML_SUCCESS ) { |
| 990 |
*_value = (float)d; |
| 991 |
} |
| 992 |
return result; |
| 993 |
} |
| 994 |
#ifdef TIXML_USE_STL |
| 995 |
|
| 996 |
|
| 997 |
|
| 998 |
|
| 999 |
|
| 1000 |
|
| 1001 |
template< typename T > int QueryValueAttribute( const std::string& name, T* outValue ) const |
| 1002 |
{ |
| 1003 |
const TiXmlAttribute* node = attributeSet.Find( name ); |
| 1004 |
if ( !node ) |
| 1005 |
return TIXML_NO_ATTRIBUTE; |
| 1006 |
|
| 1007 |
std::stringstream sstream( node->ValueStr() ); |
| 1008 |
sstream >> *outValue; |
| 1009 |
if ( !sstream.fail() ) |
| 1010 |
return TIXML_SUCCESS; |
| 1011 |
return TIXML_WRONG_TYPE; |
| 1012 |
} |
| 1013 |
#endif |
| 1014 |
|
| 1015 |
|
| 1016 |
|
| 1017 |
|
| 1018 |
void SetAttribute( const char* name, const char * _value ); |
| 1019 |
|
| 1020 |
#ifdef TIXML_USE_STL |
| 1021 |
const std::string* Attribute( const std::string& name ) const; |
| 1022 |
const std::string* Attribute( const std::string& name, int* i ) const; |
| 1023 |
const std::string* Attribute( const std::string& name, double* d ) const; |
| 1024 |
int QueryIntAttribute( const std::string& name, int* _value ) const; |
| 1025 |
int QueryDoubleAttribute( const std::string& name, double* _value ) const; |
| 1026 |
|
| 1027 |
|
| 1028 |
void SetAttribute( const std::string& name, const std::string& _value ); |
| 1029 |
|
| 1030 |
void SetAttribute( const std::string& name, int _value ); |
| 1031 |
#endif |
| 1032 |
|
| 1033 |
|
| 1034 |
|
| 1035 |
|
| 1036 |
void SetAttribute( const char * name, int value ); |
| 1037 |
|
| 1038 |
|
| 1039 |
|
| 1040 |
|
| 1041 |
void SetDoubleAttribute( const char * name, double value ); |
| 1042 |
|
| 1043 |
|
| 1044 |
|
| 1045 |
void RemoveAttribute( const char * name ); |
| 1046 |
#ifdef TIXML_USE_STL |
| 1047 |
void RemoveAttribute( const std::string& name ) { RemoveAttribute (name.c_str ()); } |
| 1048 |
#endif |
| 1049 |
|
| 1050 |
const TiXmlAttribute* FirstAttribute() const { return attributeSet.First(); } |
| 1051 |
TiXmlAttribute* FirstAttribute() { return attributeSet.First(); } |
| 1052 |
const TiXmlAttribute* LastAttribute() const { return attributeSet.Last(); } |
| 1053 |
TiXmlAttribute* LastAttribute() { return attributeSet.Last(); } |
| 1054 |
|
| 1055 |
|
| 1056 |
|
| 1057 |
|
| 1058 |
|
| 1059 |
|
| 1060 |
|
| 1061 |
|
| 1062 |
|
| 1063 |
|
| 1064 |
|
| 1065 |
|
| 1066 |
|
| 1067 |
|
| 1068 |
|
| 1069 |
|
| 1070 |
|
| 1071 |
|
| 1072 |
|
| 1073 |
|
| 1074 |
|
| 1075 |
|
| 1076 |
|
| 1077 |
|
| 1078 |
|
| 1079 |
|
| 1080 |
|
| 1081 |
|
| 1082 |
|
| 1083 |
|
| 1084 |
|
| 1085 |
|
| 1086 |
|
| 1087 |
const char* GetText() const; |
| 1088 |
|
| 1089 |
|
| 1090 |
virtual TiXmlNode* Clone() const; |
| 1091 |
|
| 1092 |
virtual void Print( FILE* cfile, int depth ) const; |
| 1093 |
|
| 1094 |
|
| 1095 |
|
| 1096 |
|
| 1097 |
virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); |
| 1098 |
|
| 1099 |
virtual const TiXmlElement* ToElement() const { return this; } |
| 1100 |
virtual TiXmlElement* ToElement() { return this; } |
| 1101 |
|
| 1102 |
|
| 1103 |
|
| 1104 |
virtual bool Accept( TiXmlVisitor* visitor ) const; |
| 1105 |
|
| 1106 |
protected: |
| 1107 |
|
| 1108 |
void CopyTo( TiXmlElement* target ) const; |
| 1109 |
void ClearThis(); |
| 1110 |
|
| 1111 |
|
| 1112 |
#ifdef TIXML_USE_STL |
| 1113 |
virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); |
| 1114 |
#endif |
| 1115 |
|
| 1116 |
|
| 1117 |
|
| 1118 |
|
| 1119 |
const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding ); |
| 1120 |
|
| 1121 |
private: |
| 1122 |
|
| 1123 |
TiXmlAttributeSet attributeSet; |
| 1124 |
}; |
| 1125 |
|
| 1126 |
|
| 1127 |
|
| 1128 |
|
| 1129 |
class TiXmlComment : public TiXmlNode |
| 1130 |
{ |
| 1131 |
public: |
| 1132 |
|
| 1133 |
TiXmlComment() : TiXmlNode( TiXmlNode::COMMENT ) {} |
| 1134 |
|
| 1135 |
TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::COMMENT ) { |
| 1136 |
SetValue( _value ); |
| 1137 |
} |
| 1138 |
TiXmlComment( const TiXmlComment& ); |
| 1139 |
void operator=( const TiXmlComment& base ); |
| 1140 |
|
| 1141 |
virtual ~TiXmlComment() {} |
| 1142 |
|
| 1143 |
|
| 1144 |
virtual TiXmlNode* Clone() const; |
| 1145 |
|
| 1146 |
virtual void Print( FILE* cfile, int depth ) const; |
| 1147 |
|
| 1148 |
|
| 1149 |
|
| 1150 |
|
| 1151 |
virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); |
| 1152 |
|
| 1153 |
virtual const TiXmlComment* ToComment() const { return this; } |
| 1154 |
virtual TiXmlComment* ToComment() { return this; } |
| 1155 |
|
| 1156 |
|
| 1157 |
|
| 1158 |
virtual bool Accept( TiXmlVisitor* visitor ) const; |
| 1159 |
|
| 1160 |
protected: |
| 1161 |
void CopyTo( TiXmlComment* target ) const; |
| 1162 |
|
| 1163 |
|
| 1164 |
#ifdef TIXML_USE_STL |
| 1165 |
virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); |
| 1166 |
#endif |
| 1167 |
|
| 1168 |
|
| 1169 |
private: |
| 1170 |
|
| 1171 |
}; |
| 1172 |
|
| 1173 |
|
| 1174 |
|
| 1175 |
|
| 1176 |
|
| 1177 |
|
| 1178 |
|
| 1179 |
class TiXmlText : public TiXmlNode |
| 1180 |
{ |
| 1181 |
friend class TiXmlElement; |
| 1182 |
public: |
| 1183 |
|
| 1184 |
|
| 1185 |
|
| 1186 |
|
| 1187 |
TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TEXT) |
| 1188 |
{ |
| 1189 |
SetValue( initValue ); |
| 1190 |
cdata = false; |
| 1191 |
} |
| 1192 |
virtual ~TiXmlText() {} |
| 1193 |
|
| 1194 |
#ifdef TIXML_USE_STL |
| 1195 |
|
| 1196 |
TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TEXT) |
| 1197 |
{ |
| 1198 |
SetValue( initValue ); |
| 1199 |
cdata = false; |
| 1200 |
} |
| 1201 |
#endif |
| 1202 |
|
| 1203 |
TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TEXT ) { copy.CopyTo( this ); } |
| 1204 |
void operator=( const TiXmlText& base ) { base.CopyTo( this ); } |
| 1205 |
|
| 1206 |
|
| 1207 |
virtual void Print( FILE* cfile, int depth ) const; |
| 1208 |
|
| 1209 |
|
| 1210 |
bool CDATA() const { return cdata; } |
| 1211 |
|
| 1212 |
void SetCDATA( bool _cdata ) { cdata = _cdata; } |
| 1213 |
|
| 1214 |
virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); |
| 1215 |
|
| 1216 |
virtual const TiXmlText* ToText() const { return this; } |
| 1217 |
virtual TiXmlText* ToText() { return this; } |
| 1218 |
|
| 1219 |
|
| 1220 |
|
| 1221 |
virtual bool Accept( TiXmlVisitor* content ) const; |
| 1222 |
|
| 1223 |
protected : |
| 1224 |
|
| 1225 |
virtual TiXmlNode* Clone() const; |
| 1226 |
void CopyTo( TiXmlText* target ) const; |
| 1227 |
|
| 1228 |
bool Blank() const; |
| 1229 |
|
| 1230 |
#ifdef TIXML_USE_STL |
| 1231 |
virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); |
| 1232 |
#endif |
| 1233 |
|
| 1234 |
private: |
| 1235 |
bool cdata; |
| 1236 |
}; |
| 1237 |
|
| 1238 |
|
| 1239 |
|
| 1240 |
|
| 1241 |
|
| 1242 |
|
| 1243 |
|
| 1244 |
|
| 1245 |
|
| 1246 |
|
| 1247 |
|
| 1248 |
|
| 1249 |
|
| 1250 |
|
| 1251 |
|
| 1252 |
class TiXmlDeclaration : public TiXmlNode |
| 1253 |
{ |
| 1254 |
public: |
| 1255 |
|
| 1256 |
TiXmlDeclaration() : TiXmlNode( TiXmlNode::DECLARATION ) {} |
| 1257 |
|
| 1258 |
#ifdef TIXML_USE_STL |
| 1259 |
|
| 1260 |
TiXmlDeclaration( const std::string& _version, |
| 1261 |
const std::string& _encoding, |
| 1262 |
const std::string& _standalone ); |
| 1263 |
#endif |
| 1264 |
|
| 1265 |
|
| 1266 |
TiXmlDeclaration( const char* _version, |
| 1267 |
const char* _encoding, |
| 1268 |
const char* _standalone ); |
| 1269 |
|
| 1270 |
TiXmlDeclaration( const TiXmlDeclaration& copy ); |
| 1271 |
void operator=( const TiXmlDeclaration& copy ); |
| 1272 |
|
| 1273 |
virtual ~TiXmlDeclaration() {} |
| 1274 |
|
| 1275 |
|
| 1276 |
const char *Version() const { return version.c_str (); } |
| 1277 |
|
| 1278 |
const char *Encoding() const { return encoding.c_str (); } |
| 1279 |
|
| 1280 |
const char *Standalone() const { return standalone.c_str (); } |
| 1281 |
|
| 1282 |
|
| 1283 |
virtual TiXmlNode* Clone() const; |
| 1284 |
|
| 1285 |
virtual void Print( FILE* cfile, int depth, TIXML_STRING* str ) const; |
| 1286 |
virtual void Print( FILE* cfile, int depth ) const { |
| 1287 |
Print( cfile, depth, 0 ); |
| 1288 |
} |
| 1289 |
|
| 1290 |
virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); |
| 1291 |
|
| 1292 |
virtual const TiXmlDeclaration* ToDeclaration() const { return this; } |
| 1293 |
virtual TiXmlDeclaration* ToDeclaration() { return this; } |
| 1294 |
|
| 1295 |
|
| 1296 |
|
| 1297 |
virtual bool Accept( TiXmlVisitor* visitor ) const; |
| 1298 |
|
| 1299 |
protected: |
| 1300 |
void CopyTo( TiXmlDeclaration* target ) const; |
| 1301 |
|
| 1302 |
#ifdef TIXML_USE_STL |
| 1303 |
virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); |
| 1304 |
#endif |
| 1305 |
|
| 1306 |
private: |
| 1307 |
|
| 1308 |
TIXML_STRING version; |
| 1309 |
TIXML_STRING encoding; |
| 1310 |
TIXML_STRING standalone; |
| 1311 |
}; |
| 1312 |
|
| 1313 |
|
| 1314 |
|
| 1315 |
|
| 1316 |
|
| 1317 |
|
| 1318 |
|
| 1319 |
|
| 1320 |
|
| 1321 |
class TiXmlUnknown : public TiXmlNode |
| 1322 |
{ |
| 1323 |
public: |
| 1324 |
TiXmlUnknown() : TiXmlNode( TiXmlNode::UNKNOWN ) {} |
| 1325 |
virtual ~TiXmlUnknown() {} |
| 1326 |
|
| 1327 |
TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::UNKNOWN ) { copy.CopyTo( this ); } |
| 1328 |
void operator=( const TiXmlUnknown& copy ) { copy.CopyTo( this ); } |
| 1329 |
|
| 1330 |
|
| 1331 |
virtual TiXmlNode* Clone() const; |
| 1332 |
|
| 1333 |
virtual void Print( FILE* cfile, int depth ) const; |
| 1334 |
|
| 1335 |
virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); |
| 1336 |
|
| 1337 |
virtual const TiXmlUnknown* ToUnknown() const { return this; } |
| 1338 |
virtual TiXmlUnknown* ToUnknown() { return this; } |
| 1339 |
|
| 1340 |
|
| 1341 |
|
| 1342 |
virtual bool Accept( TiXmlVisitor* content ) const; |
| 1343 |
|
| 1344 |
protected: |
| 1345 |
void CopyTo( TiXmlUnknown* target ) const; |
| 1346 |
|
| 1347 |
#ifdef TIXML_USE_STL |
| 1348 |
virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); |
| 1349 |
#endif |
| 1350 |
|
| 1351 |
private: |
| 1352 |
|
| 1353 |
}; |
| 1354 |
|
| 1355 |
|
| 1356 |
|
| 1357 |
|
| 1358 |
|
| 1359 |
|
| 1360 |
class TiXmlDocument : public TiXmlNode |
| 1361 |
{ |
| 1362 |
public: |
| 1363 |
|
| 1364 |
TiXmlDocument(); |
| 1365 |
|
| 1366 |
TiXmlDocument( const char * documentName ); |
| 1367 |
|
| 1368 |
#ifdef TIXML_USE_STL |
| 1369 |
|
| 1370 |
TiXmlDocument( const std::string& documentName ); |
| 1371 |
#endif |
| 1372 |
|
| 1373 |
TiXmlDocument( const TiXmlDocument& copy ); |
| 1374 |
void operator=( const TiXmlDocument& copy ); |
| 1375 |
|
| 1376 |
virtual ~TiXmlDocument() {} |
| 1377 |
|
| 1378 |
|
| 1379 |
|
| 1380 |
|
| 1381 |
|
| 1382 |
bool LoadFile( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); |
| 1383 |
|
| 1384 |
bool SaveFile() const; |
| 1385 |
|
| 1386 |
bool LoadFile( const char * filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); |
| 1387 |
|
| 1388 |
bool SaveFile( const char * filename ) const; |
| 1389 |
|
| 1390 |
|
| 1391 |
|
| 1392 |
|
| 1393 |
|
| 1394 |
bool LoadFile( FILE*, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); |
| 1395 |
|
| 1396 |
bool SaveFile( FILE* ) const; |
| 1397 |
|
| 1398 |
#ifdef TIXML_USE_STL |
| 1399 |
bool LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ) |
| 1400 |
{ |
| 1401 |
|
| 1402 |
|
| 1403 |
return LoadFile( filename.c_str(), encoding ); |
| 1404 |
} |
| 1405 |
bool SaveFile( const std::string& filename ) const |
| 1406 |
{ |
| 1407 |
|
| 1408 |
|
| 1409 |
return SaveFile( filename.c_str() ); |
| 1410 |
} |
| 1411 |
#endif |
| 1412 |
|
| 1413 |
|
| 1414 |
|
| 1415 |
|
| 1416 |
|
| 1417 |
virtual const char* Parse( const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); |
| 1418 |
|
| 1419 |
|
| 1420 |
|
| 1421 |
|
| 1422 |
|
| 1423 |
const TiXmlElement* RootElement() const { return FirstChildElement(); } |
| 1424 |
TiXmlElement* RootElement() { return FirstChildElement(); } |
| 1425 |
|
| 1426 |
|
| 1427 |
|
| 1428 |
|
| 1429 |
|
| 1430 |
|
| 1431 |
bool Error() const { return error; } |
| 1432 |
|
| 1433 |
|
| 1434 |
const char * ErrorDesc() const { return errorDesc.c_str (); } |
| 1435 |
|
| 1436 |
|
| 1437 |
|
| 1438 |
|
| 1439 |
int ErrorId() const { return errorId; } |
| 1440 |
|
| 1441 |
|
| 1442 |
|
| 1443 |
|
| 1444 |
|
| 1445 |
|
| 1446 |
|
| 1447 |
|
| 1448 |
int ErrorRow() const { return errorLocation.row+1; } |
| 1449 |
int ErrorCol() const { return errorLocation.col+1; } |
| 1450 |
|
| 1451 |
|
| 1452 |
|
| 1453 |
|
| 1454 |
|
| 1455 |
|
| 1456 |
|
| 1457 |
|
| 1458 |
|
| 1459 |
|
| 1460 |
|
| 1461 |
|
| 1462 |
|
| 1463 |
|
| 1464 |
|
| 1465 |
|
| 1466 |
|
| 1467 |
|
| 1468 |
|
| 1469 |
|
| 1470 |
|
| 1471 |
|
| 1472 |
|
| 1473 |
|
| 1474 |
|
| 1475 |
void SetTabSize( int _tabsize ) { tabsize = _tabsize; } |
| 1476 |
|
| 1477 |
int TabSize() const { return tabsize; } |
| 1478 |
|
| 1479 |
|
| 1480 |
|
| 1481 |
|
| 1482 |
void ClearError() { error = false; |
| 1483 |
errorId = 0; |
| 1484 |
errorDesc = ""; |
| 1485 |
errorLocation.row = errorLocation.col = 0; |
| 1486 |
|
| 1487 |
} |
| 1488 |
|
| 1489 |
|
| 1490 |
void Print() const { Print( stdout, 0 ); } |
| 1491 |
|
| 1492 |
|
| 1493 |
|
| 1494 |
|
| 1495 |
|
| 1496 |
|
| 1497 |
|
| 1498 |
|
| 1499 |
virtual void Print( FILE* cfile, int depth = 0 ) const; |
| 1500 |
|
| 1501 |
void SetError( int err, const char* errorLocation, TiXmlParsingData* prevData, TiXmlEncoding encoding ); |
| 1502 |
|
| 1503 |
virtual const TiXmlDocument* ToDocument() const { return this; } |
| 1504 |
virtual TiXmlDocument* ToDocument() { return this; } |
| 1505 |
|
| 1506 |
|
| 1507 |
|
| 1508 |
virtual bool Accept( TiXmlVisitor* content ) const; |
| 1509 |
|
| 1510 |
protected : |
| 1511 |
|
| 1512 |
virtual TiXmlNode* Clone() const; |
| 1513 |
#ifdef TIXML_USE_STL |
| 1514 |
virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); |
| 1515 |
#endif |
| 1516 |
|
| 1517 |
private: |
| 1518 |
void CopyTo( TiXmlDocument* target ) const; |
| 1519 |
|
| 1520 |
bool error; |
| 1521 |
int errorId; |
| 1522 |
TIXML_STRING errorDesc; |
| 1523 |
int tabsize; |
| 1524 |
TiXmlCursor errorLocation; |
| 1525 |
bool useMicrosoftBOM; |
| 1526 |
}; |
| 1527 |
|
| 1528 |
|
| 1529 |
|
| 1530 |
|
| 1531 |
|
| 1532 |
|
| 1533 |
|
| 1534 |
|
| 1535 |
|
| 1536 |
|
| 1537 |
|
| 1538 |
|
| 1539 |
|
| 1540 |
|
| 1541 |
|
| 1542 |
|
| 1543 |
|
| 1544 |
|
| 1545 |
|
| 1546 |
|
| 1547 |
|
| 1548 |
|
| 1549 |
|
| 1550 |
|
| 1551 |
|
| 1552 |
|
| 1553 |
|
| 1554 |
|
| 1555 |
|
| 1556 |
|
| 1557 |
|
| 1558 |
|
| 1559 |
|
| 1560 |
|
| 1561 |
|
| 1562 |
|
| 1563 |
|
| 1564 |
|
| 1565 |
|
| 1566 |
|
| 1567 |
|
| 1568 |
|
| 1569 |
|
| 1570 |
|
| 1571 |
|
| 1572 |
|
| 1573 |
|
| 1574 |
|
| 1575 |
|
| 1576 |
|
| 1577 |
|
| 1578 |
|
| 1579 |
|
| 1580 |
|
| 1581 |
|
| 1582 |
|
| 1583 |
|
| 1584 |
|
| 1585 |
|
| 1586 |
|
| 1587 |
|
| 1588 |
|
| 1589 |
|
| 1590 |
|
| 1591 |
|
| 1592 |
|
| 1593 |
|
| 1594 |
|
| 1595 |
|
| 1596 |
|
| 1597 |
|
| 1598 |
|
| 1599 |
|
| 1600 |
|
| 1601 |
|
| 1602 |
|
| 1603 |
|
| 1604 |
|
| 1605 |
|
| 1606 |
|
| 1607 |
|
| 1608 |
|
| 1609 |
class TiXmlHandle |
| 1610 |
{ |
| 1611 |
public: |
| 1612 |
|
| 1613 |
TiXmlHandle( TiXmlNode* _node ) { this->node = _node; } |
| 1614 |
|
| 1615 |
TiXmlHandle( const TiXmlHandle& ref ) { this->node = ref.node; } |
| 1616 |
TiXmlHandle operator=( const TiXmlHandle& ref ) { this->node = ref.node; return *this; } |
| 1617 |
|
| 1618 |
|
| 1619 |
TiXmlHandle FirstChild() const; |
| 1620 |
|
| 1621 |
TiXmlHandle FirstChild( const char * value ) const; |
| 1622 |
|
| 1623 |
TiXmlHandle FirstChildElement() const; |
| 1624 |
|
| 1625 |
TiXmlHandle FirstChildElement( const char * value ) const; |
| 1626 |
|
| 1627 |
|
| 1628 |
|
| 1629 |
|
| 1630 |
TiXmlHandle Child( const char* value, int index ) const; |
| 1631 |
|
| 1632 |
|
| 1633 |
|
| 1634 |
TiXmlHandle Child( int index ) const; |
| 1635 |
|
| 1636 |
|
| 1637 |
|
| 1638 |
|
| 1639 |
TiXmlHandle ChildElement( const char* value, int index ) const; |
| 1640 |
|
| 1641 |
|
| 1642 |
|
| 1643 |
|
| 1644 |
TiXmlHandle ChildElement( int index ) const; |
| 1645 |
|
| 1646 |
#ifdef TIXML_USE_STL |
| 1647 |
TiXmlHandle FirstChild( const std::string& _value ) const { return FirstChild( _value.c_str() ); } |
| 1648 |
TiXmlHandle FirstChildElement( const std::string& _value ) const { return FirstChildElement( _value.c_str() ); } |
| 1649 |
|
| 1650 |
TiXmlHandle Child( const std::string& _value, int index ) const { return Child( _value.c_str(), index ); } |
| 1651 |
TiXmlHandle ChildElement( const std::string& _value, int index ) const { return ChildElement( _value.c_str(), index ); } |
| 1652 |
#endif |
| 1653 |
|
| 1654 |
|
| 1655 |
|
| 1656 |
TiXmlNode* ToNode() const { return node; } |
| 1657 |
|
| 1658 |
|
| 1659 |
TiXmlElement* ToElement() const { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); } |
| 1660 |
|
| 1661 |
|
| 1662 |
TiXmlText* ToText() const { return ( ( node && node->ToText() ) ? node->ToText() : 0 ); } |
| 1663 |
|
| 1664 |
|
| 1665 |
TiXmlUnknown* ToUnknown() const { return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); } |
| 1666 |
|
| 1667 |
|
| 1668 |
|
| 1669 |
|
| 1670 |
TiXmlNode* Node() const { return ToNode(); } |
| 1671 |
|
| 1672 |
|
| 1673 |
|
| 1674 |
TiXmlElement* Element() const { return ToElement(); } |
| 1675 |
|
| 1676 |
|
| 1677 |
|
| 1678 |
TiXmlText* Text() const { return ToText(); } |
| 1679 |
|
| 1680 |
|
| 1681 |
|
| 1682 |
TiXmlUnknown* Unknown() const { return ToUnknown(); } |
| 1683 |
|
| 1684 |
private: |
| 1685 |
TiXmlNode* node; |
| 1686 |
}; |
| 1687 |
|
| 1688 |
|
| 1689 |
|
| 1690 |
|
| 1691 |
|
| 1692 |
|
| 1693 |
|
| 1694 |
|
| 1695 |
|
| 1696 |
|
| 1697 |
|
| 1698 |
|
| 1699 |
|
| 1700 |
|
| 1701 |
|
| 1702 |
|
| 1703 |
|
| 1704 |
|
| 1705 |
|
| 1706 |
|
| 1707 |
|
| 1708 |
class TiXmlPrinter : public TiXmlVisitor |
| 1709 |
{ |
| 1710 |
public: |
| 1711 |
TiXmlPrinter() : depth( 0 ), simpleTextPrint( false ), |
| 1712 |
buffer(), indent( " " ), lineBreak( "\n" ) {} |
| 1713 |
|
| 1714 |
virtual bool VisitEnter( const TiXmlDocument& doc ); |
| 1715 |
virtual bool VisitExit( const TiXmlDocument& doc ); |
| 1716 |
|
| 1717 |
virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ); |
| 1718 |
virtual bool VisitExit( const TiXmlElement& element ); |
| 1719 |
|
| 1720 |
virtual bool Visit( const TiXmlDeclaration& declaration ); |
| 1721 |
virtual bool Visit( const TiXmlText& text ); |
| 1722 |
virtual bool Visit( const TiXmlComment& comment ); |
| 1723 |
virtual bool Visit( const TiXmlUnknown& unknown ); |
| 1724 |
|
| 1725 |
|
| 1726 |
|
| 1727 |
|
| 1728 |
void SetIndent( const char* _indent ) { indent = _indent ? _indent : "" ; } |
| 1729 |
|
| 1730 |
const char* Indent() { return indent.c_str(); } |
| 1731 |
|
| 1732 |
|
| 1733 |
|
| 1734 |
|
| 1735 |
void SetLineBreak( const char* _lineBreak ) { lineBreak = _lineBreak ? _lineBreak : ""; } |
| 1736 |
|
| 1737 |
const char* LineBreak() { return lineBreak.c_str(); } |
| 1738 |
|
| 1739 |
|
| 1740 |
|
| 1741 |
|
| 1742 |
void SetStreamPrinting() { indent = ""; |
| 1743 |
lineBreak = ""; |
| 1744 |
} |
| 1745 |
|
| 1746 |
const char* CStr() { return buffer.c_str(); } |
| 1747 |
|
| 1748 |
size_t Size() { return buffer.size(); } |
| 1749 |
|
| 1750 |
#ifdef TIXML_USE_STL |
| 1751 |
|
| 1752 |
const std::string& Str() { return buffer; } |
| 1753 |
#endif |
| 1754 |
|
| 1755 |
private: |
| 1756 |
void DoIndent() { |
| 1757 |
for( int i=0; i<depth; ++i ) |
| 1758 |
buffer += indent; |
| 1759 |
} |
| 1760 |
void DoLineBreak() { |
| 1761 |
buffer += lineBreak; |
| 1762 |
} |
| 1763 |
|
| 1764 |
int depth; |
| 1765 |
bool simpleTextPrint; |
| 1766 |
TIXML_STRING buffer; |
| 1767 |
TIXML_STRING indent; |
| 1768 |
TIXML_STRING lineBreak; |
| 1769 |
}; |
| 1770 |
|
| 1771 |
|
| 1772 |
#ifdef _MSC_VER |
| 1773 |
#pragma warning( pop ) |
| 1774 |
#endif |
| 1775 |
|
| 1776 |
#endif |
| 1777 |
|