Mark Slee | f5f2be4 | 2006-09-05 21:05:31 +0000 | [diff] [blame] | 1 | #ifndef _THRIFT_PROTOCOL_TPROTOCOL_H_ |
| 2 | #define _THRIFT_PROTOCOL_TPROTOCOL_H_ 1 |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 3 | |
Marc Slemko | 1669885 | 2006-08-04 03:16:10 +0000 | [diff] [blame] | 4 | #include <transport/TTransport.h> |
| 5 | |
| 6 | #include <boost/shared_ptr.hpp> |
| 7 | |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 8 | #include <netinet/in.h> |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 9 | #include <sys/types.h> |
| 10 | #include <string> |
| 11 | #include <map> |
| 12 | |
Marc Slemko | 6f038a7 | 2006-08-03 18:58:09 +0000 | [diff] [blame] | 13 | namespace facebook { namespace thrift { namespace protocol { |
| 14 | |
Marc Slemko | 1669885 | 2006-08-04 03:16:10 +0000 | [diff] [blame] | 15 | using namespace boost; |
| 16 | |
Marc Slemko | 6f038a7 | 2006-08-03 18:58:09 +0000 | [diff] [blame] | 17 | using namespace facebook::thrift::transport; |
| 18 | |
Mark Slee | dc8a2a2 | 2006-09-19 22:20:18 +0000 | [diff] [blame] | 19 | #if __BYTE_ORDER == __BIG_ENDIAN |
| 20 | #define ntohll(n) (n) |
| 21 | #define htonll(n) (n) |
| 22 | #else |
| 23 | #define ntohll(n) ( (((unsigned long long)ntohl(n)) << 32) + ntohl(n >> 32) ) |
| 24 | #define htonll(n) ( (((unsigned long long)htonl(n)) << 32) + htonl(n >> 32) ) |
| 25 | #endif |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 26 | |
Mark Slee | f5f2be4 | 2006-09-05 21:05:31 +0000 | [diff] [blame] | 27 | // Forward declaration for TProtocol |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 28 | struct TBuf; |
| 29 | |
| 30 | /** |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 31 | * Enumerated definition of the types that the Thrift protocol supports. |
| 32 | * Take special note of the T_END type which is used specifically to mark |
| 33 | * the end of a sequence of fields. |
| 34 | */ |
| 35 | enum TType { |
Marc Slemko | d42a2c2 | 2006-08-10 03:30:18 +0000 | [diff] [blame] | 36 | T_STOP = 0, |
Marc Slemko | 5b126d6 | 2006-08-11 23:03:42 +0000 | [diff] [blame] | 37 | T_VOID = 1, |
| 38 | T_BOOL = 2, |
| 39 | T_BYTE = 3, |
Mark Slee | cfc0193 | 2006-09-01 22:18:16 +0000 | [diff] [blame] | 40 | T_I08 = 3, |
Marc Slemko | 5b126d6 | 2006-08-11 23:03:42 +0000 | [diff] [blame] | 41 | T_I16 = 6, |
Marc Slemko | 5b126d6 | 2006-08-11 23:03:42 +0000 | [diff] [blame] | 42 | T_I32 = 8, |
| 43 | T_U64 = 9, |
| 44 | T_I64 = 10, |
Mark Slee | c98d050 | 2006-09-06 02:42:25 +0000 | [diff] [blame] | 45 | T_DOUBLE = 4, |
Marc Slemko | 5b126d6 | 2006-08-11 23:03:42 +0000 | [diff] [blame] | 46 | T_STRING = 11, |
Marc Slemko | d97eb61 | 2006-08-24 23:37:36 +0000 | [diff] [blame] | 47 | T_UTF7 = 11, |
| 48 | T_STRUCT = 12, |
| 49 | T_MAP = 13, |
| 50 | T_SET = 14, |
| 51 | T_LIST = 15, |
| 52 | T_UTF8 = 16, |
| 53 | T_UTF16 = 17 |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 54 | }; |
| 55 | |
| 56 | /** |
Mark Slee | f5f2be4 | 2006-09-05 21:05:31 +0000 | [diff] [blame] | 57 | * Enumerated definition of the message types that the Thrift protocol |
| 58 | * supports. |
Marc Slemko | 1669885 | 2006-08-04 03:16:10 +0000 | [diff] [blame] | 59 | */ |
| 60 | enum TMessageType { |
| 61 | T_CALL = 1, |
| 62 | T_REPLY = 2 |
| 63 | }; |
| 64 | |
| 65 | /** |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 66 | * Abstract class for a thrift protocol driver. These are all the methods that |
| 67 | * a protocol must implement. Essentially, there must be some way of reading |
| 68 | * and writing all the base types, plus a mechanism for writing out structs |
| 69 | * with indexed fields. Also notice that all methods are strictly const. This |
| 70 | * is by design. Protcol impelementations may NOT keep state, because the |
| 71 | * same TProtocol object may be used simultaneously by multiple threads. This |
| 72 | * theoretically introduces some limititations into the possible protocol |
| 73 | * formats, but with the benefit of performance, clarity, and simplicity. |
| 74 | * |
| 75 | * @author Mark Slee <mcslee@facebook.com> |
| 76 | */ |
| 77 | class TProtocol { |
| 78 | public: |
| 79 | virtual ~TProtocol() {} |
| 80 | |
| 81 | /** |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 82 | * Writing functions. |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 83 | */ |
| 84 | |
Marc Slemko | 0b4ffa9 | 2006-08-11 02:49:29 +0000 | [diff] [blame] | 85 | virtual uint32_t writeMessageBegin(shared_ptr<TTransport> out, |
Marc Slemko | 91f6748 | 2006-08-11 23:58:57 +0000 | [diff] [blame] | 86 | const std::string name, |
Marc Slemko | 0b4ffa9 | 2006-08-11 02:49:29 +0000 | [diff] [blame] | 87 | const TMessageType messageType, |
Mark Slee | cfc0193 | 2006-09-01 22:18:16 +0000 | [diff] [blame] | 88 | const int32_t seqid) const = 0; |
Marc Slemko | 1669885 | 2006-08-04 03:16:10 +0000 | [diff] [blame] | 89 | |
Marc Slemko | 0b4ffa9 | 2006-08-11 02:49:29 +0000 | [diff] [blame] | 90 | virtual uint32_t writeMessageEnd(shared_ptr<TTransport> out) const = 0; |
Marc Slemko | 1669885 | 2006-08-04 03:16:10 +0000 | [diff] [blame] | 91 | |
| 92 | |
Marc Slemko | 0b4ffa9 | 2006-08-11 02:49:29 +0000 | [diff] [blame] | 93 | virtual uint32_t writeStructBegin(shared_ptr<TTransport> out, |
| 94 | const std::string& name) const = 0; |
| 95 | |
| 96 | virtual uint32_t writeStructEnd(shared_ptr<TTransport> out) const = 0; |
| 97 | |
| 98 | virtual uint32_t writeFieldBegin(shared_ptr<TTransport> out, |
| 99 | const std::string& name, |
| 100 | const TType fieldType, |
| 101 | const int16_t fieldId) const = 0; |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 102 | |
Marc Slemko | 0b4ffa9 | 2006-08-11 02:49:29 +0000 | [diff] [blame] | 103 | virtual uint32_t writeFieldEnd(shared_ptr<TTransport> out) const = 0; |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 104 | |
Marc Slemko | 0b4ffa9 | 2006-08-11 02:49:29 +0000 | [diff] [blame] | 105 | virtual uint32_t writeFieldStop(shared_ptr<TTransport> out) const = 0; |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 106 | |
Marc Slemko | 0b4ffa9 | 2006-08-11 02:49:29 +0000 | [diff] [blame] | 107 | virtual uint32_t writeMapBegin(shared_ptr<TTransport> out, |
| 108 | const TType keyType, |
| 109 | const TType valType, |
Marc Slemko | b09f588 | 2006-08-23 22:03:34 +0000 | [diff] [blame] | 110 | const uint32_t size) const = 0; |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 111 | |
Marc Slemko | 0b4ffa9 | 2006-08-11 02:49:29 +0000 | [diff] [blame] | 112 | virtual uint32_t writeMapEnd(shared_ptr<TTransport> out) const = 0; |
| 113 | |
| 114 | virtual uint32_t writeListBegin(shared_ptr<TTransport> out, |
| 115 | const TType elemType, |
Marc Slemko | b09f588 | 2006-08-23 22:03:34 +0000 | [diff] [blame] | 116 | const uint32_t size) const = 0; |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 117 | |
Marc Slemko | 0b4ffa9 | 2006-08-11 02:49:29 +0000 | [diff] [blame] | 118 | virtual uint32_t writeListEnd(shared_ptr<TTransport> out) const = 0; |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 119 | |
Marc Slemko | 0b4ffa9 | 2006-08-11 02:49:29 +0000 | [diff] [blame] | 120 | virtual uint32_t writeSetBegin(shared_ptr<TTransport> out, |
| 121 | const TType elemType, |
Marc Slemko | b09f588 | 2006-08-23 22:03:34 +0000 | [diff] [blame] | 122 | const uint32_t size) const = 0; |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 123 | |
Marc Slemko | 0b4ffa9 | 2006-08-11 02:49:29 +0000 | [diff] [blame] | 124 | virtual uint32_t writeSetEnd(shared_ptr<TTransport> out) const = 0; |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 125 | |
Marc Slemko | 0b4ffa9 | 2006-08-11 02:49:29 +0000 | [diff] [blame] | 126 | virtual uint32_t writeBool(shared_ptr<TTransport> out, |
| 127 | const bool value) const = 0; |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 128 | |
Marc Slemko | 0b4ffa9 | 2006-08-11 02:49:29 +0000 | [diff] [blame] | 129 | virtual uint32_t writeByte(shared_ptr<TTransport> out, |
Mark Slee | cfc0193 | 2006-09-01 22:18:16 +0000 | [diff] [blame] | 130 | const int8_t byte) const = 0; |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 131 | |
Marc Slemko | 0b4ffa9 | 2006-08-11 02:49:29 +0000 | [diff] [blame] | 132 | virtual uint32_t writeI16(shared_ptr<TTransport> out, |
| 133 | const int16_t i16) const = 0; |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 134 | |
Marc Slemko | 0b4ffa9 | 2006-08-11 02:49:29 +0000 | [diff] [blame] | 135 | virtual uint32_t writeI32(shared_ptr<TTransport> out, |
| 136 | const int32_t i32) const = 0; |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 137 | |
Marc Slemko | 0b4ffa9 | 2006-08-11 02:49:29 +0000 | [diff] [blame] | 138 | virtual uint32_t writeI64(shared_ptr<TTransport> out, |
| 139 | const int64_t i64) const = 0; |
| 140 | |
Mark Slee | c98d050 | 2006-09-06 02:42:25 +0000 | [diff] [blame] | 141 | virtual uint32_t writeDouble(shared_ptr<TTransport> out, |
| 142 | const double dub) const = 0; |
| 143 | |
Marc Slemko | 0b4ffa9 | 2006-08-11 02:49:29 +0000 | [diff] [blame] | 144 | virtual uint32_t writeString(shared_ptr<TTransport> out, |
| 145 | const std::string& str) const = 0; |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 146 | |
| 147 | /** |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 148 | * Reading functions |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 149 | */ |
| 150 | |
Marc Slemko | 5b126d6 | 2006-08-11 23:03:42 +0000 | [diff] [blame] | 151 | virtual uint32_t readMessageBegin(shared_ptr<TTransport> in, |
Marc Slemko | 91f6748 | 2006-08-11 23:58:57 +0000 | [diff] [blame] | 152 | std::string& name, |
| 153 | TMessageType& messageType, |
Mark Slee | cfc0193 | 2006-09-01 22:18:16 +0000 | [diff] [blame] | 154 | int32_t& seqid) const = 0; |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 155 | |
Marc Slemko | 0b4ffa9 | 2006-08-11 02:49:29 +0000 | [diff] [blame] | 156 | virtual uint32_t readMessageEnd(shared_ptr<TTransport> in) const = 0; |
| 157 | |
| 158 | virtual uint32_t readStructBegin(shared_ptr<TTransport> in, |
| 159 | std::string& name) const = 0; |
| 160 | |
| 161 | virtual uint32_t readStructEnd(shared_ptr<TTransport> in) const = 0; |
| 162 | |
| 163 | virtual uint32_t readFieldBegin(shared_ptr<TTransport> in, |
| 164 | std::string& name, |
| 165 | TType& fieldType, |
| 166 | int16_t& fieldId) const = 0; |
| 167 | |
| 168 | virtual uint32_t readFieldEnd(shared_ptr<TTransport> in) const = 0; |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 169 | |
Marc Slemko | 0b4ffa9 | 2006-08-11 02:49:29 +0000 | [diff] [blame] | 170 | virtual uint32_t readMapBegin(shared_ptr<TTransport> in, |
| 171 | TType& keyType, |
| 172 | TType& valType, |
Marc Slemko | b09f588 | 2006-08-23 22:03:34 +0000 | [diff] [blame] | 173 | uint32_t& size) const = 0; |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 174 | |
Marc Slemko | 0b4ffa9 | 2006-08-11 02:49:29 +0000 | [diff] [blame] | 175 | virtual uint32_t readMapEnd(shared_ptr<TTransport> in) const = 0; |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 176 | |
Marc Slemko | 0b4ffa9 | 2006-08-11 02:49:29 +0000 | [diff] [blame] | 177 | virtual uint32_t readListBegin(shared_ptr<TTransport> in, |
| 178 | TType& elemType, |
Marc Slemko | b09f588 | 2006-08-23 22:03:34 +0000 | [diff] [blame] | 179 | uint32_t& size) const = 0; |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 180 | |
Marc Slemko | 0b4ffa9 | 2006-08-11 02:49:29 +0000 | [diff] [blame] | 181 | virtual uint32_t readListEnd(shared_ptr<TTransport> in) const = 0; |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 182 | |
Marc Slemko | 0b4ffa9 | 2006-08-11 02:49:29 +0000 | [diff] [blame] | 183 | virtual uint32_t readSetBegin(shared_ptr<TTransport> in, |
| 184 | TType& elemType, |
Marc Slemko | b09f588 | 2006-08-23 22:03:34 +0000 | [diff] [blame] | 185 | uint32_t& size) const = 0; |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 186 | |
Marc Slemko | 0b4ffa9 | 2006-08-11 02:49:29 +0000 | [diff] [blame] | 187 | virtual uint32_t readSetEnd(shared_ptr<TTransport> in) const = 0; |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 188 | |
Marc Slemko | 0b4ffa9 | 2006-08-11 02:49:29 +0000 | [diff] [blame] | 189 | virtual uint32_t readBool(shared_ptr<TTransport> in, |
| 190 | bool& value) const = 0; |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 191 | |
Marc Slemko | 0b4ffa9 | 2006-08-11 02:49:29 +0000 | [diff] [blame] | 192 | virtual uint32_t readByte(shared_ptr<TTransport> in, |
Mark Slee | cfc0193 | 2006-09-01 22:18:16 +0000 | [diff] [blame] | 193 | int8_t& byte) const = 0; |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 194 | |
Marc Slemko | 0b4ffa9 | 2006-08-11 02:49:29 +0000 | [diff] [blame] | 195 | virtual uint32_t readI16(shared_ptr<TTransport> in, |
| 196 | int16_t& i16) const = 0; |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 197 | |
Marc Slemko | 0b4ffa9 | 2006-08-11 02:49:29 +0000 | [diff] [blame] | 198 | virtual uint32_t readI32(shared_ptr<TTransport> in, |
| 199 | int32_t& i32) const = 0; |
| 200 | |
Marc Slemko | 0b4ffa9 | 2006-08-11 02:49:29 +0000 | [diff] [blame] | 201 | virtual uint32_t readI64(shared_ptr<TTransport> in, |
| 202 | int64_t& i64) const = 0; |
| 203 | |
Mark Slee | c98d050 | 2006-09-06 02:42:25 +0000 | [diff] [blame] | 204 | virtual uint32_t readDouble(shared_ptr<TTransport> in, |
| 205 | double& dub) const = 0; |
| 206 | |
Marc Slemko | 0b4ffa9 | 2006-08-11 02:49:29 +0000 | [diff] [blame] | 207 | virtual uint32_t readString(shared_ptr<TTransport> in, |
| 208 | std::string& str) const = 0; |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 209 | |
| 210 | /** |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 211 | * Method to arbitrarily skip over data. |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 212 | */ |
Marc Slemko | 1669885 | 2006-08-04 03:16:10 +0000 | [diff] [blame] | 213 | uint32_t skip(shared_ptr<TTransport> in, TType type) const { |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 214 | switch (type) { |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 215 | case T_BOOL: |
| 216 | { |
| 217 | bool boolv; |
| 218 | return readBool(in, boolv); |
| 219 | } |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 220 | case T_BYTE: |
| 221 | { |
Mark Slee | 78f58e2 | 2006-09-02 04:17:07 +0000 | [diff] [blame] | 222 | int8_t bytev; |
| 223 | return readByte(in, bytev); |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 224 | } |
Mark Slee | cfc0193 | 2006-09-01 22:18:16 +0000 | [diff] [blame] | 225 | case T_I16: |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 226 | { |
Mark Slee | cfc0193 | 2006-09-01 22:18:16 +0000 | [diff] [blame] | 227 | int16_t i16; |
| 228 | return readI16(in, i16); |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 229 | } |
| 230 | case T_I32: |
| 231 | { |
| 232 | int32_t i32; |
| 233 | return readI32(in, i32); |
| 234 | } |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 235 | case T_I64: |
| 236 | { |
| 237 | int64_t i64; |
| 238 | return readI64(in, i64); |
| 239 | } |
Mark Slee | c98d050 | 2006-09-06 02:42:25 +0000 | [diff] [blame] | 240 | case T_DOUBLE: |
| 241 | { |
| 242 | double dub; |
| 243 | return readDouble(in, dub); |
| 244 | } |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 245 | case T_STRING: |
| 246 | { |
| 247 | std::string str; |
| 248 | return readString(in, str); |
| 249 | } |
| 250 | case T_STRUCT: |
| 251 | { |
| 252 | uint32_t result = 0; |
| 253 | std::string name; |
Marc Slemko | 0b4ffa9 | 2006-08-11 02:49:29 +0000 | [diff] [blame] | 254 | int16_t fid; |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 255 | TType ftype; |
| 256 | result += readStructBegin(in, name); |
| 257 | while (true) { |
| 258 | result += readFieldBegin(in, name, ftype, fid); |
| 259 | if (ftype == T_STOP) { |
| 260 | break; |
| 261 | } |
| 262 | result += skip(in, ftype); |
| 263 | result += readFieldEnd(in); |
| 264 | } |
| 265 | result += readStructEnd(in); |
| 266 | return result; |
| 267 | } |
| 268 | case T_MAP: |
| 269 | { |
| 270 | uint32_t result = 0; |
| 271 | TType keyType; |
| 272 | TType valType; |
Marc Slemko | b09f588 | 2006-08-23 22:03:34 +0000 | [diff] [blame] | 273 | uint32_t i, size; |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 274 | result += readMapBegin(in, keyType, valType, size); |
| 275 | for (i = 0; i < size; i++) { |
| 276 | result += skip(in, keyType); |
| 277 | result += skip(in, valType); |
| 278 | } |
| 279 | result += readMapEnd(in); |
| 280 | return result; |
| 281 | } |
| 282 | case T_SET: |
| 283 | { |
| 284 | uint32_t result = 0; |
| 285 | TType elemType; |
Marc Slemko | b09f588 | 2006-08-23 22:03:34 +0000 | [diff] [blame] | 286 | uint32_t i, size; |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 287 | result += readSetBegin(in, elemType, size); |
| 288 | for (i = 0; i < size; i++) { |
| 289 | result += skip(in, elemType); |
| 290 | } |
| 291 | result += readSetEnd(in); |
| 292 | return result; |
| 293 | } |
| 294 | case T_LIST: |
| 295 | { |
| 296 | uint32_t result = 0; |
| 297 | TType elemType; |
Marc Slemko | b09f588 | 2006-08-23 22:03:34 +0000 | [diff] [blame] | 298 | uint32_t i, size; |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 299 | result += readListBegin(in, elemType, size); |
| 300 | for (i = 0; i < size; i++) { |
| 301 | result += skip(in, elemType); |
| 302 | } |
| 303 | result += readListEnd(in); |
| 304 | return result; |
| 305 | } |
| 306 | default: |
| 307 | return 0; |
| 308 | } |
| 309 | } |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 310 | |
| 311 | protected: |
| 312 | TProtocol() {} |
| 313 | }; |
| 314 | |
Marc Slemko | 6f038a7 | 2006-08-03 18:58:09 +0000 | [diff] [blame] | 315 | }}} // facebook::thrift::protocol |
| 316 | |
Mark Slee | f5f2be4 | 2006-09-05 21:05:31 +0000 | [diff] [blame] | 317 | #endif // #define _THRIFT_PROTOCOL_TPROTOCOL_H_ 1 |