34
34
#include " Firestore/core/src/firebase/firestore/model/database_id.h"
35
35
#include " Firestore/core/src/firebase/firestore/model/document_key.h"
36
36
#include " Firestore/core/src/firebase/firestore/model/field_value.h"
37
+ #include " Firestore/core/src/firebase/firestore/model/field_value_options.h"
37
38
#include " Firestore/core/src/firebase/firestore/util/hard_assert.h"
38
39
#include " Firestore/core/src/firebase/firestore/util/string_apple.h"
39
40
45
46
using firebase::firestore::model::DatabaseId;
46
47
using firebase::firestore::model::DocumentKey;
47
48
using firebase::firestore::model::FieldValue;
49
+ using firebase::firestore::model::FieldValueOptions;
50
+ using firebase::firestore::model::ServerTimestampBehavior;
48
51
using firebase::firestore::util::WrapNSString;
49
52
50
53
NS_ASSUME_NONNULL_BEGIN
57
60
ServerTimestampBehavior InternalServerTimestampBehavior (FIRServerTimestampBehavior behavior) {
58
61
switch (behavior) {
59
62
case FIRServerTimestampBehaviorNone:
60
- return ServerTimestampBehavior::None ;
63
+ return ServerTimestampBehavior::kNone ;
61
64
case FIRServerTimestampBehaviorEstimate:
62
- return ServerTimestampBehavior::Estimate ;
65
+ return ServerTimestampBehavior::kEstimate ;
63
66
case FIRServerTimestampBehaviorPrevious:
64
- return ServerTimestampBehavior::Previous ;
67
+ return ServerTimestampBehavior::kPrevious ;
65
68
default :
66
69
HARD_FAIL (" Unexpected server timestamp option: %s" , behavior);
67
70
}
@@ -147,7 +150,7 @@ - (FIRSnapshotMetadata *)metadata {
147
150
148
151
- (nullable NSDictionary <NSString *, id> *)dataWithServerTimestampBehavior :
149
152
(FIRServerTimestampBehavior)serverTimestampBehavior {
150
- FSTFieldValueOptions * options = [self optionsForServerTimestampBehavior: serverTimestampBehavior];
153
+ FieldValueOptions options = [self optionsForServerTimestampBehavior: serverTimestampBehavior];
151
154
FSTObjectValue *data = _snapshot.GetData ();
152
155
return data == nil ? nil : [self convertedObject: data options: options];
153
156
}
@@ -168,26 +171,23 @@ - (nullable id)valueForField:(id)field
168
171
}
169
172
170
173
FSTFieldValue *fieldValue = _snapshot.GetValue (fieldPath.internalValue );
171
- FSTFieldValueOptions * options = [self optionsForServerTimestampBehavior: serverTimestampBehavior];
174
+ FieldValueOptions options = [self optionsForServerTimestampBehavior: serverTimestampBehavior];
172
175
return fieldValue == nil ? nil : [self convertedValue: fieldValue options: options];
173
176
}
174
177
175
178
- (nullable id )objectForKeyedSubscript : (id )key {
176
179
return [self valueForField: key];
177
180
}
178
181
179
- - (FSTFieldValueOptions * )optionsForServerTimestampBehavior :
182
+ - (FieldValueOptions )optionsForServerTimestampBehavior :
180
183
(FIRServerTimestampBehavior)serverTimestampBehavior {
181
184
SUPPRESS_DEPRECATED_DECLARATIONS_BEGIN ()
182
- return [[FSTFieldValueOptions alloc ]
183
- initWithServerTimestampBehavior: InternalServerTimestampBehavior (serverTimestampBehavior)
184
- timestampsInSnapshotsEnabled: _snapshot.firestore ()
185
- ->settings ()
186
- .timestamps_in_snapshots_enabled ()];
185
+ return FieldValueOptions (InternalServerTimestampBehavior (serverTimestampBehavior),
186
+ _snapshot.firestore ()->settings ().timestamps_in_snapshots_enabled ());
187
187
SUPPRESS_END ()
188
188
}
189
189
190
- - (id )convertedValue : (FSTFieldValue *)value options : (FSTFieldValueOptions * )options {
190
+ - (id )convertedValue : (FSTFieldValue *)value options : (const FieldValueOptions & )options {
191
191
if (value.type == FieldValue::Type::Object) {
192
192
return [self convertedObject: (FSTObjectValue *)value options: options];
193
193
} else if (value.type == FieldValue::Type::Array) {
@@ -213,7 +213,7 @@ - (id)convertedValue:(FSTFieldValue *)value options:(FSTFieldValueOptions *)opti
213
213
}
214
214
215
215
- (NSDictionary <NSString *, id > *)convertedObject:(FSTObjectValue *)objectValue
216
- options:(FSTFieldValueOptions * )options {
216
+ options:(const FieldValueOptions & )options {
217
217
NSMutableDictionary *result = [NSMutableDictionary dictionary ];
218
218
[objectValue.internalValue
219
219
enumerateKeysAndObjectsUsingBlock: ^(NSString *key, FSTFieldValue *value, BOOL *stop) {
@@ -223,7 +223,7 @@ - (id)convertedValue:(FSTFieldValue *)value options:(FSTFieldValueOptions *)opti
223
223
}
224
224
225
225
- (NSArray <id > *)convertedArray:(FSTArrayValue *)arrayValue
226
- options:(FSTFieldValueOptions * )options {
226
+ options:(const FieldValueOptions & )options {
227
227
NSArray <FSTFieldValue *> *internalValue = arrayValue.internalValue ;
228
228
NSMutableArray *result = [NSMutableArray arrayWithCapacity: internalValue.count];
229
229
[internalValue enumerateObjectsUsingBlock: ^(id value, NSUInteger idx, BOOL *stop) {
0 commit comments