2010-10-06 62 views
1

我正在使用boost属性树来存储我的应用程序的配置数据。迭代Boost Property Tree中的项目

在配置文件中我有一个名为的项目,看起来像这样。 我想知道我如何迭代ServerList。

ServerList 
{ 
    server1 127.0.0.1:5000 
    server2 example.com 
} 

通过该解决方案此处提供的方式,似乎并没有为我工作: Boost Property Tree and Xml parsing Problems 所以不要去和那个重新报价。当我尝试它时,我得到这个错误:

config.cpp:47: error: invalid initialization of reference of type ‘boost::property_tree::wiptree&’ from expression of type ‘boost::property_tree::basic_ptree<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >’ 
make: *** [config.o] Error 1 
+0

显示您的代码。 – Abyx 2010-10-11 07:36:12

回答

1

要回答我自己的问题。线索出现在错误中。

我使用的是wiptree这里 的类型的引用无效初始化 '的boost :: property_tree :: wiptree & ......

但一个基本ptree中这里 型' 的boost :: property_tree :: basic_ptree。 ..

从wiptree更改为ptree,它的工作原理。