THRIFT-2729: C++ - .clang-format created and applied
Client: C++
Patch: Konrad Grochowski
make style command added
diff --git a/lib/cpp/src/thrift/protocol/TBase64Utils.cpp b/lib/cpp/src/thrift/protocol/TBase64Utils.cpp
index cd343ed..beb76eb 100644
--- a/lib/cpp/src/thrift/protocol/TBase64Utils.cpp
+++ b/lib/cpp/src/thrift/protocol/TBase64Utils.cpp
@@ -23,13 +23,14 @@
using std::string;
-namespace apache { namespace thrift { namespace protocol {
+namespace apache {
+namespace thrift {
+namespace protocol {
+static const uint8_t* kBase64EncodeTable
+ = (const uint8_t*)"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-static const uint8_t *kBase64EncodeTable = (const uint8_t *)
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-
-void base64_encode(const uint8_t *in, uint32_t len, uint8_t *buf) {
+void base64_encode(const uint8_t* in, uint32_t len, uint8_t* buf) {
buf[0] = kBase64EncodeTable[(in[0] >> 2) & 0x3f];
if (len == 3) {
buf[1] = kBase64EncodeTable[((in[0] << 4) & 0x30) | ((in[1] >> 4) & 0x0f)];
@@ -38,42 +39,279 @@
} else if (len == 2) {
buf[1] = kBase64EncodeTable[((in[0] << 4) & 0x30) | ((in[1] >> 4) & 0x0f)];
buf[2] = kBase64EncodeTable[(in[1] << 2) & 0x3c];
- } else { // len == 1
+ } else { // len == 1
buf[1] = kBase64EncodeTable[(in[0] << 4) & 0x30];
}
}
-static const uint8_t kBase64DecodeTable[256] ={
-0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
-0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
-0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3e,0xff,0xff,0xff,0x3f,
-0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0xff,0xff,0xff,0xff,0xff,0xff,
-0xff,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,
-0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0xff,0xff,0xff,0xff,0xff,
-0xff,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,
-0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,0x30,0x31,0x32,0x33,0xff,0xff,0xff,0xff,0xff,
-0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
-0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
-0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
-0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
-0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
-0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
-0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
-0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+static const uint8_t kBase64DecodeTable[256] = {
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0x3e,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0x3f,
+ 0x34,
+ 0x35,
+ 0x36,
+ 0x37,
+ 0x38,
+ 0x39,
+ 0x3a,
+ 0x3b,
+ 0x3c,
+ 0x3d,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0x00,
+ 0x01,
+ 0x02,
+ 0x03,
+ 0x04,
+ 0x05,
+ 0x06,
+ 0x07,
+ 0x08,
+ 0x09,
+ 0x0a,
+ 0x0b,
+ 0x0c,
+ 0x0d,
+ 0x0e,
+ 0x0f,
+ 0x10,
+ 0x11,
+ 0x12,
+ 0x13,
+ 0x14,
+ 0x15,
+ 0x16,
+ 0x17,
+ 0x18,
+ 0x19,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0x1a,
+ 0x1b,
+ 0x1c,
+ 0x1d,
+ 0x1e,
+ 0x1f,
+ 0x20,
+ 0x21,
+ 0x22,
+ 0x23,
+ 0x24,
+ 0x25,
+ 0x26,
+ 0x27,
+ 0x28,
+ 0x29,
+ 0x2a,
+ 0x2b,
+ 0x2c,
+ 0x2d,
+ 0x2e,
+ 0x2f,
+ 0x30,
+ 0x31,
+ 0x32,
+ 0x33,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
+ 0xff,
};
-void base64_decode(uint8_t *buf, uint32_t len) {
- buf[0] = (kBase64DecodeTable[buf[0]] << 2) |
- (kBase64DecodeTable[buf[1]] >> 4);
+void base64_decode(uint8_t* buf, uint32_t len) {
+ buf[0] = (kBase64DecodeTable[buf[0]] << 2) | (kBase64DecodeTable[buf[1]] >> 4);
if (len > 2) {
- buf[1] = ((kBase64DecodeTable[buf[1]] << 4) & 0xf0) |
- (kBase64DecodeTable[buf[2]] >> 2);
+ buf[1] = ((kBase64DecodeTable[buf[1]] << 4) & 0xf0) | (kBase64DecodeTable[buf[2]] >> 2);
if (len > 3) {
- buf[2] = ((kBase64DecodeTable[buf[2]] << 6) & 0xc0) |
- (kBase64DecodeTable[buf[3]]);
+ buf[2] = ((kBase64DecodeTable[buf[2]] << 6) & 0xc0) | (kBase64DecodeTable[buf[3]]);
}
}
}
-
-
-}}} // apache::thrift::protocol
+}
+}
+} // apache::thrift::protocol
diff --git a/lib/cpp/src/thrift/protocol/TBase64Utils.h b/lib/cpp/src/thrift/protocol/TBase64Utils.h
index 3def733..1ea6744 100644
--- a/lib/cpp/src/thrift/protocol/TBase64Utils.h
+++ b/lib/cpp/src/thrift/protocol/TBase64Utils.h
@@ -23,20 +23,23 @@
#include <stdint.h>
#include <string>
-namespace apache { namespace thrift { namespace protocol {
+namespace apache {
+namespace thrift {
+namespace protocol {
// in must be at least len bytes
// len must be 1, 2, or 3
// buf must be a buffer of at least 4 bytes and may not overlap in
// the data is not padded with '='; the caller can do this if desired
-void base64_encode(const uint8_t *in, uint32_t len, uint8_t *buf);
+void base64_encode(const uint8_t* in, uint32_t len, uint8_t* buf);
// buf must be a buffer of at least 4 bytes and contain base64 encoded values
// buf will be changed to contain output bytes
// len is number of bytes to consume from input (must be 2, 3, or 4)
// no '=' padding should be included in the input
-void base64_decode(uint8_t *buf, uint32_t len);
-
-}}} // apache::thrift::protocol
+void base64_decode(uint8_t* buf, uint32_t len);
+}
+}
+} // apache::thrift::protocol
#endif // #define _THRIFT_PROTOCOL_TBASE64UTILS_H_
diff --git a/lib/cpp/src/thrift/protocol/TBinaryProtocol.h b/lib/cpp/src/thrift/protocol/TBinaryProtocol.h
index a5b19e5..88b91e5 100644
--- a/lib/cpp/src/thrift/protocol/TBinaryProtocol.h
+++ b/lib/cpp/src/thrift/protocol/TBinaryProtocol.h
@@ -25,7 +25,9 @@
#include <boost/shared_ptr.hpp>
-namespace apache { namespace thrift { namespace protocol {
+namespace apache {
+namespace thrift {
+namespace protocol {
/**
* The default binary protocol for thrift. Writes all data in a very basic
@@ -33,37 +35,36 @@
*
*/
template <class Transport_>
-class TBinaryProtocolT
- : public TVirtualProtocol< TBinaryProtocolT<Transport_> > {
- protected:
+class TBinaryProtocolT : public TVirtualProtocol<TBinaryProtocolT<Transport_> > {
+protected:
static const int32_t VERSION_MASK = ((int32_t)0xffff0000);
static const int32_t VERSION_1 = ((int32_t)0x80010000);
// VERSION_2 (0x80020000) is taken by TDenseProtocol.
- public:
- TBinaryProtocolT(boost::shared_ptr<Transport_> trans) :
- TVirtualProtocol< TBinaryProtocolT<Transport_> >(trans),
- trans_(trans.get()),
- string_limit_(0),
- container_limit_(0),
- strict_read_(false),
- strict_write_(true),
- string_buf_(NULL),
- string_buf_size_(0) {}
+public:
+ TBinaryProtocolT(boost::shared_ptr<Transport_> trans)
+ : TVirtualProtocol<TBinaryProtocolT<Transport_> >(trans),
+ trans_(trans.get()),
+ string_limit_(0),
+ container_limit_(0),
+ strict_read_(false),
+ strict_write_(true),
+ string_buf_(NULL),
+ string_buf_size_(0) {}
TBinaryProtocolT(boost::shared_ptr<Transport_> trans,
int32_t string_limit,
int32_t container_limit,
bool strict_read,
- bool strict_write) :
- TVirtualProtocol< TBinaryProtocolT<Transport_> >(trans),
- trans_(trans.get()),
- string_limit_(string_limit),
- container_limit_(container_limit),
- strict_read_(strict_read),
- strict_write_(strict_write),
- string_buf_(NULL),
- string_buf_size_(0) {}
+ bool strict_write)
+ : TVirtualProtocol<TBinaryProtocolT<Transport_> >(trans),
+ trans_(trans.get()),
+ string_limit_(string_limit),
+ container_limit_(container_limit),
+ strict_read_(strict_read),
+ strict_write_(strict_write),
+ string_buf_(NULL),
+ string_buf_size_(0) {}
~TBinaryProtocolT() {
if (string_buf_ != NULL) {
@@ -72,13 +73,9 @@
}
}
- void setStringSizeLimit(int32_t string_limit) {
- string_limit_ = string_limit;
- }
+ void setStringSizeLimit(int32_t string_limit) { string_limit_ = string_limit; }
- void setContainerSizeLimit(int32_t container_limit) {
- container_limit_ = container_limit;
- }
+ void setContainerSizeLimit(int32_t container_limit) { container_limit_ = container_limit; }
void setStrict(bool strict_read, bool strict_write) {
strict_read_ = strict_read;
@@ -95,22 +92,17 @@
/*ol*/ uint32_t writeMessageEnd();
-
inline uint32_t writeStructBegin(const char* name);
inline uint32_t writeStructEnd();
- inline uint32_t writeFieldBegin(const char* name,
- const TType fieldType,
- const int16_t fieldId);
+ inline uint32_t writeFieldBegin(const char* name, const TType fieldType, const int16_t fieldId);
inline uint32_t writeFieldEnd();
inline uint32_t writeFieldStop();
- inline uint32_t writeMapBegin(const TType keyType,
- const TType valType,
- const uint32_t size);
+ inline uint32_t writeMapBegin(const TType keyType, const TType valType, const uint32_t size);
inline uint32_t writeMapEnd();
@@ -143,10 +135,7 @@
* Reading functions
*/
-
- /*ol*/ uint32_t readMessageBegin(std::string& name,
- TMessageType& messageType,
- int32_t& seqid);
+ /*ol*/ uint32_t readMessageBegin(std::string& name, TMessageType& messageType, int32_t& seqid);
/*ol*/ uint32_t readMessageEnd();
@@ -154,15 +143,11 @@
inline uint32_t readStructEnd();
- inline uint32_t readFieldBegin(std::string& name,
- TType& fieldType,
- int16_t& fieldId);
+ inline uint32_t readFieldBegin(std::string& name, TType& fieldType, int16_t& fieldId);
inline uint32_t readFieldEnd();
- inline uint32_t readMapBegin(TType& keyType,
- TType& valType,
- uint32_t& size);
+ inline uint32_t readMapBegin(TType& keyType, TType& valType, uint32_t& size);
inline uint32_t readMapEnd();
@@ -176,7 +161,7 @@
inline uint32_t readBool(bool& value);
// Provide the default readBool() implementation for std::vector<bool>
- using TVirtualProtocol< TBinaryProtocolT<Transport_> >::readBool;
+ using TVirtualProtocol<TBinaryProtocolT<Transport_> >::readBool;
inline uint32_t readByte(int8_t& byte);
@@ -188,13 +173,13 @@
inline uint32_t readDouble(double& dub);
- template<typename StrType>
+ template <typename StrType>
inline uint32_t readString(StrType& str);
inline uint32_t readBinary(std::string& str);
- protected:
- template<typename StrType>
+protected:
+ template <typename StrType>
uint32_t readStringBody(StrType& str, int32_t sz);
Transport_* trans_;
@@ -210,7 +195,6 @@
// avoid memory churn allocating memory on every string read
uint8_t* string_buf_;
int32_t string_buf_size_;
-
};
typedef TBinaryProtocolT<TTransport> TBinaryProtocol;
@@ -220,29 +204,24 @@
*/
template <class Transport_>
class TBinaryProtocolFactoryT : public TProtocolFactory {
- public:
- TBinaryProtocolFactoryT() :
- string_limit_(0),
- container_limit_(0),
- strict_read_(false),
- strict_write_(true) {}
+public:
+ TBinaryProtocolFactoryT()
+ : string_limit_(0), container_limit_(0), strict_read_(false), strict_write_(true) {}
- TBinaryProtocolFactoryT(int32_t string_limit, int32_t container_limit,
- bool strict_read, bool strict_write) :
- string_limit_(string_limit),
- container_limit_(container_limit),
- strict_read_(strict_read),
- strict_write_(strict_write) {}
+ TBinaryProtocolFactoryT(int32_t string_limit,
+ int32_t container_limit,
+ bool strict_read,
+ bool strict_write)
+ : string_limit_(string_limit),
+ container_limit_(container_limit),
+ strict_read_(strict_read),
+ strict_write_(strict_write) {}
virtual ~TBinaryProtocolFactoryT() {}
- void setStringSizeLimit(int32_t string_limit) {
- string_limit_ = string_limit;
- }
+ void setStringSizeLimit(int32_t string_limit) { string_limit_ = string_limit; }
- void setContainerSizeLimit(int32_t container_limit) {
- container_limit_ = container_limit;
- }
+ void setContainerSizeLimit(int32_t container_limit) { container_limit_ = container_limit; }
void setStrict(bool strict_read, bool strict_write) {
strict_read_ = strict_read;
@@ -250,32 +229,36 @@
}
boost::shared_ptr<TProtocol> getProtocol(boost::shared_ptr<TTransport> trans) {
- boost::shared_ptr<Transport_> specific_trans =
- boost::dynamic_pointer_cast<Transport_>(trans);
+ boost::shared_ptr<Transport_> specific_trans = boost::dynamic_pointer_cast<Transport_>(trans);
TProtocol* prot;
if (specific_trans) {
- prot = new TBinaryProtocolT<Transport_>(specific_trans, string_limit_,
- container_limit_, strict_read_,
+ prot = new TBinaryProtocolT<Transport_>(specific_trans,
+ string_limit_,
+ container_limit_,
+ strict_read_,
strict_write_);
} else {
- prot = new TBinaryProtocol(trans, string_limit_, container_limit_,
- strict_read_, strict_write_);
+ prot = new TBinaryProtocol(trans,
+ string_limit_,
+ container_limit_,
+ strict_read_,
+ strict_write_);
}
return boost::shared_ptr<TProtocol>(prot);
}
- private:
+private:
int32_t string_limit_;
int32_t container_limit_;
bool strict_read_;
bool strict_write_;
-
};
typedef TBinaryProtocolFactoryT<TTransport> TBinaryProtocolFactory;
-
-}}} // apache::thrift::protocol
+}
+}
+} // apache::thrift::protocol
#include <thrift/protocol/TBinaryProtocol.tcc>
diff --git a/lib/cpp/src/thrift/protocol/TBinaryProtocol.tcc b/lib/cpp/src/thrift/protocol/TBinaryProtocol.tcc
index 40226a5..0d72d8a 100644
--- a/lib/cpp/src/thrift/protocol/TBinaryProtocol.tcc
+++ b/lib/cpp/src/thrift/protocol/TBinaryProtocol.tcc
@@ -24,8 +24,9 @@
#include <limits>
-
-namespace apache { namespace thrift { namespace protocol {
+namespace apache {
+namespace thrift {
+namespace protocol {
template <class Transport_>
uint32_t TBinaryProtocolT<Transport_>::writeMessageBegin(const std::string& name,
@@ -54,7 +55,7 @@
template <class Transport_>
uint32_t TBinaryProtocolT<Transport_>::writeStructBegin(const char* name) {
- (void) name;
+ (void)name;
return 0;
}
@@ -67,7 +68,7 @@
uint32_t TBinaryProtocolT<Transport_>::writeFieldBegin(const char* name,
const TType fieldType,
const int16_t fieldId) {
- (void) name;
+ (void)name;
uint32_t wsize = 0;
wsize += writeByte((int8_t)fieldType);
wsize += writeI16(fieldId);
@@ -81,8 +82,7 @@
template <class Transport_>
uint32_t TBinaryProtocolT<Transport_>::writeFieldStop() {
- return
- writeByte((int8_t)T_STOP);
+ return writeByte((int8_t)T_STOP);
}
template <class Transport_>
@@ -102,10 +102,9 @@
}
template <class Transport_>
-uint32_t TBinaryProtocolT<Transport_>::writeListBegin(const TType elemType,
- const uint32_t size) {
+uint32_t TBinaryProtocolT<Transport_>::writeListBegin(const TType elemType, const uint32_t size) {
uint32_t wsize = 0;
- wsize += writeByte((int8_t) elemType);
+ wsize += writeByte((int8_t)elemType);
wsize += writeI32((int32_t)size);
return wsize;
}
@@ -116,8 +115,7 @@
}
template <class Transport_>
-uint32_t TBinaryProtocolT<Transport_>::writeSetBegin(const TType elemType,
- const uint32_t size) {
+uint32_t TBinaryProtocolT<Transport_>::writeSetBegin(const TType elemType, const uint32_t size) {
uint32_t wsize = 0;
wsize += writeByte((int8_t)elemType);
wsize += writeI32((int32_t)size);
@@ -131,7 +129,7 @@
template <class Transport_>
uint32_t TBinaryProtocolT<Transport_>::writeBool(const bool value) {
- uint8_t tmp = value ? 1 : 0;
+ uint8_t tmp = value ? 1 : 0;
this->trans_->write(&tmp, 1);
return 1;
}
@@ -174,11 +172,10 @@
return 8;
}
-
template <class Transport_>
-template<typename StrType>
+template <typename StrType>
uint32_t TBinaryProtocolT<Transport_>::writeString(const StrType& str) {
- if(str.size() > static_cast<size_t>((std::numeric_limits<int32_t>::max)()))
+ if (str.size() > static_cast<size_t>((std::numeric_limits<int32_t>::max)()))
throw TProtocolException(TProtocolException::SIZE_LIMIT);
uint32_t size = static_cast<uint32_t>(str.size());
uint32_t result = writeI32((int32_t)size);
@@ -216,7 +213,8 @@
result += readI32(seqid);
} else {
if (this->strict_read_) {
- throw TProtocolException(TProtocolException::BAD_VERSION, "No version identifier... old protocol client in strict mode?");
+ throw TProtocolException(TProtocolException::BAD_VERSION,
+ "No version identifier... old protocol client in strict mode?");
} else {
// Handle pre-versioned input
int8_t type;
@@ -249,7 +247,7 @@
uint32_t TBinaryProtocolT<Transport_>::readFieldBegin(std::string& name,
TType& fieldType,
int16_t& fieldId) {
- (void) name;
+ (void)name;
uint32_t result = 0;
int8_t type;
result += readByte(type);
@@ -294,8 +292,7 @@
}
template <class Transport_>
-uint32_t TBinaryProtocolT<Transport_>::readListBegin(TType& elemType,
- uint32_t& size) {
+uint32_t TBinaryProtocolT<Transport_>::readListBegin(TType& elemType, uint32_t& size) {
int8_t e;
uint32_t result = 0;
int32_t sizei;
@@ -317,8 +314,7 @@
}
template <class Transport_>
-uint32_t TBinaryProtocolT<Transport_>::readSetBegin(TType& elemType,
- uint32_t& size) {
+uint32_t TBinaryProtocolT<Transport_>::readSetBegin(TType& elemType, uint32_t& size) {
int8_t e;
uint32_t result = 0;
int32_t sizei;
@@ -404,7 +400,7 @@
}
template <class Transport_>
-template<typename StrType>
+template <typename StrType>
uint32_t TBinaryProtocolT<Transport_>::readString(StrType& str) {
uint32_t result;
int32_t size;
@@ -418,9 +414,8 @@
}
template <class Transport_>
-template<typename StrType>
-uint32_t TBinaryProtocolT<Transport_>::readStringBody(StrType& str,
- int32_t size) {
+template <typename StrType>
+uint32_t TBinaryProtocolT<Transport_>::readStringBody(StrType& str, int32_t size) {
uint32_t result = 0;
// Catch error cases
@@ -447,10 +442,11 @@
}
str.resize(size);
- this->trans_->readAll(reinterpret_cast<uint8_t *>(&str[0]), size);
+ this->trans_->readAll(reinterpret_cast<uint8_t*>(&str[0]), size);
return (uint32_t)size;
}
-
-}}} // apache::thrift::protocol
+}
+}
+} // apache::thrift::protocol
#endif // #ifndef _THRIFT_PROTOCOL_TBINARYPROTOCOL_TCC_
diff --git a/lib/cpp/src/thrift/protocol/TCompactProtocol.h b/lib/cpp/src/thrift/protocol/TCompactProtocol.h
index ce60b45..5b7ade2 100644
--- a/lib/cpp/src/thrift/protocol/TCompactProtocol.h
+++ b/lib/cpp/src/thrift/protocol/TCompactProtocol.h
@@ -25,21 +25,22 @@
#include <stack>
#include <boost/shared_ptr.hpp>
-namespace apache { namespace thrift { namespace protocol {
+namespace apache {
+namespace thrift {
+namespace protocol {
/**
* C++ Implementation of the Compact Protocol as described in THRIFT-110
*/
template <class Transport_>
-class TCompactProtocolT
- : public TVirtualProtocol< TCompactProtocolT<Transport_> > {
+class TCompactProtocolT : public TVirtualProtocol<TCompactProtocolT<Transport_> > {
- protected:
- static const int8_t PROTOCOL_ID = (int8_t)0x82u;
- static const int8_t VERSION_N = 1;
- static const int8_t VERSION_MASK = 0x1f; // 0001 1111
- static const int8_t TYPE_MASK = (int8_t)0xE0u; // 1110 0000
- static const int8_t TYPE_BITS = 0x07; // 0000 0111
+protected:
+ static const int8_t PROTOCOL_ID = (int8_t)0x82u;
+ static const int8_t VERSION_N = 1;
+ static const int8_t VERSION_MASK = 0x1f; // 0001 1111
+ static const int8_t TYPE_MASK = (int8_t)0xE0u; // 1110 0000
+ static const int8_t TYPE_BITS = 0x07; // 0000 0111
static const int32_t TYPE_SHIFT_AMOUNT = 5;
Transport_* trans_;
@@ -71,37 +72,34 @@
std::stack<int16_t> lastField_;
int16_t lastFieldId_;
- public:
- TCompactProtocolT(boost::shared_ptr<Transport_> trans) :
- TVirtualProtocol< TCompactProtocolT<Transport_> >(trans),
- trans_(trans.get()),
- lastFieldId_(0),
- string_limit_(0),
- string_buf_(NULL),
- string_buf_size_(0),
- container_limit_(0) {
+public:
+ TCompactProtocolT(boost::shared_ptr<Transport_> trans)
+ : TVirtualProtocol<TCompactProtocolT<Transport_> >(trans),
+ trans_(trans.get()),
+ lastFieldId_(0),
+ string_limit_(0),
+ string_buf_(NULL),
+ string_buf_size_(0),
+ container_limit_(0) {
booleanField_.name = NULL;
boolValue_.hasBoolValue = false;
}
TCompactProtocolT(boost::shared_ptr<Transport_> trans,
int32_t string_limit,
- int32_t container_limit) :
- TVirtualProtocol< TCompactProtocolT<Transport_> >(trans),
- trans_(trans.get()),
- lastFieldId_(0),
- string_limit_(string_limit),
- string_buf_(NULL),
- string_buf_size_(0),
- container_limit_(container_limit) {
+ int32_t container_limit)
+ : TVirtualProtocol<TCompactProtocolT<Transport_> >(trans),
+ trans_(trans.get()),
+ lastFieldId_(0),
+ string_limit_(string_limit),
+ string_buf_(NULL),
+ string_buf_size_(0),
+ container_limit_(container_limit) {
booleanField_.name = NULL;
boolValue_.hasBoolValue = false;
}
- ~TCompactProtocolT() {
- free(string_buf_);
- }
-
+ ~TCompactProtocolT() { free(string_buf_); }
/**
* Writing functions
@@ -115,21 +113,15 @@
uint32_t writeStructEnd();
- uint32_t writeFieldBegin(const char* name,
- const TType fieldType,
- const int16_t fieldId);
+ uint32_t writeFieldBegin(const char* name, const TType fieldType, const int16_t fieldId);
uint32_t writeFieldStop();
- uint32_t writeListBegin(const TType elemType,
- const uint32_t size);
+ uint32_t writeListBegin(const TType elemType, const uint32_t size);
- uint32_t writeSetBegin(const TType elemType,
- const uint32_t size);
+ uint32_t writeSetBegin(const TType elemType, const uint32_t size);
- virtual uint32_t writeMapBegin(const TType keyType,
- const TType valType,
- const uint32_t size);
+ virtual uint32_t writeMapBegin(const TType keyType, const TType valType, const uint32_t size);
uint32_t writeBool(const bool value);
@@ -157,7 +149,7 @@
uint32_t writeSetEnd() { return 0; }
uint32_t writeFieldEnd() { return 0; }
- protected:
+protected:
int32_t writeFieldBeginInternal(const char* name,
const TType fieldType,
const int16_t fieldId,
@@ -169,32 +161,24 @@
uint32_t i32ToZigzag(const int32_t n);
inline int8_t getCompactType(const TType ttype);
- public:
- uint32_t readMessageBegin(std::string& name,
- TMessageType& messageType,
- int32_t& seqid);
+public:
+ uint32_t readMessageBegin(std::string& name, TMessageType& messageType, int32_t& seqid);
uint32_t readStructBegin(std::string& name);
uint32_t readStructEnd();
- uint32_t readFieldBegin(std::string& name,
- TType& fieldType,
- int16_t& fieldId);
+ uint32_t readFieldBegin(std::string& name, TType& fieldType, int16_t& fieldId);
- uint32_t readMapBegin(TType& keyType,
- TType& valType,
- uint32_t& size);
+ uint32_t readMapBegin(TType& keyType, TType& valType, uint32_t& size);
- uint32_t readListBegin(TType& elemType,
- uint32_t& size);
+ uint32_t readListBegin(TType& elemType, uint32_t& size);
- uint32_t readSetBegin(TType& elemType,
- uint32_t& size);
+ uint32_t readSetBegin(TType& elemType, uint32_t& size);
uint32_t readBool(bool& value);
// Provide the default readBool() implementation for std::vector<bool>
- using TVirtualProtocol< TCompactProtocolT<Transport_> >::readBool;
+ using TVirtualProtocol<TCompactProtocolT<Transport_> >::readBool;
uint32_t readByte(int8_t& byte);
@@ -220,7 +204,7 @@
uint32_t readListEnd() { return 0; }
uint32_t readSetEnd() { return 0; }
- protected:
+protected:
uint32_t readVarint32(int32_t& i32);
uint32_t readVarint64(int64_t& i64);
int32_t zigzagToI32(uint32_t n);
@@ -242,32 +226,23 @@
*/
template <class Transport_>
class TCompactProtocolFactoryT : public TProtocolFactory {
- public:
- TCompactProtocolFactoryT() :
- string_limit_(0),
- container_limit_(0) {}
+public:
+ TCompactProtocolFactoryT() : string_limit_(0), container_limit_(0) {}
- TCompactProtocolFactoryT(int32_t string_limit, int32_t container_limit) :
- string_limit_(string_limit),
- container_limit_(container_limit) {}
+ TCompactProtocolFactoryT(int32_t string_limit, int32_t container_limit)
+ : string_limit_(string_limit), container_limit_(container_limit) {}
virtual ~TCompactProtocolFactoryT() {}
- void setStringSizeLimit(int32_t string_limit) {
- string_limit_ = string_limit;
- }
+ void setStringSizeLimit(int32_t string_limit) { string_limit_ = string_limit; }
- void setContainerSizeLimit(int32_t container_limit) {
- container_limit_ = container_limit;
- }
+ void setContainerSizeLimit(int32_t container_limit) { container_limit_ = container_limit; }
boost::shared_ptr<TProtocol> getProtocol(boost::shared_ptr<TTransport> trans) {
- boost::shared_ptr<Transport_> specific_trans =
- boost::dynamic_pointer_cast<Transport_>(trans);
+ boost::shared_ptr<Transport_> specific_trans = boost::dynamic_pointer_cast<Transport_>(trans);
TProtocol* prot;
if (specific_trans) {
- prot = new TCompactProtocolT<Transport_>(specific_trans, string_limit_,
- container_limit_);
+ prot = new TCompactProtocolT<Transport_>(specific_trans, string_limit_, container_limit_);
} else {
prot = new TCompactProtocol(trans, string_limit_, container_limit_);
}
@@ -275,15 +250,15 @@
return boost::shared_ptr<TProtocol>(prot);
}
- private:
+private:
int32_t string_limit_;
int32_t container_limit_;
-
};
typedef TCompactProtocolFactoryT<TTransport> TCompactProtocolFactory;
-
-}}} // apache::thrift::protocol
+}
+}
+} // apache::thrift::protocol
#include <thrift/protocol/TCompactProtocol.tcc>
diff --git a/lib/cpp/src/thrift/protocol/TDebugProtocol.cpp b/lib/cpp/src/thrift/protocol/TDebugProtocol.cpp
index 63ea14d..4687e82 100644
--- a/lib/cpp/src/thrift/protocol/TDebugProtocol.cpp
+++ b/lib/cpp/src/thrift/protocol/TDebugProtocol.cpp
@@ -28,7 +28,6 @@
using std::string;
-
static string byte_to_hex(const uint8_t byte) {
char buf[3];
int ret = std::sprintf(buf, "%02x", (int)byte);
@@ -38,28 +37,46 @@
return buf;
}
-
-namespace apache { namespace thrift { namespace protocol {
+namespace apache {
+namespace thrift {
+namespace protocol {
string TDebugProtocol::fieldTypeName(TType type) {
switch (type) {
- case T_STOP : return "stop" ;
- case T_VOID : return "void" ;
- case T_BOOL : return "bool" ;
- case T_BYTE : return "byte" ;
- case T_I16 : return "i16" ;
- case T_I32 : return "i32" ;
- case T_U64 : return "u64" ;
- case T_I64 : return "i64" ;
- case T_DOUBLE : return "double" ;
- case T_STRING : return "string" ;
- case T_STRUCT : return "struct" ;
- case T_MAP : return "map" ;
- case T_SET : return "set" ;
- case T_LIST : return "list" ;
- case T_UTF8 : return "utf8" ;
- case T_UTF16 : return "utf16" ;
- default: return "unknown";
+ case T_STOP:
+ return "stop";
+ case T_VOID:
+ return "void";
+ case T_BOOL:
+ return "bool";
+ case T_BYTE:
+ return "byte";
+ case T_I16:
+ return "i16";
+ case T_I32:
+ return "i32";
+ case T_U64:
+ return "u64";
+ case T_I64:
+ return "i64";
+ case T_DOUBLE:
+ return "double";
+ case T_STRING:
+ return "string";
+ case T_STRUCT:
+ return "struct";
+ case T_MAP:
+ return "map";
+ case T_SET:
+ return "set";
+ case T_LIST:
+ return "list";
+ case T_UTF8:
+ return "utf8";
+ case T_UTF16:
+ return "utf16";
+ default:
+ return "unknown";
}
}
@@ -75,19 +92,19 @@
}
uint32_t TDebugProtocol::writePlain(const string& str) {
- if(str.length() > (std::numeric_limits<uint32_t>::max)())
+ if (str.length() > (std::numeric_limits<uint32_t>::max)())
throw TProtocolException(TProtocolException::SIZE_LIMIT);
trans_->write((uint8_t*)str.data(), static_cast<uint32_t>(str.length()));
return static_cast<uint32_t>(str.length());
}
uint32_t TDebugProtocol::writeIndented(const string& str) {
- if(str.length() > (std::numeric_limits<uint32_t>::max)())
+ if (str.length() > (std::numeric_limits<uint32_t>::max)())
throw TProtocolException(TProtocolException::SIZE_LIMIT);
- if(indent_str_.length() > (std::numeric_limits<uint32_t>::max)())
+ if (indent_str_.length() > (std::numeric_limits<uint32_t>::max)())
throw TProtocolException(TProtocolException::SIZE_LIMIT);
uint64_t total_len = indent_str_.length() + str.length();
- if(total_len > (std::numeric_limits<uint32_t>::max)())
+ if (total_len > (std::numeric_limits<uint32_t>::max)())
throw TProtocolException(TProtocolException::SIZE_LIMIT);
trans_->write((uint8_t*)indent_str_.data(), static_cast<uint32_t>(indent_str_.length()));
trans_->write((uint8_t*)str.data(), static_cast<uint32_t>(str.length()));
@@ -98,52 +115,51 @@
uint32_t size;
switch (write_state_.back()) {
- case UNINIT:
- // XXX figure out what to do here.
- //throw TProtocolException(TProtocolException::INVALID_DATA);
- //return writeIndented(str);
- return 0;
- case STRUCT:
- return 0;
- case SET:
- return writeIndented("");
- case MAP_KEY:
- return writeIndented("");
- case MAP_VALUE:
- return writePlain(" -> ");
- case LIST:
- size = writeIndented(
- "[" + boost::lexical_cast<string>(list_idx_.back()) + "] = ");
- list_idx_.back()++;
- return size;
- default:
- throw std::logic_error("Invalid enum value.");
+ case UNINIT:
+ // XXX figure out what to do here.
+ // throw TProtocolException(TProtocolException::INVALID_DATA);
+ // return writeIndented(str);
+ return 0;
+ case STRUCT:
+ return 0;
+ case SET:
+ return writeIndented("");
+ case MAP_KEY:
+ return writeIndented("");
+ case MAP_VALUE:
+ return writePlain(" -> ");
+ case LIST:
+ size = writeIndented("[" + boost::lexical_cast<string>(list_idx_.back()) + "] = ");
+ list_idx_.back()++;
+ return size;
+ default:
+ throw std::logic_error("Invalid enum value.");
}
}
uint32_t TDebugProtocol::endItem() {
- //uint32_t size;
+ // uint32_t size;
switch (write_state_.back()) {
- case UNINIT:
- // XXX figure out what to do here.
- //throw TProtocolException(TProtocolException::INVALID_DATA);
- //return writeIndented(str);
- return 0;
- case STRUCT:
- return writePlain(",\n");
- case SET:
- return writePlain(",\n");
- case MAP_KEY:
- write_state_.back() = MAP_VALUE;
- return 0;
- case MAP_VALUE:
- write_state_.back() = MAP_KEY;
- return writePlain(",\n");
- case LIST:
- return writePlain(",\n");
- default:
- throw std::logic_error("Invalid enum value.");
+ case UNINIT:
+ // XXX figure out what to do here.
+ // throw TProtocolException(TProtocolException::INVALID_DATA);
+ // return writeIndented(str);
+ return 0;
+ case STRUCT:
+ return writePlain(",\n");
+ case SET:
+ return writePlain(",\n");
+ case MAP_KEY:
+ write_state_.back() = MAP_VALUE;
+ return 0;
+ case MAP_VALUE:
+ write_state_.back() = MAP_KEY;
+ return writePlain(",\n");
+ case LIST:
+ return writePlain(",\n");
+ default:
+ throw std::logic_error("Invalid enum value.");
}
}
@@ -158,13 +174,21 @@
uint32_t TDebugProtocol::writeMessageBegin(const std::string& name,
const TMessageType messageType,
const int32_t seqid) {
- (void) seqid;
+ (void)seqid;
string mtype;
switch (messageType) {
- case T_CALL : mtype = "call" ; break;
- case T_REPLY : mtype = "reply" ; break;
- case T_EXCEPTION : mtype = "exn" ; break;
- case T_ONEWAY : mtype = "oneway" ; break;
+ case T_CALL:
+ mtype = "call";
+ break;
+ case T_REPLY:
+ mtype = "reply";
+ break;
+ case T_EXCEPTION:
+ mtype = "exn";
+ break;
+ case T_ONEWAY:
+ mtype = "oneway";
+ break;
}
uint32_t size = writeIndented("(" + mtype + ") " + name + "(");
@@ -200,12 +224,10 @@
const int16_t fieldId) {
// sprintf(id_str, "%02d", fieldId);
string id_str = boost::lexical_cast<string>(fieldId);
- if (id_str.length() == 1) id_str = '0' + id_str;
+ if (id_str.length() == 1)
+ id_str = '0' + id_str;
- return writeIndented(
- id_str + ": " +
- name + " (" +
- fieldTypeName(fieldType) + ") = ");
+ return writeIndented(id_str + ": " + name + " (" + fieldTypeName(fieldType) + ") = ");
}
uint32_t TDebugProtocol::writeFieldEnd() {
@@ -215,7 +237,7 @@
uint32_t TDebugProtocol::writeFieldStop() {
return 0;
- //writeIndented("***STOP***\n");
+ // writeIndented("***STOP***\n");
}
uint32_t TDebugProtocol::writeMapBegin(const TType keyType,
@@ -241,8 +263,7 @@
return size;
}
-uint32_t TDebugProtocol::writeListBegin(const TType elemType,
- const uint32_t size) {
+uint32_t TDebugProtocol::writeListBegin(const TType elemType, const uint32_t size) {
// TODO(dreiss): Optimize short arrays.
uint32_t bsize = 0;
bsize += startItem();
@@ -265,8 +286,7 @@
return size;
}
-uint32_t TDebugProtocol::writeSetBegin(const TType elemType,
- const uint32_t size) {
+uint32_t TDebugProtocol::writeSetBegin(const TType elemType, const uint32_t size) {
// TODO(dreiss): Optimize short sets.
uint32_t bsize = 0;
bsize += startItem();
@@ -311,7 +331,6 @@
return writeItem(boost::lexical_cast<string>(dub));
}
-
uint32_t TDebugProtocol::writeString(const string& str) {
// XXX Raw/UTF-8?
@@ -332,16 +351,30 @@
output += *it;
} else {
switch (*it) {
- case '\a': output += "\\a"; break;
- case '\b': output += "\\b"; break;
- case '\f': output += "\\f"; break;
- case '\n': output += "\\n"; break;
- case '\r': output += "\\r"; break;
- case '\t': output += "\\t"; break;
- case '\v': output += "\\v"; break;
- default:
- output += "\\x";
- output += byte_to_hex(*it);
+ case '\a':
+ output += "\\a";
+ break;
+ case '\b':
+ output += "\\b";
+ break;
+ case '\f':
+ output += "\\f";
+ break;
+ case '\n':
+ output += "\\n";
+ break;
+ case '\r':
+ output += "\\r";
+ break;
+ case '\t':
+ output += "\\t";
+ break;
+ case '\v':
+ output += "\\v";
+ break;
+ default:
+ output += "\\x";
+ output += byte_to_hex(*it);
}
}
}
@@ -354,5 +387,6 @@
// XXX Hex?
return TDebugProtocol::writeString(str);
}
-
-}}} // apache::thrift::protocol
+}
+}
+} // apache::thrift::protocol
diff --git a/lib/cpp/src/thrift/protocol/TDebugProtocol.h b/lib/cpp/src/thrift/protocol/TDebugProtocol.h
index f85e691..cc93230 100644
--- a/lib/cpp/src/thrift/protocol/TDebugProtocol.h
+++ b/lib/cpp/src/thrift/protocol/TDebugProtocol.h
@@ -24,7 +24,9 @@
#include <boost/shared_ptr.hpp>
-namespace apache { namespace thrift { namespace protocol {
+namespace apache {
+namespace thrift {
+namespace protocol {
/*
@@ -39,44 +41,30 @@
*/
-
/**
* Protocol that prints the payload in a nice human-readable format.
* Reading from this protocol is not supported.
*
*/
class TDebugProtocol : public TVirtualProtocol<TDebugProtocol> {
- private:
- enum write_state_t
- { UNINIT
- , STRUCT
- , LIST
- , SET
- , MAP_KEY
- , MAP_VALUE
- };
+private:
+ enum write_state_t { UNINIT, STRUCT, LIST, SET, MAP_KEY, MAP_VALUE };
- public:
+public:
TDebugProtocol(boost::shared_ptr<TTransport> trans)
- : TVirtualProtocol<TDebugProtocol>(trans)
- , trans_(trans.get())
- , string_limit_(DEFAULT_STRING_LIMIT)
- , string_prefix_size_(DEFAULT_STRING_PREFIX_SIZE)
- {
+ : TVirtualProtocol<TDebugProtocol>(trans),
+ trans_(trans.get()),
+ string_limit_(DEFAULT_STRING_LIMIT),
+ string_prefix_size_(DEFAULT_STRING_PREFIX_SIZE) {
write_state_.push_back(UNINIT);
}
static const int32_t DEFAULT_STRING_LIMIT = 256;
static const int32_t DEFAULT_STRING_PREFIX_SIZE = 16;
- void setStringSizeLimit(int32_t string_limit) {
- string_limit_ = string_limit;
- }
+ void setStringSizeLimit(int32_t string_limit) { string_limit_ = string_limit; }
- void setStringPrefixSize(int32_t string_prefix_size) {
- string_prefix_size_ = string_prefix_size;
- }
-
+ void setStringPrefixSize(int32_t string_prefix_size) { string_prefix_size_ = string_prefix_size; }
uint32_t writeMessageBegin(const std::string& name,
const TMessageType messageType,
@@ -84,32 +72,25 @@
uint32_t writeMessageEnd();
-
uint32_t writeStructBegin(const char* name);
uint32_t writeStructEnd();
- uint32_t writeFieldBegin(const char* name,
- const TType fieldType,
- const int16_t fieldId);
+ uint32_t writeFieldBegin(const char* name, const TType fieldType, const int16_t fieldId);
uint32_t writeFieldEnd();
uint32_t writeFieldStop();
- uint32_t writeMapBegin(const TType keyType,
- const TType valType,
- const uint32_t size);
+ uint32_t writeMapBegin(const TType keyType, const TType valType, const uint32_t size);
uint32_t writeMapEnd();
- uint32_t writeListBegin(const TType elemType,
- const uint32_t size);
+ uint32_t writeListBegin(const TType elemType, const uint32_t size);
uint32_t writeListEnd();
- uint32_t writeSetBegin(const TType elemType,
- const uint32_t size);
+ uint32_t writeSetBegin(const TType elemType, const uint32_t size);
uint32_t writeSetEnd();
@@ -129,8 +110,7 @@
uint32_t writeBinary(const std::string& str);
-
- private:
+private:
void indentUp();
void indentDown();
uint32_t writePlain(const std::string& str);
@@ -157,25 +137,25 @@
* Constructs debug protocol handlers
*/
class TDebugProtocolFactory : public TProtocolFactory {
- public:
+public:
TDebugProtocolFactory() {}
virtual ~TDebugProtocolFactory() {}
boost::shared_ptr<TProtocol> getProtocol(boost::shared_ptr<TTransport> trans) {
return boost::shared_ptr<TProtocol>(new TDebugProtocol(trans));
}
-
};
-
-}}} // apache::thrift::protocol
-
+}
+}
+} // apache::thrift::protocol
// TODO(dreiss): Move (part of) ThriftDebugString into a .cpp file and remove this.
#include <thrift/transport/TBufferTransports.h>
-namespace apache { namespace thrift {
+namespace apache {
+namespace thrift {
-template<typename ThriftStruct>
+template <typename ThriftStruct>
std::string ThriftDebugString(const ThriftStruct& ts) {
using namespace apache::thrift::transport;
using namespace apache::thrift::protocol;
@@ -218,10 +198,7 @@
return std::string((char*)buf, (unsigned int)size);
}
#endif // 0
-
-}} // apache::thrift
-
+}
+} // apache::thrift
#endif // #ifndef _THRIFT_PROTOCOL_TDEBUGPROTOCOL_H_
-
-
diff --git a/lib/cpp/src/thrift/protocol/TDenseProtocol.cpp b/lib/cpp/src/thrift/protocol/TDenseProtocol.cpp
index 4fbfc13..d6644b7 100644
--- a/lib/cpp/src/thrift/protocol/TDenseProtocol.cpp
+++ b/lib/cpp/src/thrift/protocol/TDenseProtocol.cpp
@@ -117,24 +117,24 @@
#define UNLIKELY(val) (val)
#endif
-namespace apache { namespace thrift { namespace protocol {
+namespace apache {
+namespace thrift {
+namespace protocol {
-const int TDenseProtocol::FP_PREFIX_LEN =
- apache::thrift::reflection::local::FP_PREFIX_LEN;
+const int TDenseProtocol::FP_PREFIX_LEN = apache::thrift::reflection::local::FP_PREFIX_LEN;
// Top TypeSpec. TypeSpec of the structure being encoded.
-#define TTS (ts_stack_.back()) // type = TypeSpec*
+#define TTS (ts_stack_.back()) // type = TypeSpec*
// InDeX. Index into TTS of the current/next field to encode.
-#define IDX (idx_stack_.back()) // type = int
+#define IDX (idx_stack_.back()) // type = int
// Field TypeSpec. TypeSpec of the current/next field to encode.
-#define FTS (TTS->tstruct.specs[IDX]) // type = TypeSpec*
+#define FTS (TTS->tstruct.specs[IDX]) // type = TypeSpec*
// Field MeTa. Metadata of the current/next field to encode.
-#define FMT (TTS->tstruct.metas[IDX]) // type = FieldMeta
+#define FMT (TTS->tstruct.metas[IDX]) // type = FieldMeta
// SubType 1/2. TypeSpec of the first/second subtype of this container.
#define ST1 (TTS->tcontainer.subtype1)
#define ST2 (TTS->tcontainer.subtype2)
-
/**
* Checks that @c ttype is indeed the ttype that we should be writing,
* according to our typespec. Aborts if the test fails and debugging in on.
@@ -161,30 +161,28 @@
switch (TTS->ttype) {
- case T_STRUCT:
- assert(old_tts == FTS);
- break;
+ case T_STRUCT:
+ assert(old_tts == FTS);
+ break;
- case T_LIST:
- case T_SET:
- assert(old_tts == ST1);
- ts_stack_.push_back(old_tts);
- break;
+ case T_LIST:
+ case T_SET:
+ assert(old_tts == ST1);
+ ts_stack_.push_back(old_tts);
+ break;
- case T_MAP:
- assert(old_tts == (mkv_stack_.back() ? ST1 : ST2));
- mkv_stack_.back() = !mkv_stack_.back();
- ts_stack_.push_back(mkv_stack_.back() ? ST1 : ST2);
- break;
+ case T_MAP:
+ assert(old_tts == (mkv_stack_.back() ? ST1 : ST2));
+ mkv_stack_.back() = !mkv_stack_.back();
+ ts_stack_.push_back(mkv_stack_.back() ? ST1 : ST2);
+ break;
- default:
- assert(!"Invalid TType in stateTransition.");
- break;
-
+ default:
+ assert(!"Invalid TType in stateTransition.");
+ break;
}
}
-
/*
* Variable-length quantity functions.
*/
@@ -192,7 +190,7 @@
inline uint32_t TDenseProtocol::vlqRead(uint64_t& vlq) {
uint32_t used = 0;
uint64_t val = 0;
- uint8_t buf[10]; // 64 bits / (7 bits/byte) = 10 bytes.
+ uint8_t buf[10]; // 64 bits / (7 bits/byte) = 10 bytes.
uint32_t buf_size = sizeof(buf);
const uint8_t* borrowed = trans_->borrow(buf, &buf_size);
@@ -210,7 +208,8 @@
// Have to check for invalid data so we don't crash.
if (UNLIKELY(used == sizeof(buf))) {
resetState();
- throw TProtocolException(TProtocolException::INVALID_DATA, "Variable-length int over 10 bytes.");
+ throw TProtocolException(TProtocolException::INVALID_DATA,
+ "Variable-length int over 10 bytes.");
}
}
}
@@ -228,14 +227,15 @@
// Might as well check for invalid data on the slow path too.
if (UNLIKELY(used >= sizeof(buf))) {
resetState();
- throw TProtocolException(TProtocolException::INVALID_DATA, "Variable-length int over 10 bytes.");
+ throw TProtocolException(TProtocolException::INVALID_DATA,
+ "Variable-length int over 10 bytes.");
}
}
}
}
inline uint32_t TDenseProtocol::vlqWrite(uint64_t vlq) {
- uint8_t buf[10]; // 64 bits / (7 bits/byte) = 10 bytes.
+ uint8_t buf[10]; // 64 bits / (7 bits/byte) = 10 bytes.
int32_t pos = sizeof(buf) - 1;
// Write the thing from back to front.
@@ -253,12 +253,10 @@
// Back up one step before writing.
pos++;
- trans_->write(buf+pos, static_cast<uint32_t>(sizeof(buf) - pos));
+ trans_->write(buf + pos, static_cast<uint32_t>(sizeof(buf) - pos));
return static_cast<uint32_t>(sizeof(buf) - pos);
}
-
-
/*
* Writing functions.
*/
@@ -281,7 +279,7 @@
}
uint32_t TDenseProtocol::writeStructBegin(const char* name) {
- (void) name;
+ (void)name;
uint32_t xfer = 0;
// The TypeSpec stack should be empty if this is the top-level read/write.
@@ -315,7 +313,7 @@
uint32_t TDenseProtocol::writeFieldBegin(const char* name,
const TType fieldType,
const int16_t fieldId) {
- (void) name;
+ (void)name;
uint32_t xfer = 0;
// Skip over optional fields.
@@ -380,8 +378,7 @@
return 0;
}
-uint32_t TDenseProtocol::writeListBegin(const TType elemType,
- const uint32_t size) {
+uint32_t TDenseProtocol::writeListBegin(const TType elemType, const uint32_t size) {
checkTType(T_LIST);
assert(elemType == ST1->ttype);
@@ -396,8 +393,7 @@
return 0;
}
-uint32_t TDenseProtocol::writeSetBegin(const TType elemType,
- const uint32_t size) {
+uint32_t TDenseProtocol::writeSetBegin(const TType elemType, const uint32_t size) {
checkTType(T_SET);
assert(elemType == ST1->ttype);
@@ -463,7 +459,7 @@
}
uint32_t TDenseProtocol::subWriteString(const std::string& str) {
- if(str.size() > static_cast<size_t>((std::numeric_limits<int32_t>::max)()))
+ if (str.size() > static_cast<size_t>((std::numeric_limits<int32_t>::max)()))
throw TProtocolException(TProtocolException::SIZE_LIMIT);
uint32_t size = static_cast<uint32_t>(str.size());
uint32_t xfer = subWriteI32((int32_t)size);
@@ -473,8 +469,6 @@
return xfer + size;
}
-
-
/*
* Reading functions
*
@@ -501,7 +495,8 @@
xfer += subReadString(name);
xfer += subReadI32(seqid);
} else {
- throw TProtocolException(TProtocolException::BAD_VERSION, "No version identifier... old protocol client in strict mode?");
+ throw TProtocolException(TProtocolException::BAD_VERSION,
+ "No version identifier... old protocol client in strict mode?");
}
return xfer;
}
@@ -511,7 +506,7 @@
}
uint32_t TDenseProtocol::readStructBegin(string& name) {
- (void) name;
+ (void)name;
uint32_t xfer = 0;
if (ts_stack_.empty()) {
@@ -530,7 +525,7 @@
if (std::memcmp(buf, type_spec_->fp_prefix, FP_PREFIX_LEN) != 0) {
resetState();
throw TProtocolException(TProtocolException::INVALID_DATA,
- "Fingerprint in data does not match type_spec.");
+ "Fingerprint in data does not match type_spec.");
}
}
}
@@ -546,10 +541,8 @@
return 0;
}
-uint32_t TDenseProtocol::readFieldBegin(string& name,
- TType& fieldType,
- int16_t& fieldId) {
- (void) name;
+uint32_t TDenseProtocol::readFieldBegin(string& name, TType& fieldType, int16_t& fieldId) {
+ (void)name;
uint32_t xfer = 0;
// For optional fields, check to see if they are there.
@@ -565,7 +558,7 @@
// Once we hit a mandatory field, or an optional field that is present,
// we know that FMT and FTS point to the appropriate field.
- fieldId = FMT.tag;
+ fieldId = FMT.tag;
fieldType = FTS->ttype;
// Normally, we push the TypeSpec that we are about to read,
@@ -581,9 +574,7 @@
return 0;
}
-uint32_t TDenseProtocol::readMapBegin(TType& keyType,
- TType& valType,
- uint32_t& size) {
+uint32_t TDenseProtocol::readMapBegin(TType& keyType, TType& valType, uint32_t& size) {
checkTType(T_MAP);
uint32_t xfer = 0;
@@ -614,8 +605,7 @@
return 0;
}
-uint32_t TDenseProtocol::readListBegin(TType& elemType,
- uint32_t& size) {
+uint32_t TDenseProtocol::readListBegin(TType& elemType, uint32_t& size) {
checkTType(T_LIST);
uint32_t xfer = 0;
@@ -643,8 +633,7 @@
return 0;
}
-uint32_t TDenseProtocol::readSetBegin(TType& elemType,
- uint32_t& size) {
+uint32_t TDenseProtocol::readSetBegin(TType& elemType, uint32_t& size) {
checkTType(T_SET);
uint32_t xfer = 0;
@@ -692,8 +681,7 @@
int64_t val = (int64_t)u64;
if (UNLIKELY(val > INT16_MAX || val < INT16_MIN)) {
resetState();
- throw TProtocolException(TProtocolException::INVALID_DATA,
- "i16 out of range.");
+ throw TProtocolException(TProtocolException::INVALID_DATA, "i16 out of range.");
}
i16 = (int16_t)val;
return rv;
@@ -707,8 +695,7 @@
int64_t val = (int64_t)u64;
if (UNLIKELY(val > INT32_MAX || val < INT32_MIN)) {
resetState();
- throw TProtocolException(TProtocolException::INVALID_DATA,
- "i32 out of range.");
+ throw TProtocolException(TProtocolException::INVALID_DATA, "i32 out of range.");
}
i32 = (int32_t)val;
return rv;
@@ -722,8 +709,7 @@
int64_t val = (int64_t)u64;
if (UNLIKELY(val > INT64_MAX || val < INT64_MIN)) {
resetState();
- throw TProtocolException(TProtocolException::INVALID_DATA,
- "i64 out of range.");
+ throw TProtocolException(TProtocolException::INVALID_DATA, "i64 out of range.");
}
i64 = (int64_t)val;
return rv;
@@ -751,8 +737,7 @@
int64_t val = (int64_t)u64;
if (UNLIKELY(val > INT32_MAX || val < INT32_MIN)) {
resetState();
- throw TProtocolException(TProtocolException::INVALID_DATA,
- "i32 out of range.");
+ throw TProtocolException(TProtocolException::INVALID_DATA, "i32 out of range.");
}
i32 = (int32_t)val;
return rv;
@@ -764,5 +749,6 @@
xfer = subReadI32(size);
return xfer + readStringBody(str, size);
}
-
-}}} // apache::thrift::protocol
+}
+}
+} // apache::thrift::protocol
diff --git a/lib/cpp/src/thrift/protocol/TDenseProtocol.h b/lib/cpp/src/thrift/protocol/TDenseProtocol.h
index 4808d79..e7f2cd2 100644
--- a/lib/cpp/src/thrift/protocol/TDenseProtocol.h
+++ b/lib/cpp/src/thrift/protocol/TDenseProtocol.h
@@ -22,7 +22,9 @@
#include <thrift/protocol/TBinaryProtocol.h>
-namespace apache { namespace thrift { namespace protocol {
+namespace apache {
+namespace thrift {
+namespace protocol {
/**
* !!!WARNING!!!
@@ -56,14 +58,13 @@
* methods within our versions.
*
*/
-class TDenseProtocol
- : public TVirtualProtocol<TDenseProtocol, TBinaryProtocol> {
- protected:
+class TDenseProtocol : public TVirtualProtocol<TDenseProtocol, TBinaryProtocol> {
+protected:
static const int32_t VERSION_MASK = ((int32_t)0xffff0000);
// VERSION_1 (0x80010000) is taken by TBinaryProtocol.
static const int32_t VERSION_2 = ((int32_t)0x80020000);
- public:
+public:
typedef apache::thrift::reflection::local::TypeSpec TypeSpec;
static const int FP_PREFIX_LEN;
@@ -71,20 +72,13 @@
* @param tran The transport to use.
* @param type_spec The TypeSpec of the structures using this protocol.
*/
- TDenseProtocol(boost::shared_ptr<TTransport> trans,
- TypeSpec* type_spec = NULL) :
- TVirtualProtocol<TDenseProtocol, TBinaryProtocol>(trans),
- type_spec_(type_spec),
- standalone_(true)
- {}
+ TDenseProtocol(boost::shared_ptr<TTransport> trans, TypeSpec* type_spec = NULL)
+ : TVirtualProtocol<TDenseProtocol, TBinaryProtocol>(trans),
+ type_spec_(type_spec),
+ standalone_(true) {}
- void setTypeSpec(TypeSpec* type_spec) {
- type_spec_ = type_spec;
- }
- TypeSpec* getTypeSpec() {
- return type_spec_;
- }
-
+ void setTypeSpec(TypeSpec* type_spec) { type_spec_ = type_spec; }
+ TypeSpec* getTypeSpec() { return type_spec_; }
/*
* Writing functions.
@@ -96,22 +90,17 @@
uint32_t writeMessageEnd();
-
uint32_t writeStructBegin(const char* name);
uint32_t writeStructEnd();
- uint32_t writeFieldBegin(const char* name,
- const TType fieldType,
- const int16_t fieldId);
+ uint32_t writeFieldBegin(const char* name, const TType fieldType, const int16_t fieldId);
uint32_t writeFieldEnd();
uint32_t writeFieldStop();
- uint32_t writeMapBegin(const TType keyType,
- const TType valType,
- const uint32_t size);
+ uint32_t writeMapBegin(const TType keyType, const TType valType, const uint32_t size);
uint32_t writeMapEnd();
@@ -139,7 +128,6 @@
uint32_t writeBinary(const std::string& str);
-
/*
* Helper writing functions (don't do state transitions).
*/
@@ -147,18 +135,13 @@
inline uint32_t subWriteString(const std::string& str);
- uint32_t subWriteBool(const bool value) {
- return TBinaryProtocol::writeBool(value);
- }
-
+ uint32_t subWriteBool(const bool value) { return TBinaryProtocol::writeBool(value); }
/*
* Reading functions
*/
- uint32_t readMessageBegin(std::string& name,
- TMessageType& messageType,
- int32_t& seqid);
+ uint32_t readMessageBegin(std::string& name, TMessageType& messageType, int32_t& seqid);
uint32_t readMessageEnd();
@@ -166,25 +149,19 @@
uint32_t readStructEnd();
- uint32_t readFieldBegin(std::string& name,
- TType& fieldType,
- int16_t& fieldId);
+ uint32_t readFieldBegin(std::string& name, TType& fieldType, int16_t& fieldId);
uint32_t readFieldEnd();
- uint32_t readMapBegin(TType& keyType,
- TType& valType,
- uint32_t& size);
+ uint32_t readMapBegin(TType& keyType, TType& valType, uint32_t& size);
uint32_t readMapEnd();
- uint32_t readListBegin(TType& elemType,
- uint32_t& size);
+ uint32_t readListBegin(TType& elemType, uint32_t& size);
uint32_t readListEnd();
- uint32_t readSetBegin(TType& elemType,
- uint32_t& size);
+ uint32_t readSetBegin(TType& elemType, uint32_t& size);
uint32_t readSetEnd();
@@ -213,13 +190,9 @@
inline uint32_t subReadString(std::string& str);
- uint32_t subReadBool(bool& value) {
- return TBinaryProtocol::readBool(value);
- }
+ uint32_t subReadBool(bool& value) { return TBinaryProtocol::readBool(value); }
-
- private:
-
+private:
// Implementation functions, documented in the .cpp.
inline void checkTType(const TType ttype);
inline void stateTransition();
@@ -240,15 +213,16 @@
// for standalone protocol objects.
TypeSpec* type_spec_;
- std::vector<TypeSpec*> ts_stack_; // TypeSpec stack.
- std::vector<int> idx_stack_; // InDeX stack.
- std::vector<bool> mkv_stack_; // Map Key/Vlue stack.
- // True = key, False = value.
+ std::vector<TypeSpec*> ts_stack_; // TypeSpec stack.
+ std::vector<int> idx_stack_; // InDeX stack.
+ std::vector<bool> mkv_stack_; // Map Key/Vlue stack.
+ // True = key, False = value.
// True iff this is a standalone instance (no RPC).
bool standalone_;
};
-
-}}} // apache::thrift::protocol
+}
+}
+} // apache::thrift::protocol
#endif // #ifndef _THRIFT_PROTOCOL_TDENSEPROTOCOL_H_
diff --git a/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp b/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp
index a0cc8e2..ca450f4 100644
--- a/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp
+++ b/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp
@@ -26,8 +26,9 @@
using namespace apache::thrift::transport;
-namespace apache { namespace thrift { namespace protocol {
-
+namespace apache {
+namespace thrift {
+namespace protocol {
// Static data
@@ -63,7 +64,7 @@
static const std::string kTypeNameList("lst");
static const std::string kTypeNameSet("set");
-static const std::string &getTypeNameForTypeID(TType typeID) {
+static const std::string& getTypeNameForTypeID(TType typeID) {
switch (typeID) {
case T_BOOL:
return kTypeNameBool;
@@ -88,12 +89,11 @@
case T_LIST:
return kTypeNameList;
default:
- throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
- "Unrecognized type");
+ throw TProtocolException(TProtocolException::NOT_IMPLEMENTED, "Unrecognized type");
}
}
-static TType getTypeIDForTypeName(const std::string &name) {
+static TType getTypeIDForTypeName(const std::string& name) {
TType result = T_STOP; // Sentinel value
if (name.length() > 1) {
switch (name[0]) {
@@ -128,8 +128,7 @@
case 's':
if (name[1] == 't') {
result = T_STRING;
- }
- else if (name[1] == 'e') {
+ } else if (name[1] == 'e') {
result = T_SET;
}
break;
@@ -139,25 +138,67 @@
}
}
if (result == T_STOP) {
- throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
- "Unrecognized type");
+ throw TProtocolException(TProtocolException::NOT_IMPLEMENTED, "Unrecognized type");
}
return result;
}
-
// This table describes the handling for the first 0x30 characters
// 0 : escape using "\u00xx" notation
// 1 : just output index
// <other> : escape using "\<other>" notation
static const uint8_t kJSONCharTable[0x30] = {
-// 0 1 2 3 4 5 6 7 8 9 A B C D E F
- 0, 0, 0, 0, 0, 0, 0, 0,'b','t','n', 0,'f','r', 0, 0, // 0
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1
- 1, 1,'"', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 2
+ // 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 'b',
+ 't',
+ 'n',
+ 0,
+ 'f',
+ 'r',
+ 0,
+ 0, // 0
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0, // 1
+ 1,
+ 1,
+ '"',
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1, // 2
};
-
// This string's characters must match up with the elements in kEscapeCharVals.
// I don't have '/' on this list even though it appears on www.json.org --
// it is not in the RFC
@@ -166,23 +207,26 @@
// The elements of this array must match up with the sequence of characters in
// kEscapeChars
const static uint8_t kEscapeCharVals[7] = {
- '"', '\\', '\b', '\f', '\n', '\r', '\t',
+ '"',
+ '\\',
+ '\b',
+ '\f',
+ '\n',
+ '\r',
+ '\t',
};
-
// Static helper functions
// Read 1 character from the transport trans and verify that it is the
// expected character ch.
// Throw a protocol exception if it is not.
-static uint32_t readSyntaxChar(TJSONProtocol::LookaheadReader &reader,
- uint8_t ch) {
+static uint32_t readSyntaxChar(TJSONProtocol::LookaheadReader& reader, uint8_t ch) {
uint8_t ch2 = reader.read();
if (ch2 != ch) {
throw TProtocolException(TProtocolException::INVALID_DATA,
- "Expected \'" + std::string((char *)&ch, 1) +
- "\'; got \'" + std::string((char *)&ch2, 1) +
- "\'.");
+ "Expected \'" + std::string((char*)&ch, 1) + "\'; got \'"
+ + std::string((char*)&ch2, 1) + "\'.");
}
return 1;
}
@@ -192,14 +236,12 @@
static uint8_t hexVal(uint8_t ch) {
if ((ch >= '0') && (ch <= '9')) {
return ch - '0';
- }
- else if ((ch >= 'a') && (ch <= 'f')) {
+ } else if ((ch >= 'a') && (ch <= 'f')) {
return ch - 'a' + 10;
- }
- else {
+ } else {
throw TProtocolException(TProtocolException::INVALID_DATA,
- "Expected hex val ([0-9a-f]); got \'"
- + std::string((char *)&ch, 1) + "\'.");
+ "Expected hex val ([0-9a-f]); got \'" + std::string((char*)&ch, 1)
+ + "\'.");
}
}
@@ -209,8 +251,7 @@
val &= 0x0F;
if (val < 10) {
return val + '0';
- }
- else {
+ } else {
return val - 10 + 'a';
}
}
@@ -238,32 +279,30 @@
return false;
}
-
/**
* Class to serve as base JSON context and as base class for other context
* implementations
*/
class TJSONContext {
- public:
+public:
+ TJSONContext(){};
- TJSONContext() {};
-
- virtual ~TJSONContext() {};
+ virtual ~TJSONContext(){};
/**
* Write context data to the transport. Default is to do nothing.
*/
- virtual uint32_t write(TTransport &trans) {
- (void) trans;
+ virtual uint32_t write(TTransport& trans) {
+ (void)trans;
return 0;
};
/**
* Read context data from the transport. Default is to do nothing.
*/
- virtual uint32_t read(TJSONProtocol::LookaheadReader &reader) {
- (void) reader;
+ virtual uint32_t read(TJSONProtocol::LookaheadReader& reader) {
+ (void)reader;
return 0;
};
@@ -271,41 +310,33 @@
* Return true if numbers need to be escaped as strings in this context.
* Default behavior is to return false.
*/
- virtual bool escapeNum() {
- return false;
- }
+ virtual bool escapeNum() { return false; }
};
// Context class for object member key-value pairs
class JSONPairContext : public TJSONContext {
public:
+ JSONPairContext() : first_(true), colon_(true) {}
- JSONPairContext() :
- first_(true),
- colon_(true) {
- }
-
- uint32_t write(TTransport &trans) {
+ uint32_t write(TTransport& trans) {
if (first_) {
first_ = false;
colon_ = true;
return 0;
- }
- else {
+ } else {
trans.write(colon_ ? &kJSONPairSeparator : &kJSONElemSeparator, 1);
colon_ = !colon_;
return 1;
}
}
- uint32_t read(TJSONProtocol::LookaheadReader &reader) {
+ uint32_t read(TJSONProtocol::LookaheadReader& reader) {
if (first_) {
first_ = false;
colon_ = true;
return 0;
- }
- else {
+ } else {
uint8_t ch = (colon_ ? kJSONPairSeparator : kJSONElemSeparator);
colon_ = !colon_;
return readSyntaxChar(reader, ch);
@@ -313,59 +344,51 @@
}
// Numbers must be turned into strings if they are the key part of a pair
- virtual bool escapeNum() {
- return colon_;
- }
+ virtual bool escapeNum() { return colon_; }
- private:
-
- bool first_;
- bool colon_;
+private:
+ bool first_;
+ bool colon_;
};
// Context class for lists
class JSONListContext : public TJSONContext {
public:
+ JSONListContext() : first_(true) {}
- JSONListContext() :
- first_(true) {
- }
-
- uint32_t write(TTransport &trans) {
+ uint32_t write(TTransport& trans) {
if (first_) {
first_ = false;
return 0;
- }
- else {
+ } else {
trans.write(&kJSONElemSeparator, 1);
return 1;
}
}
- uint32_t read(TJSONProtocol::LookaheadReader &reader) {
+ uint32_t read(TJSONProtocol::LookaheadReader& reader) {
if (first_) {
first_ = false;
return 0;
- }
- else {
+ } else {
return readSyntaxChar(reader, kJSONElemSeparator);
}
}
- private:
- bool first_;
+private:
+ bool first_;
};
-
-TJSONProtocol::TJSONProtocol(boost::shared_ptr<TTransport> ptrans) :
- TVirtualProtocol<TJSONProtocol>(ptrans),
- trans_(ptrans.get()),
- context_(new TJSONContext()),
- reader_(*ptrans) {
+TJSONProtocol::TJSONProtocol(boost::shared_ptr<TTransport> ptrans)
+ : TVirtualProtocol<TJSONProtocol>(ptrans),
+ trans_(ptrans.get()),
+ context_(new TJSONContext()),
+ reader_(*ptrans) {
}
-TJSONProtocol::~TJSONProtocol() {}
+TJSONProtocol::~TJSONProtocol() {
+}
void TJSONProtocol::pushContext(boost::shared_ptr<TJSONContext> c) {
contexts_.push(context_);
@@ -379,7 +402,7 @@
// Write the character ch as a JSON escape sequence ("\u00xx")
uint32_t TJSONProtocol::writeJSONEscapeChar(uint8_t ch) {
- trans_->write((const uint8_t *)kJSONEscapePrefix.c_str(),
+ trans_->write((const uint8_t*)kJSONEscapePrefix.c_str(),
static_cast<uint32_t>(kJSONEscapePrefix.length()));
uint8_t outCh = hexChar(ch >> 4);
trans_->write(&outCh, 1);
@@ -395,25 +418,21 @@
trans_->write(&kJSONBackslash, 1);
trans_->write(&kJSONBackslash, 1);
return 2;
- }
- else {
+ } else {
trans_->write(&ch, 1);
return 1;
}
- }
- else {
+ } else {
uint8_t outCh = kJSONCharTable[ch];
// Check if regular character, backslash escaped, or JSON escaped
if (outCh == 1) {
trans_->write(&ch, 1);
return 1;
- }
- else if (outCh > 1) {
+ } else if (outCh > 1) {
trans_->write(&kJSONBackslash, 1);
trans_->write(&outCh, 1);
return 2;
- }
- else {
+ } else {
return writeJSONEscapeChar(ch);
}
}
@@ -421,7 +440,7 @@
// Write out the contents of the string str as a JSON string, escaping
// characters as appropriate.
-uint32_t TJSONProtocol::writeJSONString(const std::string &str) {
+uint32_t TJSONProtocol::writeJSONString(const std::string& str) {
uint32_t result = context_->write(*trans_);
result += 2; // For quotes
trans_->write(&kJSONStringDelimiter, 1);
@@ -436,13 +455,13 @@
// Write out the contents of the string as JSON string, base64-encoding
// the string's contents, and escaping as appropriate
-uint32_t TJSONProtocol::writeJSONBase64(const std::string &str) {
+uint32_t TJSONProtocol::writeJSONBase64(const std::string& str) {
uint32_t result = context_->write(*trans_);
result += 2; // For quotes
trans_->write(&kJSONStringDelimiter, 1);
uint8_t b[4];
- const uint8_t *bytes = (const uint8_t *)str.c_str();
- if(str.length() > (std::numeric_limits<uint32_t>::max)())
+ const uint8_t* bytes = (const uint8_t*)str.c_str();
+ if (str.length() > (std::numeric_limits<uint32_t>::max)())
throw TProtocolException(TProtocolException::SIZE_LIMIT);
uint32_t len = static_cast<uint32_t>(str.length());
while (len >= 3) {
@@ -451,7 +470,7 @@
trans_->write(b, 4);
result += 4;
bytes += 3;
- len -=3;
+ len -= 3;
}
if (len) { // Handle remainder
base64_encode(bytes, len, b);
@@ -473,9 +492,9 @@
trans_->write(&kJSONStringDelimiter, 1);
result += 1;
}
- if(val.length() > (std::numeric_limits<uint32_t>::max)())
+ if (val.length() > (std::numeric_limits<uint32_t>::max)())
throw TProtocolException(TProtocolException::SIZE_LIMIT);
- trans_->write((const uint8_t *)val.c_str(), static_cast<uint32_t>(val.length()));
+ trans_->write((const uint8_t*)val.c_str(), static_cast<uint32_t>(val.length()));
result += static_cast<uint32_t>(val.length());
if (escapeNum) {
trans_->write(&kJSONStringDelimiter, 1);
@@ -516,9 +535,9 @@
trans_->write(&kJSONStringDelimiter, 1);
result += 1;
}
- if(val.length() > (std::numeric_limits<uint32_t>::max)())
+ if (val.length() > (std::numeric_limits<uint32_t>::max)())
throw TProtocolException(TProtocolException::SIZE_LIMIT);
- trans_->write((const uint8_t *)val.c_str(), static_cast<uint32_t>(val.length()));
+ trans_->write((const uint8_t*)val.c_str(), static_cast<uint32_t>(val.length()));
result += static_cast<uint32_t>(val.length());
if (escapeNum) {
trans_->write(&kJSONStringDelimiter, 1);
@@ -569,7 +588,7 @@
}
uint32_t TJSONProtocol::writeStructBegin(const char* name) {
- (void) name;
+ (void)name;
return writeJSONObjectStart();
}
@@ -580,7 +599,7 @@
uint32_t TJSONProtocol::writeFieldBegin(const char* name,
const TType fieldType,
const int16_t fieldId) {
- (void) name;
+ (void)name;
uint32_t result = writeJSONInteger(fieldId);
result += writeJSONObjectStart();
result += writeJSONString(getTypeNameForTypeID(fieldType));
@@ -610,8 +629,7 @@
return writeJSONObjectEnd() + writeJSONArrayEnd();
}
-uint32_t TJSONProtocol::writeListBegin(const TType elemType,
- const uint32_t size) {
+uint32_t TJSONProtocol::writeListBegin(const TType elemType, const uint32_t size) {
uint32_t result = writeJSONArrayStart();
result += writeJSONString(getTypeNameForTypeID(elemType));
result += writeJSONInteger((int64_t)size);
@@ -622,8 +640,7 @@
return writeJSONArrayEnd();
}
-uint32_t TJSONProtocol::writeSetBegin(const TType elemType,
- const uint32_t size) {
+uint32_t TJSONProtocol::writeSetBegin(const TType elemType, const uint32_t size) {
uint32_t result = writeJSONArrayStart();
result += writeJSONString(getTypeNameForTypeID(elemType));
result += writeJSONInteger((int64_t)size);
@@ -668,9 +685,9 @@
return writeJSONBase64(str);
}
- /**
- * Reading functions
- */
+/**
+ * Reading functions
+ */
// Reads 1 byte and verifies that it matches ch.
uint32_t TJSONProtocol::readJSONSyntaxChar(uint8_t ch) {
@@ -679,7 +696,7 @@
// Decodes the four hex parts of a JSON escaped string character and returns
// the character via out. The first two characters must be "00".
-uint32_t TJSONProtocol::readJSONEscapeChar(uint8_t *out) {
+uint32_t TJSONProtocol::readJSONEscapeChar(uint8_t* out) {
uint8_t b[2];
readJSONSyntaxChar(kJSONZeroChar);
readJSONSyntaxChar(kJSONZeroChar);
@@ -690,7 +707,7 @@
}
// Decodes a JSON string, including unescaping, and returns the string via str
-uint32_t TJSONProtocol::readJSONString(std::string &str, bool skipContext) {
+uint32_t TJSONProtocol::readJSONString(std::string& str, bool skipContext) {
uint32_t result = (skipContext ? 0 : context_->read(reader_));
result += readJSONSyntaxChar(kJSONStringDelimiter);
uint8_t ch;
@@ -706,13 +723,12 @@
++result;
if (ch == kJSONEscapeChar) {
result += readJSONEscapeChar(&ch);
- }
- else {
+ } else {
size_t pos = kEscapeChars.find(ch);
if (pos == std::string::npos) {
throw TProtocolException(TProtocolException::INVALID_DATA,
- "Expected control char, got '" +
- std::string((const char *)&ch, 1) + "'.");
+ "Expected control char, got '" + std::string((const char*)&ch, 1)
+ + "'.");
}
ch = kEscapeCharVals[pos];
}
@@ -723,17 +739,17 @@
}
// Reads a block of base64 characters, decoding it, and returns via str
-uint32_t TJSONProtocol::readJSONBase64(std::string &str) {
+uint32_t TJSONProtocol::readJSONBase64(std::string& str) {
std::string tmp;
uint32_t result = readJSONString(tmp);
- uint8_t *b = (uint8_t *)tmp.c_str();
- if(tmp.length() > (std::numeric_limits<uint32_t>::max)())
+ uint8_t* b = (uint8_t*)tmp.c_str();
+ if (tmp.length() > (std::numeric_limits<uint32_t>::max)())
throw TProtocolException(TProtocolException::SIZE_LIMIT);
uint32_t len = static_cast<uint32_t>(tmp.length());
str.clear();
while (len >= 4) {
base64_decode(b, 4);
- str.append((const char *)b, 3);
+ str.append((const char*)b, 3);
b += 4;
len -= 4;
}
@@ -741,14 +757,14 @@
// base64 but legal for skip of regular string type)
if (len > 1) {
base64_decode(b, len);
- str.append((const char *)b, len - 1);
+ str.append((const char*)b, len - 1);
}
return result;
}
// Reads a sequence of characters, stopping at the first one that is not
// a valid JSON numeric character.
-uint32_t TJSONProtocol::readJSONNumericChars(std::string &str) {
+uint32_t TJSONProtocol::readJSONNumericChars(std::string& str) {
uint32_t result = 0;
str.clear();
while (true) {
@@ -766,7 +782,7 @@
// Reads a sequence of characters and assembles them into a number,
// returning them via num
template <typename NumberType>
-uint32_t TJSONProtocol::readJSONInteger(NumberType &num) {
+uint32_t TJSONProtocol::readJSONInteger(NumberType& num) {
uint32_t result = context_->read(reader_);
if (context_->escapeNum()) {
result += readJSONSyntaxChar(kJSONStringDelimiter);
@@ -775,11 +791,9 @@
result += readJSONNumericChars(str);
try {
num = boost::lexical_cast<NumberType>(str);
- }
- catch (boost::bad_lexical_cast e) {
+ } catch (boost::bad_lexical_cast e) {
throw new TProtocolException(TProtocolException::INVALID_DATA,
- "Expected numeric value; got \"" + str +
- "\"");
+ "Expected numeric value; got \"" + str + "\"");
}
if (context_->escapeNum()) {
result += readJSONSyntaxChar(kJSONStringDelimiter);
@@ -788,22 +802,19 @@
}
// Reads a JSON number or string and interprets it as a double.
-uint32_t TJSONProtocol::readJSONDouble(double &num) {
+uint32_t TJSONProtocol::readJSONDouble(double& num) {
uint32_t result = context_->read(reader_);
std::string str;
if (reader_.peek() == kJSONStringDelimiter) {
result += readJSONString(str, true);
// Check for NaN, Infinity and -Infinity
if (str == kThriftNan) {
- num = HUGE_VAL/HUGE_VAL; // generates NaN
- }
- else if (str == kThriftInfinity) {
+ num = HUGE_VAL / HUGE_VAL; // generates NaN
+ } else if (str == kThriftInfinity) {
num = HUGE_VAL;
- }
- else if (str == kThriftNegativeInfinity) {
+ } else if (str == kThriftNegativeInfinity) {
num = -HUGE_VAL;
- }
- else {
+ } else {
if (!context_->escapeNum()) {
// Throw exception -- we should not be in a string in this case
throw new TProtocolException(TProtocolException::INVALID_DATA,
@@ -811,15 +822,12 @@
}
try {
num = boost::lexical_cast<double>(str);
- }
- catch (boost::bad_lexical_cast e) {
+ } catch (boost::bad_lexical_cast e) {
throw new TProtocolException(TProtocolException::INVALID_DATA,
- "Expected numeric value; got \"" + str +
- "\"");
+ "Expected numeric value; got \"" + str + "\"");
}
}
- }
- else {
+ } else {
if (context_->escapeNum()) {
// This will throw - we should have had a quote if escapeNum == true
readJSONSyntaxChar(kJSONStringDelimiter);
@@ -827,11 +835,9 @@
result += readJSONNumericChars(str);
try {
num = boost::lexical_cast<double>(str);
- }
- catch (boost::bad_lexical_cast e) {
+ } catch (boost::bad_lexical_cast e) {
throw new TProtocolException(TProtocolException::INVALID_DATA,
- "Expected numeric value; got \"" + str +
- "\"");
+ "Expected numeric value; got \"" + str + "\"");
}
}
return result;
@@ -870,14 +876,13 @@
uint64_t tmpVal = 0;
result += readJSONInteger(tmpVal);
if (tmpVal != kThriftVersion1) {
- throw TProtocolException(TProtocolException::BAD_VERSION,
- "Message contained bad version.");
+ throw TProtocolException(TProtocolException::BAD_VERSION, "Message contained bad version.");
}
result += readJSONString(name);
result += readJSONInteger(tmpVal);
messageType = (TMessageType)tmpVal;
result += readJSONInteger(tmpVal);
- if(tmpVal > static_cast<uint64_t>((std::numeric_limits<int32_t>::max)()))
+ if (tmpVal > static_cast<uint64_t>((std::numeric_limits<int32_t>::max)()))
throw TProtocolException(TProtocolException::SIZE_LIMIT);
seqid = static_cast<int32_t>(tmpVal);
return result;
@@ -888,7 +893,7 @@
}
uint32_t TJSONProtocol::readStructBegin(std::string& name) {
- (void) name;
+ (void)name;
return readJSONObjectStart();
}
@@ -896,21 +901,18 @@
return readJSONObjectEnd();
}
-uint32_t TJSONProtocol::readFieldBegin(std::string& name,
- TType& fieldType,
- int16_t& fieldId) {
- (void) name;
+uint32_t TJSONProtocol::readFieldBegin(std::string& name, TType& fieldType, int16_t& fieldId) {
+ (void)name;
uint32_t result = 0;
// Check if we hit the end of the list
uint8_t ch = reader_.peek();
if (ch == kJSONObjectEnd) {
fieldType = apache::thrift::protocol::T_STOP;
- }
- else {
+ } else {
uint64_t tmpVal = 0;
std::string tmpStr;
result += readJSONInteger(tmpVal);
- if(tmpVal > static_cast<uint32_t>((std::numeric_limits<int16_t>::max)()))
+ if (tmpVal > static_cast<uint32_t>((std::numeric_limits<int16_t>::max)()))
throw TProtocolException(TProtocolException::SIZE_LIMIT);
fieldId = static_cast<int16_t>(tmpVal);
result += readJSONObjectStart();
@@ -924,9 +926,7 @@
return readJSONObjectEnd();
}
-uint32_t TJSONProtocol::readMapBegin(TType& keyType,
- TType& valType,
- uint32_t& size) {
+uint32_t TJSONProtocol::readMapBegin(TType& keyType, TType& valType, uint32_t& size) {
uint64_t tmpVal = 0;
std::string tmpStr;
uint32_t result = readJSONArrayStart();
@@ -935,7 +935,7 @@
result += readJSONString(tmpStr);
valType = getTypeIDForTypeName(tmpStr);
result += readJSONInteger(tmpVal);
- if(tmpVal > (std::numeric_limits<uint32_t>::max)())
+ if (tmpVal > (std::numeric_limits<uint32_t>::max)())
throw TProtocolException(TProtocolException::SIZE_LIMIT);
size = static_cast<uint32_t>(tmpVal);
result += readJSONObjectStart();
@@ -946,15 +946,14 @@
return readJSONObjectEnd() + readJSONArrayEnd();
}
-uint32_t TJSONProtocol::readListBegin(TType& elemType,
- uint32_t& size) {
+uint32_t TJSONProtocol::readListBegin(TType& elemType, uint32_t& size) {
uint64_t tmpVal = 0;
std::string tmpStr;
uint32_t result = readJSONArrayStart();
result += readJSONString(tmpStr);
elemType = getTypeIDForTypeName(tmpStr);
result += readJSONInteger(tmpVal);
- if(tmpVal > (std::numeric_limits<uint32_t>::max)())
+ if (tmpVal > (std::numeric_limits<uint32_t>::max)())
throw TProtocolException(TProtocolException::SIZE_LIMIT);
size = static_cast<uint32_t>(tmpVal);
return result;
@@ -964,15 +963,14 @@
return readJSONArrayEnd();
}
-uint32_t TJSONProtocol::readSetBegin(TType& elemType,
- uint32_t& size) {
+uint32_t TJSONProtocol::readSetBegin(TType& elemType, uint32_t& size) {
uint64_t tmpVal = 0;
std::string tmpStr;
uint32_t result = readJSONArrayStart();
result += readJSONString(tmpStr);
elemType = getTypeIDForTypeName(tmpStr);
result += readJSONInteger(tmpVal);
- if(tmpVal > (std::numeric_limits<uint32_t>::max)())
+ if (tmpVal > (std::numeric_limits<uint32_t>::max)())
throw TProtocolException(TProtocolException::SIZE_LIMIT);
size = static_cast<uint32_t>(tmpVal);
return result;
@@ -989,8 +987,8 @@
// readByte() must be handled properly becuase boost::lexical cast sees int8_t
// as a text type instead of an integer type
uint32_t TJSONProtocol::readByte(int8_t& byte) {
- int16_t tmp = (int16_t) byte;
- uint32_t result = readJSONInteger(tmp);
+ int16_t tmp = (int16_t)byte;
+ uint32_t result = readJSONInteger(tmp);
assert(tmp < 256);
byte = (int8_t)tmp;
return result;
@@ -1012,12 +1010,13 @@
return readJSONDouble(dub);
}
-uint32_t TJSONProtocol::readString(std::string &str) {
+uint32_t TJSONProtocol::readString(std::string& str) {
return readJSONString(str);
}
-uint32_t TJSONProtocol::readBinary(std::string &str) {
+uint32_t TJSONProtocol::readBinary(std::string& str) {
return readJSONBase64(str);
}
-
-}}} // apache::thrift::protocol
+}
+}
+} // apache::thrift::protocol
diff --git a/lib/cpp/src/thrift/protocol/TJSONProtocol.h b/lib/cpp/src/thrift/protocol/TJSONProtocol.h
index edfc744..b19c35d 100644
--- a/lib/cpp/src/thrift/protocol/TJSONProtocol.h
+++ b/lib/cpp/src/thrift/protocol/TJSONProtocol.h
@@ -24,7 +24,9 @@
#include <stack>
-namespace apache { namespace thrift { namespace protocol {
+namespace apache {
+namespace thrift {
+namespace protocol {
// Forward declaration
class TJSONContext;
@@ -88,14 +90,12 @@
*
*/
class TJSONProtocol : public TVirtualProtocol<TJSONProtocol> {
- public:
-
+public:
TJSONProtocol(boost::shared_ptr<TTransport> ptrans);
~TJSONProtocol();
- private:
-
+private:
void pushContext(boost::shared_ptr<TJSONContext> c);
void popContext();
@@ -104,16 +104,16 @@
uint32_t writeJSONChar(uint8_t ch);
- uint32_t writeJSONString(const std::string &str);
+ uint32_t writeJSONString(const std::string& str);
- uint32_t writeJSONBase64(const std::string &str);
+ uint32_t writeJSONBase64(const std::string& str);
template <typename NumberType>
uint32_t writeJSONInteger(NumberType num);
uint32_t writeJSONDouble(double num);
- uint32_t writeJSONObjectStart() ;
+ uint32_t writeJSONObjectStart();
uint32_t writeJSONObjectEnd();
@@ -123,18 +123,18 @@
uint32_t readJSONSyntaxChar(uint8_t ch);
- uint32_t readJSONEscapeChar(uint8_t *out);
+ uint32_t readJSONEscapeChar(uint8_t* out);
- uint32_t readJSONString(std::string &str, bool skipContext = false);
+ uint32_t readJSONString(std::string& str, bool skipContext = false);
- uint32_t readJSONBase64(std::string &str);
+ uint32_t readJSONBase64(std::string& str);
- uint32_t readJSONNumericChars(std::string &str);
+ uint32_t readJSONNumericChars(std::string& str);
template <typename NumberType>
- uint32_t readJSONInteger(NumberType &num);
+ uint32_t readJSONInteger(NumberType& num);
- uint32_t readJSONDouble(double &num);
+ uint32_t readJSONDouble(double& num);
uint32_t readJSONObjectStart();
@@ -144,8 +144,7 @@
uint32_t readJSONArrayEnd();
- public:
-
+public:
/**
* Writing functions.
*/
@@ -160,27 +159,21 @@
uint32_t writeStructEnd();
- uint32_t writeFieldBegin(const char* name,
- const TType fieldType,
- const int16_t fieldId);
+ uint32_t writeFieldBegin(const char* name, const TType fieldType, const int16_t fieldId);
uint32_t writeFieldEnd();
uint32_t writeFieldStop();
- uint32_t writeMapBegin(const TType keyType,
- const TType valType,
- const uint32_t size);
+ uint32_t writeMapBegin(const TType keyType, const TType valType, const uint32_t size);
uint32_t writeMapEnd();
- uint32_t writeListBegin(const TType elemType,
- const uint32_t size);
+ uint32_t writeListBegin(const TType elemType, const uint32_t size);
uint32_t writeListEnd();
- uint32_t writeSetBegin(const TType elemType,
- const uint32_t size);
+ uint32_t writeSetBegin(const TType elemType, const uint32_t size);
uint32_t writeSetEnd();
@@ -204,9 +197,7 @@
* Reading functions
*/
- uint32_t readMessageBegin(std::string& name,
- TMessageType& messageType,
- int32_t& seqid);
+ uint32_t readMessageBegin(std::string& name, TMessageType& messageType, int32_t& seqid);
uint32_t readMessageEnd();
@@ -214,25 +205,19 @@
uint32_t readStructEnd();
- uint32_t readFieldBegin(std::string& name,
- TType& fieldType,
- int16_t& fieldId);
+ uint32_t readFieldBegin(std::string& name, TType& fieldType, int16_t& fieldId);
uint32_t readFieldEnd();
- uint32_t readMapBegin(TType& keyType,
- TType& valType,
- uint32_t& size);
+ uint32_t readMapBegin(TType& keyType, TType& valType, uint32_t& size);
uint32_t readMapEnd();
- uint32_t readListBegin(TType& elemType,
- uint32_t& size);
+ uint32_t readListBegin(TType& elemType, uint32_t& size);
uint32_t readListEnd();
- uint32_t readSetBegin(TType& elemType,
- uint32_t& size);
+ uint32_t readSetBegin(TType& elemType, uint32_t& size);
uint32_t readSetEnd();
@@ -257,18 +242,13 @@
class LookaheadReader {
- public:
-
- LookaheadReader(TTransport &trans) :
- trans_(&trans),
- hasData_(false) {
- }
+ public:
+ LookaheadReader(TTransport& trans) : trans_(&trans), hasData_(false) {}
uint8_t read() {
if (hasData_) {
hasData_ = false;
- }
- else {
+ } else {
trans_->readAll(&data_, 1);
}
return data_;
@@ -282,13 +262,13 @@
return data_;
}
- private:
- TTransport *trans_;
+ private:
+ TTransport* trans_;
bool hasData_;
uint8_t data_;
};
- private:
+private:
TTransport* trans_;
std::stack<boost::shared_ptr<TJSONContext> > contexts_;
@@ -300,7 +280,7 @@
* Constructs input and output protocol objects given transports.
*/
class TJSONProtocolFactory : public TProtocolFactory {
- public:
+public:
TJSONProtocolFactory() {}
virtual ~TJSONProtocolFactory() {}
@@ -309,17 +289,18 @@
return boost::shared_ptr<TProtocol>(new TJSONProtocol(trans));
}
};
-
-}}} // apache::thrift::protocol
-
+}
+}
+} // apache::thrift::protocol
// TODO(dreiss): Move part of ThriftJSONString into a .cpp file and remove this.
#include <thrift/transport/TBufferTransports.h>
-namespace apache { namespace thrift {
+namespace apache {
+namespace thrift {
-template<typename ThriftStruct>
- std::string ThriftJSONString(const ThriftStruct& ts) {
+template <typename ThriftStruct>
+std::string ThriftJSONString(const ThriftStruct& ts) {
using namespace apache::thrift::transport;
using namespace apache::thrift::protocol;
TMemoryBuffer* buffer = new TMemoryBuffer;
@@ -333,7 +314,7 @@
buffer->getBuffer(&buf, &size);
return std::string((char*)buf, (unsigned int)size);
}
-
-}} // apache::thrift
+}
+} // apache::thrift
#endif // #define _THRIFT_PROTOCOL_TJSONPROTOCOL_H_ 1
diff --git a/lib/cpp/src/thrift/protocol/TMultiplexedProtocol.cpp b/lib/cpp/src/thrift/protocol/TMultiplexedProtocol.cpp
index 756b9b9..f0dc69e 100644
--- a/lib/cpp/src/thrift/protocol/TMultiplexedProtocol.cpp
+++ b/lib/cpp/src/thrift/protocol/TMultiplexedProtocol.cpp
@@ -21,27 +21,20 @@
#include <thrift/processor/TMultiplexedProcessor.h>
#include <thrift/protocol/TProtocolDecorator.h>
-namespace apache
-{
- namespace thrift
- {
- namespace protocol
- {
- uint32_t TMultiplexedProtocol::writeMessageBegin_virt(
- const std::string& _name,
- const TMessageType _type,
- const int32_t _seqid)
- {
- if( _type == T_CALL || _type == T_ONEWAY )
- {
- return TProtocolDecorator::writeMessageBegin_virt( serviceName + separator + _name, _type, _seqid );
- }
- else
- {
- return TProtocolDecorator::writeMessageBegin_virt(_name, _type, _seqid);
- }
- }
- }
- }
+namespace apache {
+namespace thrift {
+namespace protocol {
+uint32_t TMultiplexedProtocol::writeMessageBegin_virt(const std::string& _name,
+ const TMessageType _type,
+ const int32_t _seqid) {
+ if (_type == T_CALL || _type == T_ONEWAY) {
+ return TProtocolDecorator::writeMessageBegin_virt(serviceName + separator + _name,
+ _type,
+ _seqid);
+ } else {
+ return TProtocolDecorator::writeMessageBegin_virt(_name, _type, _seqid);
+ }
}
-
+}
+}
+}
diff --git a/lib/cpp/src/thrift/protocol/TMultiplexedProtocol.h b/lib/cpp/src/thrift/protocol/TMultiplexedProtocol.h
index e93f371..0244fbe 100644
--- a/lib/cpp/src/thrift/protocol/TMultiplexedProtocol.h
+++ b/lib/cpp/src/thrift/protocol/TMultiplexedProtocol.h
@@ -22,82 +22,74 @@
#include <thrift/protocol/TProtocolDecorator.h>
-namespace apache
-{
- namespace thrift
- {
- namespace protocol
- {
- using boost::shared_ptr;
+namespace apache {
+namespace thrift {
+namespace protocol {
+using boost::shared_ptr;
- /**
- * <code>TMultiplexedProtocol</code> is a protocol-independent concrete decorator
- * that allows a Thrift client to communicate with a multiplexing Thrift server,
- * by prepending the service name to the function name during function calls.
- *
- * \note THIS IS NOT USED BY SERVERS. On the server, use
- * {@link apache::thrift::TMultiplexedProcessor TMultiplexedProcessor} to handle requests
- * from a multiplexing client.
- *
- * This example uses a single socket transport to invoke two services:
- *
- * <blockquote><code>
- * shared_ptr<TSocket> transport(new TSocket("localhost", 9090));
- * transport->open();
- *
- * shared_ptr<TBinaryProtocol> protocol(new TBinaryProtocol(transport));
- *
- * shared_ptr<TMultiplexedProtocol> mp1(new TMultiplexedProtocol(protocol, "Calculator"));
- * shared_ptr<CalculatorClient> service1(new CalculatorClient(mp1));
- *
- * shared_ptr<TMultiplexedProtocol> mp2(new TMultiplexedProtocol(protocol, "WeatherReport"));
- * shared_ptr<WeatherReportClient> service2(new WeatherReportClient(mp2));
- *
- * service1->add(2,2);
- * int temp = service2->getTemperature();
- * </code></blockquote>
- *
- * @see apache::thrift::protocol::TProtocolDecorator
- */
- class TMultiplexedProtocol : public TProtocolDecorator
- {
- public:
- /**
- * Wrap the specified protocol, allowing it to be used to communicate with a
- * multiplexing server. The <code>serviceName</code> is required as it is
- * prepended to the message header so that the multiplexing server can broker
- * the function call to the proper service.
- *
- * \param _protocol Your communication protocol of choice, e.g. <code>TBinaryProtocol</code>.
- * \param _serviceName The service name of the service communicating via this protocol.
- */
- TMultiplexedProtocol( shared_ptr<TProtocol> _protocol, const std::string& _serviceName )
- : TProtocolDecorator(_protocol),
- serviceName(_serviceName),
- separator(":")
- { }
- virtual ~TMultiplexedProtocol() {}
+/**
+ * <code>TMultiplexedProtocol</code> is a protocol-independent concrete decorator
+ * that allows a Thrift client to communicate with a multiplexing Thrift server,
+ * by prepending the service name to the function name during function calls.
+ *
+ * \note THIS IS NOT USED BY SERVERS. On the server, use
+ * {@link apache::thrift::TMultiplexedProcessor TMultiplexedProcessor} to handle requests
+ * from a multiplexing client.
+ *
+ * This example uses a single socket transport to invoke two services:
+ *
+ * <blockquote><code>
+ * shared_ptr<TSocket> transport(new TSocket("localhost", 9090));
+ * transport->open();
+ *
+ * shared_ptr<TBinaryProtocol> protocol(new TBinaryProtocol(transport));
+ *
+ * shared_ptr<TMultiplexedProtocol> mp1(new TMultiplexedProtocol(protocol, "Calculator"));
+ * shared_ptr<CalculatorClient> service1(new CalculatorClient(mp1));
+ *
+ * shared_ptr<TMultiplexedProtocol> mp2(new TMultiplexedProtocol(protocol, "WeatherReport"));
+ * shared_ptr<WeatherReportClient> service2(new WeatherReportClient(mp2));
+ *
+ * service1->add(2,2);
+ * int temp = service2->getTemperature();
+ * </code></blockquote>
+ *
+ * @see apache::thrift::protocol::TProtocolDecorator
+ */
+class TMultiplexedProtocol : public TProtocolDecorator {
+public:
+ /**
+ * Wrap the specified protocol, allowing it to be used to communicate with a
+ * multiplexing server. The <code>serviceName</code> is required as it is
+ * prepended to the message header so that the multiplexing server can broker
+ * the function call to the proper service.
+ *
+ * \param _protocol Your communication protocol of choice, e.g. <code>TBinaryProtocol</code>.
+ * \param _serviceName The service name of the service communicating via this protocol.
+ */
+ TMultiplexedProtocol(shared_ptr<TProtocol> _protocol, const std::string& _serviceName)
+ : TProtocolDecorator(_protocol), serviceName(_serviceName), separator(":") {}
+ virtual ~TMultiplexedProtocol() {}
- /**
- * Prepends the service name to the function name, separated by TMultiplexedProtocol::SEPARATOR.
- *
- * \param [in] _name The name of the method to be called in the service.
- * \param [in] _type The type of message
- * \param [in] _name The sequential id of the message
- *
- * \throws TException Passed through from wrapped <code>TProtocol</code> instance.
- */
- uint32_t writeMessageBegin_virt(
- const std::string& _name,
- const TMessageType _type,
- const int32_t _seqid);
- private:
- const std::string serviceName;
- const std::string separator;
- };
+ /**
+ * Prepends the service name to the function name, separated by TMultiplexedProtocol::SEPARATOR.
+ *
+ * \param [in] _name The name of the method to be called in the service.
+ * \param [in] _type The type of message
+ * \param [in] _name The sequential id of the message
+ *
+ * \throws TException Passed through from wrapped <code>TProtocol</code> instance.
+ */
+ uint32_t writeMessageBegin_virt(const std::string& _name,
+ const TMessageType _type,
+ const int32_t _seqid);
- }
- }
+private:
+ const std::string serviceName;
+ const std::string separator;
+};
+}
+}
}
#endif // THRIFT_TMULTIPLEXEDPROTOCOL_H_
diff --git a/lib/cpp/src/thrift/protocol/TProtocol.h b/lib/cpp/src/thrift/protocol/TProtocol.h
index d4c343d..eb323b0 100644
--- a/lib/cpp/src/thrift/protocol/TProtocol.h
+++ b/lib/cpp/src/thrift/protocol/TProtocol.h
@@ -34,7 +34,6 @@
#include <map>
#include <vector>
-
// Use this to get around strict aliasing rules.
// For example, uint64_t i = bitwise_cast<uint64_t>(returns_double());
// The most obvious implementation is to just cast a pointer,
@@ -136,7 +135,9 @@
# error "Can't define htonll or ntohll!"
#endif
-namespace apache { namespace thrift { namespace protocol {
+namespace apache {
+namespace thrift {
+namespace protocol {
using apache::thrift::transport::TTransport;
@@ -186,98 +187,91 @@
template <class Protocol_>
uint32_t skip(Protocol_& prot, TType type) {
switch (type) {
- case T_BOOL:
- {
- bool boolv;
- return prot.readBool(boolv);
- }
- case T_BYTE:
- {
- int8_t bytev;
- return prot.readByte(bytev);
- }
- case T_I16:
- {
- int16_t i16;
- return prot.readI16(i16);
- }
- case T_I32:
- {
- int32_t i32;
- return prot.readI32(i32);
- }
- case T_I64:
- {
- int64_t i64;
- return prot.readI64(i64);
- }
- case T_DOUBLE:
- {
- double dub;
- return prot.readDouble(dub);
- }
- case T_STRING:
- {
- std::string str;
- return prot.readBinary(str);
- }
- case T_STRUCT:
- {
- uint32_t result = 0;
- std::string name;
- int16_t fid;
- TType ftype;
- result += prot.readStructBegin(name);
- while (true) {
- result += prot.readFieldBegin(name, ftype, fid);
- if (ftype == T_STOP) {
- break;
- }
- result += skip(prot, ftype);
- result += prot.readFieldEnd();
+ case T_BOOL: {
+ bool boolv;
+ return prot.readBool(boolv);
+ }
+ case T_BYTE: {
+ int8_t bytev;
+ return prot.readByte(bytev);
+ }
+ case T_I16: {
+ int16_t i16;
+ return prot.readI16(i16);
+ }
+ case T_I32: {
+ int32_t i32;
+ return prot.readI32(i32);
+ }
+ case T_I64: {
+ int64_t i64;
+ return prot.readI64(i64);
+ }
+ case T_DOUBLE: {
+ double dub;
+ return prot.readDouble(dub);
+ }
+ case T_STRING: {
+ std::string str;
+ return prot.readBinary(str);
+ }
+ case T_STRUCT: {
+ uint32_t result = 0;
+ std::string name;
+ int16_t fid;
+ TType ftype;
+ result += prot.readStructBegin(name);
+ while (true) {
+ result += prot.readFieldBegin(name, ftype, fid);
+ if (ftype == T_STOP) {
+ break;
}
- result += prot.readStructEnd();
- return result;
+ result += skip(prot, ftype);
+ result += prot.readFieldEnd();
}
- case T_MAP:
- {
- uint32_t result = 0;
- TType keyType;
- TType valType;
- uint32_t i, size;
- result += prot.readMapBegin(keyType, valType, size);
- for (i = 0; i < size; i++) {
- result += skip(prot, keyType);
- result += skip(prot, valType);
- }
- result += prot.readMapEnd();
- return result;
+ result += prot.readStructEnd();
+ return result;
+ }
+ case T_MAP: {
+ uint32_t result = 0;
+ TType keyType;
+ TType valType;
+ uint32_t i, size;
+ result += prot.readMapBegin(keyType, valType, size);
+ for (i = 0; i < size; i++) {
+ result += skip(prot, keyType);
+ result += skip(prot, valType);
}
- case T_SET:
- {
- uint32_t result = 0;
- TType elemType;
- uint32_t i, size;
- result += prot.readSetBegin(elemType, size);
- for (i = 0; i < size; i++) {
- result += skip(prot, elemType);
- }
- result += prot.readSetEnd();
- return result;
+ result += prot.readMapEnd();
+ return result;
+ }
+ case T_SET: {
+ uint32_t result = 0;
+ TType elemType;
+ uint32_t i, size;
+ result += prot.readSetBegin(elemType, size);
+ for (i = 0; i < size; i++) {
+ result += skip(prot, elemType);
}
- case T_LIST:
- {
- uint32_t result = 0;
- TType elemType;
- uint32_t i, size;
- result += prot.readListBegin(elemType, size);
- for (i = 0; i < size; i++) {
- result += skip(prot, elemType);
- }
- result += prot.readListEnd();
- return result;
+ result += prot.readSetEnd();
+ return result;
+ }
+ case T_LIST: {
+ uint32_t result = 0;
+ TType elemType;
+ uint32_t i, size;
+ result += prot.readListBegin(elemType, size);
+ for (i = 0; i < size; i++) {
+ result += skip(prot, elemType);
}
- case T_STOP: case T_VOID: case T_U64: case T_UTF8: case T_UTF16:
+ result += prot.readListEnd();
+ return result;
+ }
+ case T_STOP:
+ case T_VOID:
+ case T_U64:
+ case T_UTF8:
+ case T_UTF16:
break;
}
return 0;
@@ -300,7 +294,7 @@
*
*/
class TProtocol {
- public:
+public:
virtual ~TProtocol() {}
/**
@@ -313,7 +307,6 @@
virtual uint32_t writeMessageEnd_virt() = 0;
-
virtual uint32_t writeStructBegin_virt(const char* name) = 0;
virtual uint32_t writeStructEnd_virt() = 0;
@@ -326,19 +319,16 @@
virtual uint32_t writeFieldStop_virt() = 0;
- virtual uint32_t writeMapBegin_virt(const TType keyType,
- const TType valType,
- const uint32_t size) = 0;
+ virtual uint32_t writeMapBegin_virt(const TType keyType, const TType valType, const uint32_t size)
+ = 0;
virtual uint32_t writeMapEnd_virt() = 0;
- virtual uint32_t writeListBegin_virt(const TType elemType,
- const uint32_t size) = 0;
+ virtual uint32_t writeListBegin_virt(const TType elemType, const uint32_t size) = 0;
virtual uint32_t writeListEnd_virt() = 0;
- virtual uint32_t writeSetBegin_virt(const TType elemType,
- const uint32_t size) = 0;
+ virtual uint32_t writeSetBegin_virt(const TType elemType, const uint32_t size) = 0;
virtual uint32_t writeSetEnd_virt() = 0;
@@ -370,7 +360,6 @@
return writeMessageEnd_virt();
}
-
uint32_t writeStructBegin(const char* name) {
T_VIRTUAL_CALL();
return writeStructBegin_virt(name);
@@ -381,9 +370,7 @@
return writeStructEnd_virt();
}
- uint32_t writeFieldBegin(const char* name,
- const TType fieldType,
- const int16_t fieldId) {
+ uint32_t writeFieldBegin(const char* name, const TType fieldType, const int16_t fieldId) {
T_VIRTUAL_CALL();
return writeFieldBegin_virt(name, fieldType, fieldId);
}
@@ -398,9 +385,7 @@
return writeFieldStop_virt();
}
- uint32_t writeMapBegin(const TType keyType,
- const TType valType,
- const uint32_t size) {
+ uint32_t writeMapBegin(const TType keyType, const TType valType, const uint32_t size) {
T_VIRTUAL_CALL();
return writeMapBegin_virt(keyType, valType, size);
}
@@ -484,25 +469,19 @@
virtual uint32_t readStructEnd_virt() = 0;
- virtual uint32_t readFieldBegin_virt(std::string& name,
- TType& fieldType,
- int16_t& fieldId) = 0;
+ virtual uint32_t readFieldBegin_virt(std::string& name, TType& fieldType, int16_t& fieldId) = 0;
virtual uint32_t readFieldEnd_virt() = 0;
- virtual uint32_t readMapBegin_virt(TType& keyType,
- TType& valType,
- uint32_t& size) = 0;
+ virtual uint32_t readMapBegin_virt(TType& keyType, TType& valType, uint32_t& size) = 0;
virtual uint32_t readMapEnd_virt() = 0;
- virtual uint32_t readListBegin_virt(TType& elemType,
- uint32_t& size) = 0;
+ virtual uint32_t readListBegin_virt(TType& elemType, uint32_t& size) = 0;
virtual uint32_t readListEnd_virt() = 0;
- virtual uint32_t readSetBegin_virt(TType& elemType,
- uint32_t& size) = 0;
+ virtual uint32_t readSetBegin_virt(TType& elemType, uint32_t& size) = 0;
virtual uint32_t readSetEnd_virt() = 0;
@@ -524,9 +503,7 @@
virtual uint32_t readBinary_virt(std::string& str) = 0;
- uint32_t readMessageBegin(std::string& name,
- TMessageType& messageType,
- int32_t& seqid) {
+ uint32_t readMessageBegin(std::string& name, TMessageType& messageType, int32_t& seqid) {
T_VIRTUAL_CALL();
return readMessageBegin_virt(name, messageType, seqid);
}
@@ -546,9 +523,7 @@
return readStructEnd_virt();
}
- uint32_t readFieldBegin(std::string& name,
- TType& fieldType,
- int16_t& fieldId) {
+ uint32_t readFieldBegin(std::string& name, TType& fieldType, int16_t& fieldId) {
T_VIRTUAL_CALL();
return readFieldBegin_virt(name, fieldType, fieldId);
}
@@ -645,22 +620,14 @@
T_VIRTUAL_CALL();
return skip_virt(type);
}
- virtual uint32_t skip_virt(TType type) {
- return ::apache::thrift::protocol::skip(*this, type);
- }
+ virtual uint32_t skip_virt(TType type) { return ::apache::thrift::protocol::skip(*this, type); }
- inline boost::shared_ptr<TTransport> getTransport() {
- return ptrans_;
- }
+ inline boost::shared_ptr<TTransport> getTransport() { return ptrans_; }
// TODO: remove these two calls, they are for backwards
// compatibility
- inline boost::shared_ptr<TTransport> getInputTransport() {
- return ptrans_;
- }
- inline boost::shared_ptr<TTransport> getOutputTransport() {
- return ptrans_;
- }
+ inline boost::shared_ptr<TTransport> getInputTransport() { return ptrans_; }
+ inline boost::shared_ptr<TTransport> getOutputTransport() { return ptrans_; }
void incrementRecursionDepth() {
if (recursion_limit_ < ++recursion_depth_) {
@@ -668,19 +635,15 @@
}
}
- void decrementRecursionDepth() {
- --recursion_depth_;
- }
+ void decrementRecursionDepth() { --recursion_depth_; }
- protected:
+protected:
TProtocol(boost::shared_ptr<TTransport> ptrans)
- : ptrans_(ptrans)
- , recursion_depth_(0)
- , recursion_limit_(DEFAULT_RECURSION_LIMIT) {}
+ : ptrans_(ptrans), recursion_depth_(0), recursion_limit_(DEFAULT_RECURSION_LIMIT) {}
boost::shared_ptr<TTransport> ptrans_;
- private:
+private:
TProtocol() {}
uint32_t recursion_depth_;
uint32_t recursion_limit_;
@@ -690,7 +653,7 @@
* Constructs input and output protocol objects given transports.
*/
class TProtocolFactory {
- public:
+public:
TProtocolFactory() {}
virtual ~TProtocolFactory() {}
@@ -704,9 +667,9 @@
* This class does nothing, and should never be instantiated.
* It is used only by the generator code.
*/
-class TDummyProtocol : public TProtocol {
-};
-
-}}} // apache::thrift::protocol
+class TDummyProtocol : public TProtocol {};
+}
+}
+} // apache::thrift::protocol
#endif // #define _THRIFT_PROTOCOL_TPROTOCOL_H_ 1
diff --git a/lib/cpp/src/thrift/protocol/TProtocolDecorator.h b/lib/cpp/src/thrift/protocol/TProtocolDecorator.h
index 570e977..446a81f 100644
--- a/lib/cpp/src/thrift/protocol/TProtocolDecorator.h
+++ b/lib/cpp/src/thrift/protocol/TProtocolDecorator.h
@@ -23,111 +23,129 @@
#include <thrift/protocol/TProtocol.h>
#include <boost/shared_ptr.hpp>
-namespace apache
-{
- namespace thrift
- {
- namespace protocol
- {
- using boost::shared_ptr;
+namespace apache {
+namespace thrift {
+namespace protocol {
+using boost::shared_ptr;
- /**
- * <code>TProtocolDecorator</code> forwards all requests to an enclosed
- * <code>TProtocol</code> instance, providing a way to author concise
- * concrete decorator subclasses.
- *
- * <p>See p.175 of Design Patterns (by Gamma et al.)</p>
- *
- * @see apache::thrift::protocol::TMultiplexedProtocol
- */
- class TProtocolDecorator : public TProtocol
- {
- public:
- virtual ~TProtocolDecorator() {}
+/**
+ * <code>TProtocolDecorator</code> forwards all requests to an enclosed
+ * <code>TProtocol</code> instance, providing a way to author concise
+ * concrete decorator subclasses.
+ *
+ * <p>See p.175 of Design Patterns (by Gamma et al.)</p>
+ *
+ * @see apache::thrift::protocol::TMultiplexedProtocol
+ */
+class TProtocolDecorator : public TProtocol {
+public:
+ virtual ~TProtocolDecorator() {}
- // Desc: Initializes the protocol decorator object.
- TProtocolDecorator( shared_ptr<TProtocol> proto )
- : TProtocol(proto->getTransport()), protocol(proto)
- {
- }
+ // Desc: Initializes the protocol decorator object.
+ TProtocolDecorator(shared_ptr<TProtocol> proto)
+ : TProtocol(proto->getTransport()), protocol(proto) {}
- virtual uint32_t writeMessageBegin_virt(
- const std::string& name,
- const TMessageType messageType,
- const int32_t seqid)
- {
- return protocol->writeMessageBegin(name, messageType, seqid);
- }
- virtual uint32_t writeMessageEnd_virt() { return protocol->writeMessageEnd(); }
- virtual uint32_t writeStructBegin_virt(const char* name) { return protocol->writeStructBegin(name); }
- virtual uint32_t writeStructEnd_virt() { return protocol->writeStructEnd(); }
+ virtual uint32_t writeMessageBegin_virt(const std::string& name,
+ const TMessageType messageType,
+ const int32_t seqid) {
+ return protocol->writeMessageBegin(name, messageType, seqid);
+ }
+ virtual uint32_t writeMessageEnd_virt() { return protocol->writeMessageEnd(); }
+ virtual uint32_t writeStructBegin_virt(const char* name) {
+ return protocol->writeStructBegin(name);
+ }
+ virtual uint32_t writeStructEnd_virt() { return protocol->writeStructEnd(); }
- virtual uint32_t writeFieldBegin_virt(const char* name,
- const TType fieldType,
- const int16_t fieldId) { return protocol->writeFieldBegin(name,fieldType,fieldId); }
+ virtual uint32_t writeFieldBegin_virt(const char* name,
+ const TType fieldType,
+ const int16_t fieldId) {
+ return protocol->writeFieldBegin(name, fieldType, fieldId);
+ }
- virtual uint32_t writeFieldEnd_virt() { return protocol->writeFieldEnd(); }
- virtual uint32_t writeFieldStop_virt() { return protocol->writeFieldStop(); }
+ virtual uint32_t writeFieldEnd_virt() { return protocol->writeFieldEnd(); }
+ virtual uint32_t writeFieldStop_virt() { return protocol->writeFieldStop(); }
- virtual uint32_t writeMapBegin_virt(const TType keyType,
- const TType valType,
- const uint32_t size) { return protocol->writeMapBegin(keyType,valType,size); }
+ virtual uint32_t writeMapBegin_virt(const TType keyType,
+ const TType valType,
+ const uint32_t size) {
+ return protocol->writeMapBegin(keyType, valType, size);
+ }
- virtual uint32_t writeMapEnd_virt() { return protocol->writeMapEnd(); }
+ virtual uint32_t writeMapEnd_virt() { return protocol->writeMapEnd(); }
- virtual uint32_t writeListBegin_virt(const TType elemType, const uint32_t size) { return protocol->writeListBegin(elemType,size); }
- virtual uint32_t writeListEnd_virt() { return protocol->writeListEnd(); }
+ virtual uint32_t writeListBegin_virt(const TType elemType, const uint32_t size) {
+ return protocol->writeListBegin(elemType, size);
+ }
+ virtual uint32_t writeListEnd_virt() { return protocol->writeListEnd(); }
- virtual uint32_t writeSetBegin_virt(const TType elemType, const uint32_t size) { return protocol->writeSetBegin(elemType,size); }
- virtual uint32_t writeSetEnd_virt() { return protocol->writeSetEnd(); }
+ virtual uint32_t writeSetBegin_virt(const TType elemType, const uint32_t size) {
+ return protocol->writeSetBegin(elemType, size);
+ }
+ virtual uint32_t writeSetEnd_virt() { return protocol->writeSetEnd(); }
- virtual uint32_t writeBool_virt(const bool value) { return protocol->writeBool(value); }
- virtual uint32_t writeByte_virt(const int8_t byte) { return protocol->writeByte(byte); }
- virtual uint32_t writeI16_virt(const int16_t i16) { return protocol->writeI16(i16); }
- virtual uint32_t writeI32_virt(const int32_t i32) { return protocol->writeI32(i32); }
- virtual uint32_t writeI64_virt(const int64_t i64) { return protocol->writeI64(i64); }
+ virtual uint32_t writeBool_virt(const bool value) { return protocol->writeBool(value); }
+ virtual uint32_t writeByte_virt(const int8_t byte) { return protocol->writeByte(byte); }
+ virtual uint32_t writeI16_virt(const int16_t i16) { return protocol->writeI16(i16); }
+ virtual uint32_t writeI32_virt(const int32_t i32) { return protocol->writeI32(i32); }
+ virtual uint32_t writeI64_virt(const int64_t i64) { return protocol->writeI64(i64); }
- virtual uint32_t writeDouble_virt(const double dub) { return protocol->writeDouble(dub); }
- virtual uint32_t writeString_virt(const std::string& str) { return protocol->writeString(str); }
- virtual uint32_t writeBinary_virt(const std::string& str) { return protocol->writeBinary(str); }
+ virtual uint32_t writeDouble_virt(const double dub) { return protocol->writeDouble(dub); }
+ virtual uint32_t writeString_virt(const std::string& str) { return protocol->writeString(str); }
+ virtual uint32_t writeBinary_virt(const std::string& str) { return protocol->writeBinary(str); }
- virtual uint32_t readMessageBegin_virt(std::string& name, TMessageType& messageType, int32_t& seqid) { return protocol->readMessageBegin(name,messageType,seqid); }
- virtual uint32_t readMessageEnd_virt() { return protocol->readMessageEnd(); }
+ virtual uint32_t readMessageBegin_virt(std::string& name,
+ TMessageType& messageType,
+ int32_t& seqid) {
+ return protocol->readMessageBegin(name, messageType, seqid);
+ }
+ virtual uint32_t readMessageEnd_virt() { return protocol->readMessageEnd(); }
- virtual uint32_t readStructBegin_virt(std::string& name) { return protocol->readStructBegin(name); }
- virtual uint32_t readStructEnd_virt() { return protocol->readStructEnd(); }
+ virtual uint32_t readStructBegin_virt(std::string& name) {
+ return protocol->readStructBegin(name);
+ }
+ virtual uint32_t readStructEnd_virt() { return protocol->readStructEnd(); }
- virtual uint32_t readFieldBegin_virt(std::string& name, TType& fieldType, int16_t& fieldId) { return protocol->readFieldBegin(name, fieldType, fieldId); }
- virtual uint32_t readFieldEnd_virt() { return protocol->readFieldEnd(); }
+ virtual uint32_t readFieldBegin_virt(std::string& name, TType& fieldType, int16_t& fieldId) {
+ return protocol->readFieldBegin(name, fieldType, fieldId);
+ }
+ virtual uint32_t readFieldEnd_virt() { return protocol->readFieldEnd(); }
- virtual uint32_t readMapBegin_virt(TType& keyType, TType& valType, uint32_t& size) { return protocol->readMapBegin(keyType,valType,size); }
- virtual uint32_t readMapEnd_virt() { return protocol->readMapEnd(); }
+ virtual uint32_t readMapBegin_virt(TType& keyType, TType& valType, uint32_t& size) {
+ return protocol->readMapBegin(keyType, valType, size);
+ }
+ virtual uint32_t readMapEnd_virt() { return protocol->readMapEnd(); }
- virtual uint32_t readListBegin_virt(TType& elemType, uint32_t& size) { return protocol->readListBegin(elemType,size); }
- virtual uint32_t readListEnd_virt() { return protocol->readListEnd(); }
+ virtual uint32_t readListBegin_virt(TType& elemType, uint32_t& size) {
+ return protocol->readListBegin(elemType, size);
+ }
+ virtual uint32_t readListEnd_virt() { return protocol->readListEnd(); }
- virtual uint32_t readSetBegin_virt(TType& elemType, uint32_t& size) { return protocol->readSetBegin(elemType,size); }
- virtual uint32_t readSetEnd_virt() { return protocol->readSetEnd(); }
+ virtual uint32_t readSetBegin_virt(TType& elemType, uint32_t& size) {
+ return protocol->readSetBegin(elemType, size);
+ }
+ virtual uint32_t readSetEnd_virt() { return protocol->readSetEnd(); }
- virtual uint32_t readBool_virt(bool& value) { return protocol->readBool(value); }
- virtual uint32_t readBool_virt(std::vector<bool>::reference value) { return protocol->readBool(value); }
+ virtual uint32_t readBool_virt(bool& value) { return protocol->readBool(value); }
+ virtual uint32_t readBool_virt(std::vector<bool>::reference value) {
+ return protocol->readBool(value);
+ }
- virtual uint32_t readByte_virt(int8_t& byte) { return protocol->readByte(byte); }
+ virtual uint32_t readByte_virt(int8_t& byte) { return protocol->readByte(byte); }
- virtual uint32_t readI16_virt(int16_t& i16) { return protocol->readI16(i16); }
- virtual uint32_t readI32_virt(int32_t& i32) { return protocol->readI32(i32); }
- virtual uint32_t readI64_virt(int64_t& i64) { return protocol->readI64(i64); }
+ virtual uint32_t readI16_virt(int16_t& i16) { return protocol->readI16(i16); }
+ virtual uint32_t readI32_virt(int32_t& i32) { return protocol->readI32(i32); }
+ virtual uint32_t readI64_virt(int64_t& i64) { return protocol->readI64(i64); }
- virtual uint32_t readDouble_virt(double& dub) { return protocol->readDouble(dub); }
+ virtual uint32_t readDouble_virt(double& dub) { return protocol->readDouble(dub); }
- virtual uint32_t readString_virt(std::string& str) { return protocol->readString(str); }
- virtual uint32_t readBinary_virt(std::string& str) { return protocol->readBinary(str); }
+ virtual uint32_t readString_virt(std::string& str) { return protocol->readString(str); }
+ virtual uint32_t readBinary_virt(std::string& str) { return protocol->readBinary(str); }
- private:
- shared_ptr<TProtocol> protocol;
- };
- }
- }
+private:
+ shared_ptr<TProtocol> protocol;
+};
+}
+}
}
#endif // THRIFT_TPROTOCOLDECORATOR_H_
diff --git a/lib/cpp/src/thrift/protocol/TProtocolException.h b/lib/cpp/src/thrift/protocol/TProtocolException.h
index 4ddb81e..18a8ed0 100644
--- a/lib/cpp/src/thrift/protocol/TProtocolException.h
+++ b/lib/cpp/src/thrift/protocol/TProtocolException.h
@@ -22,7 +22,9 @@
#include <string>
-namespace apache { namespace thrift { namespace protocol {
+namespace apache {
+namespace thrift {
+namespace protocol {
/**
* Class to encapsulate all the possible types of protocol errors that may
@@ -33,36 +35,29 @@
*
*/
class TProtocolException : public apache::thrift::TException {
- public:
-
+public:
/**
* Error codes for the various types of exceptions.
*/
- enum TProtocolExceptionType
- { UNKNOWN = 0
- , INVALID_DATA = 1
- , NEGATIVE_SIZE = 2
- , SIZE_LIMIT = 3
- , BAD_VERSION = 4
- , NOT_IMPLEMENTED = 5
- , DEPTH_LIMIT = 6
+ enum TProtocolExceptionType {
+ UNKNOWN = 0,
+ INVALID_DATA = 1,
+ NEGATIVE_SIZE = 2,
+ SIZE_LIMIT = 3,
+ BAD_VERSION = 4,
+ NOT_IMPLEMENTED = 5,
+ DEPTH_LIMIT = 6
};
- TProtocolException() :
- apache::thrift::TException(),
- type_(UNKNOWN) {}
+ TProtocolException() : apache::thrift::TException(), type_(UNKNOWN) {}
- TProtocolException(TProtocolExceptionType type) :
- apache::thrift::TException(),
- type_(type) {}
+ TProtocolException(TProtocolExceptionType type) : apache::thrift::TException(), type_(type) {}
- TProtocolException(const std::string& message) :
- apache::thrift::TException(message),
- type_(UNKNOWN) {}
+ TProtocolException(const std::string& message)
+ : apache::thrift::TException(message), type_(UNKNOWN) {}
- TProtocolException(TProtocolExceptionType type, const std::string& message) :
- apache::thrift::TException(message),
- type_(type) {}
+ TProtocolException(TProtocolExceptionType type, const std::string& message)
+ : apache::thrift::TException(message), type_(type) {}
virtual ~TProtocolException() throw() {}
@@ -72,34 +67,39 @@
*
* @return Error code
*/
- TProtocolExceptionType getType() {
- return type_;
- }
+ TProtocolExceptionType getType() { return type_; }
virtual const char* what() const throw() {
if (message_.empty()) {
switch (type_) {
- case UNKNOWN : return "TProtocolException: Unknown protocol exception";
- case INVALID_DATA : return "TProtocolException: Invalid data";
- case NEGATIVE_SIZE : return "TProtocolException: Negative size";
- case SIZE_LIMIT : return "TProtocolException: Exceeded size limit";
- case BAD_VERSION : return "TProtocolException: Invalid version";
- case NOT_IMPLEMENTED : return "TProtocolException: Not implemented";
- default : return "TProtocolException: (Invalid exception type)";
+ case UNKNOWN:
+ return "TProtocolException: Unknown protocol exception";
+ case INVALID_DATA:
+ return "TProtocolException: Invalid data";
+ case NEGATIVE_SIZE:
+ return "TProtocolException: Negative size";
+ case SIZE_LIMIT:
+ return "TProtocolException: Exceeded size limit";
+ case BAD_VERSION:
+ return "TProtocolException: Invalid version";
+ case NOT_IMPLEMENTED:
+ return "TProtocolException: Not implemented";
+ default:
+ return "TProtocolException: (Invalid exception type)";
}
} else {
return message_.c_str();
}
}
- protected:
+protected:
/**
* Error code
*/
TProtocolExceptionType type_;
-
};
-
-}}} // apache::thrift::protocol
+}
+}
+} // apache::thrift::protocol
#endif // #ifndef _THRIFT_PROTOCOL_TPROTOCOLEXCEPTION_H_
diff --git a/lib/cpp/src/thrift/protocol/TProtocolTap.h b/lib/cpp/src/thrift/protocol/TProtocolTap.h
index f493f88..3e56393 100644
--- a/lib/cpp/src/thrift/protocol/TProtocolTap.h
+++ b/lib/cpp/src/thrift/protocol/TProtocolTap.h
@@ -22,7 +22,9 @@
#include <thrift/protocol/TVirtualProtocol.h>
-namespace apache { namespace thrift { namespace protocol {
+namespace apache {
+namespace thrift {
+namespace protocol {
using apache::thrift::transport::TTransport;
@@ -33,17 +35,11 @@
*
*/
class TProtocolTap : public TVirtualProtocol<TProtocolTap> {
- public:
- TProtocolTap(boost::shared_ptr<TProtocol> source,
- boost::shared_ptr<TProtocol> sink)
- : TVirtualProtocol<TProtocolTap>(source->getTransport())
- , source_(source)
- , sink_(sink)
- {}
+public:
+ TProtocolTap(boost::shared_ptr<TProtocol> source, boost::shared_ptr<TProtocol> sink)
+ : TVirtualProtocol<TProtocolTap>(source->getTransport()), source_(source), sink_(sink) {}
- uint32_t readMessageBegin(std::string& name,
- TMessageType& messageType,
- int32_t& seqid) {
+ uint32_t readMessageBegin(std::string& name, TMessageType& messageType, int32_t& seqid) {
uint32_t rv = source_->readMessageBegin(name, messageType, seqid);
sink_->writeMessageBegin(name, messageType, seqid);
return rv;
@@ -67,9 +63,7 @@
return rv;
}
- uint32_t readFieldBegin(std::string& name,
- TType& fieldType,
- int16_t& fieldId) {
+ uint32_t readFieldBegin(std::string& name, TType& fieldType, int16_t& fieldId) {
uint32_t rv = source_->readFieldBegin(name, fieldType, fieldId);
if (fieldType == T_STOP) {
sink_->writeFieldStop();
@@ -79,22 +73,18 @@
return rv;
}
-
uint32_t readFieldEnd() {
uint32_t rv = source_->readFieldEnd();
sink_->writeFieldEnd();
return rv;
}
- uint32_t readMapBegin(TType& keyType,
- TType& valType,
- uint32_t& size) {
+ uint32_t readMapBegin(TType& keyType, TType& valType, uint32_t& size) {
uint32_t rv = source_->readMapBegin(keyType, valType, size);
sink_->writeMapBegin(keyType, valType, size);
return rv;
}
-
uint32_t readMapEnd() {
uint32_t rv = source_->readMapEnd();
sink_->writeMapEnd();
@@ -107,7 +97,6 @@
return rv;
}
-
uint32_t readListEnd() {
uint32_t rv = source_->readListEnd();
sink_->writeListEnd();
@@ -120,7 +109,6 @@
return rv;
}
-
uint32_t readSetEnd() {
uint32_t rv = source_->readSetEnd();
sink_->writeSetEnd();
@@ -178,11 +166,12 @@
return rv;
}
- private:
+private:
boost::shared_ptr<TProtocol> source_;
boost::shared_ptr<TProtocol> sink_;
};
-
-}}} // apache::thrift::protocol
+}
+}
+} // apache::thrift::protocol
#endif // #define _THRIFT_PROTOCOL_TPROTOCOLTAP_H_ 1
diff --git a/lib/cpp/src/thrift/protocol/TVirtualProtocol.h b/lib/cpp/src/thrift/protocol/TVirtualProtocol.h
index e068725..831c3a2 100644
--- a/lib/cpp/src/thrift/protocol/TVirtualProtocol.h
+++ b/lib/cpp/src/thrift/protocol/TVirtualProtocol.h
@@ -22,7 +22,9 @@
#include <thrift/protocol/TProtocol.h>
-namespace apache { namespace thrift { namespace protocol {
+namespace apache {
+namespace thrift {
+namespace protocol {
using apache::thrift::transport::TTransport;
@@ -38,13 +40,11 @@
* instead.
*/
class TProtocolDefaults : public TProtocol {
- public:
- uint32_t readMessageBegin(std::string& name,
- TMessageType& messageType,
- int32_t& seqid) {
- (void) name;
- (void) messageType;
- (void) seqid;
+public:
+ uint32_t readMessageBegin(std::string& name, TMessageType& messageType, int32_t& seqid) {
+ (void)name;
+ (void)messageType;
+ (void)seqid;
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
"this protocol does not support reading (yet).");
}
@@ -55,7 +55,7 @@
}
uint32_t readStructBegin(std::string& name) {
- (void) name;
+ (void)name;
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
"this protocol does not support reading (yet).");
}
@@ -65,12 +65,10 @@
"this protocol does not support reading (yet).");
}
- uint32_t readFieldBegin(std::string& name,
- TType& fieldType,
- int16_t& fieldId) {
- (void) name;
- (void) fieldType;
- (void) fieldId;
+ uint32_t readFieldBegin(std::string& name, TType& fieldType, int16_t& fieldId) {
+ (void)name;
+ (void)fieldType;
+ (void)fieldId;
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
"this protocol does not support reading (yet).");
}
@@ -81,9 +79,9 @@
}
uint32_t readMapBegin(TType& keyType, TType& valType, uint32_t& size) {
- (void) keyType;
- (void) valType;
- (void) size;
+ (void)keyType;
+ (void)valType;
+ (void)size;
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
"this protocol does not support reading (yet).");
}
@@ -94,8 +92,8 @@
}
uint32_t readListBegin(TType& elemType, uint32_t& size) {
- (void) elemType;
- (void) size;
+ (void)elemType;
+ (void)size;
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
"this protocol does not support reading (yet).");
}
@@ -106,8 +104,8 @@
}
uint32_t readSetBegin(TType& elemType, uint32_t& size) {
- (void) elemType;
- (void) size;
+ (void)elemType;
+ (void)size;
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
"this protocol does not support reading (yet).");
}
@@ -118,55 +116,55 @@
}
uint32_t readBool(bool& value) {
- (void) value;
+ (void)value;
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
"this protocol does not support reading (yet).");
}
uint32_t readBool(std::vector<bool>::reference value) {
- (void) value;
+ (void)value;
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
"this protocol does not support reading (yet).");
}
uint32_t readByte(int8_t& byte) {
- (void) byte;
+ (void)byte;
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
"this protocol does not support reading (yet).");
}
uint32_t readI16(int16_t& i16) {
- (void) i16;
+ (void)i16;
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
"this protocol does not support reading (yet).");
}
uint32_t readI32(int32_t& i32) {
- (void) i32;
+ (void)i32;
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
"this protocol does not support reading (yet).");
}
uint32_t readI64(int64_t& i64) {
- (void) i64;
+ (void)i64;
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
"this protocol does not support reading (yet).");
}
uint32_t readDouble(double& dub) {
- (void) dub;
+ (void)dub;
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
"this protocol does not support reading (yet).");
}
uint32_t readString(std::string& str) {
- (void) str;
+ (void)str;
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
"this protocol does not support reading (yet).");
}
uint32_t readBinary(std::string& str) {
- (void) str;
+ (void)str;
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
"this protocol does not support reading (yet).");
}
@@ -174,9 +172,9 @@
uint32_t writeMessageBegin(const std::string& name,
const TMessageType messageType,
const int32_t seqid) {
- (void) name;
- (void) messageType;
- (void) seqid;
+ (void)name;
+ (void)messageType;
+ (void)seqid;
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
"this protocol does not support writing (yet).");
}
@@ -186,9 +184,8 @@
"this protocol does not support writing (yet).");
}
-
uint32_t writeStructBegin(const char* name) {
- (void) name;
+ (void)name;
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
"this protocol does not support writing (yet).");
}
@@ -198,12 +195,10 @@
"this protocol does not support writing (yet).");
}
- uint32_t writeFieldBegin(const char* name,
- const TType fieldType,
- const int16_t fieldId) {
- (void) name;
- (void) fieldType;
- (void) fieldId;
+ uint32_t writeFieldBegin(const char* name, const TType fieldType, const int16_t fieldId) {
+ (void)name;
+ (void)fieldType;
+ (void)fieldId;
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
"this protocol does not support writing (yet).");
}
@@ -218,12 +213,10 @@
"this protocol does not support writing (yet).");
}
- uint32_t writeMapBegin(const TType keyType,
- const TType valType,
- const uint32_t size) {
- (void) keyType;
- (void) valType;
- (void) size;
+ uint32_t writeMapBegin(const TType keyType, const TType valType, const uint32_t size) {
+ (void)keyType;
+ (void)valType;
+ (void)size;
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
"this protocol does not support writing (yet).");
}
@@ -234,8 +227,8 @@
}
uint32_t writeListBegin(const TType elemType, const uint32_t size) {
- (void) elemType;
- (void) size;
+ (void)elemType;
+ (void)size;
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
"this protocol does not support writing (yet).");
}
@@ -246,8 +239,8 @@
}
uint32_t writeSetBegin(const TType elemType, const uint32_t size) {
- (void) elemType;
- (void) size;
+ (void)elemType;
+ (void)size;
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
"this protocol does not support writing (yet).");
}
@@ -258,70 +251,66 @@
}
uint32_t writeBool(const bool value) {
- (void) value;
+ (void)value;
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
"this protocol does not support writing (yet).");
}
uint32_t writeByte(const int8_t byte) {
- (void) byte;
+ (void)byte;
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
"this protocol does not support writing (yet).");
}
uint32_t writeI16(const int16_t i16) {
- (void) i16;
+ (void)i16;
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
"this protocol does not support writing (yet).");
}
uint32_t writeI32(const int32_t i32) {
- (void) i32;
+ (void)i32;
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
"this protocol does not support writing (yet).");
}
uint32_t writeI64(const int64_t i64) {
- (void) i64;
+ (void)i64;
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
"this protocol does not support writing (yet).");
}
uint32_t writeDouble(const double dub) {
- (void) dub;
+ (void)dub;
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
"this protocol does not support writing (yet).");
}
uint32_t writeString(const std::string& str) {
- (void) str;
+ (void)str;
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
"this protocol does not support writing (yet).");
}
uint32_t writeBinary(const std::string& str) {
- (void) str;
+ (void)str;
throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
"this protocol does not support writing (yet).");
}
- uint32_t skip(TType type) {
- return ::apache::thrift::protocol::skip(*this, type);
- }
+ uint32_t skip(TType type) { return ::apache::thrift::protocol::skip(*this, type); }
- protected:
- TProtocolDefaults(boost::shared_ptr<TTransport> ptrans)
- : TProtocol(ptrans)
- {}
+protected:
+ TProtocolDefaults(boost::shared_ptr<TTransport> ptrans) : TProtocol(ptrans) {}
};
/**
* Concrete TProtocol classes should inherit from TVirtualProtocol
* so they don't have to manually override virtual methods.
*/
-template <class Protocol_, class Super_=TProtocolDefaults>
+template <class Protocol_, class Super_ = TProtocolDefaults>
class TVirtualProtocol : public Super_ {
- public:
+public:
/**
* Writing functions.
*/
@@ -329,37 +318,28 @@
virtual uint32_t writeMessageBegin_virt(const std::string& name,
const TMessageType messageType,
const int32_t seqid) {
- return static_cast<Protocol_*>(this)->writeMessageBegin(name, messageType,
- seqid);
+ return static_cast<Protocol_*>(this)->writeMessageBegin(name, messageType, seqid);
}
virtual uint32_t writeMessageEnd_virt() {
return static_cast<Protocol_*>(this)->writeMessageEnd();
}
-
virtual uint32_t writeStructBegin_virt(const char* name) {
return static_cast<Protocol_*>(this)->writeStructBegin(name);
}
- virtual uint32_t writeStructEnd_virt() {
- return static_cast<Protocol_*>(this)->writeStructEnd();
- }
+ virtual uint32_t writeStructEnd_virt() { return static_cast<Protocol_*>(this)->writeStructEnd(); }
virtual uint32_t writeFieldBegin_virt(const char* name,
const TType fieldType,
const int16_t fieldId) {
- return static_cast<Protocol_*>(this)->writeFieldBegin(name, fieldType,
- fieldId);
+ return static_cast<Protocol_*>(this)->writeFieldBegin(name, fieldType, fieldId);
}
- virtual uint32_t writeFieldEnd_virt() {
- return static_cast<Protocol_*>(this)->writeFieldEnd();
- }
+ virtual uint32_t writeFieldEnd_virt() { return static_cast<Protocol_*>(this)->writeFieldEnd(); }
- virtual uint32_t writeFieldStop_virt() {
- return static_cast<Protocol_*>(this)->writeFieldStop();
- }
+ virtual uint32_t writeFieldStop_virt() { return static_cast<Protocol_*>(this)->writeFieldStop(); }
virtual uint32_t writeMapBegin_virt(const TType keyType,
const TType valType,
@@ -367,27 +347,19 @@
return static_cast<Protocol_*>(this)->writeMapBegin(keyType, valType, size);
}
- virtual uint32_t writeMapEnd_virt() {
- return static_cast<Protocol_*>(this)->writeMapEnd();
- }
+ virtual uint32_t writeMapEnd_virt() { return static_cast<Protocol_*>(this)->writeMapEnd(); }
- virtual uint32_t writeListBegin_virt(const TType elemType,
- const uint32_t size) {
+ virtual uint32_t writeListBegin_virt(const TType elemType, const uint32_t size) {
return static_cast<Protocol_*>(this)->writeListBegin(elemType, size);
}
- virtual uint32_t writeListEnd_virt() {
- return static_cast<Protocol_*>(this)->writeListEnd();
- }
+ virtual uint32_t writeListEnd_virt() { return static_cast<Protocol_*>(this)->writeListEnd(); }
- virtual uint32_t writeSetBegin_virt(const TType elemType,
- const uint32_t size) {
+ virtual uint32_t writeSetBegin_virt(const TType elemType, const uint32_t size) {
return static_cast<Protocol_*>(this)->writeSetBegin(elemType, size);
}
- virtual uint32_t writeSetEnd_virt() {
- return static_cast<Protocol_*>(this)->writeSetEnd();
- }
+ virtual uint32_t writeSetEnd_virt() { return static_cast<Protocol_*>(this)->writeSetEnd(); }
virtual uint32_t writeBool_virt(const bool value) {
return static_cast<Protocol_*>(this)->writeBool(value);
@@ -428,60 +400,40 @@
virtual uint32_t readMessageBegin_virt(std::string& name,
TMessageType& messageType,
int32_t& seqid) {
- return static_cast<Protocol_*>(this)->readMessageBegin(name, messageType,
- seqid);
+ return static_cast<Protocol_*>(this)->readMessageBegin(name, messageType, seqid);
}
- virtual uint32_t readMessageEnd_virt() {
- return static_cast<Protocol_*>(this)->readMessageEnd();
- }
+ virtual uint32_t readMessageEnd_virt() { return static_cast<Protocol_*>(this)->readMessageEnd(); }
virtual uint32_t readStructBegin_virt(std::string& name) {
return static_cast<Protocol_*>(this)->readStructBegin(name);
}
- virtual uint32_t readStructEnd_virt() {
- return static_cast<Protocol_*>(this)->readStructEnd();
+ virtual uint32_t readStructEnd_virt() { return static_cast<Protocol_*>(this)->readStructEnd(); }
+
+ virtual uint32_t readFieldBegin_virt(std::string& name, TType& fieldType, int16_t& fieldId) {
+ return static_cast<Protocol_*>(this)->readFieldBegin(name, fieldType, fieldId);
}
- virtual uint32_t readFieldBegin_virt(std::string& name,
- TType& fieldType,
- int16_t& fieldId) {
- return static_cast<Protocol_*>(this)->readFieldBegin(name, fieldType,
- fieldId);
- }
+ virtual uint32_t readFieldEnd_virt() { return static_cast<Protocol_*>(this)->readFieldEnd(); }
- virtual uint32_t readFieldEnd_virt() {
- return static_cast<Protocol_*>(this)->readFieldEnd();
- }
-
- virtual uint32_t readMapBegin_virt(TType& keyType,
- TType& valType,
- uint32_t& size) {
+ virtual uint32_t readMapBegin_virt(TType& keyType, TType& valType, uint32_t& size) {
return static_cast<Protocol_*>(this)->readMapBegin(keyType, valType, size);
}
- virtual uint32_t readMapEnd_virt() {
- return static_cast<Protocol_*>(this)->readMapEnd();
- }
+ virtual uint32_t readMapEnd_virt() { return static_cast<Protocol_*>(this)->readMapEnd(); }
- virtual uint32_t readListBegin_virt(TType& elemType,
- uint32_t& size) {
+ virtual uint32_t readListBegin_virt(TType& elemType, uint32_t& size) {
return static_cast<Protocol_*>(this)->readListBegin(elemType, size);
}
- virtual uint32_t readListEnd_virt() {
- return static_cast<Protocol_*>(this)->readListEnd();
- }
+ virtual uint32_t readListEnd_virt() { return static_cast<Protocol_*>(this)->readListEnd(); }
- virtual uint32_t readSetBegin_virt(TType& elemType,
- uint32_t& size) {
+ virtual uint32_t readSetBegin_virt(TType& elemType, uint32_t& size) {
return static_cast<Protocol_*>(this)->readSetBegin(elemType, size);
}
- virtual uint32_t readSetEnd_virt() {
- return static_cast<Protocol_*>(this)->readSetEnd();
- }
+ virtual uint32_t readSetEnd_virt() { return static_cast<Protocol_*>(this)->readSetEnd(); }
virtual uint32_t readBool_virt(bool& value) {
return static_cast<Protocol_*>(this)->readBool(value);
@@ -519,9 +471,7 @@
return static_cast<Protocol_*>(this)->readBinary(str);
}
- virtual uint32_t skip_virt(TType type) {
- return static_cast<Protocol_*>(this)->skip(type);
- }
+ virtual uint32_t skip_virt(TType type) { return static_cast<Protocol_*>(this)->skip(type); }
/*
* Provide a default skip() implementation that uses non-virtual read
@@ -553,12 +503,11 @@
}
using Super_::readBool; // so we don't hide readBool(bool&)
- protected:
- TVirtualProtocol(boost::shared_ptr<TTransport> ptrans)
- : Super_(ptrans)
- {}
+protected:
+ TVirtualProtocol(boost::shared_ptr<TTransport> ptrans) : Super_(ptrans) {}
};
-
-}}} // apache::thrift::protocol
+}
+}
+} // apache::thrift::protocol
#endif // #define _THRIFT_PROTOCOL_TVIRTUALPROTOCOL_H_ 1