本文整理汇总了C++中boost::property_tree::ptree::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ ptree::begin方法的具体用法?C++ ptree::begin怎么用?C++ ptree::begin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::property_tree::ptree
的用法示例。
在下文中一共展示了ptree::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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";
}
}
}
示例2: loadConfig
int Split::loadConfig(const boost::property_tree::ptree& pt)
{
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << " " << id();
const boost::property_tree::ptree& split = pt.get_child("split");
boost::optional<string> name = split.get_optional<string>("name");
if (name.is_initialized()) {
this->name(*name);
}
cout << "HAHA!!!" << id() << " " << pt.begin()->first << endl;
updateConfig(pt.begin()->second );
return 1;
}
示例3: 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
}
}
示例4: 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));
}
}
}
示例5: 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;
}
}
示例6: setSettings
void NetworkManagerHandler::setSettings(const boost::property_tree::ptree &requestPt)
{
if (requestPt.find("type") != requestPt.not_found())
{
NetworkInterfaces::InterfaceSettings settings;
settings.interface = _interfaceName;
settings.type = requestPt.get<std::string>("type");
settings.autoConnect = requestPt.get<bool>("auto", true);
for (boost::property_tree::ptree::const_iterator it = requestPt.begin(); it != requestPt.end(); ++it)
{
if (it->first != "type")
settings.arguments[it->first] = it->second.get_value<std::string>();
}
NetworkInterfaces::writeInterfaceSettings(kNetworkInterfacesFile, settings);
if (_interfaceName != qpcrApp.wirelessManager()->interfaceName())
{
NetworkInterfaces::ifdown(_interfaceName);
NetworkInterfaces::ifup(_interfaceName);
}
else
wifiConnect();
}
else
{
setStatus(Poco::Net::HTTPResponse::HTTP_BAD_REQUEST);
setErrorString("type must be set");
}
}
示例7: 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();
}
}
示例8: 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;
}
示例9: 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;
}
}
示例10: handleConfigItem
int ParallelFilter::handleConfigItem(const std::string& confFile,
const boost::property_tree::ptree::const_iterator& it)
{
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << ":: "<< type() << " " << it->first ;
cout << "PF::handle " << it->first << endl;
if (it->first == "parallelFilter") {
// recurse
return loadConfig(confFile, it->second.begin(), it->second.end());
} else if (it->first == "thread") {
cout << "PF::THREAD FOUND!"<< endl;
Filter* f;
if ( it->second.size() > 1
) {
// instantiate a filterbank
FilterBank* fb = new FilterBank();
fb->bank(NULL);
fb->loadConfig( it->second );
f=fb;
} else if (it->second.begin()->first == "filterGroup") {
// instantiate a filterbank
FilterBank* fb = new FilterBank();
const boost::property_tree::ptree pt = it->second.begin()->second;
cout << "DD " << pt.data() << endl;
fb->bank(NULL);
fb->loadFileConfig(pt.data());
f=fb;
} else {
const boost::property_tree::ptree pt = it->second;
f = instantiateFilter(pt.begin() );
}
FilterThread* ft = new FilterThread(f);
lanes.push_back(ft);
add(f); // book-keeping
} else if (it->first == "barrier") {
boost::property_tree::ptree::const_iterator child = it->second.begin();
cout << "PF::BARRIER FOUND! "<< child->first << endl;
Filter* f = instantiateFilter( child );
f->loadConfig( it->second );
this->mux = (Mux*) f;
add(f); // book-keeping
} else {
//return FilterBank::handleConfigItem(confFile, it);
}
return 1;
}
示例11: 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);
}
}
示例12: 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);
}
}
示例13: 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)
{}
示例14:
// Takes a branch of a property tree and reads in a vec3
glm::vec3 readVec3(const boost::property_tree::ptree& pt)
{
glm::vec3 v;
boost::property_tree::ptree::const_iterator iter = pt.begin();
v.x = (iter++)->second.get_value<float>();
v.y = (iter++)->second.get_value<float>();
v.z = (iter++)->second.get_value<float>();
return v;
}
示例15: 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);
}
}