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 do with Java library. However, I could not find the similar classes for C++ library.
Apache Thrift allows you to define data types and service interfaces in a simple definition file. Taking that file as input, the compiler generates code to be used to easily build RPC clients and servers that communicate seamlessly across programming languages.
Apache Thrift is a set of code-generation tools that allows developers to build RPC clients and servers by just defining the data types and service interfaces in a simple definition file.
Thrift is an interface definition language and binary communication protocol used for defining and creating services for numerous programming languages. It was developed at Facebook for "scalable cross-language services development" and as of 2020 is an open source project in the Apache Software Foundation.
Yes it is possible. Thrift lacks documentation about this subject. Well, about anything really.
Here i found this:
http://mail-archives.apache.org/mod_mbox/thrift-user/201010.mbox/%[email protected]%3E
i personally use boost::serialization if there is no need to transfer data over network. Much clear syntax and supports JSON, XML and binary output/input.
If you simply want to serialize into bytes (without having to write to a file), you can use TMemoryBuffer
.
boost::shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer());
boost::shared_ptr<TBinaryProtocol> binaryProtcol(new TBinaryProtocol(buffer));
obj->write(binaryProtcol.get());
obj->read((binaryProtcol.get()));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With