blob: 0b480d306700db1adb3e910620b7ef3e4b5d56cf [file] [log] [blame]
Mark Sleecde2b612006-09-03 21:13:07 +00001class TType:
2 STOP = 0
3 VOID = 1
4 BOOL = 2
5 BYTE = 3
Mark Sleec98d0502006-09-06 02:42:25 +00006 I08 = 3
7 DOUBLE = 4
Mark Sleecde2b612006-09-03 21:13:07 +00008 I16 = 6
9 I32 = 8
10 I64 = 10
11 STRING = 11
12 UTF7 = 11
13 STRUCT = 12
14 MAP = 13
15 SET = 14
16 LIST = 15
17 UTF8 = 16
18 UTF16 = 17
19
20class TMessageType:
21 CALL = 1
22 REPLY = 2
23
24class TProtocolBase:
25
26 """Base class for Thrift protocol driver."""
27
28 def writeMessageBegin(self, otrans, name, type, seqid):
29 pass
30
31 def writeMessageEnd(self, otrans):
32 pass
33
34 def writeStructBegin(self, otrans, name):
35 pass
36
37 def writeStructEnd(self, otrans):
38 pass
39
40 def writeFieldBegin(self, otrans, name, type, id):
41 pass
42
43 def writeFieldEnd(self, otrans):
44 pass
45
46 def writeFieldStop(self, otrans):
47 pass
48
49 def writeMapBegin(self, otrans, ktype, vtype, size):
50 pass
51
52 def writeMapEnd(self, otrans):
53 pass
54
55 def writeListBegin(self, otrans, etype, size):
56 pass
57
58 def writeListEnd(self, otrans):
59 pass
60
61 def writeSetBegin(self, otrans, etype, size):
62 pass
63
64 def writeSetEnd(self, otrans):
65 pass
66
67 def writeBool(self, otrans, bool):
68 pass
69
70 def writeByte(self, otrans, byte):
71 pass
72
73 def writeI16(self, otrans, i16):
74 pass
75
76 def writeI32(self, otrans, i32):
77 pass
78
79 def writeI64(self, otrans, i64):
80 pass
81
Mark Sleec98d0502006-09-06 02:42:25 +000082 def writeDouble(self, otrans, dub):
83 pass
84
Mark Sleecde2b612006-09-03 21:13:07 +000085 def writeString(self, otrans, str):
86 pass
87
88 def readMessageBegin(self, itrans):
89 pass
90
91 def readMessageEnd(self, itrans):
92 pass
93
94 def readStructBegin(self, itrans):
95 pass
96
97 def readStructEnd(self, itrans):
98 pass
99
100 def readFieldBegin(self, itrans):
101 pass
102
103 def readFieldEnd(self, itrans):
104 pass
105
106 def readMapBegin(self, itrans):
107 pass
108
109 def readMapEnd(self, itrans):
110 pass
111
112 def readListBegin(self, itrans):
113 pass
114
115 def readListEnd(self, itrans):
116 pass
117
118 def readSetBegin(self, itrans):
119 pass
120
121 def readSetEnd(self, itrans):
122 pass
123
124 def readBool(self, itrans):
125 pass
126
127 def readByte(self, itrans):
128 pass
129
130 def readI16(self, itrans):
131 pass
132
133 def readI32(self, itrans):
134 pass
135
136 def readI64(self, itrans):
137 pass
138
Mark Sleec98d0502006-09-06 02:42:25 +0000139 def readDouble(self, itrans):
140 pass
141
Mark Sleecde2b612006-09-03 21:13:07 +0000142 def readString(self, itrans):
143 pass
144
145 def skip(self, itrans, type):
146 if type == TType.STOP:
147 return
148 elif type == TType.BOOL:
149 self.readBool(itrans)
150 elif type == TType.BYTE:
151 self.readByte(itrans)
152 elif type == TType.I16:
153 self.readI16(itrans)
154 elif type == TType.I32:
155 self.readI32(itrans)
156 elif type == TType.I64:
157 self.readI64(itrans)
Mark Sleec98d0502006-09-06 02:42:25 +0000158 elif type == TType.DOUBLE:
159 self.readDouble(itrans)
Mark Sleecde2b612006-09-03 21:13:07 +0000160 elif type == TType.STRING:
161 self.readString(itrans)
162 elif type == TType.STRUCT:
163 name = self.readStructBegin(itrans)
164 while True:
165 (name, type, id) = self.readFieldBegin(itrans)
166 if type == TType.STOP:
167 break
168 self.skip(itrans, type)
169 self.readFieldEnd(itrans)
170 self.readStructEnd(itrans)
171 elif type == TType.MAP:
172 (ktype, vtype, size) = self.readMapBegin(itrans)
173 for i in range(size):
174 self.skip(itrans, ktype)
175 self.skip(itrans, vtype)
176 self.readMapEnd(itrans)
177 elif type == TType.SET:
178 (etype, size) = self.readSetBegin(itrans)
179 for i in range(size):
180 self.skip(itrans, etype)
181 self.readSetEnd(itrans)
182 elif type == TType.LIST:
183 (etype, size) = self.readListBegin(itrans)
184 for i in range(size):
185 self.skip(itrans, etype)
186 self.readListEnd(itrans)
187
188
189