diff options
author | Sebastian Schmidt <mrschmidt@google.com> | 2018-05-02 11:10:19 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-02 11:10:19 -0700 |
commit | 542d81ac68c416e8d76839e438ad1d6aaab528f3 (patch) | |
tree | d9cdc0797d3757d6899047f9f78b578b73fd2cdd /Firestore/core/src/firebase/firestore/model | |
parent | 39e68afc1a76f5e2ee19405bd32de7b335d4fb43 (diff) |
Adding mergeFields support (#1141)
Diffstat (limited to 'Firestore/core/src/firebase/firestore/model')
-rw-r--r-- | Firestore/core/src/firebase/firestore/model/field_mask.h | 16 |
1 files changed, 16 insertions, 0 deletions
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. |