| 14 | } |
| 15 | |
| 16 | bool XmlRepository::save() const |
| 17 | { |
| 18 | if (!_list) { |
| 19 | return false; |
| 20 | } |
| 21 | pugi::xml_document xml; |
| 22 | pugi::xml_node root = xml.append_child("ASAP_Annotations"); |
| 23 | if (root.empty()) { |
| 24 | return false; |
| 25 | } |
| 26 | pugi::xml_node nodeAnnotations = root.append_child("Annotations"); |
| 27 | pugi::xml_node nodeGroups = root.append_child("AnnotationGroups"); |
| 28 | |
| 29 | std::vector<std::shared_ptr<Annotation> > annotations = _list->getAnnotations(); |
| 30 | for (std::vector<std::shared_ptr<Annotation> >::const_iterator it = annotations.begin(); it != annotations.end(); ++it) |
| 31 | { |
| 32 | saveAnnotation(*it, &nodeAnnotations); |
| 33 | } |
| 34 | |
| 35 | std::vector<std::shared_ptr<AnnotationGroup> > groups = _list->getGroups(); |
| 36 | for (std::vector<std::shared_ptr<AnnotationGroup>>::const_iterator it = groups.begin(); it != groups.end(); ++it) |
| 37 | { |
| 38 | saveGroup(*it, &nodeGroups); |
| 39 | } |
| 40 | |
| 41 | return xml.save_file(_source.c_str()); |
| 42 | } |
| 43 | |
| 44 | void XmlRepository::saveAnnotation(const std::shared_ptr<Annotation>& annotation, pugi::xml_node* node) const |
| 45 | { |
no test coverage detected