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


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

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


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

示例1:

//------------------------------------------------------------------------------
void
Image::set(ptree pt)
{
    if(pt.get_child_optional("UV"))        this->setUV(Box(pt.get_child("UV")), getBoolFromPT(pt, "UV.normalized", false));
    if(pt.get_child_optional("NinePatch")) this->setNinePatchData(NinePatchData(pt.get_child("NinePatch")));
    if(pt.get_child_optional("color"))     this->color = Color(pt.get("color", "#FFF"));
};
开发者ID:iliis,项目名称:Anathea,代码行数:8,代码来源:image_mgr.cpp

示例2:

void AVRRobot::Config::readTree(const ptree &pt) {
	compass.readTree(pt.get_child("compass"));
	sonar1.readTree(pt.get_child("sonar1"));
	sonar2.readTree(pt.get_child("sonar2"));
	wheels.readTree(pt.get_child("wheels"));
	stepper.readTree(pt.get_child("stepper"));
}
开发者ID:matthewbot,项目名称:IEEEGumstix,代码行数:7,代码来源:AVRRobot.cpp

示例3: ReadObject

bool AnimaMaterial::ReadObject(const ptree& objectTree, AnimaScene* scene, bool readName)
{
	try
	{
		if(readName)
			SetName(objectTree.get<AnimaString>("AnimaMaterial.Name"));
		
		for(auto& shadersName : objectTree.get_child("AnimaMaterial.ShaderNames"))
		{
			if(shadersName.first == "ShaderName")
			{
				AnimaString shaderName = shadersName.second.get_value<AnimaString>("");
				_shadersNames.push_back(shaderName);
			}
		}
		
		ptree mappedValuesTree = objectTree.get_child("AnimaMaterial.MappedValues");
		
		return AnimaMappedValues::ReadObject(mappedValuesTree, scene, false);
	}
	catch (boost::property_tree::ptree_bad_path& exception)
	{
		AnimaLogger::LogMessageFormat("ERROR - Error parsing material: %s", exception.what());
		return false;
	}
	catch (boost::property_tree::ptree_bad_data& exception)
	{
		AnimaLogger::LogMessageFormat("ERROR - Error parsing material: %s", exception.what());
		return false;
	}
}
开发者ID:zillemarco,项目名称:Anima_Old,代码行数:31,代码来源:AnimaMaterial.cpp

示例4:

void WheelsControl::Config::readTree(const ptree &pt) {
	left.readTree(pt.get_child("left"));
	right.readTree(pt.get_child("right"));
	back.readTree(pt.get_child("back"));

	turnhysteresis = (int16_t)pt.get<int>("turnhysteresis");
}
开发者ID:matthewbot,项目名称:IEEEGumstix,代码行数:7,代码来源:WheelsControl.cpp

示例5:

void DriveEquation::Config::readTree(const ptree &pt) {
	left.readTree(pt.get_child("left"));
	right.readTree(pt.get_child("right"));
	back.readTree(pt.get_child("back"));

	wheelangleoffset = Angle::fromDegrees(pt.get<float>("wheelangleoffset_deg"));
	minspeed = pt.get<float>("minspeed");
}
开发者ID:matthewbot,项目名称:IEEEGumstix,代码行数:8,代码来源:DriveEquation.cpp

示例6: deserialize

void AttackCommand::deserialize(ptree serial)
{
    assertCompatibility(serial.get<std::string>("type"), "AttackCommand");
    queued = serial.get<bool>("queued");
    time = _atoi64(serial.get<string>("time").c_str());
    unit.deserialize(serial.get_child("unit"));
    target.deserialize(serial.get_child("target"));
}
开发者ID:pwag42,项目名称:moba_source---2013,代码行数:8,代码来源:attackCommand.cpp

示例7: processSimpleRelation

 /// Parses relation as simple relation with non-relation children. If child is single, then
 /// calls visitor with this child instead of relation.
 void processSimpleRelation(Visitor &visitor, std::uint32_t featureId, const ptree &feature) const {
   auto relation = parseRelation(featureId, feature.get_child("geometry.coordinates"));
   if (relation.elements.size()==1) {
     parseProperties(*relation.elements[0], featureId, feature.get_child("properties"));
     visitor.add(*relation.elements[0]);
   } else {
     parseProperties(relation, featureId, feature.get_child("properties"));
     visitor.add(relation);
   }
 }
