| 4199 | } |
| 4200 | |
| 4201 | PUGI__FN xml_attribute xml_node::insert_attribute_before(const char_t* name_, const xml_attribute& attr) |
| 4202 | { |
| 4203 | if ((type() != node_element && type() != node_declaration) || attr.empty()) return xml_attribute(); |
| 4204 | |
| 4205 | // check that attribute belongs to *this |
| 4206 | xml_attribute_struct* cur = attr._attr; |
| 4207 | |
| 4208 | while (cur->prev_attribute_c->next_attribute) cur = cur->prev_attribute_c; |
| 4209 | |
| 4210 | if (cur != _root->first_attribute) return xml_attribute(); |
| 4211 | |
| 4212 | xml_attribute a(impl::allocate_attribute(impl::get_allocator(_root))); |
| 4213 | if (!a) return xml_attribute(); |
| 4214 | |
| 4215 | a.set_name(name_); |
| 4216 | |
| 4217 | if (attr._attr->prev_attribute_c->next_attribute) |
| 4218 | attr._attr->prev_attribute_c->next_attribute = a._attr; |
| 4219 | else |
| 4220 | _root->first_attribute = a._attr; |
| 4221 | |
| 4222 | a._attr->prev_attribute_c = attr._attr->prev_attribute_c; |
| 4223 | a._attr->next_attribute = attr._attr; |
| 4224 | attr._attr->prev_attribute_c = a._attr; |
| 4225 | |
| 4226 | return a; |
| 4227 | } |
| 4228 | |
| 4229 | PUGI__FN xml_attribute xml_node::insert_attribute_after(const char_t* name_, const xml_attribute& attr) |
| 4230 | { |
nothing calls this directly
no test coverage detected