| 278 | |
| 279 | |
| 280 | TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ) |
| 281 | { |
| 282 | if ( !afterThis || afterThis->parent != this ) { |
| 283 | return 0; |
| 284 | } |
| 285 | if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT ) |
| 286 | { |
| 287 | if ( GetDocument() ) |
| 288 | GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); |
| 289 | return 0; |
| 290 | } |
| 291 | |
| 292 | TiXmlNode* node = addThis.Clone(); |
| 293 | if ( !node ) |
| 294 | return 0; |
| 295 | node->parent = this; |
| 296 | |
| 297 | node->prev = afterThis; |
| 298 | node->next = afterThis->next; |
| 299 | if ( afterThis->next ) |
| 300 | { |
| 301 | afterThis->next->prev = node; |
| 302 | } |
| 303 | else |
| 304 | { |
| 305 | assert( lastChild == afterThis ); |
| 306 | lastChild = node; |
| 307 | } |
| 308 | afterThis->next = node; |
| 309 | return node; |
| 310 | } |
| 311 | |
| 312 | |
| 313 | TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ) |