本文整理汇总了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();
}
}
示例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;
}
示例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();
}
}