blob: 0f3ad881ccfe393e9a08a8b951f04ba0c004b403 [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
12uint32_t TApplicationException::read(facebook::thrift::protocol::TProtocol* iprot) {
13 uint32_t xfer = 0;
14 std::string fname;
15 facebook::thrift::protocol::TType ftype;
16 int16_t fid;
17
18 xfer += iprot->readStructBegin(fname);
19
20 while (true) {
21 xfer += iprot->readFieldBegin(fname, ftype, fid);
22 if (ftype == facebook::thrift::protocol::T_STOP) {
23 break;
24 }
25 switch (fid) {
26 case 1:
27 if (ftype == facebook::thrift::protocol::T_STRING) {
28 xfer += iprot->readString(message_);
29 } else {
30 xfer += iprot->skip(ftype);
31 }
32 break;
33 case 2:
34 if (ftype == facebook::thrift::protocol::T_I32) {
35 int32_t type;
36 xfer += iprot->readI32(type);
37 type_ = (TApplicationExceptionType)type;
38 } else {
39 xfer += iprot->skip(ftype);
40 }
41 break;
42 default:
43 xfer += iprot->skip(ftype);
44 break;
45 }
46 xfer += iprot->readFieldEnd();
47 }
48
49 xfer += iprot->readStructEnd();
50 return xfer;
51}
52
53uint32_t TApplicationException::write(facebook::thrift::protocol::TProtocol* oprot) const {
54 uint32_t xfer = 0;
55 xfer += oprot->writeStructBegin("TApplicationException");
56 xfer += oprot->writeFieldBegin("message", facebook::thrift::protocol::T_STRING, 1);
57 xfer += oprot->writeString(message_);
58 xfer += oprot->writeFieldEnd();
59 xfer += oprot->writeFieldBegin("type", facebook::thrift::protocol::T_I32, 2);
60 xfer += oprot->writeI32(type_);
61 xfer += oprot->writeFieldEnd();
62 xfer += oprot->writeFieldStop();
63 xfer += oprot->writeStructEnd();
64 return xfer;
65}
66
67}} // facebook::thrift