You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by hc...@apache.org on 2014/11/18 10:02:38 UTC

[10/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/protocol/TDenseProtocol.h
----------------------------------------------------------------------
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 @@ namespace apache { namespace thrift { namespace protocol {
  * 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 @@ class TDenseProtocol
    * @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)
-  {}
-
-  void setTypeSpec(TypeSpec* type_spec) {
-    type_spec_ = type_spec;
-  }
-  TypeSpec* getTypeSpec() {
-    return type_spec_;
-  }
+  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_; }
 
   /*
    * Writing functions.
@@ -96,22 +90,17 @@ class TDenseProtocol
 
   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 @@ class TDenseProtocol
 
   uint32_t writeBinary(const std::string& str);
 
-
   /*
    * Helper writing functions (don't do state transitions).
    */
@@ -147,18 +135,13 @@ class TDenseProtocol
 
   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 @@ class TDenseProtocol
 
   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 @@ class TDenseProtocol
 
   inline uint32_t subReadString(std::string& str);
 
-  uint32_t subReadBool(bool& value) {
-    return TBinaryProtocol::readBool(value);
-  }
-
-
- private:
+  uint32_t subReadBool(bool& value) { return TBinaryProtocol::readBool(value); }
 
+private:
   // Implementation functions, documented in the .cpp.
   inline void checkTType(const TType ttype);
   inline void stateTransition();
@@ -240,15 +213,16 @@ class TDenseProtocol
   // 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_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp
----------------------------------------------------------------------
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 kTypeNameMap("map");
 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 @@ static const std::string &getTypeNameForTypeID(TType typeID) {
   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 @@ static TType getTypeIDForTypeName(const std::string &name) {
     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 @@ static TType getTypeIDForTypeName(const std::string &name) {
     }
   }
   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 @@ const static std::string kEscapeChars("\"\\bfnrt");
 // 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 uint32_t readSyntaxChar(TJSONProtocol::LookaheadReader &reader,
 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 @@ static uint8_t hexChar(uint8_t val) {
   val &= 0x0F;
   if (val < 10) {
     return val + '0';
-  }
-  else {
+  } else {
     return val - 10 + 'a';
   }
 }
@@ -238,32 +279,30 @@ static bool isJSONNumeric(uint8_t ch) {
   return false;
 }
 
-
 /**
  * Class to serve as base JSON context and as base class for other context
  * implementations
  */
 class TJSONContext {
 
- public:
-
-  TJSONContext() {};
+public:
+  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 @@ class TJSONContext {
    * 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 @@ public:
   }
 
   // Numbers must be turned into strings if they are the key part of a pair
-  virtual bool escapeNum() {
-    return colon_;
-  }
-
-  private:
+  virtual bool escapeNum() { return colon_; }
 
-    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 @@ void TJSONProtocol::popContext() {
 
 // 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 @@ uint32_t TJSONProtocol::writeJSONChar(uint8_t ch) {
       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 @@ uint32_t TJSONProtocol::writeJSONChar(uint8_t ch) {
 
 // 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 @@ uint32_t TJSONProtocol::writeJSONString(const std::string &str) {
 
 // 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 @@ uint32_t TJSONProtocol::writeJSONBase64(const std::string &str) {
     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 @@ uint32_t TJSONProtocol::writeJSONInteger(NumberType num) {
     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 @@ uint32_t TJSONProtocol::writeJSONDouble(double num) {
     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::writeMessageEnd() {
 }
 
 uint32_t TJSONProtocol::writeStructBegin(const char* name) {
-  (void) name;
+  (void)name;
   return writeJSONObjectStart();
 }
 
@@ -580,7 +599,7 @@ uint32_t TJSONProtocol::writeStructEnd() {
 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 @@ uint32_t TJSONProtocol::writeMapEnd() {
   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 @@ uint32_t TJSONProtocol::writeListEnd() {
   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 @@ uint32_t TJSONProtocol::writeBinary(const std::string& str) {
   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 @@ uint32_t TJSONProtocol::readJSONSyntaxChar(uint8_t ch) {
 
 // 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 @@ uint32_t TJSONProtocol::readJSONEscapeChar(uint8_t *out) {
 }
 
 // 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 @@ uint32_t TJSONProtocol::readJSONString(std::string &str, bool skipContext) {
       ++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 @@ uint32_t TJSONProtocol::readJSONString(std::string &str, bool skipContext) {
 }
 
 // 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 @@ uint32_t TJSONProtocol::readJSONBase64(std::string &str) {
   // 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 @@ uint32_t TJSONProtocol::readJSONNumericChars(std::string &str) {
 // 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 @@ uint32_t TJSONProtocol::readJSONInteger(NumberType &num) {
   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 @@ uint32_t TJSONProtocol::readJSONInteger(NumberType &num) {
 }
 
 // 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 @@ uint32_t TJSONProtocol::readJSONDouble(double &num) {
       }
       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 @@ uint32_t TJSONProtocol::readJSONDouble(double &num) {
     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 @@ uint32_t TJSONProtocol::readMessageBegin(std::string& name,
   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::readMessageEnd() {
 }
 
 uint32_t TJSONProtocol::readStructBegin(std::string& name) {
-  (void) name;
+  (void)name;
   return readJSONObjectStart();
 }
 
@@ -896,21 +901,18 @@ uint32_t TJSONProtocol::readStructEnd() {
   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 @@ uint32_t TJSONProtocol::readFieldEnd() {
   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 @@ uint32_t TJSONProtocol::readMapBegin(TType& keyType,
   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 @@ uint32_t TJSONProtocol::readMapEnd() {
   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 @@ uint32_t TJSONProtocol::readListEnd() {
   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 @@ uint32_t TJSONProtocol::readBool(bool& value) {
 // 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 @@ uint32_t TJSONProtocol::readDouble(double& dub) {
   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

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/protocol/TJSONProtocol.h
----------------------------------------------------------------------
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 TJSONContext;
  *
  */
 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 @@ class TJSONProtocol : public TVirtualProtocol<TJSONProtocol> {
 
   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 @@ class TJSONProtocol : public TVirtualProtocol<TJSONProtocol> {
 
   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 @@ class TJSONProtocol : public TVirtualProtocol<TJSONProtocol> {
 
   uint32_t readJSONArrayEnd();
 
- public:
-
+public:
   /**
    * Writing functions.
    */
@@ -160,27 +159,21 @@ class TJSONProtocol : public TVirtualProtocol<TJSONProtocol> {
 
   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 @@ class TJSONProtocol : public TVirtualProtocol<TJSONProtocol> {
    * 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 @@ class TJSONProtocol : public TVirtualProtocol<TJSONProtocol> {
 
   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 TJSONProtocol : public TVirtualProtocol<TJSONProtocol> {
 
   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 @@ class TJSONProtocol : public TVirtualProtocol<TJSONProtocol> {
       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 @@ class TJSONProtocol : public TVirtualProtocol<TJSONProtocol> {
  * Constructs input and output protocol objects given transports.
  */
 class TJSONProtocolFactory : public TProtocolFactory {
- public:
+public:
   TJSONProtocolFactory() {}
 
   virtual ~TJSONProtocolFactory() {}
@@ -309,17 +289,18 @@ class TJSONProtocolFactory : public TProtocolFactory {
     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 @@ template<typename ThriftStruct>
   buffer->getBuffer(&buf, &size);
   return std::string((char*)buf, (unsigned int)size);
 }
-
-}} // apache::thrift
+}
+} // apache::thrift
 
 #endif // #define _THRIFT_PROTOCOL_TJSONPROTOCOL_H_ 1

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/protocol/TMultiplexedProtocol.cpp
----------------------------------------------------------------------
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);
+  }
+}
+}
+}
 }
-

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/protocol/TMultiplexedProtocol.h
----------------------------------------------------------------------
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_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/protocol/TProtocol.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/protocol/TProtocol.h b/lib/cpp/src/thrift/protocol/TProtocol.h
index d4c343d..0c76cc0 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 @@ static inline To bitwise_cast(From from) {
 # 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 @@ enum TMessageType {
 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 @@ static const uint32_t DEFAULT_RECURSION_LIMIT = 64;
  *
  */
 class TProtocol {
- public:
+public:
   virtual ~TProtocol() {}
 
   /**
@@ -313,7 +307,6 @@ class TProtocol {
 
   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 @@ class TProtocol {
 
   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 @@ class TProtocol {
     return writeMessageEnd_virt();
   }
 
-
   uint32_t writeStructBegin(const char* name) {
     T_VIRTUAL_CALL();
     return writeStructBegin_virt(name);
@@ -381,9 +370,7 @@ class TProtocol {
     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 @@ class TProtocol {
     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);
   }
@@ -485,24 +470,19 @@ class TProtocol {
   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 +504,7 @@ class TProtocol {
 
   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 +524,7 @@ class TProtocol {
     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 +621,14 @@ class TProtocol {
     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 +636,15 @@ class TProtocol {
     }
   }
 
-  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 +654,7 @@ class TProtocol {
  * Constructs input and output protocol objects given transports.
  */
 class TProtocolFactory {
- public:
+public:
   TProtocolFactory() {}
 
   virtual ~TProtocolFactory() {}
@@ -704,9 +668,9 @@ class TProtocolFactory {
  * 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

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/protocol/TProtocolDecorator.h
----------------------------------------------------------------------
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;
-
-            /**
-             * <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)
-                {
-                }
-
-                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 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 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 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 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 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 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 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 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 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); }
-
-            private:
-                shared_ptr<TProtocol> protocol;
-            };
-        }
-    }
+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() {}
+
+  // 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 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 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 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 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 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 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 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 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 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 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;
+};
+}
+}
 }
 
 #endif // THRIFT_TPROTOCOLDECORATOR_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/protocol/TProtocolException.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 @@ namespace apache { namespace thrift { namespace protocol {
  *
  */
 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 @@ class TProtocolException : public apache::thrift::TException {
    *
    * @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_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/src/thrift/protocol/TProtocolTap.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 @@ using apache::thrift::transport::TTransport;
  *
  */
 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)
-  {}
-
-  uint32_t readMessageBegin(std::string& name,
-                            TMessageType& messageType,
-                            int32_t& seqid) {
+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 rv = source_->readMessageBegin(name, messageType, seqid);
     sink_->writeMessageBegin(name, messageType, seqid);
     return rv;
@@ -67,9 +63,7 @@ class TProtocolTap : public TVirtualProtocol<TProtocolTap> {
     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 @@ class TProtocolTap : public TVirtualProtocol<TProtocolTap> {
     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 @@ class TProtocolTap : public TVirtualProtocol<TProtocolTap> {
     return rv;
   }
 
-
   uint32_t readListEnd() {
     uint32_t rv = source_->readListEnd();
     sink_->writeListEnd();
@@ -120,7 +109,6 @@ class TProtocolTap : public TVirtualProtocol<TProtocolTap> {
     return rv;
   }
 
-
   uint32_t readSetEnd() {
     uint32_t rv = source_->readSetEnd();
     sink_->writeSetEnd();
@@ -178,11 +166,12 @@ class TProtocolTap : public TVirtualProtocol<TProtocolTap> {
     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