• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ property_tree::ptree类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中boost::property_tree::ptree的典型用法代码示例。如果您正苦于以下问题:C++ ptree类的具体用法?C++ ptree怎么用?C++ ptree使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ptree类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: operator

    void operator()( boost::property_tree::ptree & state, const device_free_space< IntType, OrderTag > & obj ) {
//        state.put( "total", obj.total);
//
        typedef device_free_space< IntType, OrderTag > space_type;
        typedef typename space_type::int_type  int_type;

        state_getter < device_event_space< IntType, OrderTag > > base_getter;
        base_getter( state, obj );

        state.put( "fixed_count", obj.fixed_count );
        state.put( "size", obj.size );
        state.put( "capacity", obj.capacity );

        if( obj.free_list == NULL ) {
            state.put( "free_list", "" );
            state.put( "free_map", "" );
            state.put( "fixed_list", "" );
            state.put( "lost_list", "" );
            return;
        }

        unsigned int nInts = obj.size / space_type::OBJECTS_PER_INT;
        int_type * flist = new int_type[ nInts ];

        copy_heap_data( flist, obj.free_list, nInts );

        boost::property_tree::ptree fl, xl, ll;
        for( unsigned int i = 0; i < nInts; ++i ) {
            std::ostringstream oss;
            oss << "0x" << std::hex << std::setw( sizeof( int_type) * 2 ) << std::setfill( '0' ) << flist[i];

            clotho::utility::add_value_array( fl, oss.str() );
        }

        copy_heap_data( flist, obj.fixed_list, nInts );

        for( unsigned int i = 0; i < nInts; ++i ) {
            std::ostringstream oss;
            oss << "0x" << std::hex << std::setw( sizeof( int_type) * 2 ) << std::setfill( '0' ) << flist[i];

            clotho::utility::add_value_array( xl, oss.str() );
        }

        copy_heap_data( flist, obj.lost_list, nInts );

        for( unsigned int i = 0; i < nInts; ++i ) {
            std::ostringstream oss;
            oss << "0x" << std::hex << std::setw( sizeof( int_type) * 2 ) << std::setfill( '0' ) << flist[i];

            clotho::utility::add_value_array( ll, oss.str() );
        }

        unsigned int * fmap = new unsigned int[ obj.size ];

        copy_heap_data( fmap, obj.free_map, obj.size );

        boost::property_tree::ptree fm;
        for( unsigned int i = 0; i < obj.size; ++i ) {
            clotho::utility::add_value_array( fm, fmap[i] );
        }

        state.add_child( "free_list", fl );
        state.add_child( "free_map", fm );
        state.add_child( "lost_list", ll );
        state.add_child( "fixed_list", xl );

        delete flist;
        delete fmap;
    }
开发者ID:putnampp,项目名称:clotho,代码行数:69,代码来源:device_free_space_helper.hpp


示例2: populate

 void populate(boost::property_tree::ptree& tree, Key&& key, Value&& value, Remaining&&... args)
 {
     this->properties.insert(std::make_pair(key, std::make_pair(tree.get(key, value), value)));
     populate(tree, args...);
 }
开发者ID:KILLGPL,项目名称:FontSync,代码行数:5,代码来源:Config.cpp


示例3: serialize

 void GunneboReaderUnitConfiguration::serialize(boost::property_tree::ptree& parentNode)
 {
     boost::property_tree::ptree node;
     parentNode.add_child(getDefaultXmlNodeName(), node);
 }
开发者ID:Rick0124,项目名称:liblogicalaccess,代码行数:5,代码来源:gunneboreaderunitconfiguration.cpp


示例4: logMutationBinFrequencies

