void mergePropertyTrees (boost::property_tree::ptree &ptMerged, const boost::property_tree::ptree &ptSecond, int level ) { // Value or object or array if (level > 0 && ptSecond.empty() ) { // Copy value ptMerged = ptSecond; } else if (level > 0 && ptSecond.count (std::string() ) == ptSecond.size() ) { // Copy array ptMerged = ptSecond; } else { auto it = ptSecond.begin(); for (; it != ptSecond.end(); ++it) { boost::property_tree::ptree child = ptMerged.get_child (it->first.data(), boost::property_tree::ptree() ); mergePropertyTrees (child, it->second, level + 1); ptMerged.erase (it->first.data() ); ptMerged.add_child (it->first.data(), child); } } }
void parse_configuration( boost::property_tree::ptree & config ) { boost::property_tree::ptree lconfig; if( config.get_child_optional( "mutation" ) != boost::none ) { lconfig = config.get_child( "mutation" ); } if( lconfig.get_child_optional( "mutation_per_sequence" ) == boost::none ) { lconfig.put("mutation_per_sequence", m_mutation_rate ); } else { m_mutation_rate = lconfig.get< real_type >( "mutation_per_sequence", m_mutation_rate ); } if( lconfig.get_child_optional( "rng.seed" ) != boost::none ) { m_seed = lconfig.get< seed_type >( "rng.seed", m_seed ); } if( m_seed == 0 ) { m_seed = clotho::utility::clock_type::now().time_since_epoch().count(); lconfig.put("rng.seed", m_seed ); } config.put_child( "mutation", lconfig ); }
tsun::tsun(const boost::property_tree::ptree& sun) : tsun{sun.get<std::string>("id"), geometry::tcartesian::load(sun.get_child("position"))} { TRACE; }
void VarOrderPtree::ReadPtree(const boost::property_tree::ptree& pt, const wxString& proj_path) { LOG_MSG("Entering VarOrderPtree::ReadPtree"); using boost::property_tree::ptree; using namespace std; set<wxString> grp_set; try { try { pt.get_child("variable_order"); } catch (boost::property_tree::ptree_bad_path& e) { // variable_order is optional return; } // iterate over each child of variable_order time_ids.clear(); BOOST_FOREACH(const ptree::value_type &v, pt.get_child("variable_order")) { wxString key = v.first.data(); LOG_MSG(key); if (key == "var") { VarGroup ent; ent.name = v.second.data(); LOG_MSG("found var: "); LOG_MSG(v.second.data()); //var_order.push_back(v.second.data()); var_grps.push_back(ent); } else if (key == "time_ids") { BOOST_FOREACH(const ptree::value_type &v, v.second) { wxString key = v.first.data(); LOG_MSG(key); LOG_MSG(v.second.data()); time_ids.push_back(v.second.data()); } } else if (key == "group") { VarGroup ent; BOOST_FOREACH(const ptree::value_type &v, v.second) { wxString key = v.first.data(); if (key == "name") { LOG_MSG("found name: "); LOG_MSG(v.second.data()); ent.name = v.second.data(); } else if (key == "var") { LOG_MSG("found var: "); LOG_MSG(v.second.data()); ent.vars.push_back(v.second.data()); } else if (key == "placeholder") { LOG_MSG("placeholder found"); ent.vars.push_back(""); } else if (key == "displayed_decimals") { wxString vs(v.second.data()); LOG_MSG("found displayed_decimals: "); LOG_MSG(vs); long dd; if (!vs.ToLong(&dd)) dd = -1; ent.displayed_decimals = dd; } } if (ent.name.empty()) { wxString msg = "space-time variable found with no name"; throw GdaException(msg.mb_str()); } if (grp_set.find(ent.name) != grp_set.end()) { wxString ss; ss << "Space-time variables with duplicate name \""; ss << ent.name << "\" found."; throw GdaException(ss.mb_str()); } var_grps.push_back(ent); grp_set.insert(ent.name); }
void WeightsManPtree::ReadPtree(const boost::property_tree::ptree& pt, const wxString& proj_path) { LOG_MSG("Entering WeightsManPtree::ReadPtree"); using boost::property_tree::ptree; using namespace std; weights_list.clear(); try { try { pt.get_child("weights_entries"); } catch (boost::property_tree::ptree_bad_path& e) { // weights_entries is optional return; } // iterate over each child of weights_entries BOOST_FOREACH(const ptree::value_type &v, pt.get_child("weights_entries")) { wxString key = v.first.data(); LOG_MSG(key); if (key == "weights") { WeightsPtreeEntry e; BOOST_FOREACH(const ptree::value_type &v, v.second) { wxString key = v.first.data(); LOG_MSG(key); if (key == "title") { wxString s = v.second.data(); e.title = s; } else if (key == "default") { e.is_default = true; } else if (key == "meta_info") { BOOST_FOREACH(const ptree::value_type &v, v.second) { wxString key = v.first.data(); LOG_MSG(key); if (key == "weights_type") { wxString s = v.second.data(); if (s == "rook") { e.wmi.weights_type = WeightsMetaInfo::WT_rook; } else if (s == "queen") { e.wmi.weights_type = WeightsMetaInfo::WT_queen; } else if (s == "threshold") { e.wmi.weights_type = WeightsMetaInfo::WT_threshold; } else if (s == "knn") { e.wmi.weights_type = WeightsMetaInfo::WT_knn; } else { // s == "custom" e.wmi.weights_type = WeightsMetaInfo::WT_custom; } } else if (key == "path") { wxString s = v.second.data(); e.wmi.filename = GenUtils::RestorePath(proj_path, s); if (!wxFileExists(e.wmi.filename)) { wxString msg; msg << "The GeoDa project file cannot find one or more associated data sources.\n\n"; msg << "Details: Weights file (" << e.wmi.filename << ") is missing"; msg << "\n\nTip: You can open the .gda project file in a text editor to modify the path(s) of the weights file(s) (.gwt or .gal extension) associated with your project."; throw GdaException(msg.mb_str()); } } else if (key == "id_variable") { wxString s = v.second.data(); e.wmi.id_var = s; } else if (key == "symmetry") { wxString s = v.second.data(); if (s == "symmetric") { e.wmi.sym_type = WeightsMetaInfo::SYM_symmetric; } else if (s == "asymmetric") { e.wmi.sym_type = WeightsMetaInfo::SYM_asymmetric; } else if (s == "unknown" || s.IsEmpty()) { e.wmi.sym_type = WeightsMetaInfo::SYM_unknown; } else { wxString msg("unrecognized value: "); msg << s << " for key: " << key; throw GdaException(msg.mb_str()); } } else if (key == "order") { long l; wxString(v.second.data()).ToLong(&l); e.wmi.order = l; } else if (key == "inc_lower_orders") { wxString s = v.second.data(); if (s.CmpNoCase("false") == 0) { e.wmi.inc_lower_orders = false; } else if (s.CmpNoCase("true") == 0) { e.wmi.inc_lower_orders = true; } else { wxString msg("unrecognized value: "); msg << s << " for key: " << key; throw GdaException(msg.mb_str()); } } else if (key == "dist_metric") { wxString s = v.second.data(); if (s == "euclidean") { e.wmi.dist_metric = WeightsMetaInfo::DM_euclidean; } else if (s == "arc") { e.wmi.dist_metric = WeightsMetaInfo::DM_arc; } else if (s == "unspecified" || s.IsEmpty()) { e.wmi.dist_metric = WeightsMetaInfo::DM_unspecified; } else { wxString msg("unrecognized value: "); msg << s << " for key: " << key; throw GdaException(msg.mb_str()); } } else if (key == "dist_units") { wxString s = v.second.data(); if (s == "km") { e.wmi.dist_units = WeightsMetaInfo::DU_km; } else if (s == "mile") { e.wmi.dist_units = WeightsMetaInfo::DU_mile; } else { e.wmi.dist_units = WeightsMetaInfo::DU_unspecified; e.wmi.dist_units_str = s; } } else if (key == "dist_values") { wxString s = v.second.data(); if (s == "centroids") { e.wmi.dist_values = WeightsMetaInfo::DV_centroids; } else if (s == "mean_centers") { e.wmi.dist_values = WeightsMetaInfo::DV_mean_centers; } else if (s == "vars") { e.wmi.dist_values = WeightsMetaInfo::DV_vars; } else if (s == "unspecified" || s.IsEmpty()) { e.wmi.dist_values = WeightsMetaInfo::DV_unspecified; } else { wxString msg("unrecognized value: "); msg << s << " for key: " << key; throw GdaException(msg.mb_str()); } } else if (key == "dist_var1") { wxString s = v.second.data(); e.wmi.dist_var1 = s; e.wmi.dist_values = WeightsMetaInfo::DV_vars; } else if (key == "dist_var2") { wxString s = v.second.data(); e.wmi.dist_var2 = s; e.wmi.dist_values = WeightsMetaInfo::DV_vars; } else if (key == "dist_tm1") { long l; wxString(v.second.data()).ToLong(&l); e.wmi.dist_tm1 = l; } else if (key == "dist_tm2") { long l; wxString(v.second.data()).ToLong(&l); e.wmi.dist_tm2 = l; } else if (key == "num_neighbors") { long l; wxString(v.second.data()).ToLong(&l); e.wmi.num_neighbors = l; } else if (key == "threshold_val") { double d; wxString(v.second.data()).ToDouble(&d); e.wmi.threshold_val = d; } } } else { // ignore unrecognized key wxString msg("unrecognized key: "); msg << key; LOG_MSG(msg); } } LOG_MSG(e.ToStr()); weights_list.push_back(e); } else {
void parse_ptree(boost::property_tree::ptree& pt, std::shared_ptr<dabEnsemble> ensemble, std::shared_ptr<BaseRemoteController> rc ) { using boost::property_tree::ptree; using boost::property_tree::ptree_error; /******************** READ GENERAL OPTIONS *****************/ ptree pt_general = pt.get_child("general"); /* Dab mode logic */ ensemble->mode = pt_general.get("dabmode", 2); if ((ensemble->mode < 1) || (ensemble->mode > 4)) { throw runtime_error("Mode must be between 1-4"); } if (ensemble->mode == 4) { ensemble->mode = 0; } /* Enable Logging to syslog conditionally */ if (pt_general.get<bool>("syslog", false)) { etiLog.register_backend(new LogToSyslog()); // TODO don't leak the LogToSyslog backend } /******************** READ ENSEMBLE PARAMETERS *************/ ptree pt_ensemble = pt.get_child("ensemble"); /* Ensemble ID */ ensemble->id = hexparse(pt_ensemble.get("id", "0")); /* Extended Country Code */ ensemble->ecc = hexparse(pt_ensemble.get("ecc", "0")); ensemble->international_table = pt_ensemble.get("international-table", 0); string lto_auto = pt_ensemble.get("local-time-offset", ""); if (lto_auto == "auto") { ensemble->lto_auto = true; ensemble->lto = 0; } else { double lto_hours = pt_ensemble.get("local-time-offset", 0.0); if (round(lto_hours * 2) != lto_hours * 2) { etiLog.level(error) << "Ensemble local time offset " << lto_hours << "h cannot be expressed in half-hour blocks."; throw runtime_error("ensemble local-time-offset definition error"); } if (lto_hours > 12 || lto_hours < -12) { etiLog.level(error) << "Ensemble local time offset " << lto_hours << "h out of bounds [-12, +12]."; throw runtime_error("ensemble local-time-offset definition error"); } ensemble->lto_auto = false; ensemble->lto = abs(rint(lto_hours * 2)); } int success = -5; string ensemble_label = pt_ensemble.get<string>("label"); string ensemble_short_label(ensemble_label); try { ensemble_short_label = pt_ensemble.get<string>("shortlabel"); success = ensemble->label.setLabel(ensemble_label, ensemble_short_label); } catch (ptree_error &e) { etiLog.level(warn) << "Ensemble short label undefined, " "truncating label " << ensemble_label; success = ensemble->label.setLabel(ensemble_label); } switch (success) { case 0: break; case -1: etiLog.level(error) << "Ensemble short label " << ensemble_short_label << " is not subset of label '" << ensemble_label << "'"; throw runtime_error("ensemble label definition error"); case -2: etiLog.level(error) << "Ensemble short label " << ensemble_short_label << " is too long (max 8 characters)"; throw runtime_error("ensemble label definition error"); case -3: etiLog.level(error) << "Ensemble label " << ensemble_label << " is too long (max 16 characters)"; throw runtime_error("ensemble label definition error"); default: etiLog.level(error) << "Ensemble short label definition: program error !"; abort(); } try { ptree pt_announcements = pt_ensemble.get_child("announcements"); for (auto announcement : pt_announcements) { string name = announcement.first; ptree pt_announcement = announcement.second; auto cl = make_shared<AnnouncementCluster>(name); cl->cluster_id = hexparse(pt_announcement.get<string>("cluster")); cl->flags = get_announcement_flag_from_ptree( pt_announcement.get_child("flags")); cl->subchanneluid = pt_announcement.get<string>("subchannel"); cl->enrol_at(*rc); ensemble->clusters.push_back(cl); } } catch (ptree_error& e) { etiLog.level(info) << "No announcements defined in ensemble"; etiLog.level(debug) << "because " << e.what(); } /******************** READ SERVICES PARAMETERS *************/ map<string, shared_ptr<DabService> > allservices; /* For each service, we keep a separate SCIdS counter */ map<shared_ptr<DabService>, int> SCIdS_per_service; ptree pt_services = pt.get_child("services"); for (ptree::iterator it = pt_services.begin(); it != pt_services.end(); ++it) { string serviceuid = it->first; ptree pt_service = it->second; shared_ptr<DabService> service; bool service_already_existing = false; for (auto srv : ensemble->services) { if (srv->uid == serviceuid) { service = srv; service_already_existing = true; break; } } if (not service_already_existing) { auto new_srv = make_shared<DabService>(serviceuid); ensemble->services.push_back(new_srv); service = new_srv; } try { /* Parse announcements */ service->ASu = get_announcement_flag_from_ptree( pt_service.get_child("announcements")); auto clusterlist = pt_service.get<std::string>("announcements.clusters", ""); vector<string> clusters_s; boost::split(clusters_s, clusterlist, boost::is_any_of(",")); for (const auto& cluster_s : clusters_s) { if (cluster_s == "") { continue; } try { service->clusters.push_back(hexparse(cluster_s)); } catch (std::logic_error& e) { etiLog.level(warn) << "Cannot parse '" << clusterlist << "' announcement clusters for service " << serviceuid << ": " << e.what(); } } if (service->ASu != 0 and service->clusters.empty()) { etiLog.level(warn) << "Cluster list for service " << serviceuid << "is empty, but announcements are defined"; } } catch (ptree_error& e) { service->ASu = 0; service->clusters.clear(); etiLog.level(info) << "No announcements defined in service " << serviceuid; } int success = -5; string servicelabel = pt_service.get<string>("label"); string serviceshortlabel(servicelabel); try { serviceshortlabel = pt_service.get<string>("shortlabel"); success = service->label.setLabel(servicelabel, serviceshortlabel); } catch (ptree_error &e) { etiLog.level(warn) << "Service short label undefined, " "truncating label " << servicelabel; success = service->label.setLabel(servicelabel); } switch (success) { case 0: break; case -1: etiLog.level(error) << "Service short label " << serviceshortlabel << " is not subset of label '" << servicelabel << "'"; throw runtime_error("service label definition error"); case -2: etiLog.level(error) << "Service short label " << serviceshortlabel << " is too long (max 8 characters)"; throw runtime_error("service label definition error"); case -3: etiLog.level(error) << "Service label " << servicelabel << " is too long (max 16 characters)"; throw runtime_error("service label definition error"); default: etiLog.level(error) << "Service short label definition: program error !"; abort(); } stringstream def_serviceid; def_serviceid << DEFAULT_SERVICE_ID + ensemble->services.size(); service->id = hexparse(pt_service.get("id", def_serviceid.str())); service->pty = hexparse(pt_service.get("pty", "0")); service->language = hexparse(pt_service.get("language", "0")); // keep service in map, and check for uniqueness of the UID if (allservices.count(serviceuid) == 0) { allservices[serviceuid] = service; // Set the service's SCIds to zero SCIdS_per_service[service] = 0; } else { stringstream ss; ss << "Service with uid " << serviceuid << " not unique!"; throw runtime_error(ss.str()); } } /******************** READ SUBCHAN PARAMETERS **************/ map<string, dabSubchannel*> allsubchans; ptree pt_subchans = pt.get_child("subchannels"); for (ptree::iterator it = pt_subchans.begin(); it != pt_subchans.end(); ++it) { string subchanuid = it->first; dabSubchannel* subchan = new dabSubchannel(subchanuid); ensemble->subchannels.push_back(subchan); try { setup_subchannel_from_ptree(subchan, it->second, ensemble, subchanuid, rc); } catch (runtime_error &e) { etiLog.log(error, "%s\n", e.what()); throw e; } // keep subchannels in map, and check for uniqueness of the UID if (allsubchans.count(subchanuid) == 0) { allsubchans[subchanuid] = subchan; } else { stringstream ss; ss << "Subchannel with uid " << subchanuid << " not unique!"; throw runtime_error(ss.str()); } } /******************** READ COMPONENT PARAMETERS ************/ map<string, DabComponent*> allcomponents; ptree pt_components = pt.get_child("components"); for (ptree::iterator it = pt_components.begin(); it != pt_components.end(); ++it) { string componentuid = it->first; ptree pt_comp = it->second; shared_ptr<DabService> service; try { // Those two uids serve as foreign keys to select the service+subchannel string service_uid = pt_comp.get<string>("service"); if (allservices.count(service_uid) != 1) { stringstream ss; ss << "Component with uid " << componentuid << " is refers to unknown service " << service_uid << " !"; throw runtime_error(ss.str()); } service = allservices[service_uid]; } catch (ptree_error &e) { stringstream ss; ss << "Component with uid " << componentuid << " is missing service definition!"; throw runtime_error(ss.str()); } dabSubchannel* subchannel; try { string subchan_uid = pt_comp.get<string>("subchannel"); if (allsubchans.count(subchan_uid) != 1) { stringstream ss; ss << "Component with uid " << componentuid << " is refers to unknown subchannel " << subchan_uid << " !"; throw runtime_error(ss.str()); } subchannel = allsubchans[subchan_uid]; } catch (ptree_error &e) { stringstream ss; ss << "Component with uid " << componentuid << " is missing subchannel definition!"; throw runtime_error(ss.str()); } int figType = hexparse(pt_comp.get("figtype", "-1")); int packet_address = hexparse(pt_comp.get("address", "-1")); int packet_datagroup = pt_comp.get("datagroup", false); uint8_t component_type = hexparse(pt_comp.get("type", "0")); DabComponent* component = new DabComponent(componentuid); component->serviceId = service->id; component->subchId = subchannel->id; component->SCIdS = SCIdS_per_service[service]++; component->type = component_type; int success = -5; string componentlabel = pt_comp.get("label", ""); string componentshortlabel(componentlabel); try { componentshortlabel = pt_comp.get<string>("shortlabel"); success = component->label.setLabel(componentlabel, componentshortlabel); } catch (ptree_error &e) { if (not componentlabel.empty()) { etiLog.level(warn) << "Component short label undefined, " "truncating label " << componentlabel; } success = component->label.setLabel(componentlabel); } switch (success) { case 0: break; case -1: etiLog.level(error) << "Component short label " << componentshortlabel << " is not subset of label '" << componentlabel << "'"; throw runtime_error("component label definition error"); case -2: etiLog.level(error) << "Component short label " << componentshortlabel << " is too long (max 8 characters)"; throw runtime_error("component label definition error"); case -3: etiLog.level(error) << "Component label " << componentlabel << " is too long (max 16 characters)"; throw runtime_error("component label definition error"); default: etiLog.level(error) << "Component short label definition: program error !"; abort(); } if (figType != -1) { if (figType >= (1<<12)) { stringstream ss; ss << "Component with uid " << componentuid << ": figtype '" << figType << "' is too large !"; throw runtime_error(ss.str()); } if (component->isPacketComponent(ensemble->subchannels)) { component->packet.appType = figType; } else { component->audio.uaType = figType; } if (packet_address != -1) { if (! component->isPacketComponent(ensemble->subchannels)) { stringstream ss; ss << "Component with uid " << componentuid << " is not packet, cannot have address defined !"; throw runtime_error(ss.str()); } component->packet.address = packet_address; } if (packet_datagroup) { if (! component->isPacketComponent(ensemble->subchannels)) { stringstream ss; ss << "Component with uid " << componentuid << " is not packet, cannot have datagroup enabled !"; throw runtime_error(ss.str()); } component->packet.datagroup = packet_datagroup; } } ensemble->components.push_back(component); } }
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; } }
void DESFireKey::unSerialize(boost::property_tree::ptree& node) { Key::unSerialize(node); d_keyType = static_cast<DESFireKeyType>(node.get_child("KeyType").get_value<unsigned int>()); d_key_version = node.get_child("KeyVersion").get_value<unsigned char>(); }
void UdpDataTransport::unSerialize(boost::property_tree::ptree& node) { d_ipAddress = node.get_child("IpAddress").get_value<std::string>(); d_port = node.get_child("Port").get_value<int>(); }
void Pack::initialize(const std::string& name, const std::string& source, const pt::ptree& tree) { name_ = name; source_ = source; // Check the shard limitation, shards falling below this value are included. if (tree.count("shard") > 0) { shard_ = tree.get<size_t>("shard", 0); } // Check for a platform restriction. platform_.clear(); if (tree.count("platform") > 0) { platform_ = tree.get<std::string>("platform", ""); } // Check for a version restriction. version_.clear(); if (tree.count("version") > 0) { version_ = tree.get<std::string>("version", ""); } // Apply the shard, platform, and version checking. // It is important to set each value such that the packs meta-table can report // each of the restrictions. if ((shard_ > 0 && shard_ < getMachineShard()) || !checkPlatform() || !checkVersion()) { return; } 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>()); } } // Initialize a discovery cache at time 0. discovery_cache_ = std::make_pair<size_t, bool>(0, false); valid_ = true; // If the splay percent is less than 1 reset to a sane estimate. if (FLAGS_schedule_splay_percent <= 1) { FLAGS_schedule_splay_percent = 10; } schedule_.clear(); if (tree.count("queries") == 0) { // This pack contained no queries. return; } // Iterate the queries (or schedule) and check platform/version/sanity. for (const auto& q : tree.get_child("queries")) { if (q.second.count("shard") > 0) { auto shard = q.second.get<size_t>("shard", 0); if (shard > 0 && shard < getMachineShard()) { continue; } } 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() || query.interval > 592200) { // Invalid pack query. VLOG(1) << "Query has invalid interval: " << q.first << ": " << query.interval; 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; } }
void SceneObject::read(boost::property_tree::ptree pt){ using boost::property_tree::ptree; if(pt.find("body") != pt.not_found()) body.read(pt.get_child("body")); }
void XSDSchemaParser::parseElement(const pt::ptree &elemTree) { std::string elementName = elemTree.get("<xmlattr>.name", ""); std::string className = elemTree.get("<xmlattr>.hpcc:class", ""); std::string category = elemTree.get("<xmlattr>.hpcc:category", ""); std::string displayName = elemTree.get("<xmlattr>.hpcc:displayName", ""); std::string typeName = elemTree.get("<xmlattr>.type", ""); unsigned minOccurs = elemTree.get("<xmlattr>.minOccurs", 1); std::string maxOccursStr = elemTree.get("<xmlattr>.maxOccurs", "1"); unsigned maxOccurs = (maxOccursStr != "unbounded") ? stoi(maxOccursStr) : UINTMAX_MAX; std::shared_ptr<SchemaItem> pConfigElement = std::make_shared<SchemaItem>(elementName, className, m_pSchemaItem); pConfigElement->setProperty("displayName", displayName); pConfigElement->setMinInstances(minOccurs); pConfigElement->setMaxInstances(maxOccurs); pConfigElement->setProperty("category", category); pt::ptree childTree = elemTree.get_child("", pt::ptree()); // special case to set the root since the top level schema can't specify it if (category == "root") // special case to set the root since the top level schema can't specify it { m_pSchemaItem->setProperty("name", elementName); parseXSD(childTree); } else { // // If a type is specified, then either it's a simple value type (which could be previously defined) for this element, or a named complex type. if (!typeName.empty()) { const std::shared_ptr<SchemaType> pSimpleType = m_pSchemaItem->getSchemaValueType(typeName, false); if (pSimpleType != nullptr) { std::shared_ptr<SchemaValue> pCfgValue = std::make_shared<SchemaValue>(""); // no name value since it's the element's value pCfgValue->setType(pSimpleType); // will throw if type is not defined pConfigElement->setItemSchemaValue(pCfgValue); } else { std::shared_ptr<SchemaItem> pConfigType = m_pSchemaItem->getSchemaType(typeName, false); if (pConfigType != nullptr) { // // Insert into this config element the component defined data (attributes, references, etc.) pConfigElement->insertSchemaType(pConfigType); // // Set element min/max instances to that defined by the component type def (ignore values parsed above) pConfigElement->setMinInstances(pConfigType->getMinInstances()); pConfigElement->setMaxInstances(pConfigType->getMaxInstances()); // // If a component, then set element data (allow overriding with locally parsed values) if (pConfigType->getProperty("className") == "component") { pConfigElement->setProperty("name", (!elementName.empty()) ? elementName : pConfigType->getProperty("name")); pConfigElement->setProperty("className", (!className.empty()) ? className : pConfigType->getProperty("className")); pConfigElement->setProperty("category", (!category.empty()) ? category : pConfigType->getProperty("category")); pConfigElement->setProperty("displayName", (!displayName.empty()) ? displayName : pConfigType->getProperty("displayName")); pConfigElement->setProperty("componentName", pConfigType->getProperty("componentName")); } } else { std::string msg = "Unable to find type " + typeName + " when parsing element " + elementName; throw(ParseException(msg)); } } } // // Now, if there are children, create a parser and have at it if (!childTree.empty()) { std::shared_ptr<XSDSchemaParser> pXSDParaser = std::make_shared<XSDSchemaParser>(pConfigElement); pXSDParaser->parseXSD(childTree); } // // Add the element m_pSchemaItem->addChild(pConfigElement); } }
void XSDSchemaParser::parseComplexType(const pt::ptree &typeTree) { std::string complexTypeName = getXSDAttributeValue(typeTree, "<xmlattr>.name", false, ""); std::string className = typeTree.get("<xmlattr>.hpcc:class", ""); std::string catName = typeTree.get("<xmlattr>.hpcc:category", ""); std::string componentName = typeTree.get("<xmlattr>.hpcc:componentName", ""); std::string displayName = typeTree.get("<xmlattr>.hpcc:displayName", ""); if (!complexTypeName.empty()) { if (!className.empty()) { if (className == "component") { std::shared_ptr<SchemaItem> pComponent = std::make_shared<SchemaItem>(complexTypeName, "component", m_pSchemaItem); pComponent->setProperty("category", catName); pComponent->setProperty("componentName", componentName); pComponent->setProperty("displayName", displayName); pt::ptree componentTree = typeTree.get_child("", pt::ptree()); if (!componentTree.empty()) { std::shared_ptr<XSDComponentParser> pComponentXSDParaser = std::make_shared<XSDComponentParser>(std::dynamic_pointer_cast<SchemaItem>(pComponent)); pComponentXSDParaser->parseXSD(typeTree); m_pSchemaItem->addSchemaType(pComponent, complexTypeName); } else { throw(ParseException("Component definition empty: " + displayName)); } } else { throw(ParseException("Unrecognized class name for complex type: " + className)); } } // // This is a complex type definition of just regular XSD statements, no special format. Create a parser and parse it // and add it to the else { std::shared_ptr<SchemaItem> pTypeItem = std::make_shared<SchemaItem>(complexTypeName, "", m_pSchemaItem); pt::ptree childTree = typeTree.get_child("", pt::ptree()); if (!childTree.empty()) { std::shared_ptr<XSDSchemaParser> pXSDParaser = std::make_shared<XSDSchemaParser>(pTypeItem); pXSDParaser->parseXSD(childTree); m_pSchemaItem->addSchemaType(pTypeItem, complexTypeName); } else { throw(ParseException("Complex type definition empty: " + displayName)); } } } // // Just a complexType delimiter, ignore and parse the children else { parseXSD(typeTree.get_child("", pt::ptree())); } }
void SAMKeyStorage::unSerialize(boost::property_tree::ptree& node) { d_key_slot = node.get_child("KeySlot").get_value<unsigned char>(); }
void Wiegand37WithFacilityFormat::unSerialize(boost::property_tree::ptree& node) { setFacilityCode(node.get_child("FacilityCode").get_value<unsigned short>()); setUid(node.get_child("Uid").get_value<unsigned long long>()); }
void MifareUltralightLocation::unSerialize(boost::property_tree::ptree& node) { page = node.get_child("Page").get_value<int>(); byte = node.get_child("Byte").get_value<int>(); }
void SInit::fromPT(const boost::property_tree::ptree& _pt) { const ptree& pt = _pt.get_child("dds.plug-in"); m_id = pt.get<string>("id"); }
void NFCReaderUnit::unSerialize(boost::property_tree::ptree& node) { d_name = node.get_child("Name").get_value<std::string>(); ReaderUnit::unSerialize(node); }
void ASCIIFormat::unSerialize(boost::property_tree::ptree& node) { setASCIILength(node.get_child("ASCIILength").get_value<unsigned int>()); setPadding(node.get_child("Padding").get_value<unsigned char>()); }
MLC_Config::MLC_Config(const boost::property_tree::ptree& pt, const char* name) { mConfigSet = pt.get_child(name); }
void Wiegand37Format::unSerialize(boost::property_tree::ptree& node) { setUid(node.get_child("Uid").get_value<unsigned long long>()); }
void BinaryDataField::unSerialize(boost::property_tree::ptree& node) { ValueDataField::unSerialize(node); d_value = BinaryFieldValue(node.get_child("Value").get_value<std::string>()); d_padding = node.get_child("Padding").get_value<unsigned char>(); }
int DistAmpl::loadConfig(const boost::property_tree::ptree& pt) { const boost::property_tree::ptree& fltr = pt.get_child(this->name()); updateConfig(fltr); return 1; }
void TwicLocation::unSerialize(boost::property_tree::ptree& node) { dataObject = node.get_child("DataObject").get_value<uint64_t>(); }
void A3MLGM5600ReaderUnitConfiguration::unSerialize(boost::property_tree::ptree& node) { d_localPort = node.get_child("LocalPort").get_value<int>(); }
void MifareUltralightAccessInfo::unSerialize(boost::property_tree::ptree& node) { lockPage = node.get_child("LockPage").get_value<bool>(); }
/** * \brief UnSerialize a XML node to the current object. * \param node The XML node. */ void unSerialize(boost::property_tree::ptree& node) { SerialPortDataTransport::unSerialize(node.get_child(SerialPortDataTransport::getDefaultXmlNodeName())); d_port->getSerialPort()->setCircularBufferParser(new ElatecBufferParser()); }
void RFIDeasReaderUnit::unSerialize(boost::property_tree::ptree& node) { d_readerUnitConfig->unSerialize(node.get_child(d_readerUnitConfig->getDefaultXmlNodeName())); }
CWT_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")), "CWT") { base_t::build(); }
void SerialPortDataTransport::unSerialize(boost::property_tree::ptree& node) { d_portBaudRate = node.get_child("PortBaudRate").get_value<unsigned long>(); d_port.reset(new SerialPortXml()); d_port->unSerialize(node.get_child(d_port->getDefaultXmlNodeName())); }