2010-10-06 63 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,它的工作原理。