]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
1 | /* |
2 | * Licensed to the Apache Software Foundation (ASF) under one | |
3 | * or more contributor license agreements. See the NOTICE file | |
4 | * distributed with this work for additional information | |
5 | * regarding copyright ownership. The ASF licenses this file | |
6 | * to you under the Apache License, Version 2.0 (the | |
7 | * "License"); you may not use this file except in compliance | |
8 | * with the License. You may obtain a copy of the License at | |
9 | * | |
10 | * http://www.apache.org/licenses/LICENSE-2.0 | |
11 | * | |
12 | * Unless required by applicable law or agreed to in writing, | |
13 | * software distributed under the License is distributed on an | |
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
15 | * KIND, either express or implied. See the License for the | |
16 | * specific language governing permissions and limitations | |
17 | * under the License. | |
18 | */ | |
19 | ||
20 | #include <thrift/TApplicationException.h> | |
21 | #include <thrift/protocol/TProtocol.h> | |
22 | ||
23 | namespace apache { | |
24 | namespace thrift { | |
25 | ||
26 | uint32_t TApplicationException::read(apache::thrift::protocol::TProtocol* iprot) { | |
27 | uint32_t xfer = 0; | |
28 | std::string fname; | |
29 | apache::thrift::protocol::TType ftype; | |
30 | int16_t fid; | |
31 | ||
32 | xfer += iprot->readStructBegin(fname); | |
33 | ||
34 | while (true) { | |
35 | xfer += iprot->readFieldBegin(fname, ftype, fid); | |
36 | if (ftype == apache::thrift::protocol::T_STOP) { | |
37 | break; | |
38 | } | |
39 | switch (fid) { | |
40 | case 1: | |
41 | if (ftype == apache::thrift::protocol::T_STRING) { | |
42 | xfer += iprot->readString(message_); | |
43 | } else { | |
44 | xfer += iprot->skip(ftype); | |
45 | } | |
46 | break; | |
47 | case 2: | |
48 | if (ftype == apache::thrift::protocol::T_I32) { | |
49 | int32_t type; | |
50 | xfer += iprot->readI32(type); | |
51 | type_ = (TApplicationExceptionType)type; | |
52 | } else { | |
53 | xfer += iprot->skip(ftype); | |
54 | } | |
55 | break; | |
56 | default: | |
57 | xfer += iprot->skip(ftype); | |
58 | break; | |
59 | } | |
60 | xfer += iprot->readFieldEnd(); | |
61 | } | |
62 | ||
63 | xfer += iprot->readStructEnd(); | |
64 | return xfer; | |
65 | } | |
66 | ||
67 | uint32_t TApplicationException::write(apache::thrift::protocol::TProtocol* oprot) const { | |
68 | uint32_t xfer = 0; | |
69 | xfer += oprot->writeStructBegin("TApplicationException"); | |
70 | xfer += oprot->writeFieldBegin("message", apache::thrift::protocol::T_STRING, 1); | |
71 | xfer += oprot->writeString(message_); | |
72 | xfer += oprot->writeFieldEnd(); | |
73 | xfer += oprot->writeFieldBegin("type", apache::thrift::protocol::T_I32, 2); | |
74 | xfer += oprot->writeI32(type_); | |
75 | xfer += oprot->writeFieldEnd(); | |
76 | xfer += oprot->writeFieldStop(); | |
77 | xfer += oprot->writeStructEnd(); | |
78 | return xfer; | |
79 | } | |
80 | } | |
81 | } // apache::thrift |