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