| 230 | } |
| 231 | |
| 232 | void PropertyContainer::Save (Base::Writer &writer) const |
| 233 | { |
| 234 | std::map<std::string,Property*> Map; |
| 235 | getPropertyMap(Map); |
| 236 | |
| 237 | std::vector<Property*> transients; |
| 238 | for(auto it=Map.begin();it!=Map.end();) { |
| 239 | auto prop = it->second; |
| 240 | if(prop->testStatus(Property::PropNoPersist)) { |
| 241 | it = Map.erase(it); |
| 242 | continue; |
| 243 | } |
| 244 | if(!prop->testStatus(Property::PropDynamic) |
| 245 | && (prop->testStatus(Property::Transient) || |
| 246 | getPropertyType(prop) & Prop_Transient)) |
| 247 | { |
| 248 | transients.push_back(prop); |
| 249 | it = Map.erase(it); |
| 250 | } else { |
| 251 | ++it; |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | writer.incInd(); // indentation for 'Properties Count' |
| 256 | writer.Stream() << writer.ind() << "<Properties Count=\"" << Map.size() |
| 257 | << "\" TransientCount=\"" << transients.size() << "\">" << endl; |
| 258 | |
| 259 | // First store transient properties to persist their status value. We use |
| 260 | // a new element named "_Property" so that the save file can be opened by |
| 261 | // older versions of FC. |
| 262 | writer.incInd(); |
| 263 | for(auto prop : transients) { |
| 264 | writer.Stream() << writer.ind() << "<_Property name=\"" << prop->getName() |
| 265 | << "\" type=\"" << prop->getTypeId().getName() |
| 266 | << "\" status=\"" << prop->getStatus() << "\"/>" << std::endl; |
| 267 | } |
| 268 | writer.decInd(); |
| 269 | |
| 270 | // Now store normal properties |
| 271 | for (const auto& it : Map) |
| 272 | { |
| 273 | writer.incInd(); // indentation for 'Property name' |
| 274 | writer.Stream() << writer.ind() << "<Property name=\"" << it.first << "\" type=\"" |
| 275 | << it.second->getTypeId().getName(); |
| 276 | |
| 277 | dynamicProps.save(it.second,writer); |
| 278 | |
| 279 | auto status = it.second->getStatus(); |
| 280 | if(status) |
| 281 | writer.Stream() << "\" status=\"" << status; |
| 282 | writer.Stream() << "\">"; |
| 283 | |
| 284 | if(it.second->testStatus(Property::Transient) |
| 285 | || it.second->getType() & Prop_Transient) |
| 286 | { |
| 287 | writer.decInd(); |
| 288 | writer.Stream() << "</Property>" << std::endl; |
| 289 | continue; |
nothing calls this directly
no test coverage detected