void OptionsCont::writeConfiguration(std::ostream &os, bool filled, bool complete, bool addComments) throw() { std::vector<std::string>::const_iterator i, j; os << "<configuration>" << std::endl << std::endl; for (i=mySubTopics.begin(); i!=mySubTopics.end(); ++i) { std::string subtopic = *i; if (subtopic=="Configuration") { continue; } for (size_t k=0; k<subtopic.length(); ++k) { if (subtopic[k]==' ') { subtopic[k] = '_'; } if (subtopic[k]>='A'&&subtopic[k]<='Z') { subtopic[k] = subtopic[k] - 'A' + 'a'; } } const std::vector<std::string> &entries = mySubTopicEntries[*i]; bool hadOne = false; for (j=entries.begin(); j!=entries.end(); ++j) { Option *o = getSecure(*j); bool write = complete || (filled&&!o->isDefault()); if (!write) { continue; } if (!hadOne) { os << " <" << subtopic << ">" << std::endl; } // add the comment if wished if (addComments) { os << " <!-- " << o->getDescription() << " -->" << std::endl; } // write the option and the value (if given) os << " <" << *j << " value=\""; if (o->isSet()) { os << o->getValueString(); } os << "\"/>" << std::endl; // append an endline if a comment was printed if (addComments) { os << std::endl; } hadOne = true; } if (hadOne) { os << " </" << subtopic << ">" << std::endl << std::endl; } } os << "</configuration>" << std::endl; }
void OptionsCont::writeConfiguration(std::ostream& os, bool filled, bool complete, bool addComments) const { os << "<?xml version=\"1.0\"" << SUMOSAXAttributes::ENCODING << "?>\n\n"; os << "<configuration xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo.dlr.de/xsd/" << myAppName << "Configuration.xsd\">" << std::endl << std::endl; for (std::vector<std::string>::const_iterator i = mySubTopics.begin(); i != mySubTopics.end(); ++i) { std::string subtopic = *i; if (subtopic == "Configuration" && !complete) { continue; } std::replace(subtopic.begin(), subtopic.end(), ' ', '_'); std::transform(subtopic.begin(), subtopic.end(), subtopic.begin(), tolower); const std::vector<std::string>& entries = mySubTopicEntries.find(*i)->second; bool hadOne = false; for (std::vector<std::string>::const_iterator j = entries.begin(); j != entries.end(); ++j) { Option* o = getSecure(*j); bool write = complete || (filled && !o->isDefault()); if (!write) { continue; } if (!hadOne) { os << " <" << subtopic << ">" << std::endl; } // add the comment if wished if (addComments) { os << " <!-- " << StringUtils::escapeXML(o->getDescription()) << " -->" << std::endl; } // write the option and the value (if given) os << " <" << *j << " value=\""; if (o->isSet() && (filled || o->isDefault())) { os << o->getValueString(); } if (complete) { std::vector<std::string> synonymes = getSynonymes(*j); if (!synonymes.empty()) { os << "\" synonymes=\""; for (std::vector<std::string>::const_iterator s = synonymes.begin(); s != synonymes.end(); ++s) { if (s != synonymes.begin()) { os << " "; } os << (*s); } } os << "\" type=\"" << o->getTypeName(); if (!addComments) { os << "\" help=\"" << StringUtils::escapeXML(o->getDescription()); } } os << "\"/>" << std::endl; // append an endline if a comment was printed if (addComments) { os << std::endl; } hadOne = true; } if (hadOne) { os << " </" << subtopic << ">" << std::endl << std::endl; } } os << "</configuration>" << std::endl; }