blob: f6e33b2325bd58f3b613a2a7a0f9dd0fa659e696 [file] [log] [blame]
Mark Sleef9831082007-02-20 20:59:21 +00001#include <Thrift.h>
2#include <protocol/TProtocol.h>
3
4namespace facebook { namespace thrift {
5
6uint32_t TApplicationException::read(facebook::thrift::protocol::TProtocol* iprot) {
7 uint32_t xfer = 0;
8 std::string fname;
9 facebook::thrift::protocol::TType ftype;
10 int16_t fid;
11
12 xfer += iprot->readStructBegin(fname);
13
14 while (true) {
15 xfer += iprot->readFieldBegin(fname, ftype, fid);
16 if (ftype == facebook::thrift::protocol::T_STOP) {
17 break;
18 }
19 switch (fid) {
20 case 1:
21 if (ftype == facebook::thrift::protocol::T_STRING) {
22 xfer += iprot->readString(message_);
23 } else {
24 xfer += iprot->skip(ftype);
25 }
26 break;
27 case 2:
28 if (ftype == facebook::thrift::protocol::T_I32) {
29 int32_t type;
30 xfer += iprot->readI32(type);
31 type_ = (TApplicationExceptionType)type;
32 } else {
33 xfer += iprot->skip(ftype);
34 }
35 break;
36 default:
37 xfer += iprot->skip(ftype);
38 break;
39 }
40 xfer += iprot->readFieldEnd();
41 }
42
43 xfer += iprot->readStructEnd();
44 return xfer;
45}
46
47uint32_t TApplicationException::write(facebook::thrift::protocol::TProtocol* oprot) const {
48 uint32_t xfer = 0;
49 xfer += oprot->writeStructBegin("TApplicationException");
50 xfer += oprot->writeFieldBegin("message", facebook::thrift::protocol::T_STRING, 1);
51 xfer += oprot->writeString(message_);
52 xfer += oprot->writeFieldEnd();
53 xfer += oprot->writeFieldBegin("type", facebook::thrift::protocol::T_I32, 2);
54 xfer += oprot->writeI32(type_);
55 xfer += oprot->writeFieldEnd();
56 xfer += oprot->writeFieldStop();
57 xfer += oprot->writeStructEnd();
58 return xfer;
59}
60
61}} // facebook::thrift