本文整理汇总了C++中PTree::get_child方法的典型用法代码示例。如果您正苦于以下问题:C++ PTree::get_child方法的具体用法?C++ PTree::get_child怎么用?C++ PTree::get_child使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PTree
的用法示例。
在下文中一共展示了PTree::get_child方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: turn
Game::Game(const PTree& root) :
background_tiles(get_background_tiles(root.get_child("game.board"))),
hashed_background_tiles(make_hashed_pair(background_tiles)),
turn_max(root.get<int>("game.maxTurns")),
turn(root.get<int>("game.turn")),
state(root, hashed_background_tiles)
{
assert( state == state );
assert( hash_value(state) == hash_value(state) );
int kk = 0;
const PTree& child_heroes = root.get_child("game.heroes");
for (PTree::const_iterator ti=child_heroes.begin(), tie=child_heroes.end(); ti!=tie; ti++)
{
#if !defined(NDEBUG)
const int id = ti->second.get<int>("id");
assert( kk+1 == id );
#endif
const_cast<HeroInfo&>(hero_infos[kk]) = HeroInfo(ti->second);
assert( kk < 4 );
kk++;
}
}
示例2: pos
vector<SurfaceSample> SurfaceSample::loadFromXML(const std::string& filename) {
vector<SurfaceSample> samples;
try {
PTree tree;
read_xml(filename, tree);
PTree root = tree.get_child("SurfaceSamples");
for (CI p = root.begin(); p != root.end(); ++p) {
if (p->first == "Sample") {
Q posq = XMLHelpers::readQ(p->second.get_child("Pos"));
Q rpyq = XMLHelpers::readQ(p->second.get_child("RPY"));
double graspW = XMLHelpers::readDouble(p->second.get_child("GraspW"));
//cout << "pos=" << posq << " rot=" << rpyq << " graspW=" << graspW << endl;
Vector3D<> pos(posq[0], posq[1], posq[2]);
RPY<> rpy(rpyq[0], rpyq[1], rpyq[2]);
samples.push_back(SurfaceSample(Transform3D<>(pos, rpy.toRotation3D()), graspW));
}
}
} catch (const ptree_error& e) {
RW_THROW(e.what());
}
return samples;
}
示例3: fromPTree
Series Series::fromPTree(PTree& pt)
{
Series s;
s.id = pt.get<String>("id");
s.key = pt.get<String>("key");
BOOST_FOREACH(PTree::value_type &v,
pt.get_child("tags"))
s.tags.push_back(v.second.data());
BOOST_FOREACH(PTree::value_type &v,
pt.get_child("attributes"))
s.attributes[v.first.data()] = v.second.data();
return s;
}