diff options
Diffstat (limited to 'Firestore/Source/Model/FSTDocument.mm')
-rw-r--r-- | Firestore/Source/Model/FSTDocument.mm | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/Firestore/Source/Model/FSTDocument.mm b/Firestore/Source/Model/FSTDocument.mm index 9898c2a..8ebc9ab 100644 --- a/Firestore/Source/Model/FSTDocument.mm +++ b/Firestore/Source/Model/FSTDocument.mm @@ -18,7 +18,6 @@ #include <utility> -#import "Firestore/Source/Core/FSTSnapshotVersion.h" #import "Firestore/Source/Model/FSTFieldValue.h" #import "Firestore/Source/Util/FSTAssert.h" @@ -29,26 +28,28 @@ namespace util = firebase::firestore::util; using firebase::firestore::model::DocumentKey; using firebase::firestore::model::FieldPath; +using firebase::firestore::model::SnapshotVersion; NS_ASSUME_NONNULL_BEGIN @interface FSTMaybeDocument () - (instancetype)initWithKey:(DocumentKey)key - version:(FSTSnapshotVersion *)version NS_DESIGNATED_INITIALIZER; + version:(SnapshotVersion)version NS_DESIGNATED_INITIALIZER; @end @implementation FSTMaybeDocument { DocumentKey _key; + SnapshotVersion _version; } -- (instancetype)initWithKey:(DocumentKey)key version:(FSTSnapshotVersion *)version { +- (instancetype)initWithKey:(DocumentKey)key version:(SnapshotVersion)version { FSTAssert(!!version, @"Version must not be nil."); self = [super init]; if (self) { _key = std::move(key); - _version = version; + _version = std::move(version); } return self; } @@ -62,25 +63,29 @@ NS_ASSUME_NONNULL_BEGIN return _key; } +- (const SnapshotVersion &)version { + return _version; +} + @end @implementation FSTDocument + (instancetype)documentWithData:(FSTObjectValue *)data key:(DocumentKey)key - version:(FSTSnapshotVersion *)version + version:(SnapshotVersion)version hasLocalMutations:(BOOL)mutations { return [[FSTDocument alloc] initWithData:data key:std::move(key) - version:version + version:std::move(version) hasLocalMutations:mutations]; } - (instancetype)initWithData:(FSTObjectValue *)data key:(DocumentKey)key - version:(FSTSnapshotVersion *)version + version:(SnapshotVersion)version hasLocalMutations:(BOOL)mutations { - self = [super initWithKey:std::move(key) version:version]; + self = [super initWithKey:std::move(key) version:std::move(version)]; if (self) { _data = data; _localMutations = mutations; @@ -110,8 +115,9 @@ NS_ASSUME_NONNULL_BEGIN } - (NSString *)description { - return [NSString stringWithFormat:@"<FSTDocument: key:%s version:%@ localMutations:%@ data:%@>", - self.key.ToString().c_str(), self.version, + return [NSString stringWithFormat:@"<FSTDocument: key:%s version:%s localMutations:%@ data:%@>", + self.key.ToString().c_str(), + self.version.timestamp().ToString().c_str(), self.localMutations ? @"YES" : @"NO", self.data]; } @@ -123,8 +129,8 @@ NS_ASSUME_NONNULL_BEGIN @implementation FSTDeletedDocument -+ (instancetype)documentWithKey:(DocumentKey)key version:(FSTSnapshotVersion *)version { - return [[FSTDeletedDocument alloc] initWithKey:std::move(key) version:version]; ++ (instancetype)documentWithKey:(DocumentKey)key version:(SnapshotVersion)version { + return [[FSTDeletedDocument alloc] initWithKey:std::move(key) version:std::move(version)]; } - (BOOL)isEqual:(id)other { |