-
Notifications
You must be signed in to change notification settings - Fork 113
/
Copy pathtest_types.cpp
171 lines (147 loc) · 4.39 KB
/
test_types.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/**
* Autogenerated by Thrift Compiler (0.12.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
#include "test_types.h"
#include <algorithm>
#include <ostream>
#include <thrift/TToString.h>
namespace thrift_test {
Record::~Record() throw() {
}
void Record::__set_ids(const std::vector<int64_t> & val) {
this->ids = val;
}
void Record::__set_strings(const std::vector<std::string> & val) {
this->strings = val;
}
std::ostream& operator<<(std::ostream& out, const Record& obj)
{
obj.printTo(out);
return out;
}
uint32_t Record::read(::apache::thrift::protocol::TProtocol* iprot) {
::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
uint32_t xfer = 0;
std::string fname;
::apache::thrift::protocol::TType ftype;
int16_t fid;
xfer += iprot->readStructBegin(fname);
using ::apache::thrift::protocol::TProtocolException;
bool isset_ids = false;
bool isset_strings = false;
while (true)
{
xfer += iprot->readFieldBegin(fname, ftype, fid);
if (ftype == ::apache::thrift::protocol::T_STOP) {
break;
}
switch (fid)
{
case 1:
if (ftype == ::apache::thrift::protocol::T_LIST) {
{
this->ids.clear();
uint32_t _size0;
::apache::thrift::protocol::TType _etype3;
xfer += iprot->readListBegin(_etype3, _size0);
this->ids.resize(_size0);
uint32_t _i4;
for (_i4 = 0; _i4 < _size0; ++_i4)
{
xfer += iprot->readI64(this->ids[_i4]);
}
xfer += iprot->readListEnd();
}
isset_ids = true;
} else {
xfer += iprot->skip(ftype);
}
break;
case 2:
if (ftype == ::apache::thrift::protocol::T_LIST) {
{
this->strings.clear();
uint32_t _size5;
::apache::thrift::protocol::TType _etype8;
xfer += iprot->readListBegin(_etype8, _size5);
this->strings.resize(_size5);
uint32_t _i9;
for (_i9 = 0; _i9 < _size5; ++_i9)
{
xfer += iprot->readString(this->strings[_i9]);
}
xfer += iprot->readListEnd();
}
isset_strings = true;
} else {
xfer += iprot->skip(ftype);
}
break;
default:
xfer += iprot->skip(ftype);
break;
}
xfer += iprot->readFieldEnd();
}
xfer += iprot->readStructEnd();
if (!isset_ids)
throw TProtocolException(TProtocolException::INVALID_DATA);
if (!isset_strings)
throw TProtocolException(TProtocolException::INVALID_DATA);
return xfer;
}
uint32_t Record::write(::apache::thrift::protocol::TProtocol* oprot) const {
uint32_t xfer = 0;
::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
xfer += oprot->writeStructBegin("Record");
xfer += oprot->writeFieldBegin("ids", ::apache::thrift::protocol::T_LIST, 1);
{
xfer += oprot->writeListBegin(::apache::thrift::protocol::T_I64, static_cast<uint32_t>(this->ids.size()));
std::vector<int64_t> ::const_iterator _iter10;
for (_iter10 = this->ids.begin(); _iter10 != this->ids.end(); ++_iter10)
{
xfer += oprot->writeI64((*_iter10));
}
xfer += oprot->writeListEnd();
}
xfer += oprot->writeFieldEnd();
xfer += oprot->writeFieldBegin("strings", ::apache::thrift::protocol::T_LIST, 2);
{
xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->strings.size()));
std::vector<std::string> ::const_iterator _iter11;
for (_iter11 = this->strings.begin(); _iter11 != this->strings.end(); ++_iter11)
{
xfer += oprot->writeString((*_iter11));
}
xfer += oprot->writeListEnd();
}
xfer += oprot->writeFieldEnd();
xfer += oprot->writeFieldStop();
xfer += oprot->writeStructEnd();
return xfer;
}
void swap(Record &a, Record &b) {
using ::std::swap;
swap(a.ids, b.ids);
swap(a.strings, b.strings);
}
Record::Record(const Record& other12) {
ids = other12.ids;
strings = other12.strings;
}
Record& Record::operator=(const Record& other13) {
ids = other13.ids;
strings = other13.strings;
return *this;
}
void Record::printTo(std::ostream& out) const {
using ::apache::thrift::to_string;
out << "Record(";
out << "ids=" << to_string(ids);
out << ", " << "strings=" << to_string(strings);
out << ")";
}
} // namespace