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