blob: 15206b0def1aca3f65247c973932fd7b78c36850 [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
Aditya Agarwal5c468192007-02-06 01:14:33 +000028 def __init__(self, trans):
29 self.trans = trans
Mark Slee4ac459f2006-10-25 21:39:01 +000030
31 def writeMessageBegin(self, name, type, seqid):
Mark Sleecde2b612006-09-03 21:13:07 +000032 pass
33
Mark Slee4ac459f2006-10-25 21:39:01 +000034 def writeMessageEnd(self):
Mark Sleecde2b612006-09-03 21:13:07 +000035 pass
36
Mark Slee4ac459f2006-10-25 21:39:01 +000037 def writeStructBegin(self, name):
Mark Sleecde2b612006-09-03 21:13:07 +000038 pass
39
Mark Slee4ac459f2006-10-25 21:39:01 +000040 def writeStructEnd(self):
Mark Sleecde2b612006-09-03 21:13:07 +000041 pass
42
Mark Slee4ac459f2006-10-25 21:39:01 +000043 def writeFieldBegin(self, name, type, id):
Mark Sleecde2b612006-09-03 21:13:07 +000044 pass
45
Mark Slee4ac459f2006-10-25 21:39:01 +000046 def writeFieldEnd(self):
Mark Sleecde2b612006-09-03 21:13:07 +000047 pass
48
Mark Slee4ac459f2006-10-25 21:39:01 +000049 def writeFieldStop(self):
Mark Sleecde2b612006-09-03 21:13:07 +000050 pass
51
Mark Slee4ac459f2006-10-25 21:39:01 +000052 def writeMapBegin(self, ktype, vtype, size):
Mark Sleecde2b612006-09-03 21:13:07 +000053 pass
54
Mark Slee4ac459f2006-10-25 21:39:01 +000055 def writeMapEnd(self):
Mark Sleecde2b612006-09-03 21:13:07 +000056 pass
57
Mark Slee4ac459f2006-10-25 21:39:01 +000058 def writeListBegin(self, etype, size):
Mark Sleecde2b612006-09-03 21:13:07 +000059 pass
60
Mark Slee4ac459f2006-10-25 21:39:01 +000061 def writeListEnd(self):
Mark Sleecde2b612006-09-03 21:13:07 +000062 pass
63
Mark Slee4ac459f2006-10-25 21:39:01 +000064 def writeSetBegin(self, etype, size):
Mark Sleecde2b612006-09-03 21:13:07 +000065 pass
66
Mark Slee4ac459f2006-10-25 21:39:01 +000067 def writeSetEnd(self):
Mark Sleecde2b612006-09-03 21:13:07 +000068 pass
69
Mark Slee4ac459f2006-10-25 21:39:01 +000070 def writeBool(self, bool):
Mark Sleecde2b612006-09-03 21:13:07 +000071 pass
72
Mark Slee4ac459f2006-10-25 21:39:01 +000073 def writeByte(self, byte):
Mark Sleecde2b612006-09-03 21:13:07 +000074 pass
75
Mark Slee4ac459f2006-10-25 21:39:01 +000076 def writeI16(self, i16):
Mark Sleecde2b612006-09-03 21:13:07 +000077 pass
78
Mark Slee4ac459f2006-10-25 21:39:01 +000079 def writeI32(self, i32):
Mark Sleecde2b612006-09-03 21:13:07 +000080 pass
81
Mark Slee4ac459f2006-10-25 21:39:01 +000082 def writeI64(self, i64):
Mark Sleecde2b612006-09-03 21:13:07 +000083 pass
84
Mark Slee4ac459f2006-10-25 21:39:01 +000085 def writeDouble(self, dub):
Mark Sleec98d0502006-09-06 02:42:25 +000086 pass
87
Mark Slee4ac459f2006-10-25 21:39:01 +000088 def writeString(self, str):
Mark Sleecde2b612006-09-03 21:13:07 +000089 pass
90
Mark Slee4ac459f2006-10-25 21:39:01 +000091 def readMessageBegin(self):
Mark Sleecde2b612006-09-03 21:13:07 +000092 pass
93
Mark Slee4ac459f2006-10-25 21:39:01 +000094 def readMessageEnd(self):
Mark Sleecde2b612006-09-03 21:13:07 +000095 pass
96
Mark Slee4ac459f2006-10-25 21:39:01 +000097 def readStructBegin(self):
Mark Sleecde2b612006-09-03 21:13:07 +000098 pass
99
Mark Slee4ac459f2006-10-25 21:39:01 +0000100 def readStructEnd(self):
Mark Sleecde2b612006-09-03 21:13:07 +0000101 pass
102
Mark Slee4ac459f2006-10-25 21:39:01 +0000103 def readFieldBegin(self):
Mark Sleecde2b612006-09-03 21:13:07 +0000104 pass
105
Mark Slee4ac459f2006-10-25 21:39:01 +0000106 def readFieldEnd(self):
Mark Sleecde2b612006-09-03 21:13:07 +0000107 pass
108
Mark Slee4ac459f2006-10-25 21:39:01 +0000109 def readMapBegin(self):
Mark Sleecde2b612006-09-03 21:13:07 +0000110 pass
111
Mark Slee4ac459f2006-10-25 21:39:01 +0000112 def readMapEnd(self):
Mark Sleecde2b612006-09-03 21:13:07 +0000113 pass
114
Mark Slee4ac459f2006-10-25 21:39:01 +0000115 def readListBegin(self):
Mark Sleecde2b612006-09-03 21:13:07 +0000116 pass
117
Mark Slee4ac459f2006-10-25 21:39:01 +0000118 def readListEnd(self):
Mark Sleecde2b612006-09-03 21:13:07 +0000119 pass
120
Mark Slee4ac459f2006-10-25 21:39:01 +0000121 def readSetBegin(self):
Mark Sleecde2b612006-09-03 21:13:07 +0000122 pass
123
Mark Slee4ac459f2006-10-25 21:39:01 +0000124 def readSetEnd(self):
Mark Sleecde2b612006-09-03 21:13:07 +0000125 pass
126
Mark Slee4ac459f2006-10-25 21:39:01 +0000127 def readBool(self):
Mark Sleecde2b612006-09-03 21:13:07 +0000128 pass
129
Mark Slee4ac459f2006-10-25 21:39:01 +0000130 def readByte(self):
Mark Sleecde2b612006-09-03 21:13:07 +0000131 pass
132
Mark Slee4ac459f2006-10-25 21:39:01 +0000133 def readI16(self):
Mark Sleecde2b612006-09-03 21:13:07 +0000134 pass
135
Mark Slee4ac459f2006-10-25 21:39:01 +0000136 def readI32(self):
Mark Sleecde2b612006-09-03 21:13:07 +0000137 pass
138
Mark Slee4ac459f2006-10-25 21:39:01 +0000139 def readI64(self):
Mark Sleecde2b612006-09-03 21:13:07 +0000140 pass
141
Mark Slee4ac459f2006-10-25 21:39:01 +0000142 def readDouble(self):
Mark Sleec98d0502006-09-06 02:42:25 +0000143 pass
144
Mark Slee4ac459f2006-10-25 21:39:01 +0000145 def readString(self):
Mark Sleecde2b612006-09-03 21:13:07 +0000146 pass
147
Mark Slee4ac459f2006-10-25 21:39:01 +0000148 def skip(self, type):
Mark Sleecde2b612006-09-03 21:13:07 +0000149 if type == TType.STOP:
150 return
151 elif type == TType.BOOL:
Mark Slee4ac459f2006-10-25 21:39:01 +0000152 self.readBool()
Mark Sleecde2b612006-09-03 21:13:07 +0000153 elif type == TType.BYTE:
Mark Slee4ac459f2006-10-25 21:39:01 +0000154 self.readByte()
Mark Sleecde2b612006-09-03 21:13:07 +0000155 elif type == TType.I16:
Mark Slee4ac459f2006-10-25 21:39:01 +0000156 self.readI16()
Mark Sleecde2b612006-09-03 21:13:07 +0000157 elif type == TType.I32:
Mark Slee4ac459f2006-10-25 21:39:01 +0000158 self.readI32()
Mark Sleecde2b612006-09-03 21:13:07 +0000159 elif type == TType.I64:
Mark Slee4ac459f2006-10-25 21:39:01 +0000160 self.readI64()
Mark Sleec98d0502006-09-06 02:42:25 +0000161 elif type == TType.DOUBLE:
Mark Slee4ac459f2006-10-25 21:39:01 +0000162 self.readDouble()
Mark Sleecde2b612006-09-03 21:13:07 +0000163 elif type == TType.STRING:
Mark Slee4ac459f2006-10-25 21:39:01 +0000164 self.readString()
Mark Sleecde2b612006-09-03 21:13:07 +0000165 elif type == TType.STRUCT:
Mark Slee4ac459f2006-10-25 21:39:01 +0000166 name = self.readStructBegin()
Mark Sleecde2b612006-09-03 21:13:07 +0000167 while True:
Mark Slee4ac459f2006-10-25 21:39:01 +0000168 (name, type, id) = self.readFieldBegin()
Mark Sleecde2b612006-09-03 21:13:07 +0000169 if type == TType.STOP:
170 break
Mark Slee4ac459f2006-10-25 21:39:01 +0000171 self.skip(type)
172 self.readFieldEnd()
173 self.readStructEnd()
Mark Sleecde2b612006-09-03 21:13:07 +0000174 elif type == TType.MAP:
Mark Slee4ac459f2006-10-25 21:39:01 +0000175 (ktype, vtype, size) = self.readMapBegin()
Mark Sleecde2b612006-09-03 21:13:07 +0000176 for i in range(size):
Mark Slee4ac459f2006-10-25 21:39:01 +0000177 self.skip(ktype)
178 self.skip(vtype)
179 self.readMapEnd()
Mark Sleecde2b612006-09-03 21:13:07 +0000180 elif type == TType.SET:
Mark Slee4ac459f2006-10-25 21:39:01 +0000181 (etype, size) = self.readSetBegin()
Mark Sleecde2b612006-09-03 21:13:07 +0000182 for i in range(size):
Mark Slee4ac459f2006-10-25 21:39:01 +0000183 self.skip(etype)
184 self.readSetEnd()
Mark Sleecde2b612006-09-03 21:13:07 +0000185 elif type == TType.LIST:
Mark Slee4ac459f2006-10-25 21:39:01 +0000186 (etype, size) = self.readListBegin()
Mark Sleecde2b612006-09-03 21:13:07 +0000187 for i in range(size):
Mark Slee4ac459f2006-10-25 21:39:01 +0000188 self.skip(etype)
189 self.readListEnd()
Mark Sleecde2b612006-09-03 21:13:07 +0000190
Mark Slee4ac459f2006-10-25 21:39:01 +0000191class TProtocolFactory:
Aditya Agarwal5c468192007-02-06 01:14:33 +0000192 def getProtocol(self, trans):
Mark Slee4ac459f2006-10-25 21:39:01 +0000193 pass