| 4815 | } |
| 4816 | |
| 4817 | PUGI__FN xml_node xml_node::prepend_child(xml_node_type type_) |
| 4818 | { |
| 4819 | if (!impl::allow_insert_child(this->type(), type_)) |
| 4820 | return xml_node(); |
| 4821 | |
| 4822 | xml_node n(impl::allocate_node(impl::get_allocator(_root), type_)); |
| 4823 | if (!n) |
| 4824 | return xml_node(); |
| 4825 | |
| 4826 | n._root->parent = _root; |
| 4827 | |
| 4828 | xml_node_struct* head = _root->first_child; |
| 4829 | |
| 4830 | if (head) |
| 4831 | { |
| 4832 | n._root->prev_sibling_c = head->prev_sibling_c; |
| 4833 | head->prev_sibling_c = n._root; |
| 4834 | } |
| 4835 | else |
| 4836 | n._root->prev_sibling_c = n._root; |
| 4837 | |
| 4838 | n._root->next_sibling = head; |
| 4839 | _root->first_child = n._root; |
| 4840 | |
| 4841 | if (type_ == node_declaration) |
| 4842 | n.set_name(PUGIXML_TEXT("xml")); |
| 4843 | |
| 4844 | return n; |
| 4845 | } |
| 4846 | |
| 4847 | PUGI__FN xml_node xml_node::insert_child_before(xml_node_type type_, const xml_node& node) |
| 4848 | { |