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


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

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


在下文中一共展示了PTree::value方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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_ini

bool read_ini(const std::string & file_name, const file_open & fopen, PTree & p)
{
	p.value() = file_name;
	std::istream * in = fopen(file_name);
	if (in->good())
	{
		ini reader(*in, p, &fopen);
		reader.read();
		delete in;
		return true;
	}
	delete in;
	return false;
}
开发者ID:abhishekshishodia,项目名称:vdrift,代码行数:14,代码来源:ini.cpp

示例3: 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


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