diff options
author | rsgowman <rgowman@google.com> | 2018-06-25 10:06:35 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-25 10:06:35 -0400 |
commit | 47ab39aee6330f59263b0a9b2fc36536544651fd (patch) | |
tree | efff1d390bc56c7a7d00628da6d81dca377684be /Firestore/core/src/firebase/firestore/nanopb/reader.cc | |
parent | 137ce37363d72ac1d643ea9f93bc6e6665367e57 (diff) |
Refactor nanopb decoding methods (#1438)
Rather than decoding the type, and then the contents, decode them both at once.
Diffstat (limited to 'Firestore/core/src/firebase/firestore/nanopb/reader.cc')
-rw-r--r-- | Firestore/core/src/firebase/firestore/nanopb/reader.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Firestore/core/src/firebase/firestore/nanopb/reader.cc b/Firestore/core/src/firebase/firestore/nanopb/reader.cc index 3b102f0..3e6d92e 100644 --- a/Firestore/core/src/firebase/firestore/nanopb/reader.cc +++ b/Firestore/core/src/firebase/firestore/nanopb/reader.cc @@ -46,6 +46,17 @@ Tag Reader::ReadTag() { return tag; } +bool Reader::RequireWireType(pb_wire_type_t wire_type, Tag tag) { + if (!status_.ok()) return false; + if (wire_type != tag.wire_type) { + set_status(Status(FirestoreErrorCode::DataLoss, + "Input proto bytes cannot be parsed (mismatch between " + "the wiretype and the field number (tag))")); + return false; + } + return true; +} + void Reader::ReadNanopbMessage(const pb_field_t fields[], void* dest_struct) { if (!status_.ok()) return; |