Mark Slee | 9f0c651 | 2007-02-28 23:58:26 +0000 | [diff] [blame] | 1 | // 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 Slee | f983108 | 2007-02-20 20:59:21 +0000 | [diff] [blame] | 7 | #include <Thrift.h> |
| 8 | #include <protocol/TProtocol.h> |
| 9 | |
| 10 | namespace facebook { namespace thrift { |
| 11 | |
boz | 6ded775 | 2007-06-05 22:41:18 +0000 | [diff] [blame] | 12 | TOutput GlobalOutput; |
| 13 | |
Mark Slee | f983108 | 2007-02-20 20:59:21 +0000 | [diff] [blame] | 14 | uint32_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); |
David Reiss | 0c90f6f | 2008-02-06 22:18:40 +0000 | [diff] [blame] | 24 | if (ftype == facebook::thrift::protocol::T_STOP) { |
Mark Slee | f983108 | 2007-02-20 20:59:21 +0000 | [diff] [blame] | 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 | |
| 55 | uint32_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 |