- Timestamp:
- Dec 31, 2007, 1:32:53 AM (17 years ago)
- Location:
- code/branches/FICN/src/tinyxml
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/tinyxml/tinyxml.cc
r738 r740 22 22 distribution. 23 23 */ 24 #include "tinyxml.h" 24 25 25 26 #include <ctype.h> … … 29 30 #include <iostream> 30 31 #endif 31 32 #include "tinyxml.h"33 32 34 33 … … 1467 1466 } 1468 1467 1468 TiXmlStylesheetReference::TiXmlStylesheetReference( const char * _type, 1469 const char * _href ) 1470 : TiXmlNode( TiXmlNode::STYLESHEETREFERENCE ) 1471 { 1472 type = _type; 1473 href = _href; 1474 } 1475 1476 1477 #ifdef TIXML_USE_STL 1478 TiXmlStylesheetReference::TiXmlStylesheetReference( const std::string& _type, 1479 const std::string& _href ) 1480 : TiXmlNode( TiXmlNode::STYLESHEETREFERENCE ) 1481 { 1482 type = _type; 1483 href = _href; 1484 } 1485 #endif 1486 1487 1488 TiXmlStylesheetReference::TiXmlStylesheetReference( const TiXmlStylesheetReference& copy ) 1489 : TiXmlNode( TiXmlNode::STYLESHEETREFERENCE ) 1490 { 1491 copy.CopyTo( this ); 1492 } 1493 1494 1495 void TiXmlStylesheetReference::operator=( const TiXmlStylesheetReference& copy ) 1496 { 1497 Clear(); 1498 copy.CopyTo( this ); 1499 } 1500 1501 1502 void TiXmlStylesheetReference::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const 1503 { 1504 if ( cfile ) fprintf( cfile, "<?xml-stylesheet " ); 1505 if ( str ) (*str) += "<?xml-stylesheet "; 1506 1507 if ( !type.empty() ) { 1508 if ( cfile ) fprintf (cfile, "type=\"%s\" ", type.c_str ()); 1509 if ( str ) { (*str) += "type=\""; (*str) += type; (*str) += "\" "; } 1510 } 1511 if ( !href.empty() ) { 1512 if ( cfile ) fprintf (cfile, "href=\"%s\" ", href.c_str ()); 1513 if ( str ) { (*str) += "href=\""; (*str) += href; (*str) += "\" "; } 1514 } 1515 if ( cfile ) fprintf (cfile, "?>"); 1516 if ( str ) (*str) += "?>"; 1517 } 1518 1519 void TiXmlStylesheetReference::CopyTo( TiXmlStylesheetReference* target ) const 1520 { 1521 TiXmlNode::CopyTo( target ); 1522 1523 target->type = type; 1524 target->href = href; 1525 } 1526 1527 bool TiXmlStylesheetReference::Accept( TiXmlVisitor* visitor ) const 1528 { 1529 return visitor->Visit( *this ); 1530 } 1531 1532 TiXmlNode* TiXmlStylesheetReference::Clone() const 1533 { 1534 TiXmlStylesheetReference* clone = new TiXmlStylesheetReference(); 1535 1536 if ( !clone ) 1537 return 0; 1538 1539 CopyTo( clone ); 1540 return clone; 1541 } 1469 1542 1470 1543 void TiXmlUnknown::Print( FILE* cfile, int depth ) const -
code/branches/FICN/src/tinyxml/tinyxml.h
r738 r740 42 42 #if defined( _DEBUG ) && !defined( DEBUG ) 43 43 #define DEBUG 44 #endif 45 46 #ifdef TIXML_USE_TICPP 47 #ifndef TIXML_USE_STL 48 #define TIXML_USE_STL 49 #endif 44 50 #endif 45 51 … … 81 87 #define TIXML_SSCANF sscanf 82 88 #endif 83 #endif 89 #endif 84 90 85 91 class TiXmlDocument; … … 90 96 class TiXmlText; 91 97 class TiXmlDeclaration; 98 class TiXmlStylesheetReference; 92 99 class TiXmlParsingData; 93 100 … … 96 103 const int TIXML_PATCH_VERSION = 3; 97 104 98 /* Internal structure for tracking location of items 105 /* Internal structure for tracking location of items 99 106 in the XML file. 100 107 */ … … 118 125 false, <b>no children of this node or its sibilings</b> will be Visited. 119 126 120 All flavors of Visit methods have a default implementation that returns 'true' (continue 127 All flavors of Visit methods have a default implementation that returns 'true' (continue 121 128 visiting). You need to only override methods that are interesting to you. 122 129 … … 144 151 /// Visit a declaration 145 152 virtual bool Visit( const TiXmlDeclaration& /*declaration*/ ) { return true; } 153 /// Visit a stylesheet reference 154 virtual bool Visit( const TiXmlStylesheetReference& /*stylesheet*/ ) { return true; } 146 155 /// Visit a text node 147 156 virtual bool Visit( const TiXmlText& /*text*/ ) { return true; } … … 153 162 154 163 // Only used by Attribute::Query functions 155 enum 156 { 164 enum 165 { 157 166 TIXML_SUCCESS, 158 167 TIXML_NO_ATTRIBUTE, … … 193 202 @endverbatim 194 203 */ 204 #ifdef TIXML_USE_TICPP 205 #include "ticpprc.h" 206 class TiXmlBase : public TiCppRC 207 #else 195 208 class TiXmlBase 209 #endif 196 210 { 197 211 friend class TiXmlNode; … … 206 220 or the string class (TiXmlString in non-STL mode, std::string 207 221 in STL mode.) Either or both cfile and str can be null. 208 209 This is a formatted print, and will insert 222 223 This is a formatted print, and will insert 210 224 tabs and newlines. 211 225 212 226 (For an unformatted stream, use the << operator.) 213 227 */ … … 254 268 static const int utf8ByteTable[256]; 255 269 256 virtual const char* Parse( const char* p, 257 TiXmlParsingData* data, 270 virtual const char* Parse( const char* p, 271 TiXmlParsingData* data, 258 272 TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0; 259 273 260 /** Expands entities in a string. Note this should not contian the tag's '<', '>', etc, 274 /** Expands entities in a string. Note this should not contian the tag's '<', '>', etc, 261 275 or they will be transformed into entities! 262 276 */ … … 289 303 290 304 static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding ); 291 inline static bool IsWhiteSpace( char c ) 292 { 293 return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' ); 305 inline static bool IsWhiteSpace( char c ) 306 { 307 return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' ); 294 308 } 295 309 inline static bool IsWhiteSpace( int c ) … … 376 390 /// Field containing a generic user pointer 377 391 void* userData; 378 392 379 393 // None of these methods are reliable for any language except English. 380 394 // Good for approximation, not great for accuracy. … … 428 442 429 443 public: 430 #ifdef TIXML_USE_STL 444 #ifdef TIXML_USE_STL 431 445 432 446 /** An input stream operator, for every class. Tolerant of newlines and … … 442 456 a node to a stream is very well defined. You'll get a nice stream 443 457 of output, without any extra whitespace or newlines. 444 458 445 459 But reading is not as well defined. (As it always is.) If you create 446 460 a TiXmlElement (for example) and read that from an input stream, … … 450 464 A TiXmlDocument will read nodes until it reads a root element, and 451 465 all the children of that root element. 452 */ 466 */ 453 467 friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base); 454 468 … … 469 483 TEXT, 470 484 DECLARATION, 485 STYLESHEETREFERENCE, 471 486 TYPECOUNT 472 487 }; … … 532 547 const TiXmlNode* LastChild() const { return lastChild; } /// The last child of this node. Will be null if there are no children. 533 548 TiXmlNode* LastChild() { return lastChild; } 534 549 535 550 const TiXmlNode* LastChild( const char * value ) const; /// The last child of this node matching 'value'. Will be null if there are no children. 536 551 TiXmlNode* LastChild( const char * _value ) { … … 702 717 virtual const TiXmlText* ToText() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. 703 718 virtual const TiXmlDeclaration* ToDeclaration() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. 719 virtual const TiXmlStylesheetReference* ToStylesheetReference() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. 704 720 705 721 virtual TiXmlDocument* ToDocument() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. … … 709 725 virtual TiXmlText* ToText() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. 710 726 virtual TiXmlDeclaration* ToDeclaration() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. 727 virtual TiXmlStylesheetReference* ToStylesheetReference() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. 711 728 712 729 /** Create an exact duplicate of this node and return it. The memory must be deleted 713 by the caller. 730 by the caller. 714 731 */ 715 732 virtual TiXmlNode* Clone() const = 0; 716 733 717 /** Accept a hierchical visit the nodes in the TinyXML DOM. Every node in the 734 /** Accept a hierchical visit the nodes in the TinyXML DOM. Every node in the 718 735 XML tree will be conditionally visited and the host will be called back 719 736 via the TiXmlVisitor interface. … … 726 743 727 744 - http://www.saxproject.org/ 728 - http://c2.com/cgi/wiki?HierarchicalVisitorPattern 745 - http://c2.com/cgi/wiki?HierarchicalVisitorPattern 729 746 730 747 Which are both good references for "visiting". … … 823 840 /** QueryIntValue examines the value string. It is an alternative to the 824 841 IntValue() method with richer error checking. 825 If the value is an integer, it is stored in 'value' and 842 If the value is an integer, it is stored in 'value' and 826 843 the call returns TIXML_SUCCESS. If it is not 827 844 an integer, it returns TIXML_WRONG_TYPE. … … 842 859 #ifdef TIXML_USE_STL 843 860 /// STL std::string form. 844 void SetName( const std::string& _name ) { name = _name; } 845 /// STL std::string form. 861 void SetName( const std::string& _name ) { name = _name; } 862 /// STL std::string form. 846 863 void SetValue( const std::string& _value ) { value = _value; } 847 864 #endif … … 850 867 const TiXmlAttribute* Next() const; 851 868 TiXmlAttribute* Next() { 852 return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() ); 869 return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() ); 853 870 } 854 871 … … 856 873 const TiXmlAttribute* Previous() const; 857 874 TiXmlAttribute* Previous() { 858 return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() ); 875 return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() ); 859 876 } 860 877 … … 892 909 /* A class used to manage a group of attributes. 893 910 It is only used internally, both by the ELEMENT and the DECLARATION. 894 911 895 912 The set can be changed transparent to the Element and Declaration 896 913 classes that use it, but NOT transparent to the Attribute … … 982 999 /** QueryIntAttribute examines the attribute - it is an alternative to the 983 1000 Attribute() method with richer error checking. 984 If the attribute is an integer, it is stored in 'value' and 1001 If the attribute is an integer, it is stored in 'value' and 985 1002 the call returns TIXML_SUCCESS. If it is not 986 1003 an integer, it returns TIXML_WRONG_TYPE. If the attribute 987 1004 does not exist, then TIXML_NO_ATTRIBUTE is returned. 988 */ 1005 */ 989 1006 int QueryIntAttribute( const char* name, int* _value ) const; 990 1007 /// QueryDoubleAttribute examines the attribute - see QueryIntAttribute(). … … 1004 1021 attribute into the specified type. Very easy, very powerful, but 1005 1022 be careful to make sure to call this with the correct type. 1006 1023 1007 1024 NOTE: This method doesn't work correctly for 'string' types. 1008 1025 … … 1024 1041 This is - in theory - a bug fix for "QueryValueAtribute returns truncated std::string" 1025 1042 but template specialization is hard to get working cross-compiler. Leaving the bug for now. 1026 1043 1027 1044 // The above will fail for std::string because the space character is used as a seperator. 1028 1045 // Specialize for strings. Bug [ 1695429 ] QueryValueAtribute returns truncated std::string … … 1081 1098 and concise, GetText() is limited compared to getting the TiXmlText child 1082 1099 and accessing it directly. 1083 1100 1084 1101 If the first child of 'this' is a TiXmlText, the GetText() 1085 1102 returns the character string of the Text node, else null is returned. … … 1091 1108 @endverbatim 1092 1109 1093 'str' will be a pointer to "This is text". 1094 1110 'str' will be a pointer to "This is text". 1111 1095 1112 Note that this function can be misleading. If the element foo was created from 1096 1113 this XML: 1097 1114 @verbatim 1098 <foo><b>This is text</b></foo> 1115 <foo><b>This is text</b></foo> 1099 1116 @endverbatim 1100 1117 … … 1102 1119 another element. From this XML: 1103 1120 @verbatim 1104 <foo>This is <b>text</b></foo> 1121 <foo>This is <b>text</b></foo> 1105 1122 @endverbatim 1106 1123 GetText() will return "This is ". 1107 1124 1108 WARNING: GetText() accesses a child node - don't become confused with the 1109 similarly named TiXmlHandle::Text() and TiXmlNode::ToText() which are 1125 WARNING: GetText() accesses a child node - don't become confused with the 1126 similarly named TiXmlHandle::Text() and TiXmlNode::ToText() which are 1110 1127 safe type casts on the referenced node. 1111 1128 */ … … 1125 1142 virtual TiXmlElement* ToElement() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. 1126 1143 1127 /** Walk the XML tree visiting this node and all of its children. 1144 /** Walk the XML tree visiting this node and all of its children. 1128 1145 */ 1129 1146 virtual bool Accept( TiXmlVisitor* visitor ) const; … … 1179 1196 virtual TiXmlComment* ToComment() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. 1180 1197 1181 /** Walk the XML tree visiting this node and all of its children. 1198 /** Walk the XML tree visiting this node and all of its children. 1182 1199 */ 1183 1200 virtual bool Accept( TiXmlVisitor* visitor ) const; … … 1197 1214 1198 1215 1199 /** XML text. A text node can have 2 ways to output the next. "normal" output 1216 /** XML text. A text node can have 2 ways to output the next. "normal" output 1200 1217 and CDATA. It will default to the mode it was parsed from the XML file and 1201 you generally want to leave it alone, but you can change the output mode with 1218 you generally want to leave it alone, but you can change the output mode with 1202 1219 SetCDATA() and query it with CDATA(). 1203 1220 */ … … 1206 1223 friend class TiXmlElement; 1207 1224 public: 1208 /** Constructor for text element. By default, it is treated as 1225 /** Constructor for text element. By default, it is treated as 1209 1226 normal, encoded text. If you want it be output as a CDATA text 1210 1227 element, set the parameter _cdata to 'true' … … 1242 1259 virtual TiXmlText* ToText() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. 1243 1260 1244 /** Walk the XML tree visiting this node and all of its children. 1261 /** Walk the XML tree visiting this node and all of its children. 1245 1262 */ 1246 1263 virtual bool Accept( TiXmlVisitor* content ) const; … … 1318 1335 virtual TiXmlDeclaration* ToDeclaration() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. 1319 1336 1320 /** Walk the XML tree visiting this node and all of its children. 1337 /** Walk the XML tree visiting this node and all of its children. 1321 1338 */ 1322 1339 virtual bool Accept( TiXmlVisitor* visitor ) const; … … 1336 1353 }; 1337 1354 1355 /** A stylesheet reference looks like this: 1356 @verbatim 1357 <?xml-stylesheet type="text/xsl" href="style.xsl"?> 1358 @endverbatim 1359 1360 Note: In this version of the code, the attributes are 1361 handled as special cases, not generic attributes, simply 1362 because there can only be at most 2 and they are always the same. 1363 */ 1364 class TiXmlStylesheetReference : public TiXmlNode 1365 { 1366 public: 1367 /// Construct an empty declaration. 1368 TiXmlStylesheetReference() : TiXmlNode( TiXmlNode::STYLESHEETREFERENCE ) {} 1369 1370 #ifdef TIXML_USE_STL 1371 /// Constructor. 1372 TiXmlStylesheetReference( const std::string& _type, 1373 const std::string& _href ); 1374 #endif 1375 1376 /// Construct. 1377 TiXmlStylesheetReference( const char* _type, 1378 const char* _href ); 1379 1380 TiXmlStylesheetReference( const TiXmlStylesheetReference& copy ); 1381 void operator=( const TiXmlStylesheetReference& copy ); 1382 1383 virtual ~TiXmlStylesheetReference() {} 1384 1385 /// Type. Will return an empty string if none was found. 1386 const char *Type() const { return type.c_str (); } 1387 /// Href. Will return an empty string if none was found. 1388 const char *Href() const { return href.c_str (); } 1389 1390 /// Creates a copy of this StylesheetReference and returns it. 1391 virtual TiXmlNode* Clone() const; 1392 // Print this declaration to a FILE stream. 1393 virtual void Print( FILE* cfile, int depth, TIXML_STRING* str ) const; 1394 virtual void Print( FILE* cfile, int depth ) const { 1395 Print( cfile, depth, 0 ); 1396 } 1397 1398 virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); 1399 1400 virtual const TiXmlStylesheetReference* ToStylesheetReference() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. 1401 virtual TiXmlStylesheetReference* ToStylesheetReference() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. 1402 1403 /** Walk the XML tree visiting this node and all of its children. 1404 */ 1405 virtual bool Accept( TiXmlVisitor* visitor ) const; 1406 1407 protected: 1408 void CopyTo( TiXmlStylesheetReference* target ) const; 1409 // used to be public 1410 #ifdef TIXML_USE_STL 1411 virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); 1412 #endif 1413 1414 private: 1415 1416 TIXML_STRING type; 1417 TIXML_STRING href; 1418 }; 1338 1419 1339 1420 /** Any tag that tinyXml doesn't recognize is saved as an … … 1363 1444 virtual TiXmlUnknown* ToUnknown() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. 1364 1445 1365 /** Walk the XML tree visiting this node and all of its children. 1446 /** Walk the XML tree visiting this node and all of its children. 1366 1447 */ 1367 1448 virtual bool Accept( TiXmlVisitor* content ) const; … … 1453 1534 - The ErrorDesc() method will return the name of the error. (very useful) 1454 1535 - The ErrorRow() and ErrorCol() will return the location of the error (if known) 1455 */ 1536 */ 1456 1537 bool Error() const { return error; } 1457 1538 … … 1464 1545 int ErrorId() const { return errorId; } 1465 1546 1466 /** Returns the location (if known) of the error. The first column is column 1, 1547 /** Returns the location (if known) of the error. The first column is column 1, 1467 1548 and the first row is row 1. A value of 0 means the row and column wasn't applicable 1468 1549 (memory errors, for example, have no row/column) or the parser lost the error. (An … … 1477 1558 to report the correct values for row and column. It does not change the output 1478 1559 or input in any way. 1479 1560 1480 1561 By calling this method, with a tab size 1481 1562 greater than 0, the row and column of each node and attribute is stored … … 1505 1586 state is automatically cleared if you Parse a new XML block. 1506 1587 */ 1507 void ClearError() { error = false; 1508 errorId = 0; 1509 errorDesc = ""; 1510 errorLocation.row = errorLocation.col = 0; 1511 //errorLocation.last = 0; 1588 void ClearError() { error = false; 1589 errorId = 0; 1590 errorDesc = ""; 1591 errorLocation.row = errorLocation.col = 0; 1592 //errorLocation.last = 0; 1512 1593 } 1513 1594 … … 1519 1600 calling code pust call delete[] on the return char* to avoid a memory leak. 1520 1601 */ 1521 //char* PrintToMemory() const; 1602 //char* PrintToMemory() const; 1522 1603 1523 1604 /// Print this Document to a FILE stream. … … 1529 1610 virtual TiXmlDocument* ToDocument() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. 1530 1611 1531 /** Walk the XML tree visiting this node and all of its children. 1612 /** Walk the XML tree visiting this node and all of its children. 1532 1613 */ 1533 1614 virtual bool Accept( TiXmlVisitor* content ) const; … … 1567 1648 @endverbatim 1568 1649 1569 Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very 1650 Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very 1570 1651 easy to write a *lot* of code that looks like: 1571 1652 … … 1587 1668 1588 1669 And that doesn't even cover "else" cases. TiXmlHandle addresses the verbosity 1589 of such code. A TiXmlHandle checks for null pointers so it is perfectly safe 1670 of such code. A TiXmlHandle checks for null pointers so it is perfectly safe 1590 1671 and correct to use: 1591 1672 … … 1608 1689 1609 1690 @verbatim 1610 int i=0; 1691 int i=0; 1611 1692 while ( true ) 1612 1693 { … … 1619 1700 @endverbatim 1620 1701 1621 It seems reasonable, but it is in fact two embedded while loops. The Child method is 1622 a linear walk to find the element, so this code would iterate much more than it needs 1702 It seems reasonable, but it is in fact two embedded while loops. The Child method is 1703 a linear walk to find the element, so this code would iterate much more than it needs 1623 1704 to. Instead, prefer: 1624 1705 … … 1650 1731 TiXmlHandle FirstChildElement( const char * value ) const; 1651 1732 1652 /** Return a handle to the "index" child with the given name. 1733 /** Return a handle to the "index" child with the given name. 1653 1734 The first child is 0, the second 1, etc. 1654 1735 */ 1655 1736 TiXmlHandle Child( const char* value, int index ) const; 1656 /** Return a handle to the "index" child. 1737 /** Return a handle to the "index" child. 1657 1738 The first child is 0, the second 1, etc. 1658 1739 */ 1659 1740 TiXmlHandle Child( int index ) const; 1660 /** Return a handle to the "index" child element with the given name. 1741 /** Return a handle to the "index" child element with the given name. 1661 1742 The first child element is 0, the second 1, etc. Note that only TiXmlElements 1662 1743 are indexed: other types are not counted. 1663 1744 */ 1664 1745 TiXmlHandle ChildElement( const char* value, int index ) const; 1665 /** Return a handle to the "index" child element. 1746 /** Return a handle to the "index" child element. 1666 1747 The first child element is 0, the second 1, etc. Note that only TiXmlElements 1667 1748 are indexed: other types are not counted. … … 1679 1760 /** Return the handle as a TiXmlNode. This may return null. 1680 1761 */ 1681 TiXmlNode* ToNode() const { return node; } 1762 TiXmlNode* ToNode() const { return node; } 1682 1763 /** Return the handle as a TiXmlElement. This may return null. 1683 1764 */ … … 1690 1771 TiXmlUnknown* ToUnknown() const { return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); } 1691 1772 1692 /** @deprecated use ToNode. 1773 /** @deprecated use ToNode. 1693 1774 Return the handle as a TiXmlNode. This may return null. 1694 1775 */ 1695 TiXmlNode* Node() const { return ToNode(); } 1696 /** @deprecated use ToElement. 1776 TiXmlNode* Node() const { return ToNode(); } 1777 /** @deprecated use ToElement. 1697 1778 Return the handle as a TiXmlElement. This may return null. 1698 1779 */ … … 1754 1835 /// Query the indention string. 1755 1836 const char* Indent() { return indent.c_str(); } 1756 /** Set the line breaking string. By default set to newline (\n). 1837 /** Set the line breaking string. By default set to newline (\n). 1757 1838 Some operating systems prefer other characters, or can be 1758 1839 set to the null/empty string for no indenation. … … 1762 1843 const char* LineBreak() { return lineBreak.c_str(); } 1763 1844 1764 /** Switch over to "stream printing" which is the most dense formatting without 1845 /** Switch over to "stream printing" which is the most dense formatting without 1765 1846 linebreaks. Common when the XML is needed for network transmission. 1766 1847 */ 1767 1848 void SetStreamPrinting() { indent = ""; 1768 1849 lineBreak = ""; 1769 } 1850 } 1770 1851 /// Return the result. 1771 1852 const char* CStr() { return buffer.c_str(); } -
code/branches/FICN/src/tinyxml/tinyxmlerror.cc
r738 r740 3 3 Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) 4 4 5 This software is provided 'as-is', without any express or implied 6 warranty. In no event will the authors be held liable for any 5 This software is provided 'as-is', without any express or implied 6 warranty. In no event will the authors be held liable for any 7 7 damages arising from the use of this software. 8 8 9 Permission is granted to anyone to use this software for any 10 purpose, including commercial applications, and to alter it and 9 Permission is granted to anyone to use this software for any 10 purpose, including commercial applications, and to alter it and 11 11 redistribute it freely, subject to the following restrictions: 12 12 -
code/branches/FICN/src/tinyxml/tinyxmlparser.cc
r738 r740 838 838 // - Comments: <!-- 839 839 // - Decleration: <?xml 840 // - StylesheetReference <?xml-stylesheet 840 841 // - Everthing else is unknown to tinyxml. 841 842 // 842 843 843 844 const char* xmlHeader = { "<?xml" }; 845 const char* xmlSSHeader = { "<?xml-stylesheet" }; 844 846 const char* commentHeader = { "<!--" }; 845 847 const char* dtdHeader = { "<!" }; 846 848 const char* cdataHeader = { "<![CDATA[" }; 847 849 848 if ( StringEqual( p, xmlHeader, true, encoding ) ) 850 if ( StringEqual( p, xmlSSHeader, true, encoding ) ) 851 { 852 #ifdef DEBUG_PARSER 853 TIXML_LOG( "XML parsing Stylesheet Reference\n" ); 854 #endif 855 returnNode = new TiXmlStylesheetReference(); 856 } 857 else if ( StringEqual( p, xmlHeader, true, encoding ) ) 849 858 { 850 859 #ifdef DEBUG_PARSER … … 1637 1646 } 1638 1647 1648 #ifdef TIXML_USE_STL 1649 void TiXmlStylesheetReference::StreamIn( std::istream * in, TIXML_STRING * tag ) 1650 { 1651 while ( in->good() ) 1652 { 1653 int c = in->get(); 1654 if ( c <= 0 ) 1655 { 1656 TiXmlDocument* document = GetDocument(); 1657 if ( document ) 1658 document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); 1659 return; 1660 } 1661 (*tag) += (char) c; 1662 1663 if ( c == '>' ) 1664 { 1665 // All is well. 1666 return; 1667 } 1668 } 1669 } 1670 #endif 1671 1672 const char* TiXmlStylesheetReference::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding _encoding ) 1673 { 1674 p = SkipWhiteSpace( p, _encoding ); 1675 // Find the beginning, find the end, and look for 1676 // the stuff in-between. 1677 TiXmlDocument* document = GetDocument(); 1678 if ( !p || !*p || !StringEqual( p, "<?xml-stylesheet", true, _encoding ) ) 1679 { 1680 if ( document ) document->SetError( TIXML_ERROR_PARSING_DECLARATION, 0, 0, _encoding ); 1681 return 0; 1682 } 1683 if ( data ) 1684 { 1685 data->Stamp( p, _encoding ); 1686 location = data->Cursor(); 1687 } 1688 p += 5; 1689 1690 type = ""; 1691 href = ""; 1692 1693 while ( p && *p ) 1694 { 1695 if ( *p == '>' ) 1696 { 1697 ++p; 1698 return p; 1699 } 1700 1701 p = SkipWhiteSpace( p, _encoding ); 1702 if ( StringEqual( p, "type", true, _encoding ) ) 1703 { 1704 TiXmlAttribute attrib; 1705 p = attrib.Parse( p, data, _encoding ); 1706 type = attrib.Value(); 1707 } 1708 else if ( StringEqual( p, "href", true, _encoding ) ) 1709 { 1710 TiXmlAttribute attrib; 1711 p = attrib.Parse( p, data, _encoding ); 1712 href = attrib.Value(); 1713 } 1714 else 1715 { 1716 // Read over whatever it is. 1717 while( p && *p && *p != '>' && !IsWhiteSpace( *p ) ) 1718 ++p; 1719 } 1720 } 1721 return 0; 1722 }
Note: See TracChangeset
for help on using the changeset viewer.