| 167 | } |
| 168 | |
| 169 | bool PropertyListsXmlFileReaderAndWriter::WriteLists(const std::string &fileName, |
| 170 | const std::map<std::string, mitk::PropertyList::Pointer> &_PropertyLists) const |
| 171 | { |
| 172 | tinyxml2::XMLDocument doc; |
| 173 | doc.InsertEndChild(doc.NewDeclaration()); |
| 174 | |
| 175 | // create root |
| 176 | auto *propertyListsElem = doc.NewElement("PropertyLists"); |
| 177 | |
| 178 | bool allPropsConverted = true; |
| 179 | auto it = _PropertyLists.begin(); |
| 180 | while (it != _PropertyLists.end()) |
| 181 | { |
| 182 | const std::string &id = (*it).first; |
| 183 | const PropertyList *propList = (*it).second; |
| 184 | auto *propertyListElem = doc.NewElement("PropertyList"); |
| 185 | propertyListElem->SetAttribute(GetPropertyListIdElementName(), id.c_str()); |
| 186 | |
| 187 | const std::map<std::string, BaseProperty::Pointer> *propMap = propList->GetMap(); |
| 188 | auto propMapIt = propMap->begin(); |
| 189 | while (propMapIt != propMap->end()) |
| 190 | { |
| 191 | const std::string &propName = (*propMapIt).first; |
| 192 | const BaseProperty *prop = (*propMapIt).second; |
| 193 | auto *propertyElem = doc.NewElement("Property"); |
| 194 | |
| 195 | if (!this->PropertyToXmlElem(propName, prop, propertyElem)) |
| 196 | allPropsConverted = false; |
| 197 | |
| 198 | propertyListElem->InsertEndChild(propertyElem); |
| 199 | ++propMapIt; |
| 200 | } |
| 201 | |
| 202 | propertyListsElem->InsertEndChild(propertyListElem); |
| 203 | ++it; |
| 204 | } |
| 205 | |
| 206 | doc.InsertEndChild(propertyListsElem); |
| 207 | |
| 208 | return (allPropsConverted && tinyxml2::XML_SUCCESS == doc.SaveFile(fileName.c_str())); |
| 209 | } |
| 210 | |
| 211 | bool PropertyListsXmlFileReaderAndWriter::ReadLists(const std::string &fileName, |
| 212 | std::map<std::string, mitk::PropertyList::Pointer> &_PropertyLists) const |
no test coverage detected