我在序列化數據時遇到了很多麻煩。我究竟做錯了什麼?C++中的Apache Thrift序列化
std::string serialize(ContactsList& obj, std::string filename) {
shared_ptr<TMemoryBuffer> transportOut(new TMemoryBuffer());
shared_ptr<TBinaryProtocol> protocolOut(new TBinaryProtocol(transportOut));
obj.write(protocolOut);
std::string serialized_string = transportOut->getBufferAsString();
return serialized_string;
}
這是我從另一種方法調用的方法。我希望找回一個序列化的二進制字符串,我可以寫出到磁盤。在這個序列化方法中,我創建了一個TMemory緩衝區,然後將其包裝在TBinaryProtocol中,然後將其寫入內存緩衝區中的寫入方法。然後,我將該緩衝區作爲一個字符串返回。然後,我會將序列化的字符串寫入磁盤。
note: no known conversion for argument 1 from ‘boost::shared_ptr<apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TTransport> >’ to ‘apache::thrift::protocol::TProtocol*
我使用Apache節儉1.0-dev的,C++ 98如果這些東西有所作爲:
我得到這個錯誤:
error: no matching function for call to ‘addressbook::ContactsList::write(boost::shared_ptr<apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TTransport> >&)
除了此說明。
與信息更新答案 –