本文整理汇总了C++中boost::property_tree::ptree::get方法的典型用法代码示例。如果您正苦于以下问题:C++ ptree::get方法的具体用法?C++ ptree::get怎么用?C++ ptree::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::property_tree::ptree
的用法示例。
在下文中一共展示了ptree::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getPosition
Vector3D getPosition(boost::property_tree::ptree const & tree, const std::string& prefixe)
{
Vector3D position;
position.x = tree.get(prefixe+"x", 0.f);
position.y = tree.get(prefixe+"y", 0.f);
position.z = tree.get(prefixe+"z", 0.f);
return position;
}
示例2:
std::shared_ptr<IComponent> MoveComponent::loadFromXml(const boost::property_tree::ptree& tree)
{
std::shared_ptr<MoveComponent> result = std::make_shared<MoveComponent>();
result->x = tree.get("x", 0.0f);
result->y = tree.get("y", 0.0f);
result->speed = tree.get("speed", 1.0f);
result->movingLeft = false;
result->movingRight = false;
result->movingUp = false;
result->movingDown = false;
return result;
}
示例3: loadFromPropertyTree
void CompPathMove::loadFromPropertyTree(const boost::property_tree::ptree& propTree)
{
m_pathId = propTree.get("path_id", "");
m_repeat = propTree.get("repeat", false);
m_resetAngle = propTree.get("resetAngle", false);
//m_velocity = propTree.get<float>("velocity");
//if (propTree.get<std::string>("mode") != "relative")
// throw DataLoadException("CompPathMove: Only 'relatve' mode is supported");
foreach(const ptree::value_type &v, propTree)
{
if (v.first != cPoint) continue;
const ptree& point = v.second;
PathMovePoint::MotionMode mode;
std::string modeStr = point.get<std::string>(cMode);
if (modeStr == cModeUniform) mode = PathMovePoint::Uniform;
else if (modeStr == cModeAccelerated) mode = PathMovePoint::Accelerated;
else throw DataLoadException("PathMovePoint: invalid mode '"+modeStr+"'");
float linAccel = point.get(cLinAccel, 0.0f);
float angAccel = point.get(cAngAccel, 0.0f);
float topLinVel = point.get(cTopLinVel, 0.0f);
float topAngVel = point.get(cTopAngVel, 0.0f);
float linVel = point.get(cLinVel, 0.0f);
float angVel = point.get(cAngVel, 0.0f);
float time = point.get(cTime, 0.0f);
switch (mode)
{
case PathMovePoint::Uniform:
if (time != 0)
m_points.push_back(PathMovePoint::makeUniformByTime(time));
else if (linVel != 0)
m_points.push_back(PathMovePoint::makeUniformByLinVel(linVel));
else if (angVel != 0)
m_points.push_back(PathMovePoint::makeUniformByAngVel(angVel));
else
throw DataLoadException("invalid uniform PathMovePoint");
break;
case PathMovePoint::Accelerated:
if (linAccel != 0.0f)
m_points.push_back(PathMovePoint::makeLinAccelerated(linAccel, topLinVel));
else if (angAccel != 0.0f)
m_points.push_back(PathMovePoint::makeAngAccelerated(angAccel, topAngVel));
else
throw DataLoadException("invalid accelerated PathMovePoint");
break;
}
}
}
示例4: parseALFTree
QueryData parseALFTree(const pt::ptree& tree) {
Row r;
for (const auto& it : kTopLevelIntKeys) {
int val = tree.get(it.first, -1);
r[it.second] = INTEGER(val);
}
for (const auto& it : kTopLevelStringKeys) {
std::string val = tree.get(it.second, "");
r[it.first] = val;
}
return {r};
}
示例5: genXProtectEntry
void genXProtectEntry(const pt::ptree &entry, QueryData& results) {
// Entry is an XProtect dictionary of meta data about the item.
auto name = entry.get("Description", "");
auto launch_type = entry.get("LaunchServices.LSItemContentType", "");
// Get the list of matches
std::vector<Row> file_matches;
genMatches(entry, file_matches);
for (auto& r : file_matches) {
r["name"] = name;
r["launch_type"] = launch_type;
results.push_back(r);
}
}
示例6: parsePack
Status parsePack(const std::string& name, const pt::ptree& data) {
if (data.count("queries") == 0) {
return Status(0, "Pack contains no queries");
}
// Check the pack-global minimum SDK version and platform.
auto version = data.get("version", "");
if (version.size() > 0 && !versionChecker(version, kSDKVersion)) {
return Status(0, "Minimum SDK version not met");
}
auto platform = data.get("platform", "");
if (platform.size() > 0 && !platformChecker(platform, kSDKPlatform)) {
return Status(0, "Platform version mismatch");
}
// For each query in the pack's queries, check their version/platform.
for (const auto& query : data.get_child("queries")) {
auto query_string = query.second.get("query", "");
if (Config::checkScheduledQuery(query_string)) {
VLOG(1) << "Query pack " << name
<< " contains a duplicated query: " << query.first;
continue;
}
// Check the specific query's required version.
version = query.second.get("version", "");
if (version.size() > 0 && !versionChecker(version, kSDKVersion)) {
continue;
}
// Check the specific query's required platform.
platform = query.second.get("platform", "");
if (platform.size() > 0 && !platformChecker(platform, kSDKPlatform)) {
continue;
}
// Hope there is a supplied/non-0 query interval to apply this query pack
// query to the osquery schedule.
auto query_interval = query.second.get("interval", 0);
if (query_interval > 0) {
auto query_name = "pack_" + name + "_" + query.first;
Config::addScheduledQuery(query_name, query_string, query_interval);
}
}
return Status(0, "OK");
}
示例7: genMatches
void genMatches(const pt::ptree& entry, std::vector<Row>& results) {
if (entry.count("Matches") == 0) {
return;
}
bool optional = (entry.get("MatchType", "") == "MatchAny");
for (const auto& match : entry.get_child("Matches")) {
if (match.second.count("Matches") > 0) {
genMatches(match.second, results);
continue;
}
Row r;
r["optional"] = (optional) ? "1" : "0";
r["identity"] = match.second.get("Identity", "");
if (match.second.count("MatchFile") == 0) {
// There is no file in this match entry, odd.
continue;
}
// This can contain any of Foundation/Classes/NSURL_Class keys.
auto fileinfo = match.second.get_child("MatchFile");
if (fileinfo.count("LSDownloadContentTypeKey") > 0) {
r["filetype"] = fileinfo.get<std::string>("LSDownloadContentTypeKey");
} else {
r["filetype"] = fileinfo.get("NSURLTypeIdentifierKey", "");
}
r["uses_pattern"] = (match.second.count("Pattern") > 0) ? "1" : "0";
r["filename"] = fileinfo.get("NSURLNameKey", "");
results.push_back(r);
}
}
示例8: create_draw_state
draw_state create_draw_state(boost::property_tree::ptree const& props)
{
return{
nullptr,
props.get("use_alpha_blending", false),
read_property(props, "alpha_blending_src_function", get_map_from_alpha_blending_function_names_to_gl_values()),
read_property(props, "alpha_blending_dst_function", get_map_from_alpha_blending_function_names_to_gl_values())
};
}
示例9: getQuaternion
Ogre::Quaternion getQuaternion(boost::property_tree::ptree const & tree)
{
Ogre::Quaternion q;
Vector3D vec(getPosition(tree, "q"));
q.x = vec.x;
q.y = vec.y;
q.z = vec.z;
q.w = tree.get("qw", 0.f);
return q;
}
示例10: WeaponDesc
WeaponDesc(const boost::property_tree::ptree& node)
{
memset(this, 0, sizeof(WeaponDesc));
m_iDefId = node.get<int>("defindex");
m_sClass = node.get("item_class", "<unknown>");
m_sName = node.get("item_name", "<unknown>");
try
{
auto wpnProps = node.get_child("attributes");
m_bCanCrit = ( std::find_if(wpnProps.begin(), wpnProps.end(), [](const boost::property_tree::ptree::value_type& attrib)
{
return ((attrib.second.get("class", "") == "mult_crit_chance") &&
(attrib.second.get<float>("value") == 0));
} ) == wpnProps.end() );
}
catch(const boost::property_tree::ptree_error& e)
{
m_bCanCrit = true;
};
UpdateFilteredName(m_sName);
};
示例11: parseKey
void XSDSchemaParser::parseKey(const pt::ptree &keyTree)
{
std::string keyName = getXSDAttributeValue(keyTree, "<xmlattr>.name");
bool duplicateOk = keyTree.get("<xmlattr>.hpcc:allowDuplicate", "false") == "true";
std::string elementName = getXSDAttributeValue(keyTree, "xs:selector.<xmlattr>.xpath", false, "");
std::string attrName = getXSDAttributeValue(keyTree, "xs:field.<xmlattr>.xpath", false, "");
std::string attributeName;
if (attrName.find_first_of('@') != std::string::npos)
{
attributeName = attrName.substr(attrName.find_first_of('@') + 1);
}
else
{
attributeName = attrName;
}
m_pSchemaItem->addUniqueAttributeValueSetDefinition(keyName, elementName, attributeName, duplicateOk);
}
示例12: updateConfig
void Split::updateConfig(const boost::property_tree::ptree &pt)
{
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << " " << id();
_in_cloud = pt.get("inputs.cloud", _in_cloud);
_out_inliers = pt.get("outputs.inliers", _out_inliers);
_out_outliers = pt.get("outputs.outliers", _out_outliers);
_axis = pt.get("axis", _axis);
_min = pt.get("min", _min);
_max = pt.get("max", _max);
_axis = pt.get("options.axis", _axis);
_min = pt.get("options.min", _min);
_max = pt.get("options.max", _max);
}
示例13: read_element
void hydrator::read_element(const boost::property_tree::ptree& pt,
yarn::intermediate_model& m) const {
yarn::name_builder b;
const auto in_global_module(pt.get(in_global_module_key, false));
if (!in_global_module)
b.model_name(m.name().location());
const auto simple_name_value(pt.get<std::string>(simple_name_key));
b.simple_name(simple_name_value);
const auto i(pt.find(internal_modules_key));
if (i != pt.not_found()) {
std::list<std::string> ipp;
for (auto& item : pt.get_child(internal_modules_key))
ipp.push_back(item.second.get_value<std::string>());
if (!ipp.empty())
b.internal_modules(ipp);
else {
BOOST_LOG_SEV(lg, debug) << "Ignoring empty internal module path. "
<< "Type: " << simple_name_value;
}
}
yarn::name n(b.build());
const auto documentation(pt.get_optional<std::string>(documentation_key));
const auto lambda([&](yarn::element& e) {
BOOST_LOG_SEV(lg, debug) << "Processing element: " << n.qualified();
e.name(n);
e.origin_type(m.origin_type());
e.generation_type(m.generation_type());
e.in_global_module(in_global_module);
if (documentation)
e.documentation(*documentation);
const auto scope(dynamic::scope_types::entity);
e.extensions(create_dynamic_extensions(pt, scope));
});
const auto meta_type_value(pt.get<std::string>(meta_type_key));
if (meta_type_value == meta_type_object_value) {
yarn::object o;
lambda(o);
const auto ot(pt.get_optional<std::string>(object_type_key));
o.object_type(to_object_type(ot));
m.objects().insert(std::make_pair(n.qualified(), o));
} else if (meta_type_value == meta_type_primitive_value) {
yarn::primitive p;
const auto dit(pt.get(is_default_enumeration_type_key, false));
p.is_default_enumeration_type(dit);
lambda(p);
m.primitives().insert(std::make_pair(n.qualified(), p));
}
else {
BOOST_LOG_SEV(lg, error) << invalid_meta_type << meta_type_value;
BOOST_THROW_EXCEPTION(
hydration_error(invalid_meta_type + meta_type_value));
}
}
示例14: loadFromPropertyTree
void CompShapeCircle::loadFromPropertyTree(const boost::property_tree::ptree& propTree)
{
m_center.x = propTree.get("circle.x", 0.0f);
m_center.y = propTree.get("circle.y", 0.0f);
m_radius = propTree.get("circle.r", 1.0f);
}
示例15: setup_subchannel_from_ptree
void setup_subchannel_from_ptree(dabSubchannel* subchan,
boost::property_tree::ptree &pt,
std::shared_ptr<dabEnsemble> ensemble,
string subchanuid,
std::shared_ptr<BaseRemoteController> rc)
{
using boost::property_tree::ptree;
using boost::property_tree::ptree_error;
string type;
/* Read type first */
try {
type = pt.get<string>("type");
}
catch (ptree_error &e) {
stringstream ss;
ss << "Subchannel with uid " << subchanuid << " has no type defined!";
throw runtime_error(ss.str());
}
string inputUri = "";
// fail if no inputUri given unless type is test
if (type != "test") {
inputUri = pt.get<string>("inputuri", "");
if (inputUri == "") {
try {
inputUri = pt.get<string>("inputfile");
}
catch (ptree_error &e) {
stringstream ss;
ss << "Subchannel with uid " << subchanuid << " has no inputUri defined!";
throw runtime_error(ss.str());
}
}
}
string proto;
size_t protopos = inputUri.find("://");
if (protopos == string::npos) {
proto = "file";
}
else {
proto = inputUri.substr(0, protopos);
}
subchan->inputUri = inputUri;
/* The input is of the old_style type,
* with the struct of function pointers,
* and needs to be a DabInputCompatible
*/
bool input_is_old_style = true;
dabInputOperations operations;
dabProtection* protection = &subchan->protection;
if (0) {
#if defined(HAVE_FORMAT_MPEG)
} else if (type == "audio") {
subchan->type = subchannel_type_t::Audio;
subchan->bitrate = 0;
if (0) {
#if defined(HAVE_INPUT_FILE)
} else if (proto == "file") {
operations = dabInputMpegFileOperations;
#endif // defined(HAVE_INPUT_FILE)
#if defined(HAVE_INPUT_ZEROMQ)
}
else if (proto == "tcp" ||
proto == "epmg" ||
proto == "ipc") {
input_is_old_style = false;
dab_input_zmq_config_t zmqconfig;
try {
zmqconfig.buffer_size = pt.get<int>("zmq-buffer");
}
catch (ptree_error &e) {
stringstream ss;
ss << "ZMQ Subchannel with uid " << subchanuid <<
" has no zmq-buffer defined!";
throw runtime_error(ss.str());
}
try {
zmqconfig.prebuffering = pt.get<int>("zmq-prebuffering");
}
catch (ptree_error &e) {
stringstream ss;
ss << "ZMQ Subchannel with uid " << subchanuid <<
" has no zmq-buffer defined!";
throw runtime_error(ss.str());
}
zmqconfig.enable_encryption = false;
DabInputZmqMPEG* inzmq =
new DabInputZmqMPEG(subchanuid, zmqconfig);
inzmq->enrol_at(*rc);
//.........这里部分代码省略.........