diff options
author | zxu <zxu@google.com> | 2018-02-06 13:51:11 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-06 13:51:11 -0500 |
commit | a441190635d494f128cf02e07566ae2003af4e08 (patch) | |
tree | 618e6b0ecdb5d243f6e97f319f98f09dc9ca0a7e /Firestore/Source/API/FIRDocumentSnapshot.mm | |
parent | 7cac9dc47a8c6b7321ebf5fc13fa7140e784c8ca (diff) |
Implement Firestore DatabaseInfo and port both Database{Id,Info} C++ to the iOS code (#738)
* implement Firestore DatabaseInfo in C++
* temporary stash changes; blocking on the massive renaming of .m to .mm
* add database_info_test to project
* finish port DatabaseId and fix style, modular fixing DatabaseInfo
* port DatabaseInfo
* remove FSTDatabase{ID,Info} and their tests from project
* fix unit test
* use namespace alias
* use namespace alias, leftover
* address more changes
* refactoring to use raw pointer instead of value for property
* address changes
* remove self->
* fix style
* remove the name suffix Alloc
* fix a bug
Diffstat (limited to 'Firestore/Source/API/FIRDocumentSnapshot.mm')
-rw-r--r-- | Firestore/Source/API/FIRDocumentSnapshot.mm | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/Firestore/Source/API/FIRDocumentSnapshot.mm b/Firestore/Source/API/FIRDocumentSnapshot.mm index 10709e8..ddf4cca 100644 --- a/Firestore/Source/API/FIRDocumentSnapshot.mm +++ b/Firestore/Source/API/FIRDocumentSnapshot.mm @@ -21,7 +21,6 @@ #import "Firestore/Source/API/FIRFirestore+Internal.h" #import "Firestore/Source/API/FIRSnapshotMetadata+Internal.h" #import "Firestore/Source/API/FIRSnapshotOptions+Internal.h" -#import "Firestore/Source/Model/FSTDatabaseID.h" #import "Firestore/Source/Model/FSTDocument.h" #import "Firestore/Source/Model/FSTDocumentKey.h" #import "Firestore/Source/Model/FSTFieldValue.h" @@ -29,6 +28,12 @@ #import "Firestore/Source/Util/FSTAssert.h" #import "Firestore/Source/Util/FSTUsageValidation.h" +#include "Firestore/core/src/firebase/firestore/model/database_id.h" +#include "Firestore/core/src/firebase/firestore/util/string_apple.h" + +namespace util = firebase::firestore::util; +using firebase::firestore::model::DatabaseId; + NS_ASSUME_NONNULL_BEGIN @interface FIRDocumentSnapshot () @@ -173,16 +178,18 @@ NS_ASSUME_NONNULL_BEGIN return [self convertedArray:(FSTArrayValue *)value options:options]; } else if ([value isKindOfClass:[FSTReferenceValue class]]) { FSTReferenceValue *ref = (FSTReferenceValue *)value; - FSTDatabaseID *refDatabase = ref.databaseID; - FSTDatabaseID *database = self.firestore.databaseID; - if (![refDatabase isEqualToDatabaseId:database]) { + const DatabaseId *refDatabase = ref.databaseID; + const DatabaseId *database = self.firestore.databaseID; + if (*refDatabase != *database) { // TODO(b/32073923): Log this as a proper warning. NSLog( @"WARNING: Document %@ contains a document reference within a different database " "(%@/%@) which is not supported. It will be treated as a reference within the " "current database (%@/%@) instead.", - self.reference.path, refDatabase.projectID, refDatabase.databaseID, database.projectID, - database.databaseID); + self.reference.path, util::WrapNSStringNoCopy(refDatabase->project_id()), + util::WrapNSStringNoCopy(refDatabase->database_id()), + util::WrapNSStringNoCopy(database->project_id()), + util::WrapNSStringNoCopy(database->database_id())); } return [FIRDocumentReference referenceWithKey:[ref valueWithOptions:options] firestore:self.firestore]; |