Example #1
0
Profile *Profiles::processProfile(Profile *parent, pugi::xml_node config)
{
	std::string name = config.attribute("name").value();

	if (name.empty()) {
		throw std::runtime_error("Missing profile name");
	}
	
	/* Create new profile */
	Profile *profile = new Profile(name);
	profile->setParent(parent);
	profile->setNode(config);

	pugi::xpath_node_set profiles = config.select_nodes("profile");
	pugi::xpath_node_set channels = config.select_nodes("channel");

	for (auto& node: channels) {
		Channel *channel = processChannel(profile, node.node());
		profile->addChannel(channel, true);
	}

	for (auto& node: profiles) {
		Profile *child = processProfile(profile, node.node());
		profile->addProfile(child, true);
	}

	return profile;
}
Example #2
0
Profile *Profiles::addProfile(std::string profile)
{
	Profile *newProfile{nullptr};
	Profile *parent = nameToParentProfile(profile);

	if (parent != nullptr) {
		std::string name = nameFromPath(profile);

		newProfile = new Profile(name);
		parent->addProfile(newProfile);
	}

	return newProfile;
}