我正在讀取xml文件並存儲到boost :: property_tree :: ptree pt(object)中。boost :: property_tree :: ptree序列化和反序列化
我試圖使用ptree_serialization.hpp
boost::property_tree::serialize(ar,pt,1);
定義當我上面的代碼我得到的誤差作爲使用的方法serialize()
序列化此ptree中對象;
boost/serialization/collections_save_imp.hpp:64:9: error: no match for ‘operator<<’ in ‘ar << boost::serialization::make_nvp(const char*, T&) [with T = const std::pair<const std::basic_string<char>, boost::property_tree::basic_ptree<std::basic_string<char>, std::basic_string<char> > >]((* &((boost::iterator_facade<boost::property_tree::basic_ptree<std::basic_string<char>, std::basic_string<char> >::const_iterator, std::pair<const std::basic_string<char>, boost::property_tree::basic_ptree<std::basic_string<char>, std::basic_string<char> > >, boost::bidirectional_traversal_tag, const std::pair<const std::basic_string<char>, boost::property_tree::basic_ptree<std::basic_string<char>, std::basic_string<char> > >&, int>*)(& boost::operator++ [with I = boost::property_tree::basic_ptree<std::basic_string<char>, std::basic_string<char> >::const_iterator, V = std::pair<const std::basic_string<char>, boost::property_tree::basic_ptree<std::basic_string<char>, std::basic_string<char> > >, TC = boost::bidirectional_traversal_tag, R = const std::pair<const std::basic_string<char>, boost::property_tree::basic_ptree<std::basic_string<char>, std::basic_string<char> > >&, D = int, typename boost::detail::postfix_increment_result<I, V, R, TC>::type = boost::property_tree::basic_ptree<std::basic_string<char>, std::basic_string<char> >::const_iterator]((*(boost::iterator_facade<boost::property_tree::basic_ptree<std::basic_string<char>, std::basic_string<char> >::const_iterator, std::pair<const std::basic_string<char>, boost::property_tree::basic_ptree<std::basic_string<char>, std::basic_string<char> > >, boost::bidirectional_traversal_tag, const std::pair<const std::basic_string<char>, boost::property_tree::basic_ptree<std::basic_string<char>, std::basic_string<char> > >&, int>*)(& it)), 0)))->boost::iterator_facade<I, V, TC, R, D>::operator* [with Derived = boost::property_tree::basic_ptree<std::basic_string<char>, std::basic_string<char> >::const_iterator, Value = std::pair<const std::basic_string<char>, boost::property_tree::basic_ptree<std::basic_string<char>, std::basic_string<char> > >, CategoryOrTraversal = boost::bidirectional_traversal_tag, Reference = const std::pair<const std::basic_string<char>, boost::property_tree::basic_ptree<std::basic_string<char>, std::basic_string<char> > >&, Difference = int, boost::iterator_facade<I, V, TC, R, D>::reference = const std::pair<const std::basic_string<char>, boost::property_tree::basic_ptree<std::basic_string<char>, std::basic_string<char> > >&]()))’
請您告訴我,如果我做錯了什麼。你能否讓我知道我們是否可以序列化xml解析的屬性ptree對象。
你能告訴我們你是如何定義'ar'和'pt'的嗎? – Arashium 2015-01-21 11:30:28
ar可以是iarchive或oarchive對象。 pt被聲明爲boost :: property_tree :: ptree pt; – harshini 2015-01-21 11:31:57
我不是這方面的專家。 'boost :: property_tree :: ptree pt(object)'似乎缺少模板:''。我認爲'serialize'需要一個'basic_ptree'類型作爲第二個參數,根據它的源代碼:http://www.boost.org/doc/libs/1_42_0/boost/property_tree/ptree_serialization.hpp,另見:http:/ /codereview.stackexchange.com/questions/1818/。看看他們是否幫助 –
Arashium
2015-01-21 12:01:59