| 294 | |
| 295 | |
| 296 | TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ) |
| 297 | { |
| 298 | if ( !replaceThis ) |
| 299 | return 0; |
| 300 | |
| 301 | if ( replaceThis->parent != this ) |
| 302 | return 0; |
| 303 | |
| 304 | if ( withThis.ToDocument() ) { |
| 305 | // A document can never be a child. Thanks to Noam. |
| 306 | TiXmlDocument* document = GetDocument(); |
| 307 | if ( document ) |
| 308 | document->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); |
| 309 | return 0; |
| 310 | } |
| 311 | |
| 312 | TiXmlNode* node = withThis.Clone(); |
| 313 | if ( !node ) |
| 314 | return 0; |
| 315 | |
| 316 | node->next = replaceThis->next; |
| 317 | node->prev = replaceThis->prev; |
| 318 | |
| 319 | if ( replaceThis->next ) |
| 320 | replaceThis->next->prev = node; |
| 321 | else |
| 322 | lastChild = node; |
| 323 | |
| 324 | if ( replaceThis->prev ) |
| 325 | replaceThis->prev->next = node; |
| 326 | else |
| 327 | firstChild = node; |
| 328 | |
| 329 | delete replaceThis; |
| 330 | node->parent = this; |
| 331 | return node; |
| 332 | } |
| 333 | |
| 334 | |
| 335 | bool TiXmlNode::RemoveChild( TiXmlNode* removeThis ) |
nothing calls this directly
no test coverage detected