我在序列化数据时遇到了很多麻烦。我究竟做错了什么?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> >&)
除了此说明。
与信息更新答案 –