blob: 186c5af44f658e0f8b15e25446d9874718a54042 [file] [log] [blame]
Mark Slee9f0c6512007-02-28 23:58:26 +00001// Copyright (c) 2006- Facebook
2// Distributed under the Thrift Software License
3//
4// See accompanying file LICENSE or visit the Thrift site at:
5// http://developers.facebook.com/thrift/
6
Mark Sleef9831082007-02-20 20:59:21 +00007#include <Thrift.h>
8#include <protocol/TProtocol.h>
9
10namespace facebook { namespace thrift {
11
boz6ded7752007-06-05 22:41:18 +000012TOutput GlobalOutput;
13
Mark Sleef9831082007-02-20 20:59:21 +000014uint32_t TApplicationException::read(facebook::thrift::protocol::TProtocol* iprot) {
15 uint32_t xfer = 0;
16 std::string fname;
17 facebook::thrift::protocol::TType ftype;
18 int16_t fid;
19
20 xfer += iprot->readStructBegin(fname);
21
22 while (true) {
23 xfer += iprot->readFieldBegin(fname, ftype, fid);
24 if (ftype == facebook::thrift::protocol::T_STOP) {
25 break;
26 }
27 switch (fid) {
28 case 1:
29 if (ftype == facebook::thrift::protocol::T_STRING) {
30 xfer += iprot->readString(message_);
31 } else {
32 xfer += iprot->skip(ftype);
33 }
34 break;
35 case 2:
36 if (ftype == facebook::thrift::protocol::T_I32) {
37 int32_t type;
38 xfer += iprot->readI32(type);
39 type_ = (TApplicationExceptionType)type;
40 } else {
41 xfer += iprot->skip(ftype);
42 }
43 break;
44 default:
45 xfer += iprot->skip(ftype);
46 break;
47 }
48 xfer += iprot->readFieldEnd();
49 }
50
51 xfer += iprot->readStructEnd();
52 return xfer;
53}
54
55uint32_t TApplicationException::write(facebook::thrift::protocol::TProtocol* oprot) const {
56 uint32_t xfer = 0;
57 xfer += oprot->writeStructBegin("TApplicationException");
58 xfer += oprot->writeFieldBegin("message", facebook::thrift::protocol::T_STRING, 1);
59 xfer += oprot->writeString(message_);
60 xfer += oprot->writeFieldEnd();
61 xfer += oprot->writeFieldBegin("type", facebook::thrift::protocol::T_I32, 2);
62 xfer += oprot->writeI32(type_);
63 xfer += oprot->writeFieldEnd();
64 xfer += oprot->writeFieldStop();
65 xfer += oprot->writeStructEnd();
66 return xfer;
67}
68
69}} // facebook::thrift