aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/core/src/firebase/firestore/model
diff options
context:
space:
mode:
authorGravatar zxu <zxu@google.com>2018-03-15 11:31:16 -0400
committerGravatar GitHub <noreply@github.com>2018-03-15 11:31:16 -0400
commit2d9d3a868c996d38b4a8bf6d3ce55ee76af43d75 (patch)
tree864c27069d50bf6f57948e81044e36bee9c30509 /Firestore/core/src/firebase/firestore/model
parent35de3c54d543d7be16fdcae9205ffe247f2917a7 (diff)
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
Diffstat (limited to 'Firestore/core/src/firebase/firestore/model')
-rw-r--r--Firestore/core/src/firebase/firestore/model/document_key.h19
1 files changed, 19 insertions, 0 deletions
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 <memory>
#include <string>
+#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<ResourcePath>(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).