void logMutationBinFrequencies( boost::property_tree::ptree & p, std::vector< size_t > & frequencies, unsigned int bin_count, typename locus_bitset::alphabet_t::pointer alpha ) {
    boost::property_tree::ptree v, _v0, _v1, _v2;
    std::string key = "genome_bin";
    _v0.put("", "Bin");
    _v1.put("", "Offset");
    _v2.put("", "Frequency");
    v.push_back( std::make_pair("", _v0));
    v.push_back( std::make_pair("", _v1));
    v.push_back( std::make_pair("", _v2));
    p.add_child( key +".y.smps", v);

    boost::property_tree::ptree x, _x0, _x1, _x2;
    _x0.put("", "Bin index" );
    _x1.put("", "Genomic offset relative to bin" );
    _x2.put("", "Frequency of allele in population" );
    x.push_back( std::make_pair("", _x0 ) );
    x.push_back( std::make_pair("", _x1 ) );
    x.push_back( std::make_pair("", _x2 ) );

    p.add_child( key + ".x.Description", x);

    boost::property_tree::ptree d,s;

    typename locus_bitset::alphabet_t::active_iterator alpha_it = alpha->active_begin();

    typedef  std::vector< std::map< double, size_t > > bin_freq_type;
    bin_freq_type bin_freq( bin_count, std::map<double, size_t>() );

    for( std::vector< size_t >::iterator it = frequencies.begin(); it != frequencies.end(); ++it ) {
        if( *it > 0 ) {
            assert( alpha->checkFreeStatus( it - frequencies.begin()) );
            unsigned int bin_idx = alpha_it->first * bin_count;

            double lo = (double)(bin_idx) / (double) bin_count;

            double offset = alpha_it->first - lo;

            bin_freq[bin_idx].insert( std::make_pair( offset, (*it)));
        }
        ++alpha_it;
    }

    unsigned int bin_idx = 0;
    for( bin_freq_type::iterator it = bin_freq.begin(); it != bin_freq.end(); ++it ) {
        double lo = (double)(bin_idx) / (double) bin_count;
        boost::property_tree::ptree w;
        w.put( "", lo);
        unsigned int offset = 0;
        for( std::map< double, size_t >::iterator it2 = it->begin(); it2 != it->end(); ++it2 ) {
            boost::property_tree::ptree x,y,z, _s;
            x.put( "", it2->first);
            y.put( "", it2->second);
            z.push_back( std::make_pair("", w ));
            z.push_back( std::make_pair("", x ));
            z.push_back( std::make_pair("", y ));

            d.push_back( std::make_pair("", z ));

            std::ostringstream oss;
            oss << bin_idx << "_" << offset++;
            _s.put("", oss.str());
            s.push_back( std::make_pair("", _s));
        }
        ++bin_idx;
    }

    p.add_child( key + ".y.vars", s );
    p.add_child( key + ".y.data", d );

    boost::property_tree::ptree graph_opts;

    graph_opts.put("graphType", "Scatter3D");

    {
        boost::property_tree::ptree tmp, t;
        t.put("", "Bin");
        tmp.push_back( std::make_pair("", t ) );
        graph_opts.add_child("xAxis", tmp);
    }
    {
        boost::property_tree::ptree tmp, t;
        t.put("", "Offset");
        tmp.push_back( std::make_pair( "",t));
        graph_opts.add_child("zAxis", tmp);
    }
    {
        boost::property_tree::ptree tmp, t;
        t.put("", "Frequency");
        tmp.push_back( std::make_pair("", t ));
        graph_opts.add_child("yAxis", tmp);
    }
    graph_opts.put( "title", "Mutation Distribution grouped by bin" );

    p.add_child( key + ".graph_opts", graph_opts );
}
开发者ID:putnampp,项目名称:clotho,代码行数:95,代码来源:population_graphs.cpp


示例5: unSerialize

 void MifareUltralightAccessInfo::unSerialize(boost::property_tree::ptree& node)
 {
     lockPage = node.get_child("LockPage").get_value<bool>();
 }
开发者ID:Rick0124,项目名称:liblogicalaccess,代码行数:4,代码来源:mifareultralightaccessinfos.cpp


示例6: unSerialize

 void MifareUltralightLocation::unSerialize(boost::property_tree::ptree& node)
 {
     page = node.get_child("Page").get_value<int>();
     byte = node.get_child("Byte").get_value<int>();
 }
开发者ID:Rick0124,项目名称:liblogicalaccess,代码行数:5,代码来源:mifareultralightlocation.cpp


示例7: setup

void utility::setup(const boost::property_tree::ptree &ptree) {
  if (!ptree.empty()) BOOST_THROW_EXCEPTION(error("not implemented"));
}
开发者ID:bunsanorg,项目名称:utility,代码行数:3,代码来源:utility.cpp


示例8: MMT_data_t

 MMT_data_t(const boost::property_tree::ptree& pt) :
     base_t(pt.get<int>("N"), pt.get<int>("S"),
         base::context_t(pt.get_child("creation_context")), "MMT") { 
     base_t::build();
 }
开发者ID:caomw,项目名称:libskylark,代码行数:5,代码来源:MMT_data.hpp


示例9:

MLC_Config::MLC_Config(const boost::property_tree::ptree& pt, const char* name)
{
    mConfigSet = pt.get_child(name);
}
开发者ID:hominlinx,项目名称:cppbed,代码行数:4,代码来源:MLC_Config.cpp


示例10: initialize

