Prepends a new child node. The prepended child becomes the first child, and all existing children are moved one position back. \param child Node to prepend.
| 1074 | //! The prepended child becomes the first child, and all existing children are moved one position back. |
| 1075 | //! \param child Node to prepend. |
| 1076 | void prepend_node(xml_node<Ch> *child) |
| 1077 | { |
| 1078 | assert(child && !child->parent() && child->type() != node_document); |
| 1079 | if (first_node()) |
| 1080 | { |
| 1081 | child->m_next_sibling = m_first_node; |
| 1082 | m_first_node->m_prev_sibling = child; |
| 1083 | } |
| 1084 | else |
| 1085 | { |
| 1086 | child->m_next_sibling = 0; |
| 1087 | m_last_node = child; |
| 1088 | } |
| 1089 | m_first_node = child; |
| 1090 | child->m_parent = this; |
| 1091 | child->m_prev_sibling = 0; |
| 1092 | } |
| 1093 | |
| 1094 | //! Appends a new child node. |
| 1095 | //! The appended child becomes the last child. |