From 2d9d3a868c996d38b4a8bf6d3ce55ee76af43d75 Mon Sep 17 00:00:00 2001 From: zxu Date: Thu, 15 Mar 2018 11:31:16 -0400 Subject: adding converters between DocumentKey (#900) * naively remove FSTPath import and source/test files. * port FieldPath, part I * port FieldPath, part II * port ResourcePath, part I * port ResourcePath, part II * the grand commit to fix build errors * use testutil:: helper instead of those from FSTHelpers * fix test and lint * use c_str in errmsg directly * fix * fix * make code clean * fix integration test I missed * fix to avoid naming collision in preprocessor * address changes * address changes * address changes * fix: fieldMask are actually shared with different context. * address changes * add converter function between two DocumentKey implementations * add unit test * address changes * fix lint --- .../core/src/firebase/firestore/model/document_key.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'Firestore/core/src/firebase/firestore/model') diff --git a/Firestore/core/src/firebase/firestore/model/document_key.h b/Firestore/core/src/firebase/firestore/model/document_key.h index 6eb1e18..8e590d8 100644 --- a/Firestore/core/src/firebase/firestore/model/document_key.h +++ b/Firestore/core/src/firebase/firestore/model/document_key.h @@ -21,6 +21,10 @@ #include #include +#if defined(__OBJC__) +#import "Firestore/Source/Model/FSTDocumentKey.h" +#endif // defined(__OBJC__) + #include "Firestore/core/src/firebase/firestore/model/resource_path.h" #include "absl/strings/string_view.h" @@ -43,6 +47,16 @@ class DocumentKey { /** Creates a new document key, taking ownership of the given path. */ explicit DocumentKey(ResourcePath&& path); +#if defined(__OBJC__) + DocumentKey(FSTDocumentKey* key) // NOLINT(runtime/explicit) + : path_(std::make_shared(key.path)) { + } + + operator FSTDocumentKey*() const { + return [FSTDocumentKey keyWithPath:path()]; + } +#endif + /** * Creates and returns a new document key using '/' to split the string into * segments. @@ -69,6 +83,11 @@ class DocumentKey { return path_ ? *path_ : Empty().path(); } +#if defined(__OBJC__) + // Helper function to convert to FSTDocumentKey during the C++ migration. + FSTDocumentKey* ToFSTDocumentKey() const; +#endif // defined(__OBJC__) + private: // This is an optimization to make passing DocumentKey around cheaper (it's // copied often). -- cgit v1.2.3