Inserts a new child node at specified place inside the node. All children after and including the specified node are moved one position back. \param where Place where to insert the child, or 0 to insert at the back. \param child Node to insert.
| 1131 | //! \param where Place where to insert the child, or 0 to insert at the back. |
| 1132 | //! \param child Node to insert. |
| 1133 | void insert_node(xml_node<Ch> *where, xml_node<Ch> *child) |
| 1134 | { |
| 1135 | assert(!where || where->parent() == this); |
| 1136 | assert(child && !child->parent() && child->type() != node_document); |
| 1137 | if (where == m_first_node) |
| 1138 | prepend_node(child); |
| 1139 | else if (where == 0) |
| 1140 | append_node(child); |
| 1141 | else |
| 1142 | { |
| 1143 | child->m_prev_sibling = where->m_prev_sibling; |
| 1144 | child->m_next_sibling = where; |
| 1145 | where->m_prev_sibling->m_next_sibling = child; |
| 1146 | where->m_prev_sibling = child; |
| 1147 | child->m_parent = this; |
| 1148 | } |
| 1149 | } |
| 1150 | |
| 1151 | //! Removes first child node. |
| 1152 | //! If node has no children, behaviour is undefined. |