void Pack::initialize(const std::string& name,
                      const std::string& source,
                      const pt::ptree& tree) {
  name_ = name;
  source_ = source;
  discovery_queries_.clear();
  if (tree.count("discovery") > 0) {
    for (const auto& item : tree.get_child("discovery")) {
      discovery_queries_.push_back(item.second.get_value<std::string>());
    }
  }

  discovery_cache_ = std::make_pair<int, bool>(0, false);
  stats_ = {0, 0, 0};

  platform_.clear();
  if (tree.count("platform") > 0) {
    platform_ = tree.get<std::string>("platform", "");
  }

  version_.clear();
  if (tree.count("version") > 0) {
    version_ = tree.get<std::string>("version", "");
  }

  schedule_.clear();
  if (tree.count("queries") == 0) {
    // This pack contained no queries.
    return;
  }

  // If the splay percent is less than 1 reset to a sane estimate.
  if (FLAGS_schedule_splay_percent <= 1) {
    FLAGS_schedule_splay_percent = 10;
  }

  // Iterate the queries (or schedule) and check platform/version/sanity.
  for (const auto& q : tree.get_child("queries")) {
    if (q.second.count("platform")) {
      if (!checkPlatform(q.second.get<std::string>("platform", ""))) {
        continue;
      }
    }

    if (q.second.count("version")) {
      if (!checkVersion(q.second.get<std::string>("version", ""))) {
        continue;
      }
    }

    ScheduledQuery query;
    query.query = q.second.get<std::string>("query", "");
    query.interval = q.second.get("interval", FLAGS_schedule_default_interval);
    if (query.interval <= 0 || query.query.empty()) {
      // Invalid pack query.
      continue;
    }

    query.splayed_interval = restoreSplayedValue(q.first, query.interval);
    query.options["snapshot"] = q.second.get<bool>("snapshot", false);
    query.options["removed"] = q.second.get<bool>("removed", true);
    schedule_[q.first] = query;
  }
}
开发者ID:mgoffin,项目名称:osquery,代码行数:64,代码来源:packs.cpp


示例11: unSerialize

    void NFCReaderUnit::unSerialize(boost::property_tree::ptree& node)
    {
		d_name = node.get_child("Name").get_value<std::string>();
        ReaderUnit::unSerialize(node);
    }
开发者ID:islog,项目名称:liblogicalaccess-libnfc,代码行数:5,代码来源:nfcreaderunit.cpp


示例12: serializeDistributedQueryRequest

Status serializeDistributedQueryRequest(const DistributedQueryRequest& r,
                                        pt::ptree& tree) {
  tree.put("query", r.query);
  tree.put("id", r.id);
  return Status(0, "OK");
}
开发者ID:AidHamza,项目名称:osquery,代码行数:6,代码来源:database.cpp


示例13: setProperties

