| 261 | |
| 262 | |
| 263 | TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ) |
| 264 | { |
| 265 | if ( !afterThis || afterThis->parent != this ) { |
| 266 | return 0; |
| 267 | } |
| 268 | if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT ) |
| 269 | { |
| 270 | if ( GetDocument() ) |
| 271 | GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); |
| 272 | return 0; |
| 273 | } |
| 274 | |
| 275 | TiXmlNode* node = addThis.Clone(); |
| 276 | if ( !node ) |
| 277 | return 0; |
| 278 | node->parent = this; |
| 279 | |
| 280 | node->prev = afterThis; |
| 281 | node->next = afterThis->next; |
| 282 | if ( afterThis->next ) |
| 283 | { |
| 284 | afterThis->next->prev = node; |
| 285 | } |
| 286 | else |
| 287 | { |
| 288 | assert( lastChild == afterThis ); |
| 289 | lastChild = node; |
| 290 | } |
| 291 | afterThis->next = node; |
| 292 | return node; |
| 293 | } |
| 294 | |
| 295 | |
| 296 | TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ) |