#include <tinyxml.h>
Inheritance diagram for TiXmlNode:

Public Types | |
| enum | NodeType { DOCUMENT, ELEMENT, COMMENT, UNKNOWN, TEXT, DECLARATION, TYPECOUNT } |
Public Member Functions | |
| virtual | ~TiXmlNode () |
| const char * | Value () const |
| const std::string & | ValueStr () const |
| void | SetValue (const char *_value) |
| void | SetValue (const std::string &_value) |
| STL std::string form. | |
| void | Clear () |
| Delete all the children of this node. Does not affect 'this'. | |
| TiXmlNode * | Parent () |
| One step up the DOM. | |
| const TiXmlNode * | Parent () const |
| const TiXmlNode * | FirstChild () const |
| The first child of this node. Will be null if there are no children. | |
| TiXmlNode * | FirstChild () |
| const TiXmlNode * | FirstChild (const char *value) const |
| TiXmlNode * | FirstChild (const char *_value) |
| The first child of this node with the matching 'value'. Will be null if none found. | |
| const TiXmlNode * | LastChild () const |
| TiXmlNode * | LastChild () |
| The last child of this node. Will be null if there are no children. | |
| const TiXmlNode * | LastChild (const char *value) const |
| TiXmlNode * | LastChild (const char *_value) |
| The last child of this node matching 'value'. Will be null if there are no children. | |
| const TiXmlNode * | FirstChild (const std::string &_value) const |
| STL std::string form. | |
| TiXmlNode * | FirstChild (const std::string &_value) |
| STL std::string form. | |
| const TiXmlNode * | LastChild (const std::string &_value) const |
| STL std::string form. | |
| TiXmlNode * | LastChild (const std::string &_value) |
| STL std::string form. | |
| const TiXmlNode * | IterateChildren (const TiXmlNode *previous) const |
| TiXmlNode * | IterateChildren (const TiXmlNode *previous) |
| const TiXmlNode * | IterateChildren (const char *value, const TiXmlNode *previous) const |
| This flavor of IterateChildren searches for children with a particular 'value'. | |
| TiXmlNode * | IterateChildren (const char *_value, const TiXmlNode *previous) |
| const TiXmlNode * | IterateChildren (const std::string &_value, const TiXmlNode *previous) const |
| STL std::string form. | |
| TiXmlNode * | IterateChildren (const std::string &_value, const TiXmlNode *previous) |
| STL std::string form. | |
| TiXmlNode * | InsertEndChild (const TiXmlNode &addThis) |
| TiXmlNode * | LinkEndChild (TiXmlNode *addThis) |
| TiXmlNode * | InsertBeforeChild (TiXmlNode *beforeThis, const TiXmlNode &addThis) |
| TiXmlNode * | InsertAfterChild (TiXmlNode *afterThis, const TiXmlNode &addThis) |
| TiXmlNode * | ReplaceChild (TiXmlNode *replaceThis, const TiXmlNode &withThis) |
| bool | RemoveChild (TiXmlNode *removeThis) |
| Delete a child of this node. | |
| const TiXmlNode * | PreviousSibling () const |
| Navigate to a sibling node. | |
| TiXmlNode * | PreviousSibling () |
| const TiXmlNode * | PreviousSibling (const char *) const |
| Navigate to a sibling node. | |
| TiXmlNode * | PreviousSibling (const char *_prev) |
| const TiXmlNode * | PreviousSibling (const std::string &_value) const |
| STL std::string form. | |
| TiXmlNode * | PreviousSibling (const std::string &_value) |
| STL std::string form. | |
| const TiXmlNode * | NextSibling (const std::string &_value) const |
| STL std::string form. | |
| TiXmlNode * | NextSibling (const std::string &_value) |
| STL std::string form. | |
| const TiXmlNode * | NextSibling () const |
| Navigate to a sibling node. | |
| TiXmlNode * | NextSibling () |
| const TiXmlNode * | NextSibling (const char *) const |
| Navigate to a sibling node with the given 'value'. | |
| TiXmlNode * | NextSibling (const char *_next) |
| const TiXmlElement * | NextSiblingElement () const |
| TiXmlElement * | NextSiblingElement () |
| const TiXmlElement * | NextSiblingElement (const char *) const |
| TiXmlElement * | NextSiblingElement (const char *_next) |
| const TiXmlElement * | NextSiblingElement (const std::string &_value) const |
| STL std::string form. | |
| TiXmlElement * | NextSiblingElement (const std::string &_value) |
| STL std::string form. | |
| const TiXmlElement * | FirstChildElement () const |
| Convenience function to get through elements. | |
| TiXmlElement * | FirstChildElement () |
| const TiXmlElement * | FirstChildElement (const char *_value) const |
| Convenience function to get through elements. | |
| TiXmlElement * | FirstChildElement (const char *_value) |
| const TiXmlElement * | FirstChildElement (const std::string &_value) const |
| STL std::string form. | |
| TiXmlElement * | FirstChildElement (const std::string &_value) |
| STL std::string form. | |
| int | Type () const |
| const TiXmlDocument * | GetDocument () const |
| TiXmlDocument * | GetDocument () |
| bool | NoChildren () const |
| Returns true if this node has no children. | |
| virtual const TiXmlDocument * | ToDocument () const |
| Cast to a more defined type. Will return null if not of the requested type. | |
| virtual const TiXmlElement * | ToElement () const |
| Cast to a more defined type. Will return null if not of the requested type. | |
| virtual const TiXmlComment * | ToComment () const |
| Cast to a more defined type. Will return null if not of the requested type. | |
| virtual const TiXmlUnknown * | ToUnknown () const |
| Cast to a more defined type. Will return null if not of the requested type. | |
| virtual const TiXmlText * | ToText () const |
| Cast to a more defined type. Will return null if not of the requested type. | |
| virtual const TiXmlDeclaration * | ToDeclaration () const |
| Cast to a more defined type. Will return null if not of the requested type. | |
| virtual TiXmlDocument * | ToDocument () |
| Cast to a more defined type. Will return null if not of the requested type. | |
| virtual TiXmlElement * | ToElement () |
| Cast to a more defined type. Will return null if not of the requested type. | |
| virtual TiXmlComment * | ToComment () |
| Cast to a more defined type. Will return null if not of the requested type. | |
| virtual TiXmlUnknown * | ToUnknown () |
| Cast to a more defined type. Will return null if not of the requested type. | |
| virtual TiXmlText * | ToText () |
| Cast to a more defined type. Will return null if not of the requested type. | |
| virtual TiXmlDeclaration * | ToDeclaration () |
| Cast to a more defined type. Will return null if not of the requested type. | |
| virtual TiXmlNode * | Clone () const =0 |
| virtual bool | Accept (TiXmlVisitor *visitor) const =0 |
Protected Member Functions | |
| TiXmlNode (NodeType _type) | |
| void | CopyTo (TiXmlNode *target) const |
| virtual void | StreamIn (std::istream *in, TIXML_STRING *tag)=0 |
| TiXmlNode * | Identify (const char *start, TiXmlEncoding encoding) |
Protected Attributes | |
| TiXmlNode * | parent |
| NodeType | type |
| TiXmlNode * | firstChild |
| TiXmlNode * | lastChild |
| TIXML_STRING | value |
| TiXmlNode * | prev |
| TiXmlNode * | next |
Private Member Functions | |
| TiXmlNode (const TiXmlNode &) | |
| void | operator= (const TiXmlNode &base) |
Friends | |
| class | TiXmlDocument |
| class | TiXmlElement |
| std::istream & | operator>> (std::istream &in, TiXmlNode &base) |
| std::ostream & | operator<< (std::ostream &out, const TiXmlNode &base) |
| std::string & | operator<< (std::string &out, const TiXmlNode &base) |
| Appends the XML node or attribute to a std::string. | |
Definition at line 423 of file tinyxml.h.
|
|
The types of XML nodes supported by TinyXml. (All the unsupported types are picked up by UNKNOWN.) Definition at line 462 of file tinyxml.h. 00463 {
00464 DOCUMENT,
00465 ELEMENT,
00466 COMMENT,
00467 UNKNOWN,
00468 TEXT,
00469 DECLARATION,
00470 TYPECOUNT
00471 };
|
|
|
Definition at line 132 of file tinyxml.cpp. References next. 00133 {
00134 TiXmlNode* node = firstChild;
00135 TiXmlNode* temp = 0;
00136
00137 while ( node )
00138 {
00139 temp = node;
00140 node = node->next;
00141 delete temp;
00142 }
00143 }
|
|
|
Definition at line 121 of file tinyxml.cpp. References firstChild, lastChild, next, parent, prev, and type. 00121 : TiXmlBase() 00122 { 00123 parent = 0; 00124 type = _type; 00125 firstChild = 0; 00126 lastChild = 0; 00127 prev = 0; 00128 next = 0; 00129 }
|
|
|
|
|
|
Accept a hierchical visit the nodes in the TinyXML DOM. Every node in the XML tree will be conditionally visited and the host will be called back via the TiXmlVisitor interface. This is essentially a SAX interface for TinyXML. (Note however it doesn't re-parse the XML for the callbacks, so the performance of TinyXML is unchanged by using this interface versus any other.) The interface has been based on ideas from:
Which are both good references for "visiting". An example of using Accept(): TiXmlPrinter printer; tinyxmlDoc.Accept( &printer ); const char* xmlcstr = printer.CStr(); Implemented in TiXmlElement, TiXmlComment, TiXmlText, TiXmlDeclaration, TiXmlUnknown, and TiXmlDocument. Referenced by TiXmlDocument::Accept(), TiXmlElement::Accept(), and operator<<(). |
|
|
Delete all the children of this node. Does not affect 'this'.
Definition at line 153 of file tinyxml.cpp. References firstChild, lastChild, and next. Referenced by TiXmlElement::ClearThis(), TiXmlDocument::LoadFile(), TiXmlDeclaration::operator=(), TiXmlComment::operator=(), and TiXmlDocument::operator=(). 00154 {
00155 TiXmlNode* node = firstChild;
00156 TiXmlNode* temp = 0;
00157
00158 while ( node )
00159 {
00160 temp = node;
00161 node = node->next;
00162 delete temp;
00163 }
00164
00165 firstChild = 0;
00166 lastChild = 0;
00167 }
|
|
|
Create an exact duplicate of this node and return it. The memory must be deleted by the caller. Implemented in TiXmlElement, TiXmlComment, TiXmlText, TiXmlDeclaration, TiXmlUnknown, and TiXmlDocument. Referenced by TiXmlDocument::CopyTo(), TiXmlElement::CopyTo(), InsertAfterChild(), InsertBeforeChild(), InsertEndChild(), and ReplaceChild(). |
|
|
Definition at line 146 of file tinyxml.cpp. References SetValue(), TiXmlBase::userData, and value. Referenced by TiXmlUnknown::CopyTo(), TiXmlDeclaration::CopyTo(), TiXmlText::CopyTo(), TiXmlComment::CopyTo(), TiXmlDocument::CopyTo(), and TiXmlElement::CopyTo().
|
|
|
STL std::string form.
Definition at line 539 of file tinyxml.h. References FirstChild(). |
|
|
STL std::string form.
Definition at line 538 of file tinyxml.h. References FirstChild(). |
|
|
The first child of this node with the matching 'value'. Will be null if none found.
Definition at line 524 of file tinyxml.h. 00524 {
00525 // Call through to the const version - safe since nothing is changed. Exiting syntax: cast this to a const (always safe)
00526 // call the method, cast the return back to non-const.
00527 return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->FirstChild( _value ));
00528 }
|
|
|
The first child of this node with the matching 'value'. Will be null if none found. Definition at line 326 of file tinyxml.cpp. 00327 {
00328 const TiXmlNode* node;
00329 for ( node = firstChild; node; node = node->next )
00330 {
00331 if ( strcmp( node->Value(), _value ) == 0 )
00332 return node;
00333 }
00334 return 0;
00335 }
|
|
|
Definition at line 521 of file tinyxml.h. 00521 { return firstChild; }
|
|
|
The first child of this node. Will be null if there are no children.
Definition at line 520 of file tinyxml.h. Referenced by TiXmlDocument::Accept(), TiXmlElement::Accept(), TiXmlHandle::Child(), FirstChild(), TiXmlHandle::FirstChild(), FirstChildElement(), TiXmlElement::GetText(), IterateChildren(), TiXmlDocument::Print(), Anp::HistMan::ReadHistogram(), Anp::HistMan::ReadHistogramBlock(), TiXmlPrinter::VisitEnter(), and TiXmlPrinter::VisitExit(). |
|
|
STL std::string form.
Definition at line 675 of file tinyxml.h. References FirstChildElement(). |
|
|
STL std::string form.
Definition at line 674 of file tinyxml.h. References FirstChildElement(). |
|
|
Definition at line 669 of file tinyxml.h. 00669 {
00670 return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement( _value ) );
00671 }
|
|
|
Convenience function to get through elements.
Definition at line 432 of file tinyxml.cpp. References FirstChild(), NextSibling(), and ToElement(). 00433 {
00434 const TiXmlNode* node;
00435
00436 for ( node = FirstChild( _value );
00437 node;
00438 node = node->NextSibling( _value ) )
00439 {
00440 if ( node->ToElement() )
00441 return node->ToElement();
00442 }
00443 return 0;
00444 }
|
|
|
Definition at line 663 of file tinyxml.h. 00663 {
00664 return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement() );
00665 }
|
|
|
Convenience function to get through elements.
Definition at line 417 of file tinyxml.cpp. References FirstChild(), NextSibling(), and ToElement(). Referenced by TiXmlHandle::ChildElement(), FirstChildElement(), TiXmlHandle::FirstChildElement(), and TiXmlDocument::RootElement(). 00418 {
00419 const TiXmlNode* node;
00420
00421 for ( node = FirstChild();
00422 node;
00423 node = node->NextSibling() )
00424 {
00425 if ( node->ToElement() )
00426 return node->ToElement();
00427 }
00428 return 0;
00429 }
|
|
|
Definition at line 688 of file tinyxml.h. 00688 {
00689 return const_cast< TiXmlDocument* >( (const_cast< const TiXmlNode* >(this))->GetDocument() );
00690 }
|
|
|
Return a pointer to the Document this node lives in. Returns null if not in a document. Definition at line 477 of file tinyxml.cpp. References parent, and ToDocument(). Referenced by Identify(), InsertAfterChild(), InsertBeforeChild(), InsertEndChild(), LinkEndChild(), TiXmlDeclaration::Parse(), TiXmlText::Parse(), TiXmlComment::Parse(), TiXmlUnknown::Parse(), TiXmlElement::Parse(), TiXmlElement::ReadValue(), TiXmlElement::SetAttribute(), TiXmlDeclaration::StreamIn(), TiXmlText::StreamIn(), TiXmlComment::StreamIn(), TiXmlUnknown::StreamIn(), and TiXmlElement::StreamIn(). 00478 {
00479 const TiXmlNode* node;
00480
00481 for( node = this; node; node = node->parent )
00482 {
00483 if ( node->ToDocument() )
00484 return node->ToDocument();
00485 }
00486 return 0;
00487 }
|
|
||||||||||||
|
Definition at line 818 of file tinyxmlparser.cpp. References GetDocument(), TiXmlBase::IsAlpha(), parent, TiXmlText::SetCDATA(), TiXmlDocument::SetError(), TiXmlBase::SkipWhiteSpace(), TiXmlBase::StringEqual(), TIXML_ENCODING_UNKNOWN, and TiXmlElement. Referenced by TiXmlDocument::Parse(), TiXmlElement::ReadValue(), TiXmlElement::StreamIn(), and TiXmlDocument::StreamIn(). 00819 {
00820 TiXmlNode* returnNode = 0;
00821
00822 p = SkipWhiteSpace( p, encoding );
00823 if( !p || !*p || *p != '<' )
00824 {
00825 return 0;
00826 }
00827
00828 TiXmlDocument* doc = GetDocument();
00829 p = SkipWhiteSpace( p, encoding );
00830
00831 if ( !p || !*p )
00832 {
00833 return 0;
00834 }
00835
00836 // What is this thing?
00837 // - Elements start with a letter or underscore, but xml is reserved.
00838 // - Comments: <!--
00839 // - Decleration: <?xml
00840 // - Everthing else is unknown to tinyxml.
00841 //
00842
00843 const char* xmlHeader = { "<?xml" };
00844 const char* commentHeader = { "<!--" };
00845 const char* dtdHeader = { "<!" };
00846 const char* cdataHeader = { "<![CDATA[" };
00847
00848 if ( StringEqual( p, xmlHeader, true, encoding ) )
00849 {
00850 #ifdef DEBUG_PARSER
00851 TIXML_LOG( "XML parsing Declaration\n" );
00852 #endif
00853 returnNode = new TiXmlDeclaration();
00854 }
00855 else if ( StringEqual( p, commentHeader, false, encoding ) )
00856 {
00857 #ifdef DEBUG_PARSER
00858 TIXML_LOG( "XML parsing Comment\n" );
00859 #endif
00860 returnNode = new TiXmlComment();
00861 }
00862 else if ( StringEqual( p, cdataHeader, false, encoding ) )
00863 {
00864 #ifdef DEBUG_PARSER
00865 TIXML_LOG( "XML parsing CDATA\n" );
00866 #endif
00867 TiXmlText* text = new TiXmlText( "" );
00868 text->SetCDATA( true );
00869 returnNode = text;
00870 }
00871 else if ( StringEqual( p, dtdHeader, false, encoding ) )
00872 {
00873 #ifdef DEBUG_PARSER
00874 TIXML_LOG( "XML parsing Unknown(1)\n" );
00875 #endif
00876 returnNode = new TiXmlUnknown();
00877 }
00878 else if ( IsAlpha( *(p+1), encoding )
00879 || *(p+1) == '_' )
00880 {
00881 #ifdef DEBUG_PARSER
00882 TIXML_LOG( "XML parsing Element\n" );
00883 #endif
00884 returnNode = new TiXmlElement( "" );
00885 }
00886 else
00887 {
00888 #ifdef DEBUG_PARSER
00889 TIXML_LOG( "XML parsing Unknown(2)\n" );
00890 #endif
00891 returnNode = new TiXmlUnknown();
00892 }
00893
00894 if ( returnNode )
00895 {
00896 // Set the parent, so it can report errors
00897 returnNode->parent = this;
00898 }
00899 else
00900 {
00901 if ( doc )
00902 doc->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN );
00903 }
00904 return returnNode;
00905 }
|
|
||||||||||||
|
Add a new node related to this. Adds a child after the specified child. Returns a pointer to the new object or NULL if an error occured. Definition at line 244 of file tinyxml.cpp. References Clone(), GetDocument(), lastChild, next, parent, prev, TiXmlDocument::SetError(), TIXML_ENCODING_UNKNOWN, and Type(). 00245 {
00246 if ( !afterThis || afterThis->parent != this ) {
00247 return 0;
00248 }
00249 if ( addThis.Type() == TiXmlNode::DOCUMENT )
00250 {
00251 if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
00252 return 0;
00253 }
00254
00255 TiXmlNode* node = addThis.Clone();
00256 if ( !node )
00257 return 0;
00258 node->parent = this;
00259
00260 node->prev = afterThis;
00261 node->next = afterThis->next;
00262 if ( afterThis->next )
00263 {
00264 afterThis->next->prev = node;
00265 }
00266 else
00267 {
00268 assert( lastChild == afterThis );
00269 lastChild = node;
00270 }
00271 afterThis->next = node;
00272 return node;
00273 }
|
|
||||||||||||
|
Add a new node related to this. Adds a child before the specified child. Returns a pointer to the new object or NULL if an error occured. Definition at line 212 of file tinyxml.cpp. References Clone(), firstChild, GetDocument(), next, parent, prev, TiXmlDocument::SetError(), TIXML_ENCODING_UNKNOWN, and Type(). 00213 {
00214 if ( !beforeThis || beforeThis->parent != this ) {
00215 return 0;
00216 }
00217 if ( addThis.Type() == TiXmlNode::DOCUMENT )
00218 {
00219 if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
00220 return 0;
00221 }
00222
00223 TiXmlNode* node = addThis.Clone();
00224 if ( !node )
00225 return 0;
00226 node->parent = this;
00227
00228 node->next = beforeThis;
00229 node->prev = beforeThis->prev;
00230 if ( beforeThis->prev )
00231 {
00232 beforeThis->prev->next = node;
00233 }
00234 else
00235 {
00236 assert( firstChild == beforeThis );
00237 firstChild = node;
00238 }
00239 beforeThis->prev = node;
00240 return node;
00241 }
|
|
|
Add a new node related to this. Adds a child past the LastChild. Returns a pointer to the new object or NULL if an error occured. Definition at line 197 of file tinyxml.cpp. References Clone(), GetDocument(), LinkEndChild(), TiXmlDocument::SetError(), TIXML_ENCODING_UNKNOWN, and Type(). 00198 {
00199 if ( addThis.Type() == TiXmlNode::DOCUMENT )
00200 {
00201 if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
00202 return 0;
00203 }
00204 TiXmlNode* node = addThis.Clone();
00205 if ( !node )
00206 return 0;
00207
00208 return LinkEndChild( node );
00209 }
|
|
||||||||||||
|
STL std::string form.
Definition at line 573 of file tinyxml.h. References IterateChildren(). |
|
||||||||||||
|
STL std::string form.
Definition at line 572 of file tinyxml.h. References IterateChildren(). |
|
||||||||||||
|
Definition at line 567 of file tinyxml.h. 00567 {
00568 return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( _value, previous ) );
00569 }
|
|
||||||||||||
|
This flavor of IterateChildren searches for children with a particular 'value'.
Definition at line 364 of file tinyxml.cpp. References FirstChild(), NextSibling(), and parent. 00365 {
00366 if ( !previous )
00367 {
00368 return FirstChild( val );
00369 }
00370 else
00371 {
00372 assert( previous->parent == this );
00373 return previous->NextSibling( val );
00374 }
00375 }
|
|
|
Definition at line 561 of file tinyxml.h. 00561 {
00562 return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( previous ) );
00563 }
|
|
|
An alternate way to walk the children of a node. One way to iterate over nodes is: for( child = parent->FirstChild(); child; child = child->NextSibling() ) IterateChildren does the same thing with the syntax: child = 0; while( child = parent->IterateChildren( child ) ) IterateChildren takes the previous child as input and finds the next one. If the previous child is null, it returns the first. IterateChildren will return null when done. Definition at line 350 of file tinyxml.cpp. References FirstChild(), NextSibling(), and parent. Referenced by IterateChildren(). 00351 {
00352 if ( !previous )
00353 {
00354 return FirstChild();
00355 }
00356 else
00357 {
00358 assert( previous->parent == this );
00359 return previous->NextSibling();
00360 }
00361 }
|
|
|
STL std::string form.
Definition at line 541 of file tinyxml.h. References LastChild(). |
|
|
STL std::string form.
Definition at line 540 of file tinyxml.h. References LastChild(). |
|
|
The last child of this node matching 'value'. Will be null if there are no children.
Definition at line 533 of file tinyxml.h. 00533 {
00534 return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->LastChild( _value ));
00535 }
|
|
|
Definition at line 338 of file tinyxml.cpp. 00339 {
00340 const TiXmlNode* node;
00341 for ( node = lastChild; node; node = node->prev )
00342 {
00343 if ( strcmp( node->Value(), _value ) == 0 )
00344 return node;
00345 }
00346 return 0;
00347 }
|
|
|
The last child of this node. Will be null if there are no children.
Definition at line 530 of file tinyxml.h. 00530 { return lastChild; }
|
|
|
Definition at line 529 of file tinyxml.h. Referenced by LastChild(), and TiXmlPrinter::VisitEnter(). 00529 { return lastChild; }
|
|
|
Add a new node related to this. Adds a child past the LastChild. NOTE: the node to be added is passed by pointer, and will be henceforth owned (and deleted) by tinyXml. This method is efficient and avoids an extra copy, but should be used with care as it uses a different memory model than the other insert functions.
Definition at line 170 of file tinyxml.cpp. References firstChild, GetDocument(), lastChild, next, parent, prev, TiXmlDocument::SetError(), TIXML_ENCODING_UNKNOWN, and Type(). Referenced by TiXmlDocument::CopyTo(), TiXmlElement::CopyTo(), InsertEndChild(), TiXmlDocument::Parse(), and TiXmlElement::ReadValue(). 00171 {
00172 assert( node->parent == 0 || node->parent == this );
00173 assert( node->GetDocument() == 0 || node->GetDocument() == this->GetDocument() );
00174
00175 if ( node->Type() == TiXmlNode::DOCUMENT )
00176 {
00177 delete node;
00178 if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
00179 return 0;
00180 }
00181
00182 node->parent = this;
00183
00184 node->prev = lastChild;
00185 node->next = 0;
00186
00187 if ( lastChild )
00188 lastChild->next = node;
00189 else
00190 firstChild = node; // it was an empty list.
00191
00192 lastChild = node;
00193 return node;
00194 }
|
|
|
Definition at line 634 of file tinyxml.h. 00634 {
00635 return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->NextSibling( _next ) );
00636 }
|
|
|
Navigate to a sibling node with the given 'value'.
Definition at line 378 of file tinyxml.cpp. 00379 {
00380 const TiXmlNode* node;
00381 for ( node = next; node; node = node->next )
00382 {
00383 if ( strcmp( node->Value(), _value ) == 0 )
00384 return node;
00385 }
00386 return 0;
00387 }
|
|
|
Definition at line 630 of file tinyxml.h. 00630 { return next; }
|
|
|
Navigate to a sibling node.
Definition at line 629 of file tinyxml.h. Referenced by NextSibling(), and NextSiblingElement(). 00629 { return next; }
|
|
|
STL std::string form.
Definition at line 625 of file tinyxml.h. References NextSibling(). |
|
|
STL std::string form.
Definition at line 624 of file tinyxml.h. References NextSibling(). Referenced by TiXmlDocument::Accept(), TiXmlElement::Accept(), TiXmlHandle::Child(), TiXmlDocument::CopyTo(), TiXmlElement::CopyTo(), FirstChildElement(), IterateChildren(), NextSiblingElement(), TiXmlDocument::Print(), and TiXmlElement::Print(). |
|
|
STL std::string form.
Definition at line 658 of file tinyxml.h. References NextSiblingElement(). |
|
|
STL std::string form.
Definition at line 657 of file tinyxml.h. References NextSiblingElement(). |
|
|
Definition at line 652 of file tinyxml.h. 00652 {
00653 return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement( _next ) );
00654 }
|
|
|
Convenience function to get through elements. Calls NextSibling and ToElement. Will skip all non-Element nodes. Returns 0 if there is not another element. Definition at line 462 of file tinyxml.cpp. References NextSibling(), and ToElement(). 00463 {
00464 const TiXmlNode* node;
00465
00466 for ( node = NextSibling( _value );
00467 node;
00468 node = node->NextSibling( _value ) )
00469 {
00470 if ( node->ToElement() )
00471 return node->ToElement();
00472 }
00473 return 0;
00474 }
|
|
|
Definition at line 643 of file tinyxml.h. 00643 {
00644 return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement() );
00645 }
|
|
|
Convenience function to get through elements. Calls NextSibling and ToElement. Will skip all non-Element nodes. Returns 0 if there is not another element. Definition at line 447 of file tinyxml.cpp. References NextSibling(), and ToElement(). Referenced by TiXmlHandle::ChildElement(), and NextSiblingElement(). 00448 {
00449 const TiXmlNode* node;
00450
00451 for ( node = NextSibling();
00452 node;
00453 node = node->NextSibling() )
00454 {
00455 if ( node->ToElement() )
00456 return node->ToElement();
00457 }
00458 return 0;
00459 }
|
|
|
Returns true if this node has no children.
Definition at line 693 of file tinyxml.h. 00693 { return !firstChild; }
|
|
|
|
|
|
Definition at line 518 of file tinyxml.h. 00518 { return parent; }
|
|
|
One step up the DOM.
Definition at line 517 of file tinyxml.h. 00517 { return parent; }
|
|
|
STL std::string form.
Definition at line 623 of file tinyxml.h. References PreviousSibling(). |
|
|
STL std::string form.
Definition at line 622 of file tinyxml.h. References PreviousSibling(). |
|
|
Definition at line 617 of file tinyxml.h. 00617 {
00618 return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->PreviousSibling( _prev ) );
00619 }
|
|
|
Navigate to a sibling node.
Definition at line 390 of file tinyxml.cpp. 00391 {
00392 const TiXmlNode* node;
00393 for ( node = prev; node; node = node->prev )
00394 {
00395 if ( strcmp( node->Value(), _value ) == 0 )
00396 return node;
00397 }
00398 return 0;
00399 }
|
|
|
Definition at line 613 of file tinyxml.h. 00613 { return prev; }
|
|
|
Navigate to a sibling node.
Definition at line 612 of file tinyxml.h. Referenced by PreviousSibling(). 00612 { return prev; }
|
|
|
Delete a child of this node.
Definition at line 304 of file tinyxml.cpp. References firstChild, lastChild, next, parent, and prev. 00305 {
00306 if ( removeThis->parent != this )
00307 {
00308 assert( 0 );
00309 return false;
00310 }
00311
00312 if ( removeThis->next )
00313 removeThis->next->prev = removeThis->prev;
00314 else
00315 lastChild = removeThis->prev;
00316
00317 if ( removeThis->prev )
00318 removeThis->prev->next = removeThis->next;
00319 else
00320 firstChild = removeThis->next;
00321
00322 delete removeThis;
00323 return true;
00324 }
|
|
||||||||||||
|
Replace a child of this node. Returns a pointer to the new object or NULL if an error occured. Definition at line 276 of file tinyxml.cpp. References Clone(), firstChild, lastChild, next, parent, and prev. 00277 {
00278 if ( replaceThis->parent != this )
00279 return 0;
00280
00281 TiXmlNode* node = withThis.Clone();
00282 if ( !node )
00283 return 0;
00284
00285 node->next = replaceThis->next;
00286 node->prev = replaceThis->prev;
00287
00288 if ( replaceThis->next )
00289 replaceThis->next->prev = node;
00290 else
00291 lastChild = node;
00292
00293 if ( replaceThis->prev )
00294 replaceThis->prev->next = node;
00295 else
00296 firstChild = node;
00297
00298 delete replaceThis;
00299 node->parent = this;
00300 return node;
00301 }
|
|
|
STL std::string form.
Definition at line 510 of file tinyxml.h. References value. 00510 { value = _value; }
|
|
|
Changes the value of the node. Defined as: Document: filename of the xml file Element: name of the element Comment: the comment text Unknown: the tag contents Text: the text string Definition at line 506 of file tinyxml.h. References value. Referenced by CopyTo(), TiXmlComment::TiXmlComment(), and TiXmlText::TiXmlText(). 00506 { value = _value;}
|
|
||||||||||||
|
Implemented in TiXmlElement, TiXmlComment, TiXmlText, TiXmlDeclaration, TiXmlUnknown, and TiXmlDocument. Referenced by operator>>(), TiXmlElement::StreamIn(), and TiXmlDocument::StreamIn(). |
|
|
Cast to a more defined type. Will return null if not of the requested type.
Reimplemented in TiXmlComment. |
|
|
Cast to a more defined type. Will return null if not of the requested type.
Reimplemented in TiXmlComment. |
|
|
Cast to a more defined type. Will return null if not of the requested type.
Reimplemented in TiXmlDeclaration. |
|
|
Cast to a more defined type. Will return null if not of the requested type.
Reimplemented in TiXmlDeclaration. Definition at line 700 of file tinyxml.h. Referenced by TiXmlDocument::Parse(). |
|
|
Cast to a more defined type. Will return null if not of the requested type.
Reimplemented in TiXmlDocument. |
|
|
Cast to a more defined type. Will return null if not of the requested type.
Reimplemented in TiXmlDocument. Definition at line 695 of file tinyxml.h. Referenced by GetDocument(). |
|
|
Cast to a more defined type. Will return null if not of the requested type.
Reimplemented in TiXmlElement. |
|
|
Cast to a more defined type. Will return null if not of the requested type.
Reimplemented in TiXmlElement. Definition at line 696 of file tinyxml.h. Referenced by FirstChildElement(), NextSiblingElement(), and TiXmlDocument::StreamIn(). |
|
|
Cast to a more defined type. Will return null if not of the requested type.
Reimplemented in TiXmlText. |
|
|
Cast to a more defined type. Will return null if not of the requested type.
Reimplemented in TiXmlText. Definition at line 699 of file tinyxml.h. Referenced by TiXmlElement::GetText(), TiXmlElement::Print(), and TiXmlPrinter::VisitEnter(). |
|
|
Cast to a more defined type. Will return null if not of the requested type.
Reimplemented in TiXmlUnknown. |
|
|
Cast to a more defined type. Will return null if not of the requested type.
Reimplemented in TiXmlUnknown. |
|
|
Query the type (as an enumerated value, above) of this node. The possible types are: DOCUMENT, ELEMENT, COMMENT, UNKNOWN, TEXT, and DECLARATION. Definition at line 682 of file tinyxml.h. Referenced by InsertAfterChild(), InsertBeforeChild(), InsertEndChild(), and LinkEndChild(). 00682 { return type; }
|
|
|
The meaning of 'value' changes for the specific type of TiXmlNode. Document: filename of the xml file Element: name of the element Comment: the comment text Unknown: the tag contents Text: the text string The subclasses will wrap this function. Definition at line 487 of file tinyxml.h. References value. Referenced by TiXmlElement::Clone(), FirstChild(), TiXmlElement::GetText(), LastChild(), TiXmlDocument::LoadFile(), NextSibling(), PreviousSibling(), Anp::HistMan::ReadHistogram(), TiXmlDocument::SaveFile(), TiXmlPrinter::Visit(), TiXmlPrinter::VisitEnter(), and TiXmlPrinter::VisitExit(). 00487 { return value.c_str (); }
|
|
|
Return Value() as a std::string. If you only use STL, this is more efficient than calling Value(). Only available in STL mode. Definition at line 494 of file tinyxml.h. 00494 { return value; }
|
|
||||||||||||
|
Appends the XML node or attribute to a std::string.
Definition at line 1604 of file tinyxml.cpp. 01605 {
01606 TiXmlPrinter printer;
01607 printer.SetStreamPrinting();
01608 base.Accept( &printer );
01609 out.append( printer.Str() );
01610
01611 return out;
01612 }
|
|
||||||||||||
|
An output stream operator, for every class. Note that this outputs without any newlines or formatting, as opposed to Print(), which includes tabs and new lines. The operator<< and operator>> are not completely symmetric. Writing a node to a stream is very well defined. You'll get a nice stream of output, without any extra whitespace or newlines. But reading is not as well defined. (As it always is.) If you create a TiXmlElement (for example) and read that from an input stream, the text needs to define an element or junk will result. This is true of all input streams, but it's worth keeping in mind. A TiXmlDocument will read nodes until it reads a root element, and all the children of that root element. Definition at line 1593 of file tinyxml.cpp. 01594 {
01595 TiXmlPrinter printer;
01596 printer.SetStreamPrinting();
01597 base.Accept( &printer );
01598 out << printer.Str();
01599
01600 return out;
01601 }
|
|
||||||||||||
|
An input stream operator, for every class. Tolerant of newlines and formatting, but doesn't expect them. Definition at line 1580 of file tinyxml.cpp. 01581 {
01582 TIXML_STRING tag;
01583 tag.reserve( 8 * 1000 );
01584 base.StreamIn( &in, &tag );
01585
01586 base.Parse( tag.c_str(), 0, TIXML_DEFAULT_ENCODING );
01587 return in;
01588 }
|
|
|
Reimplemented from TiXmlBase. |
|
|
Reimplemented from TiXmlBase. Reimplemented in TiXmlText. Definition at line 426 of file tinyxml.h. Referenced by Identify(). |
|
|
Definition at line 756 of file tinyxml.h. Referenced by Clear(), InsertBeforeChild(), LinkEndChild(), RemoveChild(), ReplaceChild(), and TiXmlNode(). |
|
|
Definition at line 757 of file tinyxml.h. Referenced by Clear(), InsertAfterChild(), LinkEndChild(), RemoveChild(), ReplaceChild(), and TiXmlNode(). |
|
|
Definition at line 762 of file tinyxml.h. Referenced by Clear(), TiXmlAttributeSet::First(), FirstChild(), InsertAfterChild(), InsertBeforeChild(), LinkEndChild(), NextSibling(), RemoveChild(), ReplaceChild(), TiXmlNode(), and ~TiXmlNode(). |
|
|
Definition at line 753 of file tinyxml.h. Referenced by GetDocument(), Identify(), InsertAfterChild(), InsertBeforeChild(), IterateChildren(), LinkEndChild(), RemoveChild(), ReplaceChild(), and TiXmlNode(). |
|
|
Definition at line 761 of file tinyxml.h. Referenced by InsertAfterChild(), InsertBeforeChild(), TiXmlAttributeSet::Last(), LastChild(), LinkEndChild(), PreviousSibling(), RemoveChild(), ReplaceChild(), and TiXmlNode(). |
|
|
Definition at line 754 of file tinyxml.h. Referenced by TiXmlNode(). |
|
|
Definition at line 759 of file tinyxml.h. Referenced by CopyTo(), SetValue(), and Value(). |
1.3.9.1