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


C++ ptree::begin方法代码示例

本文整理汇总了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";
		}
	}
}
开发者ID:nerdvegas,项目名称:certus,代码行数:35,代码来源:ptree_utils.cpp

示例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;
}
开发者ID:voxel-dot-at,项目名称:toffy,代码行数:13,代码来源:bbox.cpp

示例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
    }
}
开发者ID:sheenzhaox,项目名称:comma,代码行数:14,代码来源:ptree.cpp

示例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));
        }
    }
}
开发者ID:HPCCSmoketest,项目名称:HPCC-Platform,代码行数:25,代码来源:XSDSchemaParser.cpp

示例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;
	}
}
开发者ID:craigmcmillan01,项目名称:Graphics-Programming,代码行数:30,代码来源:scene.cpp

示例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");
    }
}
开发者ID:chaibio,项目名称:chaipcr,代码行数:31,代码来源:networkmanagerhandler.cpp

示例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();
        }
    }
开发者ID:hotwatermorning,项目名称:valijson,代码行数:38,代码来源:property_tree_adapter.hpp

示例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;
}
开发者ID:sheenzhaox,项目名称:comma,代码行数:32,代码来源:ptree.cpp

示例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;
	}
}
开发者ID:craigmcmillan01,项目名称:Graphics-Programming,代码行数:28,代码来源:scene.cpp

示例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;
}
开发者ID:voxel-dot-at,项目名称:toffy,代码行数:58,代码来源:parallelFilter.cpp

示例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);
    }
}
开发者ID:simonsonc,项目名称:PDAL,代码行数:9,代码来源:Options.cpp

示例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);
    }
}
开发者ID:spolitov,项目名称:lib,代码行数:9,代码来源:xml.cpp

示例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)
 {}
开发者ID:JanBe,项目名称:KeyRemap4MacBook,代码行数:10,代码来源:extracted_ptree.hpp

示例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;
}
开发者ID:craigmcmillan01,项目名称:Graphics-Programming,代码行数:10,代码来源:scene.cpp

示例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);
    }
}
开发者ID:Yvaine,项目名称:Schweizer-Messer,代码行数:10,代码来源:BoostPropertyTreeImplementation.cpp


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