Ejemplo n.º 1
0
	/*! Load a repeating group into a supplied map.
	  \param tag the tag to find
	  \param map_name the target map
	  \param is_session if true, special case for session map
	  \return the number of elements inserted */
	unsigned load_map(const std::string& tag, ConfigMap& map_name, const bool is_session=false)
	{
		XmlElement::XmlSet slist;
		if (_root->find(tag, slist))
		{
			for(XmlElement::XmlSet::const_iterator itr(slist.begin()); itr != slist.end(); ++itr)
			{
				std::string name;
				if ((*itr)->GetAttr("name", name) && is_session ? (*itr)->FindAttr("active", false) : true)
				{
					map_name.insert(ConfigMap::value_type(name, *itr));
					if (is_session)
						_allsessions.push_back(*itr);
				}
			}
		}

		return map_name.size();
	}
Ejemplo n.º 2
0
	void ConfigHelper::LoadConfig(ConfigMap & mapConfig, string strPath)
	{
		vector<string> vecParas;
		vector<string> vecSkip;
		vecSkip.push_back("#");
		vecSkip.push_back(";");
		Load(vecParas, strPath, vecSkip);

		vector<string> vecVariable;
		string delim = "=";
		for (auto i = vecParas.begin(); i != vecParas.end(); i++)
		{
			vecVariable.clear();
			libReactor::Utils::split(*i, delim, vecVariable);
			if (vecVariable.size() == 2)
			{
				mapConfig.insert(make_pair(libReactor::Utils::trim(vecVariable[0]),
					libReactor::Utils::trim(vecVariable[1])));
			}
		}
	}