blob: 31bbbf9d0ca1f66f9b9980a8da9dafc2a6ed64cb [file] [log] [blame]
Mark Slee4902c052007-03-01 00:31:30 +00001<?php
David Reissea2cba82009-03-30 21:35:00 +00002/*
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
Mark Slee4902c052007-03-01 00:31:30 +000010 *
David Reissea2cba82009-03-30 21:35:00 +000011 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
Mark Slee4902c052007-03-01 00:31:30 +000019 *
20 * @package thrift.protocol
Mark Slee4902c052007-03-01 00:31:30 +000021 */
Mark Slee6e536442006-06-30 18:28:50 +000022
David Reissea2cba82009-03-30 21:35:00 +000023include_once $GLOBALS['THRIFT_ROOT'].'/transport/TBufferedTransport.php';
24
Mark Slee6e536442006-06-30 18:28:50 +000025/**
26 * Binary implementation of the Thrift protocol.
27 *
Mark Slee6e536442006-06-30 18:28:50 +000028 */
29class TBinaryProtocol extends TProtocol {
30
Mark Slee808454e2007-06-20 21:51:57 +000031 const VERSION_MASK = 0xffff0000;
32 const VERSION_1 = 0x80010000;
33
dweatherfordcf997a42008-03-04 01:08:23 +000034 protected $strictRead_ = false;
35 protected $strictWrite_ = true;
Mark Slee808454e2007-06-20 21:51:57 +000036
37 public function __construct($trans, $strictRead=false, $strictWrite=true) {
Aditya Agarwal6a5bcaa2007-02-06 02:50:56 +000038 parent::__construct($trans);
Mark Slee808454e2007-06-20 21:51:57 +000039 $this->strictRead_ = $strictRead;
40 $this->strictWrite_ = $strictWrite;
Mark Slee5f8237d2006-10-26 04:57:03 +000041 }
42
43 public function writeMessageBegin($name, $type, $seqid) {
Mark Slee808454e2007-06-20 21:51:57 +000044 if ($this->strictWrite_) {
45 $version = self::VERSION_1 | $type;
46 return
47 $this->writeI32($version) +
48 $this->writeString($name) +
49 $this->writeI32($seqid);
50 } else {
Mark Slee276eea62007-11-20 02:06:47 +000051 return
Mark Slee808454e2007-06-20 21:51:57 +000052 $this->writeString($name) +
53 $this->writeByte($type) +
54 $this->writeI32($seqid);
55 }
Marc Slemkod97eb612006-08-24 23:37:36 +000056 }
57
Mark Slee5f8237d2006-10-26 04:57:03 +000058 public function writeMessageEnd() {
Marc Slemkod97eb612006-08-24 23:37:36 +000059 return 0;
60 }
61
Mark Slee5f8237d2006-10-26 04:57:03 +000062 public function writeStructBegin($name) {
Mark Slee6e536442006-06-30 18:28:50 +000063 return 0;
64 }
65
Mark Slee5f8237d2006-10-26 04:57:03 +000066 public function writeStructEnd() {
Mark Slee6e536442006-06-30 18:28:50 +000067 return 0;
68 }
69
Mark Slee5f8237d2006-10-26 04:57:03 +000070 public function writeFieldBegin($fieldName, $fieldType, $fieldId) {
Mark Slee6e536442006-06-30 18:28:50 +000071 return
Mark Slee5f8237d2006-10-26 04:57:03 +000072 $this->writeByte($fieldType) +
73 $this->writeI16($fieldId);
Mark Slee6e536442006-06-30 18:28:50 +000074 }
75
Mark Slee5f8237d2006-10-26 04:57:03 +000076 public function writeFieldEnd() {
Mark Slee6e536442006-06-30 18:28:50 +000077 return 0;
Mark Slee808454e2007-06-20 21:51:57 +000078 }
Mark Slee6e536442006-06-30 18:28:50 +000079
Mark Slee5f8237d2006-10-26 04:57:03 +000080 public function writeFieldStop() {
Mark Slee6e536442006-06-30 18:28:50 +000081 return
Mark Slee5f8237d2006-10-26 04:57:03 +000082 $this->writeByte(TType::STOP);
Mark Slee6e536442006-06-30 18:28:50 +000083 }
84
Mark Slee5f8237d2006-10-26 04:57:03 +000085 public function writeMapBegin($keyType, $valType, $size) {
Mark Slee6e536442006-06-30 18:28:50 +000086 return
Mark Slee5f8237d2006-10-26 04:57:03 +000087 $this->writeByte($keyType) +
88 $this->writeByte($valType) +
89 $this->writeI32($size);
Mark Slee6e536442006-06-30 18:28:50 +000090 }
91
Mark Slee5f8237d2006-10-26 04:57:03 +000092 public function writeMapEnd() {
Mark Slee6e536442006-06-30 18:28:50 +000093 return 0;
94 }
95
Mark Slee5f8237d2006-10-26 04:57:03 +000096 public function writeListBegin($elemType, $size) {
Mark Slee6e536442006-06-30 18:28:50 +000097 return
Mark Slee5f8237d2006-10-26 04:57:03 +000098 $this->writeByte($elemType) +
99 $this->writeI32($size);
Mark Slee6e536442006-06-30 18:28:50 +0000100 }
101
Mark Slee5f8237d2006-10-26 04:57:03 +0000102 public function writeListEnd() {
Mark Slee6e536442006-06-30 18:28:50 +0000103 return 0;
104 }
105
Mark Slee5f8237d2006-10-26 04:57:03 +0000106 public function writeSetBegin($elemType, $size) {
Mark Slee6e536442006-06-30 18:28:50 +0000107 return
Mark Slee5f8237d2006-10-26 04:57:03 +0000108 $this->writeByte($elemType) +
109 $this->writeI32($size);
Mark Slee6e536442006-06-30 18:28:50 +0000110 }
111
Mark Slee5f8237d2006-10-26 04:57:03 +0000112 public function writeSetEnd() {
Mark Slee6e536442006-06-30 18:28:50 +0000113 return 0;
114 }
115
Mark Slee5f8237d2006-10-26 04:57:03 +0000116 public function writeBool($value) {
Marc Slemkod97eb612006-08-24 23:37:36 +0000117 $data = pack('c', $value ? 1 : 0);
Aditya Agarwal6a5bcaa2007-02-06 02:50:56 +0000118 $this->trans_->write($data, 1);
Mark Slee6e536442006-06-30 18:28:50 +0000119 return 1;
120 }
121
Mark Slee5f8237d2006-10-26 04:57:03 +0000122 public function writeByte($value) {
Marc Slemkod97eb612006-08-24 23:37:36 +0000123 $data = pack('c', $value);
Aditya Agarwal6a5bcaa2007-02-06 02:50:56 +0000124 $this->trans_->write($data, 1);
Marc Slemkod97eb612006-08-24 23:37:36 +0000125 return 1;
126 }
127
Mark Slee5f8237d2006-10-26 04:57:03 +0000128 public function writeI16($value) {
Marc Slemkod97eb612006-08-24 23:37:36 +0000129 $data = pack('n', $value);
Aditya Agarwal6a5bcaa2007-02-06 02:50:56 +0000130 $this->trans_->write($data, 2);
Marc Slemkod97eb612006-08-24 23:37:36 +0000131 return 2;
132 }
133
Mark Slee5f8237d2006-10-26 04:57:03 +0000134 public function writeI32($value) {
Marc Slemkod97eb612006-08-24 23:37:36 +0000135 $data = pack('N', $value);
Aditya Agarwal6a5bcaa2007-02-06 02:50:56 +0000136 $this->trans_->write($data, 4);
Mark Slee6e536442006-06-30 18:28:50 +0000137 return 4;
138 }
139
Mark Slee5f8237d2006-10-26 04:57:03 +0000140 public function writeI64($value) {
Mark Sleecfc01932006-09-01 22:18:16 +0000141 // If we are on a 32bit architecture we have to explicitly deal with
142 // 64-bit twos-complement arithmetic since PHP wants to treat all ints
Mark Slee808454e2007-06-20 21:51:57 +0000143 // as signed and any int over 2^31 - 1 as a float
Mark Sleecfc01932006-09-01 22:18:16 +0000144 if (PHP_INT_SIZE == 4) {
Marc Slemkod97eb612006-08-24 23:37:36 +0000145 $neg = $value < 0;
Mark Sleecfc01932006-09-01 22:18:16 +0000146
147 if ($neg) {
Mark Slee808454e2007-06-20 21:51:57 +0000148 $value *= -1;
Marc Slemkod97eb612006-08-24 23:37:36 +0000149 }
Mark Slee808454e2007-06-20 21:51:57 +0000150
Marc Slemkod97eb612006-08-24 23:37:36 +0000151 $hi = (int)($value / 4294967296);
152 $lo = (int)$value;
Mark Slee808454e2007-06-20 21:51:57 +0000153
Mark Sleecfc01932006-09-01 22:18:16 +0000154 if ($neg) {
Mark Slee808454e2007-06-20 21:51:57 +0000155 $hi = ~$hi;
156 $lo = ~$lo;
157 if (($lo & (int)0xffffffff) == (int)0xffffffff) {
158 $lo = 0;
159 $hi++;
160 } else {
161 $lo++;
162 }
Marc Slemkod97eb612006-08-24 23:37:36 +0000163 }
Mark Slee6e536442006-06-30 18:28:50 +0000164 $data = pack('N2', $hi, $lo);
Mark Slee808454e2007-06-20 21:51:57 +0000165
Mark Slee6e536442006-06-30 18:28:50 +0000166 } else {
Marc Slemkod97eb612006-08-24 23:37:36 +0000167 $hi = $value >> 32;
168 $lo = $value & 0xFFFFFFFF;
169 $data = pack('N2', $hi, $lo);
Mark Slee6e536442006-06-30 18:28:50 +0000170 }
Marc Slemkod97eb612006-08-24 23:37:36 +0000171
Aditya Agarwal6a5bcaa2007-02-06 02:50:56 +0000172 $this->trans_->write($data, 8);
Mark Slee6e536442006-06-30 18:28:50 +0000173 return 8;
174 }
175
Mark Slee5f8237d2006-10-26 04:57:03 +0000176 public function writeDouble($value) {
Mark Sleec98d0502006-09-06 02:42:25 +0000177 $data = pack('d', $value);
Aditya Agarwal6a5bcaa2007-02-06 02:50:56 +0000178 $this->trans_->write(strrev($data), 8);
Mark Sleec98d0502006-09-06 02:42:25 +0000179 return 8;
180 }
181
Mark Slee5f8237d2006-10-26 04:57:03 +0000182 public function writeString($value) {
Marc Slemkod97eb612006-08-24 23:37:36 +0000183 $len = strlen($value);
Mark Slee5f8237d2006-10-26 04:57:03 +0000184 $result = $this->writeI32($len);
Mark Sleeade2c832006-09-08 03:41:50 +0000185 if ($len) {
Aditya Agarwal6a5bcaa2007-02-06 02:50:56 +0000186 $this->trans_->write($value, $len);
Mark Sleeade2c832006-09-08 03:41:50 +0000187 }
Mark Slee6e536442006-06-30 18:28:50 +0000188 return $result + $len;
189 }
190
Mark Slee5f8237d2006-10-26 04:57:03 +0000191 public function readMessageBegin(&$name, &$type, &$seqid) {
Mark Slee808454e2007-06-20 21:51:57 +0000192 $result = $this->readI32($sz);
193 if ($sz < 0) {
Mark Slee276eea62007-11-20 02:06:47 +0000194 $version = (int) ($sz & self::VERSION_MASK);
195 if ($version != (int) self::VERSION_1) {
Mark Slee808454e2007-06-20 21:51:57 +0000196 throw new TProtocolException('Bad version identifier: '.$sz, TProtocolException::BAD_VERSION);
197 }
198 $type = $sz & 0x000000ff;
199 $result +=
200 $this->readString($name) +
201 $this->readI32($seqid);
202 } else {
203 if ($this->strictRead_) {
204 throw new TProtocolException('No version identifier, old protocol client?', TProtocolException::BAD_VERSION);
205 } else {
206 // Handle pre-versioned input
207 $name = $this->trans_->readAll($sz);
Mark Slee276eea62007-11-20 02:06:47 +0000208 $result +=
Mark Slee808454e2007-06-20 21:51:57 +0000209 $sz +
210 $this->readByte($type) +
211 $this->readI32($seqid);
212 }
213 }
214 return $result;
Marc Slemkod97eb612006-08-24 23:37:36 +0000215 }
216
Mark Slee5f8237d2006-10-26 04:57:03 +0000217 public function readMessageEnd() {
Marc Slemkod97eb612006-08-24 23:37:36 +0000218 return 0;
219 }
220
Mark Slee5f8237d2006-10-26 04:57:03 +0000221 public function readStructBegin(&$name) {
Mark Slee6e536442006-06-30 18:28:50 +0000222 $name = '';
223 return 0;
224 }
225
Mark Slee5f8237d2006-10-26 04:57:03 +0000226 public function readStructEnd() {
Mark Slee6e536442006-06-30 18:28:50 +0000227 return 0;
228 }
229
Mark Slee5f8237d2006-10-26 04:57:03 +0000230 public function readFieldBegin(&$name, &$fieldType, &$fieldId) {
231 $result = $this->readByte($fieldType);
Mark Slee6e536442006-06-30 18:28:50 +0000232 if ($fieldType == TType::STOP) {
233 $fieldId = 0;
234 return $result;
235 }
Mark Slee5f8237d2006-10-26 04:57:03 +0000236 $result += $this->readI16($fieldId);
Mark Slee6e536442006-06-30 18:28:50 +0000237 return $result;
238 }
239
Mark Slee5f8237d2006-10-26 04:57:03 +0000240 public function readFieldEnd() {
Mark Slee6e536442006-06-30 18:28:50 +0000241 return 0;
242 }
243
Mark Slee5f8237d2006-10-26 04:57:03 +0000244 public function readMapBegin(&$keyType, &$valType, &$size) {
Mark Sleecfc01932006-09-01 22:18:16 +0000245 return
Mark Slee5f8237d2006-10-26 04:57:03 +0000246 $this->readByte($keyType) +
247 $this->readByte($valType) +
248 $this->readI32($size);
Mark Slee6e536442006-06-30 18:28:50 +0000249 }
250
Mark Slee5f8237d2006-10-26 04:57:03 +0000251 public function readMapEnd() {
Mark Slee6e536442006-06-30 18:28:50 +0000252 return 0;
253 }
254
Mark Slee5f8237d2006-10-26 04:57:03 +0000255 public function readListBegin(&$elemType, &$size) {
Mark Sleecfc01932006-09-01 22:18:16 +0000256 return
Mark Slee5f8237d2006-10-26 04:57:03 +0000257 $this->readByte($elemType) +
258 $this->readI32($size);
Mark Slee6e536442006-06-30 18:28:50 +0000259 }
260
Mark Slee5f8237d2006-10-26 04:57:03 +0000261 public function readListEnd() {
Mark Slee6e536442006-06-30 18:28:50 +0000262 return 0;
263 }
264
Mark Slee5f8237d2006-10-26 04:57:03 +0000265 public function readSetBegin(&$elemType, &$size) {
Mark Sleecfc01932006-09-01 22:18:16 +0000266 return
Mark Slee5f8237d2006-10-26 04:57:03 +0000267 $this->readByte($elemType) +
268 $this->readI32($size);
Mark Slee6e536442006-06-30 18:28:50 +0000269 }
270
Mark Slee5f8237d2006-10-26 04:57:03 +0000271 public function readSetEnd() {
Mark Slee6e536442006-06-30 18:28:50 +0000272 return 0;
273 }
274
Mark Slee5f8237d2006-10-26 04:57:03 +0000275 public function readBool(&$value) {
Aditya Agarwal6a5bcaa2007-02-06 02:50:56 +0000276 $data = $this->trans_->readAll(1);
Mark Slee6e536442006-06-30 18:28:50 +0000277 $arr = unpack('c', $data);
Marc Slemkod97eb612006-08-24 23:37:36 +0000278 $value = $arr[1] == 1;
Mark Slee6e536442006-06-30 18:28:50 +0000279 return 1;
280 }
281
Mark Slee5f8237d2006-10-26 04:57:03 +0000282 public function readByte(&$value) {
Aditya Agarwal6a5bcaa2007-02-06 02:50:56 +0000283 $data = $this->trans_->readAll(1);
Marc Slemkod97eb612006-08-24 23:37:36 +0000284 $arr = unpack('c', $data);
285 $value = $arr[1];
286 return 1;
287 }
288
Mark Slee5f8237d2006-10-26 04:57:03 +0000289 public function readI16(&$value) {
Aditya Agarwal6a5bcaa2007-02-06 02:50:56 +0000290 $data = $this->trans_->readAll(2);
Marc Slemkod97eb612006-08-24 23:37:36 +0000291 $arr = unpack('n', $data);
292 $value = $arr[1];
Mark Sleecfc01932006-09-01 22:18:16 +0000293 if ($value > 0x7fff) {
294 $value = 0 - (($value - 1) ^ 0xffff);
Mark Slee6e536442006-06-30 18:28:50 +0000295 }
Marc Slemkod97eb612006-08-24 23:37:36 +0000296 return 2;
297 }
298
Mark Slee5f8237d2006-10-26 04:57:03 +0000299 public function readI32(&$value) {
Aditya Agarwal6a5bcaa2007-02-06 02:50:56 +0000300 $data = $this->trans_->readAll(4);
Marc Slemkod97eb612006-08-24 23:37:36 +0000301 $arr = unpack('N', $data);
302 $value = $arr[1];
Mark Sleecfc01932006-09-01 22:18:16 +0000303 if ($value > 0x7fffffff) {
Marc Slemkod97eb612006-08-24 23:37:36 +0000304 $value = 0 - (($value - 1) ^ 0xffffffff);
305 }
Mark Slee6e536442006-06-30 18:28:50 +0000306 return 4;
307 }
308
Mark Slee5f8237d2006-10-26 04:57:03 +0000309 public function readI64(&$value) {
Aditya Agarwal6a5bcaa2007-02-06 02:50:56 +0000310 $data = $this->trans_->readAll(8);
Marc Slemkod97eb612006-08-24 23:37:36 +0000311
312 $arr = unpack('N2', $data);
Mark Slee808454e2007-06-20 21:51:57 +0000313
Mark Sleecfc01932006-09-01 22:18:16 +0000314 // If we are on a 32bit architecture we have to explicitly deal with
315 // 64-bit twos-complement arithmetic since PHP wants to treat all ints
316 // as signed and any int over 2^31 - 1 as a float
317 if (PHP_INT_SIZE == 4) {
Marc Slemkod97eb612006-08-24 23:37:36 +0000318
319 $hi = $arr[1];
320 $lo = $arr[2];
321 $isNeg = $hi < 0;
Mark Slee276eea62007-11-20 02:06:47 +0000322
Marc Slemkod97eb612006-08-24 23:37:36 +0000323 // Check for a negative
Mark Sleecfc01932006-09-01 22:18:16 +0000324 if ($isNeg) {
David Reiss0c90f6f2008-02-06 22:18:40 +0000325 $hi = ~$hi & (int)0xffffffff;
326 $lo = ~$lo & (int)0xffffffff;
Marc Slemkod97eb612006-08-24 23:37:36 +0000327
David Reiss0c90f6f2008-02-06 22:18:40 +0000328 if ($lo == (int)0xffffffff) {
329 $hi++;
330 $lo = 0;
331 } else {
332 $lo++;
333 }
Marc Slemkod97eb612006-08-24 23:37:36 +0000334 }
335
Mark Sleecfc01932006-09-01 22:18:16 +0000336 // Force 32bit words in excess of 2G to pe positive - we deal wigh sign
337 // explicitly below
Mark Slee276eea62007-11-20 02:06:47 +0000338
Mark Sleecfc01932006-09-01 22:18:16 +0000339 if ($hi & (int)0x80000000) {
David Reiss0c90f6f2008-02-06 22:18:40 +0000340 $hi &= (int)0x7fffffff;
341 $hi += 0x80000000;
Marc Slemkod97eb612006-08-24 23:37:36 +0000342 }
Mark Slee276eea62007-11-20 02:06:47 +0000343
Mark Sleecfc01932006-09-01 22:18:16 +0000344 if ($lo & (int)0x80000000) {
David Reiss0c90f6f2008-02-06 22:18:40 +0000345 $lo &= (int)0x7fffffff;
346 $lo += 0x80000000;
Marc Slemkod97eb612006-08-24 23:37:36 +0000347 }
Mark Slee276eea62007-11-20 02:06:47 +0000348
Marc Slemkod97eb612006-08-24 23:37:36 +0000349 $value = $hi * 4294967296 + $lo;
350
Mark Sleecfc01932006-09-01 22:18:16 +0000351 if ($isNeg) {
David Reiss0c90f6f2008-02-06 22:18:40 +0000352 $value = 0 - $value;
Marc Slemkod97eb612006-08-24 23:37:36 +0000353 }
354 } else {
355
Mark Slee13a0d4a2007-04-03 03:16:11 +0000356 // Upcast negatives in LSB bit
357 if ($arr[2] & 0x80000000) {
358 $arr[2] = $arr[2] & 0xffffffff;
359 }
360
Marc Slemkod97eb612006-08-24 23:37:36 +0000361 // Check for a negative
362 if ($arr[1] & 0x80000000) {
Mark Slee13a0d4a2007-04-03 03:16:11 +0000363 $arr[1] = $arr[1] & 0xffffffff;
364 $arr[1] = $arr[1] ^ 0xffffffff;
365 $arr[2] = $arr[2] ^ 0xffffffff;
366 $value = 0 - $arr[1]*4294967296 - $arr[2] - 1;
Marc Slemkod97eb612006-08-24 23:37:36 +0000367 } else {
Mark Slee13a0d4a2007-04-03 03:16:11 +0000368 $value = $arr[1]*4294967296 + $arr[2];
Marc Slemkod97eb612006-08-24 23:37:36 +0000369 }
370 }
Mark Slee276eea62007-11-20 02:06:47 +0000371
Marc Slemkod97eb612006-08-24 23:37:36 +0000372 return 8;
373 }
374
Mark Slee5f8237d2006-10-26 04:57:03 +0000375 public function readDouble(&$value) {
Aditya Agarwal6a5bcaa2007-02-06 02:50:56 +0000376 $data = strrev($this->trans_->readAll(8));
Mark Sleec98d0502006-09-06 02:42:25 +0000377 $arr = unpack('d', $data);
378 $value = $arr[1];
379 return 8;
380 }
381
Mark Slee5f8237d2006-10-26 04:57:03 +0000382 public function readString(&$value) {
383 $result = $this->readI32($len);
Mark Sleeade2c832006-09-08 03:41:50 +0000384 if ($len) {
Aditya Agarwal6a5bcaa2007-02-06 02:50:56 +0000385 $value = $this->trans_->readAll($len);
Mark Sleeade2c832006-09-08 03:41:50 +0000386 } else {
387 $value = '';
388 }
Mark Slee6e536442006-06-30 18:28:50 +0000389 return $result + $len;
390 }
391}
392
Mark Slee5f8237d2006-10-26 04:57:03 +0000393/**
394 * Binary Protocol Factory
395 */
396class TBinaryProtocolFactory implements TProtocolFactory {
Mark Slee808454e2007-06-20 21:51:57 +0000397 private $strictRead_ = false;
398 private $strictWrite_ = false;
399
400 public function __construct($strictRead=false, $strictWrite=false) {
401 $this->strictRead_ = $strictRead;
402 $this->strictWrite_ = $strictWrite;
Mark Slee276eea62007-11-20 02:06:47 +0000403 }
Mark Slee808454e2007-06-20 21:51:57 +0000404
Aditya Agarwal6a5bcaa2007-02-06 02:50:56 +0000405 public function getProtocol($trans) {
Mark Slee808454e2007-06-20 21:51:57 +0000406 return new TBinaryProtocol($trans, $this->strictRead, $this->strictWrite);
Mark Slee5f8237d2006-10-26 04:57:03 +0000407 }
408}
409
dweatherford80940b72007-10-31 23:30:56 +0000410/**
411 * Accelerated binary protocol: used in conjunction with the thrift_protocol
412 * extension for faster deserialization
413 */
414class TBinaryProtocolAccelerated extends TBinaryProtocol {
415 public function __construct($trans, $strictRead=false, $strictWrite=true) {
416 // If the transport doesn't implement putBack, wrap it in a
417 // TBufferedTransport (which does)
418 if (!method_exists($trans, 'putBack')) {
419 $trans = new TBufferedTransport($trans);
Mark Slee276eea62007-11-20 02:06:47 +0000420 }
dweatherford80940b72007-10-31 23:30:56 +0000421 parent::__construct($trans, $strictRead, $strictWrite);
422 }
dweatherfordcf997a42008-03-04 01:08:23 +0000423 public function isStrictRead() {
424 return $this->strictRead_;
425 }
426 public function isStrictWrite() {
427 return $this->strictWrite_;
428 }
dweatherford80940b72007-10-31 23:30:56 +0000429}
430
Marc Slemkod97eb612006-08-24 23:37:36 +0000431?>