Rev 2 of Thrift, the Pillar successor

Summary: End-to-end communications and serialization in C++ is working

Reviewed By: aditya

Test Plan: See the new top-level test/ folder. It vaguely resembles a unit test, though it could be more automated.

Revert Plan: Revertible

Notes: Still a LOT of optimization work to be done on the generated C++ code, which should be using dynamic memory in a number of places. Next major task is writing the PHP/Java/Python generators.




git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664712 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/protocol/TBinaryProtocol.h b/lib/cpp/protocol/TBinaryProtocol.h
new file mode 100644
index 0000000..976c383
--- /dev/null
+++ b/lib/cpp/protocol/TBinaryProtocol.h
@@ -0,0 +1,42 @@
+#ifndef T_BINARY_PROTOCOL_H
+#define T_BINARY_PROTOCOL_H
+
+#include "protocol/TProtocol.h"
+
+/**
+ * The default binary protocol for thrift. Writes all data in a very basic
+ * binary format, essentially just spitting out the raw bytes.
+ *
+ * @author Mark Slee <mcslee@facebook.com>
+ */
+class TBinaryProtocol : public TProtocol {
+ public:
+  TBinaryProtocol() {}
+  ~TBinaryProtocol() {}
+
+  std::string
+    readFunction(TBuf& buf) const;
+  std::string
+    writeFunction(const std::string& name, const std::string& args) const;
+
+  std::map<uint32_t, TBuf>
+    readStruct(TBuf& buf) const;
+  std::string
+    writeStruct(const std::map<uint32_t,std::string>& s) const;
+
+  std::string readString  (TBuf& buf) const;
+  uint8_t     readByte    (TBuf& buf) const;
+  uint32_t    readU32     (TBuf& buf) const;
+  int32_t     readI32     (TBuf& buf) const;
+  uint64_t    readU64     (TBuf& buf) const;
+  int64_t     readI64     (TBuf& buf) const;
+
+  std::string writeString (const std::string& str) const;
+  std::string writeByte   (const uint8_t  byte)    const;
+  std::string writeU32    (const uint32_t u32)     const;
+  std::string writeI32    (const int32_t  i32)     const;
+  std::string writeU64    (const uint64_t u64)     const;
+  std::string writeI64    (const int64_t  i64)     const;
+};
+
+#endif