| 235 | } |
| 236 | |
| 237 | TiXmlNode* TiXmlNode::InsertAfterChild(TiXmlNode* afterThis, const TiXmlNode& addThis) |
| 238 | { |
| 239 | if (!afterThis || afterThis->parent != this) |
| 240 | { |
| 241 | return 0; |
| 242 | } |
| 243 | if (addThis.Type() == TiXmlNode::DOCUMENT) |
| 244 | { |
| 245 | if (GetDocument()) |
| 246 | GetDocument()->SetError(TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN); |
| 247 | return 0; |
| 248 | } |
| 249 | |
| 250 | TiXmlNode* node = addThis.Clone(); |
| 251 | if (!node) |
| 252 | return 0; |
| 253 | node->parent = this; |
| 254 | |
| 255 | node->prev = afterThis; |
| 256 | node->next = afterThis->next; |
| 257 | if (afterThis->next) |
| 258 | { |
| 259 | afterThis->next->prev = node; |
| 260 | } |
| 261 | else |
| 262 | { |
| 263 | assert(lastChild == afterThis); |
| 264 | lastChild = node; |
| 265 | } |
| 266 | afterThis->next = node; |
| 267 | return node; |
| 268 | } |
| 269 | |
| 270 | TiXmlNode* TiXmlNode::ReplaceChild(TiXmlNode* replaceThis, const TiXmlNode& withThis) |
| 271 | { |