void Agent::setProperties(const boost::property_tree::ptree& properties) {
    static const std::string LOG_LEVEL("log.level");
    static const std::string ENDPOINT_SOURCE_PATH("endpoint-sources.filesystem");
    static const std::string SERVICE_SOURCE_PATH("service-sources.filesystem");
    static const std::string OPFLEX_PEERS("opflex.peers");
    static const std::string OPFLEX_SSL_MODE("opflex.ssl.mode");
    static const std::string OPFLEX_SSL_CA_STORE("opflex.ssl.ca-store");
    static const std::string OPFLEX_SSL_CERT_PATH("opflex.ssl.client-cert.path");
    static const std::string OPFLEX_SSL_CERT_PASS("opflex.ssl.client-cert.password");
    static const std::string HOSTNAME("hostname");
    static const std::string PORT("port");
    static const std::string OPFLEX_INSPECTOR("opflex.inspector.enabled");
    static const std::string OPFLEX_INSPECTOR_SOCK("opflex.inspector.socket-name");
    static const std::string OPFLEX_NOTIF("opflex.notif.enabled");
    static const std::string OPFLEX_NOTIF_SOCK("opflex.notif.socket-name");
    static const std::string OPFLEX_NOTIF_OWNER("opflex.notif.socket-owner");
    static const std::string OPFLEX_NOTIF_GROUP("opflex.notif.socket-group");
    static const std::string OPFLEX_NOTIF_PERMS("opflex.notif.socket-permissions");

    static const std::string OPFLEX_NAME("opflex.name");
    static const std::string OPFLEX_DOMAIN("opflex.domain");

    static const std::string RENDERERS_STITCHED_MODE("renderers.stitched-mode");

    optional<std::string> logLvl =
        properties.get_optional<std::string>(LOG_LEVEL);
    if (logLvl) {
        setLoggingLevel(logLvl.get());
    }

    boost::optional<std::string> ofName =
        properties.get_optional<std::string>(OPFLEX_NAME);
    if (ofName) opflexName = ofName;
    boost::optional<std::string> ofDomain =
        properties.get_optional<std::string>(OPFLEX_DOMAIN);
    if (ofDomain) opflexDomain = ofDomain;

    boost::optional<bool> enabInspector =
        properties.get_optional<bool>(OPFLEX_INSPECTOR);
    boost::optional<std::string> inspSocket =
        properties.get_optional<std::string>(OPFLEX_INSPECTOR_SOCK);
    if (enabInspector) enableInspector = enabInspector;
    if (inspSocket) inspectorSock = inspSocket;

    boost::optional<bool> enabNotif =
        properties.get_optional<bool>(OPFLEX_NOTIF);
    boost::optional<std::string> notSocket =
        properties.get_optional<std::string>(OPFLEX_NOTIF_SOCK);
    boost::optional<std::string> notOwner =
        properties.get_optional<std::string>(OPFLEX_NOTIF_OWNER);
    boost::optional<std::string> notGrp =
        properties.get_optional<std::string>(OPFLEX_NOTIF_GROUP);
    boost::optional<std::string> notPerms =
        properties.get_optional<std::string>(OPFLEX_NOTIF_PERMS);
    if (enabNotif) enableNotif = enabNotif;
    if (notSocket) notifSock = notSocket;
    if (notOwner) notifOwner = notOwner;
    if (notGrp) notifGroup = notGrp;
    if (notPerms) notifPerms = notPerms;

    optional<const ptree&> endpointSource =
        properties.get_child_optional(ENDPOINT_SOURCE_PATH);

    if (endpointSource) {
        for (const ptree::value_type &v : endpointSource.get())
            endpointSourcePaths.insert(v.second.data());
    }

    optional<const ptree&> serviceSource =
        properties.get_child_optional(SERVICE_SOURCE_PATH);

    if (serviceSource) {
        for (const ptree::value_type &v : serviceSource.get())
            serviceSourcePaths.insert(v.second.data());
    }

    optional<const ptree&> peers =
        properties.get_child_optional(OPFLEX_PEERS);
    if (peers) {
        for (const ptree::value_type &v : peers.get()) {
            optional<std::string> h =
                v.second.get_optional<std::string>(HOSTNAME);
            optional<int> p =
                v.second.get_optional<int>(PORT);
            if (h && p) {
                opflexPeers.insert(make_pair(h.get(), p.get()));
            }
        }
    }

    boost::optional<std::string> confSslMode =
        properties.get_optional<std::string>(OPFLEX_SSL_MODE);
    boost::optional<std::string> confsslCaStore =
        properties.get_optional<std::string>(OPFLEX_SSL_CA_STORE);
    boost::optional<std::string> confsslClientCert =
        properties.get_optional<std::string>(OPFLEX_SSL_CERT_PATH);
    boost::optional<std::string> confsslClientCertPass =
        properties.get_optional<std::string>(OPFLEX_SSL_CERT_PASS);
    if (confSslMode)
        sslMode = confSslMode;
//.........这里部分代码省略.........
开发者ID:mhrobinson,项目名称:opflex,代码行数:101,代码来源:Agent.cpp


示例14: unSerialize

 void TwicLocation::unSerialize(boost::property_tree::ptree& node)
 {
     dataObject = node.get_child("DataObject").get_value<uint64_t>();
 }
开发者ID:drewet,项目名称:liblogicalaccess,代码行数:4,代码来源:twiclocation.cpp


示例15:

 void NXPAV1KeyDiversification::serialize(boost::property_tree::ptree& parentNode)
 {
     boost::property_tree::ptree node;
     parentNode.add_child(getDefaultXmlNodeName(), node);
 }
开发者ID:drewet,项目名称:liblogicalaccess,代码行数:5,代码来源:nxpav1keydiversification.cpp


示例16: serialize

 void MifareUltralightAccessInfo::serialize(boost::property_tree::ptree& parentNode)
 {
     boost::property_tree::ptree node;
     node.put("LockPage", lockPage);
     parentNode.add_child(MifareUltralightAccessInfo::getDefaultXmlNodeName(), node);
 }
开发者ID:Rick0124,项目名称:liblogicalaccess,代码行数:6,代码来源:mifareultralightaccessinfos.cpp


示例17: ProduceExcelWorkbook

bool ProduceExcelWorkbook(Excel::_WorkbookPtr &pXLBook,
	const std::wstring &wstrFilename,
	const std::string &strPropellant,
	bool bMetric,
	const boost::property_tree::ptree &tree,
	const std::vector<std::tuple<double, double, double, double, double> > &vReadings,
	std::map<std::wstring, std::wstring> &mapProperties)
{
	if(vReadings.empty())
	{
		return false;
	}
	// Get the active Worksheet and set its name.
	Excel::_WorksheetPtr pXLSheet = pXLBook->ActiveSheet;
	_ASSERT(pXLSheet);
	if(nullptr == pXLSheet)
	{
		return false;
	}

	//
	// Get Max Pressure to calculate the 10% line
	double dPmaxtime = 0.0f;
	double dPmax = GetPmax(dPmaxtime, vReadings);
	double dpTenPercent = dPmax * 0.10f;

	//
	// Need to know the start and stop burn time based on 10% of Pmax:
	double dBurnStartTime = 0.0f;
	double dBurnEndTime = 0.0f;
	LONG lIndexBurnStart = 0;
	LONG lIndexBurnEnd = 0;
	LONG lExcelIndex = 1;
	bool bHaveEndTime = false;
	for(auto entry : vReadings)
	{
		double dPressure = std::get<ePressure>(entry);
		double dTime = std::get<eTime>(entry);
		++lExcelIndex;
		if(dTime <= dPmaxtime)
		{
			if(dPressure < dpTenPercent)
			{
				continue;
			}
			if(0 == lIndexBurnStart)
			{
				dBurnStartTime = dTime;
				lIndexBurnStart = lExcelIndex;
			}
		}
		else
		{
			// Watching the curve downward...
			lIndexBurnEnd = lExcelIndex;
			if(dPressure < dpTenPercent)
			{
				break;
			}
			dBurnEndTime = dTime;
		}
	}
	double dBurnTime = dBurnEndTime - dBurnStartTime;

	//
	// Convert name to a wide string and assign it to the sheet
	std::wstring wstrTabName(wstrFilename);
	SanitizeStringName(wstrTabName);

	//
	// Remove any math operators from the name:
	_bstr_t bstrTabName(SysAllocString(wstrTabName.c_str()));
	pXLSheet->Name = bstrTabName;

	std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
	// std::wstring wstrPropellantName(converter.from_bytes(strPropellant.c_str()));

	//
	// Create seven columns of data: Time, Thrust (LBS), Thrust (N), and Pressure (PSI), ...
	// Construct a safearray of the data
	LONG lIndex = 2;		// Note, 1 based not 0 - will contain # of rows...
	VARIANT saData;
	VARIANT saDataReferences;
	saData.vt = VT_ARRAY | VT_VARIANT;
	saDataReferences.vt = VT_ARRAY | VT_VARIANT;
	{
		SAFEARRAYBOUND sab[2];
		sab[0].lLbound = 1;
		sab[0].cElements = vReadings.size() + 2;
		sab[1].lLbound = 1;
		sab[1].cElements = 7;
		saData.parray = SafeArrayCreate(VT_VARIANT, 2, sab);
		if(saData.parray == nullptr)
		{
			MessageBoxW(HWND_TOP, L"Unable to create safearray for passing data to Excel.", L"Memory error...", MB_TOPMOST | MB_ICONERROR);
			return false;
		}

		//
		// Clean-up safe array when done...
//.........这里部分代码省略.........
开发者ID:alsliahona,项目名称:TCLogger2Excel,代码行数:101,代码来源:ExcelAutomation.cpp


示例18: unSerialize

 void RFIDeasReaderUnit::unSerialize(boost::property_tree::ptree& node)
 {
     d_readerUnitConfig->unSerialize(node.get_child(d_readerUnitConfig->getDefaultXmlNodeName()));
 }
开发者ID:islog,项目名称:liblogicalaccess,代码行数:4,代码来源:rfideasreaderunit.cpp


示例19: set_attr

void set_attr(boost::property_tree::ptree & pt, std::string const& name, T const& v)
{
    pt.put("<xmlattr>." + name, v);
}
开发者ID:CartoDB,项目名称:mapnik,代码行数:4,代码来源:ptree_helpers.hpp


示例20: fromPT

void SInit::fromPT(const boost::property_tree::ptree& _pt)
{
    const ptree& pt = _pt.get_child("dds.plug-in");
    m_id = pt.get<string>("id");
}
开发者ID:AnarManafov,项目名称:DDS,代码行数:5,代码来源:dds_rms_plugin_protocol.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ property_tree::wptree类代码示例发布时间:2022-05-31
下一篇:
C++ program_options::variables_map类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap