aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/core/src/firebase/firestore/nanopb/reader.h
diff options
context:
space:
mode:
Diffstat (limited to 'Firestore/core/src/firebase/firestore/nanopb/reader.h')
-rw-r--r--Firestore/core/src/firebase/firestore/nanopb/reader.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/Firestore/core/src/firebase/firestore/nanopb/reader.h b/Firestore/core/src/firebase/firestore/nanopb/reader.h
index 7d77a4d..093e20b 100644
--- a/Firestore/core/src/firebase/firestore/nanopb/reader.h
+++ b/Firestore/core/src/firebase/firestore/nanopb/reader.h
@@ -80,6 +80,11 @@ class Reader {
*
* Call this method when reading a nested message. Provide a function to read
* the message itself.
+ *
+ * @param read_message_fn Function to read the submessage. Note that this
+ * function is expected to check the Reader's status (via
+ * Reader::status().ok()) and if not ok, to return a placeholder/invalid
+ * value.
*/
template <typename T>
T ReadNestedMessage(const std::function<T(Reader*)>& read_message_fn);
@@ -130,14 +135,14 @@ T Reader::ReadNestedMessage(const std::function<T(Reader*)>& read_message_fn) {
// Implementation note: This is roughly modeled on pb_decode_delimited,
// adjusted to account for the oneof in FieldValue.
- if (!status_.ok()) return T();
+ if (!status_.ok()) return read_message_fn(this);
pb_istream_t raw_substream;
if (!pb_make_string_substream(&stream_, &raw_substream)) {
status_ =
util::Status(FirestoreErrorCode::DataLoss, PB_GET_ERROR(&stream_));
pb_close_string_substream(&stream_, &raw_substream);
- return T();
+ return read_message_fn(this);
}
Reader substream(raw_substream);