当前位置: 首页>>代码示例>>C++>>正文


C++ PTree::set方法代码示例

本文整理汇总了C++中PTree::set方法的典型用法代码示例。如果您正苦于以下问题:C++ PTree::set方法的具体用法?C++ PTree::set怎么用?C++ PTree::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PTree的用法示例。


在下文中一共展示了PTree::set方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: read_xml

static void read_xml(std::istream & in, PTree & node, Include * include, std::string key)
{
	std::string line, escape("/"+node.value());
	while (in.good())
	{
		std::getline(in, line, '\n');
		if (line.empty())
		{
			continue;
		}

		size_t begin = line.find_first_not_of(" \t\n<");
		size_t end = line.length();
		if (begin >= end || line[begin] == '!')
		{
			continue;
		}

		line = line.substr(begin, end);

		if (line.find(escape) == 0)
		{
			break;
		}

		if (key.length() == 0)
		{
			end = line.find(" ");
			key = line.substr(0, end);
			continue;
		}

		size_t next = line.find("</"+key);
		if (next < end)
		{
			// New property.
			std::string value = line.substr(0, next);

			// Include?
			if (include && key == "include")
			{
				(*include)(node, value);
			}
			else
			{
				node.set(key, value);
			}
		}
		else
		{
			// New node.
			end = line.find(" ");
			std::string child_key = line.substr(0, end);
			read_xml(in, node.set(key, PTree()), include, child_key);
		}
		key.clear();
	}
}
开发者ID:logzero,项目名称:vdrift,代码行数:58,代码来源:xml.cpp

示例2: read

	void read(PTree & node)
	{
		std::string line, name;
		while (in.good())
		{
			std::getline(in, line, '\n');
			if (line.empty())
			{
				continue;
			}

			size_t begin = line.find_first_not_of(" \t[");
			size_t end = line.find_first_of(";#]\r", begin);
			if (begin >= end)
			{
				continue;
			}

			size_t next = line.find("=", begin);
			if (next >= end)
			{
				// New node.
				next = line.find_last_not_of(" \t\r]", end);
				name = line.substr(begin, next);
				read(root.set(name, PTree()));
				continue;
			}

			size_t next2 = line.find_first_not_of(" \t\r", next+1);
			next = line.find_last_not_of(" \t", next-1);
			if (next2 >= end)
				continue;

			name = line.substr(begin, next+1);
			if (!fopen || line.at(next2) != '&')
			{
				// New property.
				std::string value = line.substr(next2, end-next2);
				node.set(name, value);
				continue;
			}

			// Value is a reference.
			std::string value = line.substr(next2+1, end-next2-1);
			const PTree * ref_ptr;
			if (root.get(value, ref_ptr) || cache.get(value, ref_ptr))
			{
				node.set(name, *ref_ptr);
				continue;
			}

			// Load external reference.
			PTree ref;
			read_ini(value, *fopen, ref);
			cache.set(value, ref);
			node.set(name, ref);
		}
	}
开发者ID:abhishekshishodia,项目名称:vdrift,代码行数:58,代码来源:ini.cpp

示例3: read_inf

static void read_inf(std::istream & in, PTree & node, Include * include, bool child)
{
	std::string line, name;
	while (in.good())
	{
		std::getline(in, line, '\n');
		if (line.empty())
		{
			continue;
		}

		size_t begin = line.find_first_not_of(" \t");
		size_t end = line.find_first_of(";#");
		if (begin >= end)
		{
			continue;
		}

		line = line.substr(begin, end);
		if (line[0] == '{' && name.length())
		{
			// New node.
			read_inf(in, node.set(name, PTree()), include, true);
			continue;
		}

		if (line[0] == '}' && child)
		{
			break;
		}

		size_t next = line.find(" ");
		end = line.length();
		name = line.substr(0, next);
		if (next < end)
		{
			// New property.
			std::string value = line.substr(next+1, end);

			// Include?
			if (include && name == "include")
			{
				(*include)(node, value);
			}
			else
			{
				node.set(name, value);
			}
			name.clear();
		}
	}
}
开发者ID:Alexander-Eck,项目名称:vdrift,代码行数:52,代码来源:ptree_inf.cpp

示例4: read_xml

static void read_xml(std::istream & in, PTree & p, std::string key)
{
	std::string line, escape("/"+p.value());
	while (in.good())
	{
		std::getline(in, line, '\n');
		if (line.empty())
		{
			continue;
		}

		size_t begin = line.find_first_not_of(" \t\n<");
		size_t end = line.length();
		if (begin >= end || line[begin] == '!')
		{
			continue;
		}

		line = line.substr(begin, end);

		if (line.find(escape) == 0)
		{
			break;
		}

		if (key.length() == 0)
		{
			end = line.find(" ");
			key = line.substr(0, end);
			continue;
		}

		size_t next = line.find("</"+key);
		if (next < end)
		{
			std::string value = line.substr(0, next);
			p.set(key, value);
		}
		else
		{
			end = line.find(" ");
			std::string child_key = line.substr(0, end);
			read_xml(in, p.set(key, PTree()), child_key);
		}
		key.clear();
	}
}
开发者ID:HaohaoLau,项目名称:stuntrally,代码行数:47,代码来源:xml.cpp

示例5: operator

	void operator()(PTree & node, std::string & value)
	{
		std::tr1::shared_ptr<PTree> sptr;
		if (content.load(sptr, path, value))
		{
			node.set(*sptr);
		}
	}
开发者ID:fanqsh,项目名称:vdrift,代码行数:8,代码来源:configfactory.cpp


注:本文中的PTree::set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。