David Reiss | ea2cba8 | 2009-03-30 21:35:00 +0000 | [diff] [blame] | 1 | /* |
| 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 Slee | 9f0c651 | 2007-02-28 23:58:26 +0000 | [diff] [blame] | 19 | |
Mark Slee | f5f2be4 | 2006-09-05 21:05:31 +0000 | [diff] [blame] | 20 | #ifndef _THRIFT_PROTOCOL_TBINARYPROTOCOL_H_ |
| 21 | #define _THRIFT_PROTOCOL_TBINARYPROTOCOL_H_ 1 |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 22 | |
Marc Slemko | d42a2c2 | 2006-08-10 03:30:18 +0000 | [diff] [blame] | 23 | #include "TProtocol.h" |
David Reiss | 6806fb8 | 2010-10-06 17:09:52 +0000 | [diff] [blame] | 24 | #include "TVirtualProtocol.h" |
Marc Slemko | 1669885 | 2006-08-04 03:16:10 +0000 | [diff] [blame] | 25 | |
| 26 | #include <boost/shared_ptr.hpp> |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 27 | |
T Jake Luciani | b5e6221 | 2009-01-31 22:36:20 +0000 | [diff] [blame] | 28 | namespace apache { namespace thrift { namespace protocol { |
Marc Slemko | 6f038a7 | 2006-08-03 18:58:09 +0000 | [diff] [blame] | 29 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 30 | /** |
| 31 | * The default binary protocol for thrift. Writes all data in a very basic |
| 32 | * binary format, essentially just spitting out the raw bytes. |
| 33 | * |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 34 | */ |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 35 | template <class Transport_> |
| 36 | class TBinaryProtocolT |
| 37 | : public TVirtualProtocol< TBinaryProtocolT<Transport_> > { |
Mark Slee | 808454e | 2007-06-20 21:51:57 +0000 | [diff] [blame] | 38 | protected: |
| 39 | static const int32_t VERSION_MASK = 0xffff0000; |
| 40 | static const int32_t VERSION_1 = 0x80010000; |
David Reiss | 4e7530d | 2007-09-04 21:49:53 +0000 | [diff] [blame] | 41 | // VERSION_2 (0x80020000) is taken by TDenseProtocol. |
Mark Slee | 808454e | 2007-06-20 21:51:57 +0000 | [diff] [blame] | 42 | |
Marc Slemko | 0b4ffa9 | 2006-08-11 02:49:29 +0000 | [diff] [blame] | 43 | public: |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 44 | TBinaryProtocolT(boost::shared_ptr<Transport_> trans) : |
| 45 | TVirtualProtocol< TBinaryProtocolT<Transport_> >(trans), |
| 46 | trans_(trans.get()), |
Mark Slee | f983108 | 2007-02-20 20:59:21 +0000 | [diff] [blame] | 47 | string_limit_(0), |
| 48 | container_limit_(0), |
Mark Slee | 808454e | 2007-06-20 21:51:57 +0000 | [diff] [blame] | 49 | strict_read_(false), |
| 50 | strict_write_(true), |
Mark Slee | f983108 | 2007-02-20 20:59:21 +0000 | [diff] [blame] | 51 | string_buf_(NULL), |
| 52 | string_buf_size_(0) {} |
Mark Slee | 4af6ed7 | 2006-10-25 19:02:49 +0000 | [diff] [blame] | 53 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 54 | TBinaryProtocolT(boost::shared_ptr<Transport_> trans, |
| 55 | int32_t string_limit, |
| 56 | int32_t container_limit, |
| 57 | bool strict_read, |
| 58 | bool strict_write) : |
| 59 | TVirtualProtocol< TBinaryProtocolT<Transport_> >(trans), |
| 60 | trans_(trans.get()), |
Mark Slee | f983108 | 2007-02-20 20:59:21 +0000 | [diff] [blame] | 61 | string_limit_(string_limit), |
| 62 | container_limit_(container_limit), |
Mark Slee | 808454e | 2007-06-20 21:51:57 +0000 | [diff] [blame] | 63 | strict_read_(strict_read), |
| 64 | strict_write_(strict_write), |
Mark Slee | f983108 | 2007-02-20 20:59:21 +0000 | [diff] [blame] | 65 | string_buf_(NULL), |
| 66 | string_buf_size_(0) {} |
| 67 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 68 | ~TBinaryProtocolT() { |
Mark Slee | f983108 | 2007-02-20 20:59:21 +0000 | [diff] [blame] | 69 | if (string_buf_ != NULL) { |
David Reiss | d7a16f4 | 2008-02-19 22:47:29 +0000 | [diff] [blame] | 70 | std::free(string_buf_); |
Mark Slee | f983108 | 2007-02-20 20:59:21 +0000 | [diff] [blame] | 71 | string_buf_size_ = 0; |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | void setStringSizeLimit(int32_t string_limit) { |
| 76 | string_limit_ = string_limit; |
| 77 | } |
| 78 | |
| 79 | void setContainerSizeLimit(int32_t container_limit) { |
| 80 | container_limit_ = container_limit; |
| 81 | } |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 82 | |
Mark Slee | 808454e | 2007-06-20 21:51:57 +0000 | [diff] [blame] | 83 | void setStrict(bool strict_read, bool strict_write) { |
| 84 | strict_read_ = strict_read; |
| 85 | strict_write_ = strict_write; |
| 86 | } |
| 87 | |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 88 | /** |
| 89 | * Writing functions. |
| 90 | */ |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 91 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 92 | /*ol*/ uint32_t writeMessageBegin(const std::string& name, |
| 93 | const TMessageType messageType, |
| 94 | const int32_t seqid); |
Marc Slemko | 1669885 | 2006-08-04 03:16:10 +0000 | [diff] [blame] | 95 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 96 | /*ol*/ uint32_t writeMessageEnd(); |
Marc Slemko | 1669885 | 2006-08-04 03:16:10 +0000 | [diff] [blame] | 97 | |
| 98 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 99 | inline uint32_t writeStructBegin(const char* name); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 100 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 101 | inline uint32_t writeStructEnd(); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 102 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 103 | inline uint32_t writeFieldBegin(const char* name, |
| 104 | const TType fieldType, |
| 105 | const int16_t fieldId); |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 106 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 107 | inline uint32_t writeFieldEnd(); |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 108 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 109 | inline uint32_t writeFieldStop(); |
David Reiss | 0c90f6f | 2008-02-06 22:18:40 +0000 | [diff] [blame] | 110 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 111 | inline uint32_t writeMapBegin(const TType keyType, |
| 112 | const TType valType, |
| 113 | const uint32_t size); |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 114 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 115 | inline uint32_t writeMapEnd(); |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 116 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 117 | inline uint32_t writeListBegin(const TType elemType, const uint32_t size); |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 118 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 119 | inline uint32_t writeListEnd(); |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 120 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 121 | inline uint32_t writeSetBegin(const TType elemType, const uint32_t size); |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 122 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 123 | inline uint32_t writeSetEnd(); |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 124 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 125 | inline uint32_t writeBool(const bool value); |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 126 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 127 | inline uint32_t writeByte(const int8_t byte); |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 128 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 129 | inline uint32_t writeI16(const int16_t i16); |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 130 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 131 | inline uint32_t writeI32(const int32_t i32); |
Marc Slemko | 0b4ffa9 | 2006-08-11 02:49:29 +0000 | [diff] [blame] | 132 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 133 | inline uint32_t writeI64(const int64_t i64); |
Marc Slemko | 0b4ffa9 | 2006-08-11 02:49:29 +0000 | [diff] [blame] | 134 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 135 | inline uint32_t writeDouble(const double dub); |
Mark Slee | c98d050 | 2006-09-06 02:42:25 +0000 | [diff] [blame] | 136 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 137 | inline uint32_t writeString(const std::string& str); |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 138 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 139 | inline uint32_t writeBinary(const std::string& str); |
David Reiss | c005b1b | 2008-02-15 01:38:18 +0000 | [diff] [blame] | 140 | |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 141 | /** |
| 142 | * Reading functions |
| 143 | */ |
| 144 | |
Marc Slemko | 1669885 | 2006-08-04 03:16:10 +0000 | [diff] [blame] | 145 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 146 | /*ol*/ uint32_t readMessageBegin(std::string& name, |
| 147 | TMessageType& messageType, |
| 148 | int32_t& seqid); |
Marc Slemko | 1669885 | 2006-08-04 03:16:10 +0000 | [diff] [blame] | 149 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 150 | /*ol*/ uint32_t readMessageEnd(); |
Marc Slemko | 1669885 | 2006-08-04 03:16:10 +0000 | [diff] [blame] | 151 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 152 | inline uint32_t readStructBegin(std::string& name); |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 153 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 154 | inline uint32_t readStructEnd(); |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 155 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 156 | inline uint32_t readFieldBegin(std::string& name, |
| 157 | TType& fieldType, |
| 158 | int16_t& fieldId); |
David Reiss | 0c90f6f | 2008-02-06 22:18:40 +0000 | [diff] [blame] | 159 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 160 | inline uint32_t readFieldEnd(); |
David Reiss | 0c90f6f | 2008-02-06 22:18:40 +0000 | [diff] [blame] | 161 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 162 | inline uint32_t readMapBegin(TType& keyType, |
| 163 | TType& valType, |
| 164 | uint32_t& size); |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 165 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 166 | inline uint32_t readMapEnd(); |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 167 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 168 | inline uint32_t readListBegin(TType& elemType, uint32_t& size); |
David Reiss | 0c90f6f | 2008-02-06 22:18:40 +0000 | [diff] [blame] | 169 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 170 | inline uint32_t readListEnd(); |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 171 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 172 | inline uint32_t readSetBegin(TType& elemType, uint32_t& size); |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 173 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 174 | inline uint32_t readSetEnd(); |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 175 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 176 | inline uint32_t readBool(bool& value); |
David Reiss | 8dfc732 | 2010-10-06 17:09:58 +0000 | [diff] [blame] | 177 | // Provide the default readBool() implementation for std::vector<bool> |
| 178 | using TVirtualProtocol< TBinaryProtocolT<Transport_> >::readBool; |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 179 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 180 | inline uint32_t readByte(int8_t& byte); |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 181 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 182 | inline uint32_t readI16(int16_t& i16); |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 183 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 184 | inline uint32_t readI32(int32_t& i32); |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 185 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 186 | inline uint32_t readI64(int64_t& i64); |
Marc Slemko | 0b4ffa9 | 2006-08-11 02:49:29 +0000 | [diff] [blame] | 187 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 188 | inline uint32_t readDouble(double& dub); |
Mark Slee | c98d050 | 2006-09-06 02:42:25 +0000 | [diff] [blame] | 189 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 190 | inline uint32_t readString(std::string& str); |
Mark Slee | f983108 | 2007-02-20 20:59:21 +0000 | [diff] [blame] | 191 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 192 | inline uint32_t readBinary(std::string& str); |
David Reiss | c005b1b | 2008-02-15 01:38:18 +0000 | [diff] [blame] | 193 | |
Mark Slee | 808454e | 2007-06-20 21:51:57 +0000 | [diff] [blame] | 194 | protected: |
| 195 | uint32_t readStringBody(std::string& str, int32_t sz); |
| 196 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 197 | Transport_* trans_; |
| 198 | |
Mark Slee | f983108 | 2007-02-20 20:59:21 +0000 | [diff] [blame] | 199 | int32_t string_limit_; |
| 200 | int32_t container_limit_; |
| 201 | |
Mark Slee | 808454e | 2007-06-20 21:51:57 +0000 | [diff] [blame] | 202 | // Enforce presence of version identifier |
| 203 | bool strict_read_; |
| 204 | bool strict_write_; |
| 205 | |
Mark Slee | f983108 | 2007-02-20 20:59:21 +0000 | [diff] [blame] | 206 | // Buffer for reading strings, save for the lifetime of the protocol to |
| 207 | // avoid memory churn allocating memory on every string read |
| 208 | uint8_t* string_buf_; |
| 209 | int32_t string_buf_size_; |
| 210 | |
Mark Slee | 4af6ed7 | 2006-10-25 19:02:49 +0000 | [diff] [blame] | 211 | }; |
| 212 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 213 | typedef TBinaryProtocolT<TTransport> TBinaryProtocol; |
| 214 | |
Mark Slee | 4af6ed7 | 2006-10-25 19:02:49 +0000 | [diff] [blame] | 215 | /** |
| 216 | * Constructs binary protocol handlers |
| 217 | */ |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 218 | template <class Transport_> |
| 219 | class TBinaryProtocolFactoryT : public TProtocolFactory { |
Mark Slee | 4af6ed7 | 2006-10-25 19:02:49 +0000 | [diff] [blame] | 220 | public: |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 221 | TBinaryProtocolFactoryT() : |
Mark Slee | f983108 | 2007-02-20 20:59:21 +0000 | [diff] [blame] | 222 | string_limit_(0), |
Mark Slee | 808454e | 2007-06-20 21:51:57 +0000 | [diff] [blame] | 223 | container_limit_(0), |
| 224 | strict_read_(false), |
| 225 | strict_write_(true) {} |
Mark Slee | f983108 | 2007-02-20 20:59:21 +0000 | [diff] [blame] | 226 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 227 | TBinaryProtocolFactoryT(int32_t string_limit, int32_t container_limit, |
| 228 | bool strict_read, bool strict_write) : |
Mark Slee | f983108 | 2007-02-20 20:59:21 +0000 | [diff] [blame] | 229 | string_limit_(string_limit), |
Mark Slee | 808454e | 2007-06-20 21:51:57 +0000 | [diff] [blame] | 230 | container_limit_(container_limit), |
| 231 | strict_read_(strict_read), |
| 232 | strict_write_(strict_write) {} |
Mark Slee | 4af6ed7 | 2006-10-25 19:02:49 +0000 | [diff] [blame] | 233 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 234 | virtual ~TBinaryProtocolFactoryT() {} |
Mark Slee | 4af6ed7 | 2006-10-25 19:02:49 +0000 | [diff] [blame] | 235 | |
Mark Slee | f983108 | 2007-02-20 20:59:21 +0000 | [diff] [blame] | 236 | void setStringSizeLimit(int32_t string_limit) { |
| 237 | string_limit_ = string_limit; |
Mark Slee | 4af6ed7 | 2006-10-25 19:02:49 +0000 | [diff] [blame] | 238 | } |
Mark Slee | f983108 | 2007-02-20 20:59:21 +0000 | [diff] [blame] | 239 | |
| 240 | void setContainerSizeLimit(int32_t container_limit) { |
| 241 | container_limit_ = container_limit; |
| 242 | } |
| 243 | |
Mark Slee | 808454e | 2007-06-20 21:51:57 +0000 | [diff] [blame] | 244 | void setStrict(bool strict_read, bool strict_write) { |
| 245 | strict_read_ = strict_read; |
| 246 | strict_write_ = strict_write; |
| 247 | } |
| 248 | |
Mark Slee | f983108 | 2007-02-20 20:59:21 +0000 | [diff] [blame] | 249 | boost::shared_ptr<TProtocol> getProtocol(boost::shared_ptr<TTransport> trans) { |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 250 | boost::shared_ptr<Transport_> specific_trans = |
| 251 | boost::dynamic_pointer_cast<Transport_>(trans); |
| 252 | TProtocol* prot; |
| 253 | if (specific_trans) { |
| 254 | prot = new TBinaryProtocolT<Transport_>(specific_trans, string_limit_, |
| 255 | container_limit_, strict_read_, |
| 256 | strict_write_); |
| 257 | } else { |
| 258 | prot = new TBinaryProtocol(trans, string_limit_, container_limit_, |
| 259 | strict_read_, strict_write_); |
| 260 | } |
| 261 | |
| 262 | return boost::shared_ptr<TProtocol>(prot); |
Mark Slee | f983108 | 2007-02-20 20:59:21 +0000 | [diff] [blame] | 263 | } |
| 264 | |
| 265 | private: |
| 266 | int32_t string_limit_; |
| 267 | int32_t container_limit_; |
Mark Slee | 808454e | 2007-06-20 21:51:57 +0000 | [diff] [blame] | 268 | bool strict_read_; |
| 269 | bool strict_write_; |
Mark Slee | f983108 | 2007-02-20 20:59:21 +0000 | [diff] [blame] | 270 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 271 | }; |
| 272 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 273 | typedef TBinaryProtocolFactoryT<TTransport> TBinaryProtocolFactory; |
| 274 | |
T Jake Luciani | b5e6221 | 2009-01-31 22:36:20 +0000 | [diff] [blame] | 275 | }}} // apache::thrift::protocol |
Marc Slemko | 6f038a7 | 2006-08-03 18:58:09 +0000 | [diff] [blame] | 276 | |
David Reiss | e71115b | 2010-10-06 17:09:56 +0000 | [diff] [blame] | 277 | #include "TBinaryProtocol.tcc" |
| 278 | |
Mark Slee | f5f2be4 | 2006-09-05 21:05:31 +0000 | [diff] [blame] | 279 | #endif // #ifndef _THRIFT_PROTOCOL_TBINARYPROTOCOL_H_ |