thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Raghava Mutharaju <m.vijayaragh...@gmail.com>
Subject Re: C++ serialization/deserialization examples
Date Fri, 23 Jul 2010 08:23:30 GMT
Thank you for the reply :)

If the file (serialized the byte array to a file) size is large, should I
read each record and place it in the buffer? Can I use the TFileTransport
class to read directly from a file as follows?

string empfile = "../EmpInfo.dat";
shared_ptr<TFileTransport> filetrans(new TFileTransport(empfile));
TBinaryProtocol* binary_protocol = new TBinaryProtocol(filetrans);
EmployeeInfo* empinfo = new EmployeeInfo();
empinfo->read(binary_protocol);

Thank you again.

Regards,
Raghava.

On Fri, Jul 23, 2010 at 3:13 AM, zd.wbh <zd.wbh@163.com> wrote:

> Raghava, you can use TMemoryBuffer, something like:
>
>  shared_ptr<TMemoryBuffer> strBuffer(new TMemoryBuffer());
>  shared_ptr<TBinaryProtocol> binaryProtcol(new TBinaryProtocol(strBuffer));
>  strBuffer->resetBuffer((uint8_t*) raw, *lengthPtr);
>  obj.read(binaryProtcol.get());
>
> serialization is the oppsite, use write method.
>
>
> ---------------------------------------------------------
> 一键发送本地文件,请用网易闪电邮(fm.163.com)!
>
>
>
> 发件人: Raghava Mutharaju <m.vijayaraghava@gmail.com>
> 发送时间: 2010-07-23 15:05
> 主 题: C++ serialization/deserialization examples
> 收件人: thrift-user@incubator.apache.org
>
>
>
> Hello all,
>
> I am using Thrift to share data between applications written in 2 different
> languages (java & c++). I have used TSerializer and TDeserializer for java
> (Binary Protocol) to serialize a message into a file. I haven't found its
> equivalent classes in C++. Can someone suggest how to serialize/deserialize
> using C++. Some steps or small code snippet would be useful.
>
> Thank you.
>
> Regards.
> Raghava.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message