From 542d81ac68c416e8d76839e438ad1d6aaab528f3 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Wed, 2 May 2018 11:10:19 -0700 Subject: Adding mergeFields support (#1141) --- Firestore/core/src/firebase/firestore/model/field_mask.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'Firestore/core/src/firebase/firestore/model') diff --git a/Firestore/core/src/firebase/firestore/model/field_mask.h b/Firestore/core/src/firebase/firestore/model/field_mask.h index b895ab3..6075519 100644 --- a/Firestore/core/src/firebase/firestore/model/field_mask.h +++ b/Firestore/core/src/firebase/firestore/model/field_mask.h @@ -55,6 +55,22 @@ class FieldMask { return fields_.end(); } + /** + * Verifies that `fieldPath` is included by at least one field in this field + * mask. + * + * This is an O(n) operation, where `n` is the size of the field mask. + */ + bool covers(const FieldPath& fieldPath) const { + for (const FieldPath& fieldMaskPath : fields_) { + if (fieldMaskPath.IsPrefixOf(fieldPath)) { + return true; + } + } + + return false; + } + std::string ToString() const { // Ideally, one should use a string builder. Since this is only non-critical // code for logging and debugging, the logic is kept simple here. -- cgit v1.2.3