开发者ID:reinterpretcat,项目名称:utymap,代码行数:12,代码来源:OsmJsonParser.hpp

示例8:

//------------------------------------------------------------------------------
void
WTextInput::_set(ptree n)
{
	WText::_set(n);

	if(n.get_child_optional("border_normal"))
		this->setBorderNormal (kernel->graphicsMgr->loadImage(n.get_child("border_normal")));

	if(n.get_child_optional("border_focused"))
		this->setBorderFocused(kernel->graphicsMgr->loadImage(n.get_child("border_focused")));
};
开发者ID:iliis,项目名称:Anathea,代码行数:12,代码来源:widget_textinput.cpp

示例9:

Department
parseDepartment(const ptree& tree)
{
    std::vector<Employee> empls;
    for (const auto& child : tree.get_child("employees", {}))
        empls.push_back(parseEmployee(child.second));

    std::vector<Department> depts;
    for (const auto& child : tree.get_child("departments", {}))
        depts.push_back(parseDepartment(child.second));

    return {tree.get<std::string>("name"), empls, depts};
}
开发者ID:hartenfels,项目名称:Cpp101,代码行数:13,代码来源:Persistence.cpp

示例10: parseMultiPolygon

 /// Parses relation with relations from multipolygon and notifies visitor.
 void parseMultiPolygon(Visitor &visitor, std::uint32_t featureId, const ptree &feature) const {
   utymap::entities::Relation relation;
   parseProperties(relation, featureId, feature.get_child("properties"));
   for (const ptree::value_type &geometry : feature.get_child("geometry.coordinates")) {
     auto child = parseRelation(featureId, geometry.second);
     if (child.elements.size()==1) {
       FoldRelation fold;
       child.elements[0]->accept(fold);
       relation.elements.push_back(fold.element);
     } else {
       relation.elements.push_back(std::make_shared<utymap::entities::Relation>(child));
     }
   }
   visitor.add(relation);
 }
开发者ID:reinterpretcat,项目名称:utymap,代码行数:16,代码来源:OsmJsonParser.hpp

示例11: CheckProperty

void BasicTest::CheckProperty(int type, const std::string &name)
{
    ptree element_pt = pt_.get_child("property." + name);
    const teamstyle16::Property &element_info = teamstyle16::kProperty[type];

    EXPECT_EQ(element_pt.get("level", -1),
              element_info.level) << "Element type: " << name;
    EXPECT_EQ(element_pt.get("health_max", -1),
              element_info.health_max) << "Element type: " << name;
    EXPECT_EQ(element_pt.get("fuel_max", -1),
              element_info.fuel_max) << "Element type: " << name;
    EXPECT_EQ(element_pt.get("ammo_max", -1),
              element_info.ammo_max) << "Element type: " << name;
    EXPECT_EQ(element_pt.get("ammo_once", -1),
              element_info.ammo_once) << "Element type: " << name;
    EXPECT_EQ(element_pt.get("metal_max", -1),
              element_info.metal_max) << "Element type: " << name;
    EXPECT_EQ(element_pt.get("speed", -1),
              element_info.speed) << "Element type: " << name;
    EXPECT_EQ(element_pt.get("cost", -1),
              element_info.cost) << "Element type: " << name;
    EXPECT_EQ(element_pt.get("build_round", -1),
              element_info.build_round) << "Element type: " << name;
    EXPECT_EQ(element_pt.get("population", -1),
              element_info.population) << "Element type: " << name;
}
开发者ID:Alex142857,项目名称:teamstyle16,代码行数:26,代码来源:basic_test.cpp

示例12: load

