本文整理汇总了C++中boost::property_tree::ptree类的典型用法代码示例。如果您正苦于以下问题:C++ ptree类的具体用法?C++ ptree怎么用?C++ ptree使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ptree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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...);
}
示例3: serialize
void GunneboReaderUnitConfiguration::serialize(boost::property_tree::ptree& parentNode)
{
boost::property_tree::ptree node;
parentNode.add_child(getDefaultXmlNodeName(), node);
}
示例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 );
}
示例5: unSerialize
void MifareUltralightAccessInfo::unSerialize(boost::property_tree::ptree& node)
{
lockPage = node.get_child("LockPage").get_value<bool>();
}
示例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>();
}
示例7: setup
void utility::setup(const boost::property_tree::ptree &ptree) {
if (!ptree.empty()) BOOST_THROW_EXCEPTION(error("not implemented"));
}
示例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();
}
示例9:
MLC_Config::MLC_Config(const boost::property_tree::ptree& pt, const char* name)
{
mConfigSet = pt.get_child(name);
}
示例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;
}
}
示例11: unSerialize
void NFCReaderUnit::unSerialize(boost::property_tree::ptree& node)
{
d_name = node.get_child("Name").get_value<std::string>();
ReaderUnit::unSerialize(node);
}
示例12: serializeDistributedQueryRequest
Status serializeDistributedQueryRequest(const DistributedQueryRequest& r,
pt::ptree& tree) {
tree.put("query", r.query);
tree.put("id", r.id);
return Status(0, "OK");
}
示例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;
//.........这里部分代码省略.........
示例14: unSerialize
void TwicLocation::unSerialize(boost::property_tree::ptree& node)
{
dataObject = node.get_child("DataObject").get_value<uint64_t>();
}
示例15:
void NXPAV1KeyDiversification::serialize(boost::property_tree::ptree& parentNode)
{
boost::property_tree::ptree node;
parentNode.add_child(getDefaultXmlNodeName(), node);
}