aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Source/API/FIRDocumentReference.mm
diff options
context:
space:
mode:
authorGravatar zxu <zxu@google.com>2018-03-14 08:57:31 -0400
committerGravatar GitHub <noreply@github.com>2018-03-14 08:57:31 -0400
commit9e815620e9f7f43b42e03db4e5118d7ad03ddee7 (patch)
tree86f362bad99281325fca7ee3ae116b6a0f36d511 /Firestore/Source/API/FIRDocumentReference.mm
parentd4d73ea53ecdf1e8ade3d00921419645dd5d66f7 (diff)
grand PR to port the remaining paths (FieldPath and ResourcePath). (#865)
* 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 * address changes
Diffstat (limited to 'Firestore/Source/API/FIRDocumentReference.mm')
-rw-r--r--Firestore/Source/API/FIRDocumentReference.mm22
1 files changed, 9 insertions, 13 deletions
diff --git a/Firestore/Source/API/FIRDocumentReference.mm b/Firestore/Source/API/FIRDocumentReference.mm
index cc14af5..5968fb2 100644
--- a/Firestore/Source/API/FIRDocumentReference.mm
+++ b/Firestore/Source/API/FIRDocumentReference.mm
@@ -34,7 +34,6 @@
#import "Firestore/Source/Model/FSTDocumentSet.h"
#import "Firestore/Source/Model/FSTFieldValue.h"
#import "Firestore/Source/Model/FSTMutation.h"
-#import "Firestore/Source/Model/FSTPath.h"
#import "Firestore/Source/Util/FSTAssert.h"
#import "Firestore/Source/Util/FSTAsyncQueryListener.h"
#import "Firestore/Source/Util/FSTUsageValidation.h"
@@ -91,16 +90,15 @@ NS_ASSUME_NONNULL_BEGIN
@implementation FIRDocumentReference (Internal)
-+ (instancetype)referenceWithPath:(FSTResourcePath *)path firestore:(FIRFirestore *)firestore {
- if (path.length % 2 != 0) {
++ (instancetype)referenceWithPath:(const ResourcePath &)path firestore:(FIRFirestore *)firestore {
+ if (path.size() % 2 != 0) {
FSTThrowInvalidArgument(
@"Invalid document reference. Document references must have an even "
- "number of segments, but %@ has %d",
- path.canonicalString, path.length);
+ "number of segments, but %s has %zu",
+ path.CanonicalString().c_str(), path.size());
}
return
- [FIRDocumentReference referenceWithKey:[FSTDocumentKey keyWithPath:[path toCPPResourcePath]]
- firestore:firestore];
+ [FIRDocumentReference referenceWithKey:[FSTDocumentKey keyWithPath:path] firestore:firestore];
}
+ (instancetype)referenceWithKey:(FSTDocumentKey *)key firestore:(FIRFirestore *)firestore {
@@ -147,9 +145,8 @@ NS_ASSUME_NONNULL_BEGIN
}
- (FIRCollectionReference *)parent {
- return [FIRCollectionReference
- referenceWithPath:[FSTResourcePath resourcePathWithCPPResourcePath:self.key.path.PopLast()]
- firestore:self.firestore];
+ return
+ [FIRCollectionReference referenceWithPath:self.key.path.PopLast() firestore:self.firestore];
}
- (NSString *)path {
@@ -160,9 +157,8 @@ NS_ASSUME_NONNULL_BEGIN
if (!collectionPath) {
FSTThrowInvalidArgument(@"Collection path cannot be nil.");
}
- FSTResourcePath *subPath = [FSTResourcePath pathWithString:collectionPath];
- FSTResourcePath *path = [FSTResourcePath
- resourcePathWithCPPResourcePath:self.key.path.Append([subPath toCPPResourcePath])];
+ const ResourcePath subPath = ResourcePath::FromString(util::MakeStringView(collectionPath));
+ const ResourcePath path = self.key.path.Append(subPath);
return [FIRCollectionReference referenceWithPath:path firestore:self.firestore];
}