| 209 | } |
| 210 | |
| 211 | bool PropertyListsXmlFileReaderAndWriter::ReadLists(const std::string &fileName, |
| 212 | std::map<std::string, mitk::PropertyList::Pointer> &_PropertyLists) const |
| 213 | { |
| 214 | // reread |
| 215 | tinyxml2::XMLDocument doc; |
| 216 | doc.LoadFile(fileName.c_str()); |
| 217 | |
| 218 | tinyxml2::XMLHandle docHandle(&doc); |
| 219 | auto *elem = docHandle.FirstChildElement("PropertyLists").FirstChildElement("PropertyList").ToElement(); |
| 220 | |
| 221 | if (nullptr == elem) |
| 222 | { |
| 223 | MITK_WARN("PropertyListFromXml") << "Cannot find a PropertyList element (inside a PropertyLists element)"; |
| 224 | return false; |
| 225 | } |
| 226 | |
| 227 | bool opRead = false; |
| 228 | while (nullptr != elem) |
| 229 | { |
| 230 | std::string propListId = ReadStringAttribute(elem, GetPropertyListIdElementName()); |
| 231 | if (propListId.empty()) |
| 232 | break; |
| 233 | |
| 234 | opRead = true; |
| 235 | |
| 236 | auto propList = mitk::PropertyList::New(); |
| 237 | |
| 238 | auto *propElem = elem->FirstChildElement("Property"); |
| 239 | |
| 240 | while (nullptr != propElem) |
| 241 | { |
| 242 | std::string name; |
| 243 | mitk::BaseProperty::Pointer prop; |
| 244 | opRead = this->PropertyFromXmlElem(name, prop, propElem); |
| 245 | if (!opRead) |
| 246 | break; |
| 247 | propList->SetProperty(name, prop); |
| 248 | propElem = propElem->NextSiblingElement("Property"); |
| 249 | } |
| 250 | |
| 251 | if (!opRead) |
| 252 | break; |
| 253 | _PropertyLists[propListId] = propList; |
| 254 | elem = elem->NextSiblingElement("PropertyList"); |
| 255 | } |
| 256 | |
| 257 | return opRead; |
| 258 | } |
| 259 | |
| 260 | PropertyListsXmlFileReaderAndWriter::PropertyListsXmlFileReaderAndWriter() {} |
| 261 | PropertyListsXmlFileReaderAndWriter::~PropertyListsXmlFileReaderAndWriter() {} |
no test coverage detected