Class: Thrift::BaseProtocol
- Inherits:
-
Object
- Object
- Thrift::BaseProtocol
show all
- Defined in:
- lib/thrift/protocol/base_protocol.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#initialize(trans) ⇒ BaseProtocol
constructor
A new instance of BaseProtocol.
-
#native? ⇒ Boolean
-
#read_bool ⇒ Object
-
#read_byte ⇒ Object
-
#read_double ⇒ Object
-
#read_field_begin ⇒ Object
-
#read_field_end ⇒ Object
-
#read_i16 ⇒ Object
-
#read_i32 ⇒ Object
-
#read_i64 ⇒ Object
-
#read_list_begin ⇒ Object
-
#read_list_end ⇒ Object
-
#read_map_begin ⇒ Object
-
#read_map_end ⇒ Object
-
#read_message_begin ⇒ Object
-
#read_message_end ⇒ Object
-
#read_set_begin ⇒ Object
-
#read_set_end ⇒ Object
-
#read_string ⇒ Object
-
#read_struct_begin ⇒ Object
-
#read_struct_end ⇒ Object
-
#read_type(type) ⇒ Object
-
#skip(type) ⇒ Object
-
#write_bool(bool) ⇒ Object
-
#write_byte(byte) ⇒ Object
-
#write_double(dub) ⇒ Object
-
#write_field(name, type, fid, value) ⇒ Object
-
#write_field_begin(name, type, id) ⇒ Object
-
#write_field_end ⇒ Object
-
#write_field_stop ⇒ Object
-
#write_i16(i16) ⇒ Object
-
#write_i32(i32) ⇒ Object
-
#write_i64(i64) ⇒ Object
-
#write_list_begin(etype, size) ⇒ Object
-
#write_list_end ⇒ Object
-
#write_map_begin(ktype, vtype, size) ⇒ Object
-
#write_map_end ⇒ Object
-
#write_message_begin(name, type, seqid) ⇒ Object
-
#write_message_end ⇒ Object
-
#write_set_begin(etype, size) ⇒ Object
-
#write_set_end ⇒ Object
-
#write_string(str) ⇒ Object
-
#write_struct_begin(name) ⇒ Object
-
#write_struct_end ⇒ Object
-
#write_type(type, value) ⇒ Object
Constructor Details
Returns a new instance of BaseProtocol.
44
45
46
|
# File 'lib/thrift/protocol/base_protocol.rb', line 44
def initialize(trans)
@trans = trans
end
|
Instance Attribute Details
#trans ⇒ Object
Returns the value of attribute trans.
42
43
44
|
# File 'lib/thrift/protocol/base_protocol.rb', line 42
def trans
@trans
end
|
Instance Method Details
#native? ⇒ Boolean
48
49
50
51
|
# File 'lib/thrift/protocol/base_protocol.rb', line 48
def native?
puts "wrong method is being called!"
false
end
|
#read_bool ⇒ Object
157
158
159
|
# File 'lib/thrift/protocol/base_protocol.rb', line 157
def read_bool
raise NotImplementedError
end
|
#read_byte ⇒ Object
161
162
163
|
# File 'lib/thrift/protocol/base_protocol.rb', line 161
def read_byte
raise NotImplementedError
end
|
#read_double ⇒ Object
177
178
179
|
# File 'lib/thrift/protocol/base_protocol.rb', line 177
def read_double
raise NotImplementedError
end
|
#read_field_begin ⇒ Object
133
134
135
|
# File 'lib/thrift/protocol/base_protocol.rb', line 133
def read_field_begin
raise NotImplementedError
end
|
#read_field_end ⇒ Object
137
|
# File 'lib/thrift/protocol/base_protocol.rb', line 137
def read_field_end; nil; end
|
#read_i16 ⇒ Object
165
166
167
|
# File 'lib/thrift/protocol/base_protocol.rb', line 165
def read_i16
raise NotImplementedError
end
|
#read_i32 ⇒ Object
169
170
171
|
# File 'lib/thrift/protocol/base_protocol.rb', line 169
def read_i32
raise NotImplementedError
end
|
#read_i64 ⇒ Object
173
174
175
|
# File 'lib/thrift/protocol/base_protocol.rb', line 173
def read_i64
raise NotImplementedError
end
|
#read_list_begin ⇒ Object
145
146
147
|
# File 'lib/thrift/protocol/base_protocol.rb', line 145
def read_list_begin
raise NotImplementedError
end
|
#read_list_end ⇒ Object
149
|
# File 'lib/thrift/protocol/base_protocol.rb', line 149
def read_list_end; nil; end
|
#read_map_begin ⇒ Object
139
140
141
|
# File 'lib/thrift/protocol/base_protocol.rb', line 139
def read_map_begin
raise NotImplementedError
end
|
#read_map_end ⇒ Object
143
|
# File 'lib/thrift/protocol/base_protocol.rb', line 143
def read_map_end; nil; end
|
#read_message_begin ⇒ Object
121
122
123
|
# File 'lib/thrift/protocol/base_protocol.rb', line 121
def read_message_begin
raise NotImplementedError
end
|
#read_message_end ⇒ Object
125
|
# File 'lib/thrift/protocol/base_protocol.rb', line 125
def read_message_end; nil; end
|
#read_set_begin ⇒ Object
151
152
153
|
# File 'lib/thrift/protocol/base_protocol.rb', line 151
def read_set_begin
raise NotImplementedError
end
|
#read_set_end ⇒ Object
155
|
# File 'lib/thrift/protocol/base_protocol.rb', line 155
def read_set_end; nil; end
|
#read_string ⇒ Object
181
182
183
|
# File 'lib/thrift/protocol/base_protocol.rb', line 181
def read_string
raise NotImplementedError
end
|
#read_struct_begin ⇒ Object
127
128
129
|
# File 'lib/thrift/protocol/base_protocol.rb', line 127
def read_struct_begin
raise NotImplementedError
end
|
#read_struct_end ⇒ Object
131
|
# File 'lib/thrift/protocol/base_protocol.rb', line 131
def read_struct_end; nil; end
|
#read_type(type) ⇒ Object
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
|
# File 'lib/thrift/protocol/base_protocol.rb', line 214
def read_type(type)
case type
when Types::BOOL
read_bool
when Types::BYTE
read_byte
when Types::DOUBLE
read_double
when Types::I16
read_i16
when Types::I32
read_i32
when Types::I64
read_i64
when Types::STRING
read_string
else
raise NotImplementedError
end
end
|
#skip(type) ⇒ Object
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
|
# File 'lib/thrift/protocol/base_protocol.rb', line 235
def skip(type)
case type
when Types::STOP
nil
when Types::BOOL
read_bool
when Types::BYTE
read_byte
when Types::I16
read_i16
when Types::I32
read_i32
when Types::I64
read_i64
when Types::DOUBLE
read_double
when Types::STRING
read_string
when Types::STRUCT
read_struct_begin
while true
name, type, id = read_field_begin
break if type == Types::STOP
skip(type)
read_field_end
end
read_struct_end
when Types::MAP
ktype, vtype, size = read_map_begin
size.times do
skip(ktype)
skip(vtype)
end
read_map_end
when Types::SET
etype, size = read_set_begin
size.times do
skip(etype)
end
read_set_end
when Types::LIST
etype, size = read_list_begin
size.times do
skip(etype)
end
read_list_end
end
end
|
#write_bool(bool) ⇒ Object
93
94
95
|
# File 'lib/thrift/protocol/base_protocol.rb', line 93
def write_bool(bool)
raise NotImplementedError
end
|
#write_byte(byte) ⇒ Object
97
98
99
|
# File 'lib/thrift/protocol/base_protocol.rb', line 97
def write_byte(byte)
raise NotImplementedError
end
|
#write_double(dub) ⇒ Object
113
114
115
|
# File 'lib/thrift/protocol/base_protocol.rb', line 113
def write_double(dub)
raise NotImplementedError
end
|
#write_field(name, type, fid, value) ⇒ Object
185
186
187
188
189
|
# File 'lib/thrift/protocol/base_protocol.rb', line 185
def write_field(name, type, fid, value)
write_field_begin(name, type, fid)
write_type(type, value)
write_field_end
end
|
#write_field_begin(name, type, id) ⇒ Object
65
66
67
|
# File 'lib/thrift/protocol/base_protocol.rb', line 65
def write_field_begin(name, type, id)
raise NotImplementedError
end
|
#write_field_end ⇒ Object
69
|
# File 'lib/thrift/protocol/base_protocol.rb', line 69
def write_field_end; nil; end
|
#write_field_stop ⇒ Object
71
72
73
|
# File 'lib/thrift/protocol/base_protocol.rb', line 71
def write_field_stop
raise NotImplementedError
end
|
#write_i16(i16) ⇒ Object
101
102
103
|
# File 'lib/thrift/protocol/base_protocol.rb', line 101
def write_i16(i16)
raise NotImplementedError
end
|
#write_i32(i32) ⇒ Object
105
106
107
|
# File 'lib/thrift/protocol/base_protocol.rb', line 105
def write_i32(i32)
raise NotImplementedError
end
|
#write_i64(i64) ⇒ Object
109
110
111
|
# File 'lib/thrift/protocol/base_protocol.rb', line 109
def write_i64(i64)
raise NotImplementedError
end
|
#write_list_begin(etype, size) ⇒ Object
81
82
83
|
# File 'lib/thrift/protocol/base_protocol.rb', line 81
def write_list_begin(etype, size)
raise NotImplementedError
end
|
#write_list_end ⇒ Object
85
|
# File 'lib/thrift/protocol/base_protocol.rb', line 85
def write_list_end; nil; end
|
#write_map_begin(ktype, vtype, size) ⇒ Object
75
76
77
|
# File 'lib/thrift/protocol/base_protocol.rb', line 75
def write_map_begin(ktype, vtype, size)
raise NotImplementedError
end
|
#write_map_end ⇒ Object
79
|
# File 'lib/thrift/protocol/base_protocol.rb', line 79
def write_map_end; nil; end
|
#write_message_begin(name, type, seqid) ⇒ Object
53
54
55
|
# File 'lib/thrift/protocol/base_protocol.rb', line 53
def write_message_begin(name, type, seqid)
raise NotImplementedError
end
|
#write_message_end ⇒ Object
57
|
# File 'lib/thrift/protocol/base_protocol.rb', line 57
def write_message_end; nil; end
|
#write_set_begin(etype, size) ⇒ Object
87
88
89
|
# File 'lib/thrift/protocol/base_protocol.rb', line 87
def write_set_begin(etype, size)
raise NotImplementedError
end
|
#write_set_end ⇒ Object
91
|
# File 'lib/thrift/protocol/base_protocol.rb', line 91
def write_set_end; nil; end
|
#write_string(str) ⇒ Object
117
118
119
|
# File 'lib/thrift/protocol/base_protocol.rb', line 117
def write_string(str)
raise NotImplementedError
end
|
#write_struct_begin(name) ⇒ Object
59
60
61
|
# File 'lib/thrift/protocol/base_protocol.rb', line 59
def write_struct_begin(name)
raise NotImplementedError
end
|
#write_struct_end ⇒ Object
63
|
# File 'lib/thrift/protocol/base_protocol.rb', line 63
def write_struct_end; nil; end
|
#write_type(type, value) ⇒ Object
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
|
# File 'lib/thrift/protocol/base_protocol.rb', line 191
def write_type(type, value)
case type
when Types::BOOL
write_bool(value)
when Types::BYTE
write_byte(value)
when Types::DOUBLE
write_double(value)
when Types::I16
write_i16(value)
when Types::I32
write_i32(value)
when Types::I64
write_i64(value)
when Types::STRING
write_string(value)
when Types::STRUCT
value.write(self)
else
raise NotImplementedError
end
end
|