Thrift: Is it possible to do only serialization with C++ Thrift library?

后端 未结 5 1543
执笔经年
执笔经年 2021-01-02 05:21

With C++ Apache Thrift library, is it possible to use only Serialization/Deserialization and not use RPC services?

As I understand from this page, it is possible to

5条回答
  •  时光取名叫无心
    2021-01-02 05:56

    If you simply want to serialize into bytes (without having to write to a file), you can use TMemoryBuffer.

    boost::shared_ptr buffer(new TMemoryBuffer());
    boost::shared_ptr binaryProtcol(new TBinaryProtocol(buffer));
    
    obj->write(binaryProtcol.get());
    obj->read((binaryProtcol.get()));
    

提交回复
热议问题