THRIFT-922. cpp: Convert protocol classes to use non-virtual functions

Updated the thrift protocol classes to use non-virtual calls for most
functions.  The correct implementation is determined at compile time via
templates now.  Only the base TProtocol class falls back to using
virtual function calls.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005135 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/protocol/TBinaryProtocol.h b/lib/cpp/src/protocol/TBinaryProtocol.h
index 7fd3de6..45c5842 100644
--- a/lib/cpp/src/protocol/TBinaryProtocol.h
+++ b/lib/cpp/src/protocol/TBinaryProtocol.h
@@ -21,6 +21,7 @@
 #define _THRIFT_PROTOCOL_TBINARYPROTOCOL_H_ 1
 
 #include "TProtocol.h"
+#include "TVirtualProtocol.h"
 
 #include <boost/shared_ptr.hpp>
 
@@ -31,7 +32,7 @@
  * binary format, essentially just spitting out the raw bytes.
  *
  */
-class TBinaryProtocol : public TProtocol {
+class TBinaryProtocol : public TVirtualProtocol<TBinaryProtocol> {
  protected:
   static const int32_t VERSION_MASK = 0xffff0000;
   static const int32_t VERSION_1 = 0x80010000;
@@ -39,7 +40,7 @@
 
  public:
   TBinaryProtocol(boost::shared_ptr<TTransport> trans) :
-    TProtocol(trans),
+    TVirtualProtocol<TBinaryProtocol>(trans),
     string_limit_(0),
     container_limit_(0),
     strict_read_(false),
@@ -52,7 +53,7 @@
                   int32_t container_limit,
                   bool strict_read,
                   bool strict_write) :
-    TProtocol(trans),
+    TVirtualProtocol<TBinaryProtocol>(trans),
     string_limit_(string_limit),
     container_limit_(container_limit),
     strict_read_(strict_read),
@@ -84,11 +85,11 @@
    * Writing functions.
    */
 
-  virtual uint32_t writeMessageBegin(const std::string& name,
-                                     const TMessageType messageType,
-                                     const int32_t seqid);
+  uint32_t writeMessageBegin(const std::string& name,
+                             const TMessageType messageType,
+                             const int32_t seqid);
 
-  virtual uint32_t writeMessageEnd();
+  uint32_t writeMessageEnd();
 
 
   uint32_t writeStructBegin(const char* name);