本文整理汇总了C++中boost::property_tree::ptree::equal_range方法的典型用法代码示例。如果您正苦于以下问题:C++ ptree::equal_range方法的具体用法?C++ ptree::equal_range怎么用?C++ ptree::equal_range使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::property_tree::ptree
的用法示例。
在下文中一共展示了ptree::equal_range方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load_inputs
inputs_type load_inputs( boost::property_tree::ptree& pt ) {
using boost::property_tree::ptree;
typedef ptree::const_assoc_iterator citer;
inputs_type result;
std::pair< citer, citer > inputs = pt.equal_range( "input" );
for( citer& i = inputs.first; i != inputs.second; ++i ) {
const ptree& input = i->second;
result.push_back( Input() );
result.back().semantic =
input.get_child( "<xmlattr>.semantic" ).data();
result.back().source =
input.get_child( "<xmlattr>.source" ).data();
result.back().offset = input.get<size_t>( "<xmlattr>.offset", 0 );
std::cout << result.back().semantic << " from " <<
result.back().source << " at " <<
result.back().offset << std::endl;
}
return result;
}
示例2: load_sources
sources_type load_sources( boost::property_tree::ptree& pt ) {
using boost::property_tree::ptree;
typedef ptree::const_assoc_iterator citer;
sources_type result;
std::pair< citer, citer > sources = pt.equal_range( "source" );
for( citer& i = sources.first; i != sources.second; ++i ) {
const std::string& id = i->second.get_child( "<xmlattr>.id" ).data();
const ptree& arr = i->second.get_child( "float_array" );
size_t count = arr.get<size_t>( "<xmlattr>.count" );
std::cout << "Loading " << count << " from " << id << std::endl;
result[ id ].reserve( count );
std::stringstream ss( arr.data() );
for( size_t f = 0; f < count; ++f ) {
float val;
ss >> val;
result[ id ].push_back( val );
}
}
return result;
}