本文整理汇总了C++中boost::property_tree::ptree::end方法的典型用法代码示例。如果您正苦于以下问题:C++ ptree::end方法的具体用法?C++ ptree::end怎么用?C++ ptree::end使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::property_tree::ptree
的用法示例。
在下文中一共展示了ptree::end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: trim
static boost::property_tree::ptree xml_to_ptree_( boost::property_tree::ptree& ptree)
{
boost::property_tree::ptree out= boost::property_tree::ptree();
boost::property_tree::ptree unnamed_array= boost::property_tree::ptree();
for ( boost::property_tree::ptree::iterator i=ptree.begin(); i!=ptree.end(); i++ )
{
//look ahead for duplicate name
boost::property_tree::ptree::iterator lah = i;
if ( ++lah != ptree.end() && i->first == lah->first )
{
//add to unnamed array
unnamed_array.push_back( std::make_pair( "", xml_to_ptree_( i->second ) ) );
}
else
{
if(unnamed_array.size()!=0)
{
//assert((i-1)->first==i->first);
//the last of duplicated name
unnamed_array.push_back( std::make_pair( "", xml_to_ptree_( i->second ) ) );
out.add_child(i->first,unnamed_array);
unnamed_array= boost::property_tree::ptree();
}
else
{
out.add_child(i->first, xml_to_ptree_(i->second) );
}
}
}
out.put_value( trim( ptree.get_value<std::string>() ) );
return out;
}
示例2: print_ptree
void print_ptree(std::ostream& os, const boost::property_tree::ptree& pt, int depth)
{
typedef bp::ptree::const_iterator c_it;
if(pt.empty())
os << "'" << pt.data() << "'\n";
else
{
std::string pad("");
pad.assign(depth*4,' ');
++depth;
std::string pad2 = pad + " ";
if(is_list(pt))
{
os << "[\n";
for(c_it it=pt.begin(); it!=pt.end(); ++it)
{
os << pad2;
print_ptree(os, it->second, depth);
}
os << pad << "]\n";
}
else
{
os << "{\n";
for(c_it it=pt.begin(); it!=pt.end(); ++it)
{
os << pad2 << "'" << it->first << "': ";
print_ptree(os, it->second, depth);
}
os << pad << "}\n";
}
}
}
示例3: parseStringTypeLimits
void XSDSchemaParser::parseStringTypeLimits(const pt::ptree &restrictTree, std::shared_ptr<SchemaTypeStringLimits> &pStringLimits)
{
for (auto it = restrictTree.begin(); it != restrictTree.end(); ++it)
{
std::string restrictionType = it->first;
if (restrictionType == "xs:minLength")
pStringLimits->setMinLength(it->second.get<int>("<xmlattr>.value"));
else if (restrictionType == "xs:maxLength")
pStringLimits->setMaxLength(it->second.get<int>("<xmlattr>.value"));
else if (restrictionType == "xs:length")
pStringLimits->setLength(it->second.get<int>("<xmlattr>.value"));
else if (restrictionType == "xs:pattern")
pStringLimits->addPattern(it->second.get("<xmlattr>.value", "0"));
else if (restrictionType == "xs:enumeration")
{
pStringLimits->addAllowedValue(it->second.get("<xmlattr>.value", "badbadbad"), it->second.get("<xmlattr>.hpcc:description", ""));
}
else if (restrictionType != "<xmlattr>")
{
std::string msg = "Invalid restriction(" + it->first + ") found while parsing type";
throw(ParseException(msg));
}
}
}
示例4: readMaterials
// Read in material data from the scene file
void readMaterials(scene_data* scene, const boost::property_tree::ptree& pt)
{
boost::property_tree::ptree::const_iterator iter = pt.begin();
// Iterate through all the sub branches, and read in the relevant data
for (; iter != pt.end(); ++iter)
{
material* mat = new material();
std::string name = iter->first;
mat->data.emissive = readVec4(iter->second.get_child("emmisive"));
mat->data.ambient = readVec4(iter->second.get_child("ambient"));
mat->data.diffuse = readVec4(iter->second.get_child("diffuse"));
mat->data.specular = readVec4(iter->second.get_child("specular"));
mat->data.shininess = iter->second.get_child("shininess").get_value<float>();
std::string texture = iter->second.get_child("texture").get_value<std::string>();
// Try and find texture, and set material accordingly. If the not found,
// set to nullptr
if (scene->textures.find(texture) != scene->textures.end())
mat->texture = scene->textures[texture];
else
mat->texture = nullptr;
// Create the material, and add to the table
mat->create();
scene->material[name] = mat;
}
}
示例5: PropertyTreeValue
/**
* @brief Construct a PropertyTreeValue from a tree object
*
* This function will determine whether the tree object represents an array
* or an object by scanning the key names for any non-empty strings. In the
* case of an empty tree object, it is not possible to determine whether it
* is an array or an object, so it will be treated as an array by default.
* Empty arrays are considered equal to empty objects when compared using
* non-strict type comparison. Empty strings will also be stored as empty
* arrays.
*
* @param tree Tree object to be wrapped
*/
PropertyTreeValue(const boost::property_tree::ptree &tree)
{
if (tree.data().empty()) { // No string content
if (tree.size() == 0) { // No children
array = tree; // Treat as empty array
} else {
bool isArray = true;
boost::property_tree::ptree::const_iterator itr;
for (itr = tree.begin(); itr != tree.end(); itr++) {
if (!itr->first.empty()) {
isArray = false;
break;
}
}
if (isArray) {
array = tree;
} else {
object = tree;
}
}
} else {
value = tree.data();
}
}
示例6: readObjects
// Reads in all the render objects from the scene file
void readObjects(scene_data* scene, const boost::property_tree::ptree& pt)
{
boost::property_tree::ptree::const_iterator iter = pt.begin();
// Iterate through the sub branches of the property file, reading in each
// object
for (; iter != pt.end(); ++iter)
{
// Create a render object
render_object* object = new render_object();
// Read in the name for the object
std::string name = iter->first;
// Read in the geometry
std::string geom = iter->second.get_child("geometry").get_value<std::string>();
object->geometry = scene->geometry[geom];
// Read in the material
std::string mat = iter->second.get_child("material").get_value<std::string>();
object->material = scene->material[mat];
// Read in the transform
readTransform(object, iter->second.get_child("transform"));
// Add the render object to the table of render objects
scene->objects[name] = object;
}
}
示例7: it
// For extracted ptree.
stack_data(const ptree_ptr& p,
const std::tr1::shared_ptr<pqrs::string::replacement>& r,
const boost::property_tree::ptree& root_children) :
it(root_children.begin()),
end(root_children.end()),
parent_replacement(*r),
pt_ptr_(p),
replacement_ptr_(r)
{}
示例8: opt
Options::Options(const boost::property_tree::ptree& tree)
{
for (auto iter = tree.begin(); iter != tree.end(); ++iter)
{
assert(iter->first == "Option");
Option opt(iter->second);
add(opt);
}
}
示例9: convert
void convert(const boost::property_tree::ptree & in, boost::property_tree::wptree & out)
{
out.data() = deutf8(in.data());
for(boost::property_tree::ptree::const_iterator i = in.begin(), end = in.end(); i != end; ++i)
{
out.push_back(boost::property_tree::wptree::value_type(deutf8(i->first), boost::property_tree::wptree()));
convert(i->second, out.back().second);
}
}
示例10: printPTree
void printPTree(const boost::property_tree::ptree &pt, const std::string prefix)
{
std::cout << prefix << "data = \"" << pt.data() << '"' << std::endl;
using boost::property_tree::ptree;
for (ptree::const_iterator it = pt.begin(); it != pt.end(); ++it)
{
std::cout << prefix << "child = \"" << it->first << '"' << std::endl;
printPTree(it->second, prefix + "\t");
}
}
示例11: traverse_recursive
void traverse_recursive(const boost::property_tree::ptree::path_type &childPath, const boost::property_tree::ptree &child, T method)
{
using boost::property_tree::ptree;
method(childPath, child);
for(ptree::const_iterator it=child.begin(); it!=child.end(); ++it) {
ptree::path_type curPath = childPath / ptree::path_type(it->first);
traverse_recursive(curPath, it->second, method);
}
}
示例12: printTree
void printTree (boost::property_tree::ptree &pt, int level) {
if (pt.empty()) {
std::cout << "\""<< pt.data()<< "\"";
} else {
if (level) std::cout << std::endl;
std::cout << indent(level) << "{" << std::endl;
for (boost::property_tree::ptree::iterator pos = pt.begin(); pos != pt.end();) {
std::cout << indent(level+1) << "\"" << pos->first << "\": ";
printTree(pos->second, level + 1);
++pos;
if (pos != pt.end()) {
std::cout << ",";
}
std::cout << std::endl;
}
std::cout << indent(level) << " }";
}
return;
}
示例13: is_list
bool is_list(const boost::property_tree::ptree& pt)
{
if(!pt.data().empty())
return false;
for(bp::ptree::const_iterator it=pt.begin(); it!=pt.end(); ++it)
{
if(!it->first.empty())
return false;
}
return true;
}
示例14: to_path_value
void property_tree::to_path_value( std::ostream& os, const boost::property_tree::ptree& ptree, path_mode mode, char equal_sign, char delimiter, const xpath& root )
{
for( boost::property_tree::ptree::const_iterator i = ptree.begin(); i != ptree.end(); ++i )
{
// display_path is the modified key path showing array indices, if array exists within e.g abc[0]/xyz[0]
// But the actual path to the value is many empty keys under abc and abc/xyz
// Boost: "JSON arrays are mapped to nodes. Each element is a child node with an empty name.
// If a node has both named and unnamed child nodes, it cannot be mapped to a JSON representation."
// http://www.boost.org/doc/libs/1_41_0/doc/html/boost_propertytree/parsers.html#boost_propertytree.parsers.json_parser
xpath path;
xpath display_path;
impl::ptree_to_path_value_string_impl( os, i, i == ptree.begin(), path, display_path, mode, equal_sign, delimiter, root.to_string() ); // quick and dirty
}
}
示例15: parseXSD
void XSDSchemaParser::parseXSD(const pt::ptree &keys)
{
for (auto it = keys.begin(); it != keys.end(); ++it)
{
//
// Element parent (a type in realilty) and the element name help figure out how to process the XSD schema element
std::string elemType = it->first;
if (elemType == "xs:include")
{
std::string schemaFile = getXSDAttributeValue(it->second, "<xmlattr>.schemaLocation");
if (m_pSchemaItem->addUniqueName(schemaFile))
{
parseXSD(schemaFile);
}
}
else if (elemType == "xs:simpleType")
{
parseSimpleType(it->second);
}
else if (elemType == "xs:complexType")
{
parseComplexType(it->second);
}
else if (elemType == "xs:attributeGroup")
{
parseAttributeGroup(it->second);
}
else if (elemType == "xs:attribute")
{
parseAttribute(it->second);
}
else if (elemType == "xs:sequence")
{
parseXSD(it->second.get_child("", pt::ptree()));
}
else if (elemType == "xs:element")
{
parseElement(it->second);
}
else if (elemType == "xs:key")
{
parseKey(it->second);
}
else if (elemType == "xs:keyref")
{
parseKeyRef(it->second);
}
}
}