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 {
25 namespace thrift
26 {
27
read(apache::thrift::protocol::TProtocol * iprot)28 uint32_t TApplicationException::read(apache::thrift::protocol::TProtocol* iprot)
29 {
30 uint32_t xfer = 0;
31 std::string fname;
32 apache::thrift::protocol::TType ftype;
33 int16_t fid;
34
35 xfer += iprot->readStructBegin(fname);
36
37 while (true)
38 {
39 xfer += iprot->readFieldBegin(fname, ftype, fid);
40
41 if (ftype == apache::thrift::protocol::T_STOP)
42 {
43 break;
44 }
45
46 switch (fid)
47 {
48 case 1:
49 if (ftype == apache::thrift::protocol::T_STRING)
50 {
51 xfer += iprot->readString(message_);
52 }
53 else
54 {
55 xfer += iprot->skip(ftype);
56 }
57
58 break;
59
60 case 2:
61 if (ftype == apache::thrift::protocol::T_I32)
62 {
63 int32_t type;
64 xfer += iprot->readI32(type);
65 type_ = (TApplicationExceptionType)type;
66 }
67 else
68 {
69 xfer += iprot->skip(ftype);
70 }
71
72 break;
73
74 default:
75 xfer += iprot->skip(ftype);
76 break;
77 }
78
79 xfer += iprot->readFieldEnd();
80 }
81
82 xfer += iprot->readStructEnd();
83 return xfer;
84 }
85
write(apache::thrift::protocol::TProtocol * oprot) const86 uint32_t TApplicationException::write(apache::thrift::protocol::TProtocol* oprot) const
87 {
88 uint32_t xfer = 0;
89 xfer += oprot->writeStructBegin("TApplicationException");
90 xfer += oprot->writeFieldBegin("message", apache::thrift::protocol::T_STRING, 1);
91 xfer += oprot->writeString(message_);
92 xfer += oprot->writeFieldEnd();
93 xfer += oprot->writeFieldBegin("type", apache::thrift::protocol::T_I32, 2);
94 xfer += oprot->writeI32(type_);
95 xfer += oprot->writeFieldEnd();
96 xfer += oprot->writeFieldStop();
97 xfer += oprot->writeStructEnd();
98 return xfer;
99 }
100
101 }
102 } // apache::thrift
103