blob: 6a4838b4446f76a913dc03a8854572afb286a718 [file] [log] [blame]
David Reissea2cba82009-03-30 21:35:00 +00001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
Mark Slee9f0c6512007-02-28 23:58:26 +000019
Marc Slemkod42a2c22006-08-10 03:30:18 +000020#include "TBinaryProtocol.h"
21
David Reiss32e95f82008-06-11 01:18:36 +000022#include <limits>
Mark Slee4f261c52007-04-13 00:33:24 +000023
Mark Slee8d7e1f62006-06-07 06:48:56 +000024using std::string;
Mark Sleee8540632006-05-30 09:24:40 +000025
T Jake Lucianib5e62212009-01-31 22:36:20 +000026namespace apache { namespace thrift { namespace protocol {
Marc Slemko6f038a72006-08-03 18:58:09 +000027
Mark Slee82a6c0f2007-04-04 21:08:21 +000028uint32_t TBinaryProtocol::writeMessageBegin(const std::string& name,
29 const TMessageType messageType,
30 const int32_t seqid) {
Mark Slee808454e2007-06-20 21:51:57 +000031 if (strict_write_) {
32 int32_t version = (VERSION_1) | ((int32_t)messageType);
David Reissf79031e2007-07-06 21:43:48 +000033 uint32_t wsize = 0;
34 wsize += writeI32(version);
35 wsize += writeString(name);
36 wsize += writeI32(seqid);
37 return wsize;
Mark Slee808454e2007-06-20 21:51:57 +000038 } else {
David Reissf79031e2007-07-06 21:43:48 +000039 uint32_t wsize = 0;
40 wsize += writeString(name);
41 wsize += writeByte((int8_t)messageType);
42 wsize += writeI32(seqid);
43 return wsize;
Mark Slee808454e2007-06-20 21:51:57 +000044 }
Marc Slemko16698852006-08-04 03:16:10 +000045}
46
Mark Slee4af6ed72006-10-25 19:02:49 +000047uint32_t TBinaryProtocol::writeMessageEnd() {
Marc Slemko16698852006-08-04 03:16:10 +000048 return 0;
49}
50
David Reiss64120002008-04-29 23:12:24 +000051uint32_t TBinaryProtocol::writeStructBegin(const char* name) {
Mark Slee8d7e1f62006-06-07 06:48:56 +000052 return 0;
Mark Sleee8540632006-05-30 09:24:40 +000053}
54
Mark Slee4af6ed72006-10-25 19:02:49 +000055uint32_t TBinaryProtocol::writeStructEnd() {
Mark Slee8d7e1f62006-06-07 06:48:56 +000056 return 0;
Mark Sleee8540632006-05-30 09:24:40 +000057}
58
David Reiss64120002008-04-29 23:12:24 +000059uint32_t TBinaryProtocol::writeFieldBegin(const char* name,
Mark Slee8d7e1f62006-06-07 06:48:56 +000060 const TType fieldType,
Mark Slee4af6ed72006-10-25 19:02:49 +000061 const int16_t fieldId) {
David Reissf79031e2007-07-06 21:43:48 +000062 uint32_t wsize = 0;
63 wsize += writeByte((int8_t)fieldType);
64 wsize += writeI16(fieldId);
65 return wsize;
Mark Slee8d7e1f62006-06-07 06:48:56 +000066}
67
Mark Slee4af6ed72006-10-25 19:02:49 +000068uint32_t TBinaryProtocol::writeFieldEnd() {
Mark Slee8d7e1f62006-06-07 06:48:56 +000069 return 0;
70}
71
Mark Slee4af6ed72006-10-25 19:02:49 +000072uint32_t TBinaryProtocol::writeFieldStop() {
Mark Slee8d7e1f62006-06-07 06:48:56 +000073 return
Mark Slee4af6ed72006-10-25 19:02:49 +000074 writeByte((int8_t)T_STOP);
David Reiss0c90f6f2008-02-06 22:18:40 +000075}
76
Mark Slee4af6ed72006-10-25 19:02:49 +000077uint32_t TBinaryProtocol::writeMapBegin(const TType keyType,
Mark Slee8d7e1f62006-06-07 06:48:56 +000078 const TType valType,
Mark Slee4af6ed72006-10-25 19:02:49 +000079 const uint32_t size) {
David Reissf79031e2007-07-06 21:43:48 +000080 uint32_t wsize = 0;
81 wsize += writeByte((int8_t)keyType);
82 wsize += writeByte((int8_t)valType);
83 wsize += writeI32((int32_t)size);
84 return wsize;
Mark Slee8d7e1f62006-06-07 06:48:56 +000085}
86
Mark Slee4af6ed72006-10-25 19:02:49 +000087uint32_t TBinaryProtocol::writeMapEnd() {
Mark Slee8d7e1f62006-06-07 06:48:56 +000088 return 0;
89}
90
Mark Slee4af6ed72006-10-25 19:02:49 +000091uint32_t TBinaryProtocol::writeListBegin(const TType elemType,
92 const uint32_t size) {
David Reissf79031e2007-07-06 21:43:48 +000093 uint32_t wsize = 0;
94 wsize += writeByte((int8_t) elemType);
95 wsize += writeI32((int32_t)size);
96 return wsize;
Mark Slee8d7e1f62006-06-07 06:48:56 +000097}
98
Mark Slee4af6ed72006-10-25 19:02:49 +000099uint32_t TBinaryProtocol::writeListEnd() {
Mark Slee8d7e1f62006-06-07 06:48:56 +0000100 return 0;
101}
102
Mark Slee4af6ed72006-10-25 19:02:49 +0000103uint32_t TBinaryProtocol::writeSetBegin(const TType elemType,
104 const uint32_t size) {
David Reissf79031e2007-07-06 21:43:48 +0000105 uint32_t wsize = 0;
David Reissf79031e2007-07-06 21:43:48 +0000106 wsize += writeByte((int8_t)elemType);
107 wsize += writeI32((int32_t)size);
108 return wsize;
Mark Slee8d7e1f62006-06-07 06:48:56 +0000109}
110
Mark Slee4af6ed72006-10-25 19:02:49 +0000111uint32_t TBinaryProtocol::writeSetEnd() {
Mark Slee8d7e1f62006-06-07 06:48:56 +0000112 return 0;
113}
114
Mark Slee4af6ed72006-10-25 19:02:49 +0000115uint32_t TBinaryProtocol::writeBool(const bool value) {
Marc Slemko0b4ffa92006-08-11 02:49:29 +0000116 uint8_t tmp = value ? 1 : 0;
Aditya Agarwal9abb0d62007-01-24 22:53:54 +0000117 trans_->write(&tmp, 1);
Marc Slemko0b4ffa92006-08-11 02:49:29 +0000118 return 1;
119}
120
Mark Slee4af6ed72006-10-25 19:02:49 +0000121uint32_t TBinaryProtocol::writeByte(const int8_t byte) {
Aditya Agarwal9abb0d62007-01-24 22:53:54 +0000122 trans_->write((uint8_t*)&byte, 1);
Mark Slee8d7e1f62006-06-07 06:48:56 +0000123 return 1;
124}
125
Mark Slee4af6ed72006-10-25 19:02:49 +0000126uint32_t TBinaryProtocol::writeI16(const int16_t i16) {
Marc Slemko0b4ffa92006-08-11 02:49:29 +0000127 int16_t net = (int16_t)htons(i16);
Aditya Agarwal9abb0d62007-01-24 22:53:54 +0000128 trans_->write((uint8_t*)&net, 2);
Marc Slemko0b4ffa92006-08-11 02:49:29 +0000129 return 2;
Mark Slee8d7e1f62006-06-07 06:48:56 +0000130}
131
Mark Slee4af6ed72006-10-25 19:02:49 +0000132uint32_t TBinaryProtocol::writeI32(const int32_t i32) {
Marc Slemkoe6889de2006-08-12 00:32:53 +0000133 int32_t net = (int32_t)htonl(i32);
Aditya Agarwal9abb0d62007-01-24 22:53:54 +0000134 trans_->write((uint8_t*)&net, 4);
Marc Slemkoe6889de2006-08-12 00:32:53 +0000135 return 4;
136}
137
Mark Slee4af6ed72006-10-25 19:02:49 +0000138uint32_t TBinaryProtocol::writeI64(const int64_t i64) {
Mark Slee8d7e1f62006-06-07 06:48:56 +0000139 int64_t net = (int64_t)htonll(i64);
Aditya Agarwal9abb0d62007-01-24 22:53:54 +0000140 trans_->write((uint8_t*)&net, 8);
Mark Slee8d7e1f62006-06-07 06:48:56 +0000141 return 8;
142}
David Reiss0c90f6f2008-02-06 22:18:40 +0000143
Mark Slee4af6ed72006-10-25 19:02:49 +0000144uint32_t TBinaryProtocol::writeDouble(const double dub) {
Mark Slee4f261c52007-04-13 00:33:24 +0000145 BOOST_STATIC_ASSERT(sizeof(double) == sizeof(uint64_t));
146 BOOST_STATIC_ASSERT(std::numeric_limits<double>::is_iec559);
147
148 uint64_t bits = bitwise_cast<uint64_t>(dub);
149 bits = htonll(bits);
150 trans_->write((uint8_t*)&bits, 8);
Mark Sleec98d0502006-09-06 02:42:25 +0000151 return 8;
152}
Mark Slee8d7e1f62006-06-07 06:48:56 +0000153
David Reiss0c90f6f2008-02-06 22:18:40 +0000154
Mark Slee4af6ed72006-10-25 19:02:49 +0000155uint32_t TBinaryProtocol::writeString(const string& str) {
Mark Sleef9831082007-02-20 20:59:21 +0000156 uint32_t size = str.size();
157 uint32_t result = writeI32((int32_t)size);
158 if (size > 0) {
159 trans_->write((uint8_t*)str.data(), size);
160 }
161 return result + size;
Mark Slee8d7e1f62006-06-07 06:48:56 +0000162}
163
David Reissc005b1b2008-02-15 01:38:18 +0000164uint32_t TBinaryProtocol::writeBinary(const string& str) {
165 return TBinaryProtocol::writeString(str);
166}
167
Mark Slee8d7e1f62006-06-07 06:48:56 +0000168/**
169 * Reading functions
170 */
171
Mark Slee4af6ed72006-10-25 19:02:49 +0000172uint32_t TBinaryProtocol::readMessageBegin(std::string& name,
David Reiss96d23882007-07-26 21:10:32 +0000173 TMessageType& messageType,
174 int32_t& seqid) {
Marc Slemko16698852006-08-04 03:16:10 +0000175 uint32_t result = 0;
Mark Slee808454e2007-06-20 21:51:57 +0000176 int32_t sz;
177 result += readI32(sz);
178
179 if (sz < 0) {
180 // Check for correct version number
181 int32_t version = sz & VERSION_MASK;
182 if (version != VERSION_1) {
183 throw TProtocolException(TProtocolException::BAD_VERSION, "Bad version identifier");
184 }
185 messageType = (TMessageType)(sz & 0x000000ff);
186 result += readString(name);
187 result += readI32(seqid);
188 } else {
189 if (strict_read_) {
190 throw TProtocolException(TProtocolException::BAD_VERSION, "No version identifier... old protocol client in strict mode?");
191 } else {
192 // Handle pre-versioned input
193 int8_t type;
194 result += readStringBody(name, sz);
195 result += readByte(type);
196 messageType = (TMessageType)type;
197 result += readI32(seqid);
198 }
199 }
Marc Slemko16698852006-08-04 03:16:10 +0000200 return result;
201}
202
Mark Slee4af6ed72006-10-25 19:02:49 +0000203uint32_t TBinaryProtocol::readMessageEnd() {
Marc Slemko16698852006-08-04 03:16:10 +0000204 return 0;
205}
206
Mark Slee4af6ed72006-10-25 19:02:49 +0000207uint32_t TBinaryProtocol::readStructBegin(string& name) {
Mark Slee8d7e1f62006-06-07 06:48:56 +0000208 name = "";
209 return 0;
210}
211
Mark Slee4af6ed72006-10-25 19:02:49 +0000212uint32_t TBinaryProtocol::readStructEnd() {
Mark Slee8d7e1f62006-06-07 06:48:56 +0000213 return 0;
214}
215
Mark Slee4af6ed72006-10-25 19:02:49 +0000216uint32_t TBinaryProtocol::readFieldBegin(string& name,
Mark Slee8d7e1f62006-06-07 06:48:56 +0000217 TType& fieldType,
Mark Slee4af6ed72006-10-25 19:02:49 +0000218 int16_t& fieldId) {
Mark Slee8d7e1f62006-06-07 06:48:56 +0000219 uint32_t result = 0;
Mark Sleecfc01932006-09-01 22:18:16 +0000220 int8_t type;
Mark Slee4af6ed72006-10-25 19:02:49 +0000221 result += readByte(type);
Mark Slee8d7e1f62006-06-07 06:48:56 +0000222 fieldType = (TType)type;
223 if (fieldType == T_STOP) {
224 fieldId = 0;
225 return result;
226 }
Mark Slee4af6ed72006-10-25 19:02:49 +0000227 result += readI16(fieldId);
Mark Slee8d7e1f62006-06-07 06:48:56 +0000228 return result;
229}
David Reiss0c90f6f2008-02-06 22:18:40 +0000230
Mark Slee4af6ed72006-10-25 19:02:49 +0000231uint32_t TBinaryProtocol::readFieldEnd() {
Mark Slee8d7e1f62006-06-07 06:48:56 +0000232 return 0;
Mark Sleee8540632006-05-30 09:24:40 +0000233}
David Reiss0c90f6f2008-02-06 22:18:40 +0000234
Mark Slee4af6ed72006-10-25 19:02:49 +0000235uint32_t TBinaryProtocol::readMapBegin(TType& keyType,
Mark Slee8d7e1f62006-06-07 06:48:56 +0000236 TType& valType,
Mark Slee4af6ed72006-10-25 19:02:49 +0000237 uint32_t& size) {
Mark Sleecfc01932006-09-01 22:18:16 +0000238 int8_t k, v;
Mark Slee8d7e1f62006-06-07 06:48:56 +0000239 uint32_t result = 0;
Mark Sleecfc01932006-09-01 22:18:16 +0000240 int32_t sizei;
Mark Slee4af6ed72006-10-25 19:02:49 +0000241 result += readByte(k);
Mark Slee8d7e1f62006-06-07 06:48:56 +0000242 keyType = (TType)k;
Mark Slee4af6ed72006-10-25 19:02:49 +0000243 result += readByte(v);
Mark Slee8d7e1f62006-06-07 06:48:56 +0000244 valType = (TType)v;
Mark Slee4af6ed72006-10-25 19:02:49 +0000245 result += readI32(sizei);
Mark Sleef9831082007-02-20 20:59:21 +0000246 if (sizei < 0) {
247 throw TProtocolException(TProtocolException::NEGATIVE_SIZE);
248 } else if (container_limit_ && sizei > container_limit_) {
249 throw TProtocolException(TProtocolException::SIZE_LIMIT);
250 }
Mark Sleecfc01932006-09-01 22:18:16 +0000251 size = (uint32_t)sizei;
Mark Sleee8540632006-05-30 09:24:40 +0000252 return result;
253}
254
Mark Slee4af6ed72006-10-25 19:02:49 +0000255uint32_t TBinaryProtocol::readMapEnd() {
Mark Slee8d7e1f62006-06-07 06:48:56 +0000256 return 0;
257}
258
Mark Slee4af6ed72006-10-25 19:02:49 +0000259uint32_t TBinaryProtocol::readListBegin(TType& elemType,
260 uint32_t& size) {
Mark Sleecfc01932006-09-01 22:18:16 +0000261 int8_t e;
Mark Slee8d7e1f62006-06-07 06:48:56 +0000262 uint32_t result = 0;
Mark Sleecfc01932006-09-01 22:18:16 +0000263 int32_t sizei;
Mark Slee4af6ed72006-10-25 19:02:49 +0000264 result += readByte(e);
Mark Slee8d7e1f62006-06-07 06:48:56 +0000265 elemType = (TType)e;
Mark Slee4af6ed72006-10-25 19:02:49 +0000266 result += readI32(sizei);
Mark Sleef9831082007-02-20 20:59:21 +0000267 if (sizei < 0) {
268 throw TProtocolException(TProtocolException::NEGATIVE_SIZE);
269 } else if (container_limit_ && sizei > container_limit_) {
270 throw TProtocolException(TProtocolException::SIZE_LIMIT);
271 }
Mark Sleecfc01932006-09-01 22:18:16 +0000272 size = (uint32_t)sizei;
Mark Sleee8540632006-05-30 09:24:40 +0000273 return result;
274}
275
Mark Slee4af6ed72006-10-25 19:02:49 +0000276uint32_t TBinaryProtocol::readListEnd() {
Mark Slee8d7e1f62006-06-07 06:48:56 +0000277 return 0;
278}
279
Mark Slee4af6ed72006-10-25 19:02:49 +0000280uint32_t TBinaryProtocol::readSetBegin(TType& elemType,
281 uint32_t& size) {
Mark Sleecfc01932006-09-01 22:18:16 +0000282 int8_t e;
Mark Slee8d7e1f62006-06-07 06:48:56 +0000283 uint32_t result = 0;
Mark Sleecfc01932006-09-01 22:18:16 +0000284 int32_t sizei;
Mark Slee4af6ed72006-10-25 19:02:49 +0000285 result += readByte(e);
Mark Slee8d7e1f62006-06-07 06:48:56 +0000286 elemType = (TType)e;
Mark Slee4af6ed72006-10-25 19:02:49 +0000287 result += readI32(sizei);
Mark Sleef9831082007-02-20 20:59:21 +0000288 if (sizei < 0) {
289 throw TProtocolException(TProtocolException::NEGATIVE_SIZE);
290 } else if (container_limit_ && sizei > container_limit_) {
291 throw TProtocolException(TProtocolException::SIZE_LIMIT);
292 }
Mark Sleecfc01932006-09-01 22:18:16 +0000293 size = (uint32_t)sizei;
Mark Sleee8540632006-05-30 09:24:40 +0000294 return result;
295}
296
Mark Slee4af6ed72006-10-25 19:02:49 +0000297uint32_t TBinaryProtocol::readSetEnd() {
Mark Slee8d7e1f62006-06-07 06:48:56 +0000298 return 0;
Mark Sleee8540632006-05-30 09:24:40 +0000299}
300
Mark Slee4af6ed72006-10-25 19:02:49 +0000301uint32_t TBinaryProtocol::readBool(bool& value) {
Marc Slemko0b4ffa92006-08-11 02:49:29 +0000302 uint8_t b[1];
Aditya Agarwal9abb0d62007-01-24 22:53:54 +0000303 trans_->readAll(b, 1);
Mark Sleecfc01932006-09-01 22:18:16 +0000304 value = *(int8_t*)b != 0;
Marc Slemko0b4ffa92006-08-11 02:49:29 +0000305 return 1;
306}
307
Mark Slee4af6ed72006-10-25 19:02:49 +0000308uint32_t TBinaryProtocol::readByte(int8_t& byte) {
Mark Slee8d7e1f62006-06-07 06:48:56 +0000309 uint8_t b[1];
Aditya Agarwal9abb0d62007-01-24 22:53:54 +0000310 trans_->readAll(b, 1);
Mark Sleecfc01932006-09-01 22:18:16 +0000311 byte = *(int8_t*)b;
Mark Slee8d7e1f62006-06-07 06:48:56 +0000312 return 1;
Mark Sleee8540632006-05-30 09:24:40 +0000313}
314
Mark Slee4af6ed72006-10-25 19:02:49 +0000315uint32_t TBinaryProtocol::readI16(int16_t& i16) {
Marc Slemko0b4ffa92006-08-11 02:49:29 +0000316 uint8_t b[2];
Aditya Agarwal9abb0d62007-01-24 22:53:54 +0000317 trans_->readAll(b, 2);
Marc Slemko0b4ffa92006-08-11 02:49:29 +0000318 i16 = *(int16_t*)b;
319 i16 = (int16_t)ntohs(i16);
320 return 2;
321}
322
Mark Slee4af6ed72006-10-25 19:02:49 +0000323uint32_t TBinaryProtocol::readI32(int32_t& i32) {
Mark Slee8d7e1f62006-06-07 06:48:56 +0000324 uint8_t b[4];
Aditya Agarwal9abb0d62007-01-24 22:53:54 +0000325 trans_->readAll(b, 4);
Mark Slee8d7e1f62006-06-07 06:48:56 +0000326 i32 = *(int32_t*)b;
327 i32 = (int32_t)ntohl(i32);
328 return 4;
Mark Sleee8540632006-05-30 09:24:40 +0000329}
330
Mark Slee4af6ed72006-10-25 19:02:49 +0000331uint32_t TBinaryProtocol::readI64(int64_t& i64) {
Mark Slee8d7e1f62006-06-07 06:48:56 +0000332 uint8_t b[8];
Aditya Agarwal9abb0d62007-01-24 22:53:54 +0000333 trans_->readAll(b, 8);
Mark Slee8d7e1f62006-06-07 06:48:56 +0000334 i64 = *(int64_t*)b;
335 i64 = (int64_t)ntohll(i64);
336 return 8;
Mark Sleee8540632006-05-30 09:24:40 +0000337}
338
Mark Slee4af6ed72006-10-25 19:02:49 +0000339uint32_t TBinaryProtocol::readDouble(double& dub) {
Mark Slee4f261c52007-04-13 00:33:24 +0000340 BOOST_STATIC_ASSERT(sizeof(double) == sizeof(uint64_t));
341 BOOST_STATIC_ASSERT(std::numeric_limits<double>::is_iec559);
342
343 uint64_t bits;
Mark Sleec98d0502006-09-06 02:42:25 +0000344 uint8_t b[8];
Aditya Agarwal9abb0d62007-01-24 22:53:54 +0000345 trans_->readAll(b, 8);
Mark Slee4f261c52007-04-13 00:33:24 +0000346 bits = *(uint64_t*)b;
347 bits = ntohll(bits);
348 dub = bitwise_cast<double>(bits);
Mark Sleec98d0502006-09-06 02:42:25 +0000349 return 8;
350}
351
Mark Slee4af6ed72006-10-25 19:02:49 +0000352uint32_t TBinaryProtocol::readString(string& str) {
Mark Sleef3c322b2006-06-26 23:52:22 +0000353 uint32_t result;
Mark Sleecfc01932006-09-01 22:18:16 +0000354 int32_t size;
Mark Slee4af6ed72006-10-25 19:02:49 +0000355 result = readI32(size);
Mark Slee808454e2007-06-20 21:51:57 +0000356 return result + readStringBody(str, size);
357}
358
David Reissc005b1b2008-02-15 01:38:18 +0000359uint32_t TBinaryProtocol::readBinary(string& str) {
360 return TBinaryProtocol::readString(str);
361}
362
Mark Slee808454e2007-06-20 21:51:57 +0000363uint32_t TBinaryProtocol::readStringBody(string& str, int32_t size) {
364 uint32_t result = 0;
Mark Sleecfc01932006-09-01 22:18:16 +0000365
Mark Sleef9831082007-02-20 20:59:21 +0000366 // Catch error cases
367 if (size < 0) {
368 throw TProtocolException(TProtocolException::NEGATIVE_SIZE);
369 }
370 if (string_limit_ > 0 && size > string_limit_) {
371 throw TProtocolException(TProtocolException::SIZE_LIMIT);
372 }
373
374 // Catch empty string case
375 if (size == 0) {
376 str = "";
377 return result;
378 }
Mark Slee6e536442006-06-30 18:28:50 +0000379
380 // Use the heap here to prevent stack overflow for v. large strings
Mark Sleef9831082007-02-20 20:59:21 +0000381 if (size > string_buf_size_ || string_buf_ == NULL) {
David Reiss58b4fa72008-04-01 04:17:58 +0000382 void* new_string_buf = std::realloc(string_buf_, (uint32_t)size);
383 if (new_string_buf == NULL) {
Mark Sleef9831082007-02-20 20:59:21 +0000384 throw TProtocolException(TProtocolException::UNKNOWN, "Out of memory in TBinaryProtocol::readString");
385 }
David Reiss58b4fa72008-04-01 04:17:58 +0000386 string_buf_ = (uint8_t*)new_string_buf;
Mark Sleef9831082007-02-20 20:59:21 +0000387 string_buf_size_ = size;
388 }
389 trans_->readAll(string_buf_, size);
390 str = string((char*)string_buf_, size);
Mark Slee808454e2007-06-20 21:51:57 +0000391 return (uint32_t)size;
Mark Sleee8540632006-05-30 09:24:40 +0000392}
Mark Sleecfc01932006-09-01 22:18:16 +0000393
T Jake Lucianib5e62212009-01-31 22:36:20 +0000394}}} // apache::thrift::protocol