Esempio n. 1
0
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();
}
Esempio n. 2
0
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());
}
Esempio n. 3
0
void Capability::toXML(XMLWriter& writer) {
	string stateStr = getStateString(fState);

	writer.startTag(ELEMENT_CAPABILITY);
	writer.setAttr(ATTR_NAME, fName);
	if (fValue.length() > 0) {
		writer.setAttr(ATTR_VALUE, fValue);
	}
	writer.setAttr(ATTR_STATE, stateStr);
	writer.setAttr(ATTR_FRAGMENTATION,
	        fFragmentation == BUILDTIME ? "buildtime" : "runtime");
	if (fType.length() > 0) {
		writer.setAttr(ATTR_TYPE, fType);
	}
	writer.endTag();
}
Esempio n. 4
0
void Profile::toXML(XMLWriter& writer, bool includeCapabilities) {
	writer.startTag(ELEMENT_PLATFORM);
	writer.setAttr(ATTR_FAMILY, fFamily);
	writer.setAttr(ATTR_VARIANT, fVariant);
	writer.setAttr(ATTR_RUNTIME, fRuntime);
	if (fIsAbstract) {
		writer.setAttr(ATTR_ABSTRACT, "true");
	}

	if (includeCapabilities) {
		set<string> capabilities = Profile::getCapabilities();
		for (set<string>::iterator capability = capabilities.begin(); capability
		        != capabilities.end(); capability++) {
			Capability value = getCapability(*capability);
			value.toXML(writer);
		}
	}
	writer.endTag();
}