示例#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;
}
示例#2
0
Channel *Profiles::addChannel(std::string channel)
{
	Channel *newChannel{nullptr};
	Profile *profile = nameToParentProfile(channel);

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

		newChannel = new Channel(name);
		profile->addChannel(newChannel);
	}

	return newChannel;
}