如何迭代boost属性树? [英] How to iterate a boost property tree?

查看:161
本文介绍了如何迭代boost属性树?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道接近提升属性树,并看到它是一个很好的功能的boost libs c ++编程。

I am know approaching to boost property tree and saw that it is a good feature of boost libs for c++ programming.

好,我有一个疑问?如何使用迭代器或类似方法迭代属性树?

Well, I have one doubt? how to iterate a property tree using iterators or similar?

在引用中,只是一个浏览树的示例:

In reference there is just an example of browsing the tree through:

BOOST_FOREACH

像stl一样的容器吗?这将是一个更好的解决方案,谈到代码质量....

But is there nothing more? Something like an stl-like container? It would be a better solution, speaking about code quality....

推荐答案

BOOST_FOREACH只是一个方便的迭代方法可以通过迭代器begin()和end()来完成。

BOOST_FOREACH is just a convenient way for iterating that can be done by iterator, begin() and end()

Your_tree_type::const_iterator end = tree.end();
for (your_tree_type::const_iterator it = tree.begin(); it != end; ++it)
    ...

在C ++ 11中:

for (auto it: tree)
    ...

这篇关于如何迭代boost属性树?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