Christopher Piro | 2f5afce | 2007-06-29 07:17:33 +0000 | [diff] [blame^] | 1 | -module(tApplicationException). |
| 2 | |
| 3 | -include("thrift.hrl"). |
| 4 | % -include("tApplicationException.hrl"). |
| 5 | |
| 6 | -export([new/0, new/1, new/2, read/2, write/2]). |
| 7 | |
| 8 | new(Type, Message) -> |
| 9 | #tApplicationException{type=Type, message=Message}. |
| 10 | |
| 11 | new() -> new(?tApplicationException_UNKNOWN, nil). % WATCH |
| 12 | new(Type) -> new(Type, nil). % WATCH |
| 13 | |
| 14 | read(This, Iprot) -> |
| 15 | ?M0(Iprot, readStructBegin), |
| 16 | read_while_loop(This, Iprot), |
| 17 | ?M0(Iprot, readStructEnd), |
| 18 | This. |
| 19 | |
| 20 | read_while_loop(This, Iprot) -> |
| 21 | {_, Ftype, Fid} = ?M0(Iprot, readFieldBegin), % field = {fname, ftype, fid} |
| 22 | |
| 23 | if |
| 24 | Ftype == ?tType_STOP -> |
| 25 | This; |
| 26 | (Fid == 1) and (Ftype == ?tType_STRING) -> |
| 27 | This1 = This#tApplicationException{message=?M0(Iprot, readString)}, |
| 28 | ?M0(Iprot, readFieldEnd), |
| 29 | read_while_loop(This1, Iprot); |
| 30 | |
| 31 | Fid == 1 -> |
| 32 | ?M0(Iprot, skip), |
| 33 | ?M0(Iprot, readFieldEnd), |
| 34 | read_while_loop(This, Iprot); |
| 35 | |
| 36 | (Fid == 2) and (Ftype == ?tType_I32) -> |
| 37 | This1 = This#tApplicationException{type=?M0(Iprot, readI32)}, |
| 38 | ?M0(Iprot, readFieldEnd), |
| 39 | read_while_loop(This1, Iprot); |
| 40 | |
| 41 | true -> |
| 42 | ?M0(Iprot, skip), |
| 43 | ?M0(Iprot, readFieldEnd), |
| 44 | read_while_loop(This, Iprot) |
| 45 | end. |
| 46 | |
| 47 | write(This, Oprot) -> |
| 48 | ?M1(Oprot, writeStructBegin, "tApplicationException"), |
| 49 | Message = This#tApplicationException.message, |
| 50 | Type = This#tApplicationException.type, |
| 51 | if Message /= undefined -> |
| 52 | ?M3(Oprot, writeFieldBegin, "message", ?tType_STRING, 1), |
| 53 | ?M1(Oprot, writeString, Message), |
| 54 | ?M0(Oprot, writeFieldEnd); |
| 55 | true -> ok |
| 56 | end, |
| 57 | if Type /= undefined -> |
| 58 | ?M3(Oprot, writeFieldBegin, "type", ?tType_I32, 2), |
| 59 | ?M1(Oprot, writeI32, Type), |
| 60 | ?M0(Oprot, writeFieldEnd); |
| 61 | true -> ok |
| 62 | end, |
| 63 | ?M0(Oprot, writeFieldStop), |
| 64 | ?M0(Oprot, writeStructEnd). |