// load
void configuration::load(const ptree& in_conf) {
  try {

    settings_ = in_conf.get_child(settings_path_);
    LOG_INFO(settings_path_, "Loading settings");

    auto model = settings_.get_optional<std::string>(model_key_);
    if (!model) {
      throw configuration_error("model descriptor '" + model_key_ +
                                "' has to be set in " + settings_path_);
    }
    defaults_path_ += "." + *model;
    auto def = in_conf.get_child_optional(defaults_path_);
    if (def) {
      LOG_INFO(settings_path_, *model + " defaults found.");
      defaults_ = *def;
    } else {
      LOG_INFO(settings_path_, "No default settings provided for this board.");
    }
  } catch (ptree_bad_path& e) {
    throw path_error(e.path<std::string>());
  } catch (ptree_error& e) {
    // shouldn't happen
    throw configuration_error("Processing error", e.what());
  }
}
开发者ID:sly2j,项目名称:CtrlRoom,代码行数:27,代码来源:configuration.cpp

示例13: if

boost::shared_ptr<scxml_parser::transition> scxml_parser::parse_transition(const ptree &pt)
{
	const ptree &xmlattr = pt.get_child("<xmlattr>");
	boost::shared_ptr<transition> tr = boost::make_shared<transition>();
	try {
		using namespace boost::algorithm;
		boost::optional<string> target(xmlattr.get_optional<string>("target"));
		if(target) split(tr->target, *target, is_any_of(" "), token_compress_on);
		if(tr->target.size() > 1) parallel_target_sizes.insert(tr->target.size());
		tr->event = xmlattr.get_optional<string>("event");

		for (ptree::const_iterator it = pt.begin(); it != pt.end(); ++it) {
			if (it->first == "<xmlcomment>") ; // ignore comments
			else if (it->first == "<xmlattr>") ; // ignore, parsed above
			else if (it->first == "script") tr->actions.push_back(parse_script(it->second));
			else if (it->first == "log") tr->actions.push_back(parse_log(it->second));
			else if (it->first == "raise") tr->actions.push_back(parse_raise(it->second));
			else cerr << "warning: unknown item '" << it->first << "' in <transition>" << endl;
		}
	}
	catch (ptree_error e) {
		cerr << "error: transition: " << e.what() << endl;
		exit(1);
	}
	return tr;
}
开发者ID:Kampbell,项目名称:scxmlcc,代码行数:26,代码来源:scxml_parser.cpp

示例14: get_child

        bool get_child(ptree& ptin, const std::string& path, ptree& ptout)
        {
            static boost::mutex io_mutex;
			boost::mutex::scoped_lock lock(io_mutex);
			//if(&ptin)return false;
			try
			{
			     ptout = ptin.get_child(path);
			     return true;
			}
			catch(std::exception& err)
			{
                LOG_BASELINE_ERROR<< "json get_child(): has error, " << err.what();
				//return (ptree&)NULL;
				return false;
            }
            catch(...)
            {
                LOG_BASELINE_ERROR << "json get_child(): has unknown error!\n";
				//return (ptree&)NULL;
				return false;
            }
			//return (ptree&)NULL;
			return false;
        }
开发者ID:lvdou,项目名称:baseline,代码行数:25,代码来源:util_json.cpp

示例15: setOption

void LisLinearSolver::setOption(const ptree &option)
{
    boost::optional<ptree> ptSolver = option.get_child("LinearSolver");
    if (!ptSolver)
        return;

    boost::optional<std::string> solver_type = ptSolver->get_optional<std::string>("solver_type");
    if (solver_type) {
        _option.solver_type = _option.getSolverType(*solver_type);
    }
    boost::optional<std::string> precon_type = ptSolver->get_optional<std::string>("precon_type");
    if (precon_type) {
        _option.precon_type = _option.getPreconType(*precon_type);
    }
    boost::optional<std::string> matrix_type = ptSolver->get_optional<std::string>("matrix_type");
    if (matrix_type) {
        _option.matrix_type = _option.getMatrixType(*matrix_type);
    }
    boost::optional<double> error_tolerance = ptSolver->get_optional<double>("error_tolerance");
    if (error_tolerance) {
        _option.error_tolerance = *error_tolerance;
    }
    boost::optional<int> max_iteration_step = ptSolver->get_optional<int>("max_iteration_step");
    if (max_iteration_step) {
        _option.max_iterations = *max_iteration_step;
    }
}
开发者ID:envinf,项目名称:ogs,代码行数:27,代码来源:LisLinearSolver.cpp


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