blob: cc9517cf3432d3ff32dd48cd747638c3e2765524 [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
Mark Slee4ac459f2006-10-25 21:39:01 +000028 def __init__(self, itrans, otrans=None):
29 self.itrans = self.otrans = itrans
30 if otrans != None:
31 self.otrans = otrans
32
33 def writeMessageBegin(self, name, type, seqid):
Mark Sleecde2b612006-09-03 21:13:07 +000034 pass
35
Mark Slee4ac459f2006-10-25 21:39:01 +000036 def writeMessageEnd(self):
Mark Sleecde2b612006-09-03 21:13:07 +000037 pass
38
Mark Slee4ac459f2006-10-25 21:39:01 +000039 def writeStructBegin(self, name):
Mark Sleecde2b612006-09-03 21:13:07 +000040 pass
41
Mark Slee4ac459f2006-10-25 21:39:01 +000042 def writeStructEnd(self):
Mark Sleecde2b612006-09-03 21:13:07 +000043 pass
44
Mark Slee4ac459f2006-10-25 21:39:01 +000045 def writeFieldBegin(self, name, type, id):
Mark Sleecde2b612006-09-03 21:13:07 +000046 pass
47
Mark Slee4ac459f2006-10-25 21:39:01 +000048 def writeFieldEnd(self):
Mark Sleecde2b612006-09-03 21:13:07 +000049 pass
50
Mark Slee4ac459f2006-10-25 21:39:01 +000051 def writeFieldStop(self):
Mark Sleecde2b612006-09-03 21:13:07 +000052 pass
53
Mark Slee4ac459f2006-10-25 21:39:01 +000054 def writeMapBegin(self, ktype, vtype, size):
Mark Sleecde2b612006-09-03 21:13:07 +000055 pass
56
Mark Slee4ac459f2006-10-25 21:39:01 +000057 def writeMapEnd(self):
Mark Sleecde2b612006-09-03 21:13:07 +000058 pass
59
Mark Slee4ac459f2006-10-25 21:39:01 +000060 def writeListBegin(self, etype, size):
Mark Sleecde2b612006-09-03 21:13:07 +000061 pass
62
Mark Slee4ac459f2006-10-25 21:39:01 +000063 def writeListEnd(self):
Mark Sleecde2b612006-09-03 21:13:07 +000064 pass
65
Mark Slee4ac459f2006-10-25 21:39:01 +000066 def writeSetBegin(self, etype, size):
Mark Sleecde2b612006-09-03 21:13:07 +000067 pass
68
Mark Slee4ac459f2006-10-25 21:39:01 +000069 def writeSetEnd(self):
Mark Sleecde2b612006-09-03 21:13:07 +000070 pass
71
Mark Slee4ac459f2006-10-25 21:39:01 +000072 def writeBool(self, bool):
Mark Sleecde2b612006-09-03 21:13:07 +000073 pass
74
Mark Slee4ac459f2006-10-25 21:39:01 +000075 def writeByte(self, byte):
Mark Sleecde2b612006-09-03 21:13:07 +000076 pass
77
Mark Slee4ac459f2006-10-25 21:39:01 +000078 def writeI16(self, i16):
Mark Sleecde2b612006-09-03 21:13:07 +000079 pass
80
Mark Slee4ac459f2006-10-25 21:39:01 +000081 def writeI32(self, i32):
Mark Sleecde2b612006-09-03 21:13:07 +000082 pass
83
Mark Slee4ac459f2006-10-25 21:39:01 +000084 def writeI64(self, i64):
Mark Sleecde2b612006-09-03 21:13:07 +000085 pass
86
Mark Slee4ac459f2006-10-25 21:39:01 +000087 def writeDouble(self, dub):
Mark Sleec98d0502006-09-06 02:42:25 +000088 pass
89
Mark Slee4ac459f2006-10-25 21:39:01 +000090 def writeString(self, str):
Mark Sleecde2b612006-09-03 21:13:07 +000091 pass
92
Mark Slee4ac459f2006-10-25 21:39:01 +000093 def readMessageBegin(self):
Mark Sleecde2b612006-09-03 21:13:07 +000094 pass
95
Mark Slee4ac459f2006-10-25 21:39:01 +000096 def readMessageEnd(self):
Mark Sleecde2b612006-09-03 21:13:07 +000097 pass
98
Mark Slee4ac459f2006-10-25 21:39:01 +000099 def readStructBegin(self):
Mark Sleecde2b612006-09-03 21:13:07 +0000100 pass
101
Mark Slee4ac459f2006-10-25 21:39:01 +0000102 def readStructEnd(self):
Mark Sleecde2b612006-09-03 21:13:07 +0000103 pass
104
Mark Slee4ac459f2006-10-25 21:39:01 +0000105 def readFieldBegin(self):
Mark Sleecde2b612006-09-03 21:13:07 +0000106 pass
107
Mark Slee4ac459f2006-10-25 21:39:01 +0000108 def readFieldEnd(self):
Mark Sleecde2b612006-09-03 21:13:07 +0000109 pass
110
Mark Slee4ac459f2006-10-25 21:39:01 +0000111 def readMapBegin(self):
Mark Sleecde2b612006-09-03 21:13:07 +0000112 pass
113
Mark Slee4ac459f2006-10-25 21:39:01 +0000114 def readMapEnd(self):
Mark Sleecde2b612006-09-03 21:13:07 +0000115 pass
116
Mark Slee4ac459f2006-10-25 21:39:01 +0000117 def readListBegin(self):
Mark Sleecde2b612006-09-03 21:13:07 +0000118 pass
119
Mark Slee4ac459f2006-10-25 21:39:01 +0000120 def readListEnd(self):
Mark Sleecde2b612006-09-03 21:13:07 +0000121 pass
122
Mark Slee4ac459f2006-10-25 21:39:01 +0000123 def readSetBegin(self):
Mark Sleecde2b612006-09-03 21:13:07 +0000124 pass
125
Mark Slee4ac459f2006-10-25 21:39:01 +0000126 def readSetEnd(self):
Mark Sleecde2b612006-09-03 21:13:07 +0000127 pass
128
Mark Slee4ac459f2006-10-25 21:39:01 +0000129 def readBool(self):
Mark Sleecde2b612006-09-03 21:13:07 +0000130 pass
131
Mark Slee4ac459f2006-10-25 21:39:01 +0000132 def readByte(self):
Mark Sleecde2b612006-09-03 21:13:07 +0000133 pass
134
Mark Slee4ac459f2006-10-25 21:39:01 +0000135 def readI16(self):
Mark Sleecde2b612006-09-03 21:13:07 +0000136 pass
137
Mark Slee4ac459f2006-10-25 21:39:01 +0000138 def readI32(self):
Mark Sleecde2b612006-09-03 21:13:07 +0000139 pass
140
Mark Slee4ac459f2006-10-25 21:39:01 +0000141 def readI64(self):
Mark Sleecde2b612006-09-03 21:13:07 +0000142 pass
143
Mark Slee4ac459f2006-10-25 21:39:01 +0000144 def readDouble(self):
Mark Sleec98d0502006-09-06 02:42:25 +0000145 pass
146
Mark Slee4ac459f2006-10-25 21:39:01 +0000147 def readString(self):
Mark Sleecde2b612006-09-03 21:13:07 +0000148 pass
149
Mark Slee4ac459f2006-10-25 21:39:01 +0000150 def skip(self, type):
Mark Sleecde2b612006-09-03 21:13:07 +0000151 if type == TType.STOP:
152 return
153 elif type == TType.BOOL:
Mark Slee4ac459f2006-10-25 21:39:01 +0000154 self.readBool()
Mark Sleecde2b612006-09-03 21:13:07 +0000155 elif type == TType.BYTE:
Mark Slee4ac459f2006-10-25 21:39:01 +0000156 self.readByte()
Mark Sleecde2b612006-09-03 21:13:07 +0000157 elif type == TType.I16:
Mark Slee4ac459f2006-10-25 21:39:01 +0000158 self.readI16()
Mark Sleecde2b612006-09-03 21:13:07 +0000159 elif type == TType.I32:
Mark Slee4ac459f2006-10-25 21:39:01 +0000160 self.readI32()
Mark Sleecde2b612006-09-03 21:13:07 +0000161 elif type == TType.I64:
Mark Slee4ac459f2006-10-25 21:39:01 +0000162 self.readI64()
Mark Sleec98d0502006-09-06 02:42:25 +0000163 elif type == TType.DOUBLE:
Mark Slee4ac459f2006-10-25 21:39:01 +0000164 self.readDouble()
Mark Sleecde2b612006-09-03 21:13:07 +0000165 elif type == TType.STRING:
Mark Slee4ac459f2006-10-25 21:39:01 +0000166 self.readString()
Mark Sleecde2b612006-09-03 21:13:07 +0000167 elif type == TType.STRUCT:
Mark Slee4ac459f2006-10-25 21:39:01 +0000168 name = self.readStructBegin()
Mark Sleecde2b612006-09-03 21:13:07 +0000169 while True:
Mark Slee4ac459f2006-10-25 21:39:01 +0000170 (name, type, id) = self.readFieldBegin()
Mark Sleecde2b612006-09-03 21:13:07 +0000171 if type == TType.STOP:
172 break
Mark Slee4ac459f2006-10-25 21:39:01 +0000173 self.skip(type)
174 self.readFieldEnd()
175 self.readStructEnd()
Mark Sleecde2b612006-09-03 21:13:07 +0000176 elif type == TType.MAP:
Mark Slee4ac459f2006-10-25 21:39:01 +0000177 (ktype, vtype, size) = self.readMapBegin()
Mark Sleecde2b612006-09-03 21:13:07 +0000178 for i in range(size):
Mark Slee4ac459f2006-10-25 21:39:01 +0000179 self.skip(ktype)
180 self.skip(vtype)
181 self.readMapEnd()
Mark Sleecde2b612006-09-03 21:13:07 +0000182 elif type == TType.SET:
Mark Slee4ac459f2006-10-25 21:39:01 +0000183 (etype, size) = self.readSetBegin()
Mark Sleecde2b612006-09-03 21:13:07 +0000184 for i in range(size):
Mark Slee4ac459f2006-10-25 21:39:01 +0000185 self.skip(etype)
186 self.readSetEnd()
Mark Sleecde2b612006-09-03 21:13:07 +0000187 elif type == TType.LIST:
Mark Slee4ac459f2006-10-25 21:39:01 +0000188 (etype, size) = self.readListBegin()
Mark Sleecde2b612006-09-03 21:13:07 +0000189 for i in range(size):
Mark Slee4ac459f2006-10-25 21:39:01 +0000190 self.skip(etype)
191 self.readListEnd()
Mark Sleecde2b612006-09-03 21:13:07 +0000192
Mark Slee4ac459f2006-10-25 21:39:01 +0000193class TProtocolFactory:
194 def getIOProtocols(self, itrans, otrans):
195 pass