Thrift: Distinguish between string and binary types in C++ and Java.
Summary:
The upcoming TJSONProtocol handles string and binary types quite differently.
This change makes that distinction in all parts of the C++ binding.
Java already distinguished between string and binary, but this change
also updates the Java skip method to skip over strings as binary
so we don't get encoding errors when skipping binary data.
Reviewed By: mcslee
Test Plan: make check
Revert Plan: ok
Other Notes:
I just pulled this out of Chad Walters' JSON patch.
The only other change was adding readBinary (or was it writeBinary)
to TDenseProtocol. Maybe inheriting from TBinaryProtocol wasn't a good idea.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665481 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/protocol/TBinaryProtocol.cpp b/lib/cpp/src/protocol/TBinaryProtocol.cpp
index 289d614..929499b 100644
--- a/lib/cpp/src/protocol/TBinaryProtocol.cpp
+++ b/lib/cpp/src/protocol/TBinaryProtocol.cpp
@@ -188,6 +188,10 @@
return result + size;
}
+uint32_t TBinaryProtocol::writeBinary(const string& str) {
+ return TBinaryProtocol::writeString(str);
+}
+
/**
* Reading functions
*/
@@ -379,6 +383,10 @@
return result + readStringBody(str, size);
}
+uint32_t TBinaryProtocol::readBinary(string& str) {
+ return TBinaryProtocol::readString(str);
+}
+
uint32_t TBinaryProtocol::readStringBody(string& str, int32_t size) {
uint32_t result = 0;