| 4845 | } |
| 4846 | |
| 4847 | PUGI__FN xml_node xml_node::insert_child_before(xml_node_type type_, const xml_node& node) |
| 4848 | { |
| 4849 | if (!impl::allow_insert_child(this->type(), type_)) |
| 4850 | return xml_node(); |
| 4851 | if (!node._root || node._root->parent != _root) |
| 4852 | return xml_node(); |
| 4853 | |
| 4854 | xml_node n(impl::allocate_node(impl::get_allocator(_root), type_)); |
| 4855 | if (!n) |
| 4856 | return xml_node(); |
| 4857 | |
| 4858 | n._root->parent = _root; |
| 4859 | |
| 4860 | if (node._root->prev_sibling_c->next_sibling) |
| 4861 | node._root->prev_sibling_c->next_sibling = n._root; |
| 4862 | else |
| 4863 | _root->first_child = n._root; |
| 4864 | |
| 4865 | n._root->prev_sibling_c = node._root->prev_sibling_c; |
| 4866 | n._root->next_sibling = node._root; |
| 4867 | node._root->prev_sibling_c = n._root; |
| 4868 | |
| 4869 | if (type_ == node_declaration) |
| 4870 | n.set_name(PUGIXML_TEXT("xml")); |
| 4871 | |
| 4872 | return n; |
| 4873 | } |
| 4874 | |
| 4875 | PUGI__FN xml_node xml_node::insert_child_after(xml_node_type type_, const xml_node& node) |
| 4876 | { |
nothing calls this directly
no test coverage detected