void ProfileDB::listCapabilities(string statePattern) { vector<Profile*> profiles; set<string> aggregateCapabilities; getProfiles("*", profiles); for (size_t i = 0; i < profiles.size(); i++) { Profile* profile = profiles.at(i); set<string> capabilities = profile->getCapabilities(); for (set<string>::iterator capabilityIt = capabilities.begin(); capabilityIt != capabilities.end(); capabilityIt++) { Capability capability = profile->getCapability(*capabilityIt); if (capability.matchCapability(statePattern)) { aggregateCapabilities.insert(*capabilityIt); } } } ostringstream output; XMLWriter writer = XMLWriter(&output); writer.start(); writer.startTag("db"); writer.setAttr("version", "1.0"); writer.setAttr("id", "main"); for (set<string>::iterator capabilityIt = aggregateCapabilities.begin(); capabilityIt != aggregateCapabilities.end(); capabilityIt++) { writer.startTag(ELEMENT_CAPABILITY); writer.setAttr(ATTR_NAME, *capabilityIt); writer.endTag(); } writer.endTag(); writer.end(); writer.dump(); }
void ProfileDB::dumpProfilesXML(vector<Profile*> profiles, map<string, Profile*> profileMappings, string profileName) { ostringstream output; XMLWriter writer = XMLWriter(&output); writer.start(); writer.startTag("db"); writer.setAttr("version", "1.0"); writer.setAttr("id", "main"); string line; if (profiles.size() > 0) { for (size_t i = 0; i < profiles.size(); i++) { Profile* profile = profiles.at(i); if (profile) { profile->toXML(writer, fIncludeCapabilities); } } if (fOutputMappings) { dumpProfileMappings(&writer, profileMappings); } } else { writer.startTag("error"); writer.text(string("Could find no matching profile for ") + profileName); writer.endTag(); } writer.endTag(); printf("%s", output.str().c_str()); }