aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/unknown_field_set.cc
diff options
context:
space:
mode:
authorGravatar temporal <temporal@630680e5-0e50-0410-840e-4b1c322b438d>2008-08-06 01:12:21 +0000
committerGravatar temporal <temporal@630680e5-0e50-0410-840e-4b1c322b438d>2008-08-06 01:12:21 +0000
commita0f27fcd96c5bf2509ca88cca54f00b78f7b8bc5 (patch)
tree6d44ab5739d6fc9b956e17eb13a6d34f71094109 /src/google/protobuf/unknown_field_set.cc
parent8ccb79057ee477c36d155f2c507c859934f858dd (diff)
Heuristically detect sub-messages when printing unknown fields.
Patch mostly written by Dilip Joseph <dilip.antony.joseph@gmail.com>.
Diffstat (limited to 'src/google/protobuf/unknown_field_set.cc')
-rw-r--r--src/google/protobuf/unknown_field_set.cc32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/google/protobuf/unknown_field_set.cc b/src/google/protobuf/unknown_field_set.cc
index 2f44901e..3d45002e 100644
--- a/src/google/protobuf/unknown_field_set.cc
+++ b/src/google/protobuf/unknown_field_set.cc
@@ -20,6 +20,10 @@
#include <google/protobuf/unknown_field_set.h>
#include <google/protobuf/stubs/stl_util-inl.h>
+#include <google/protobuf/io/coded_stream.h>
+#include <google/protobuf/io/zero_copy_stream.h>
+#include <google/protobuf/io/zero_copy_stream_impl.h>
+#include <google/protobuf/wire_format.h>
namespace google {
namespace protobuf {
@@ -57,6 +61,34 @@ void UnknownFieldSet::MergeFrom(const UnknownFieldSet& other) {
}
}
+bool UnknownFieldSet::MergeFromCodedStream(io::CodedInputStream* input) {
+
+ UnknownFieldSet other;
+ if (internal::WireFormat::SkipMessage(input, &other) &&
+ input->ConsumedEntireMessage()) {
+ MergeFrom(other);
+ return true;
+ } else {
+ return false;
+ }
+}
+
+bool UnknownFieldSet::ParseFromCodedStream(io::CodedInputStream* input) {
+ Clear();
+ return MergeFromCodedStream(input);
+}
+
+bool UnknownFieldSet::ParseFromZeroCopyStream(io::ZeroCopyInputStream* input) {
+ io::CodedInputStream coded_input(input);
+ return ParseFromCodedStream(&coded_input) &&
+ coded_input.ConsumedEntireMessage();
+}
+
+bool UnknownFieldSet::ParseFromArray(const void* data, int size) {
+ io::ArrayInputStream input(data, size);
+ return ParseFromZeroCopyStream(&input);
+}
+
const UnknownField* UnknownFieldSet::FindFieldByNumber(int number) const {
if (internal_ == NULL) return NULL;