aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Source/Remote/FSTSerializerBeta.mm
diff options
context:
space:
mode:
Diffstat (limited to 'Firestore/Source/Remote/FSTSerializerBeta.mm')
-rw-r--r--Firestore/Source/Remote/FSTSerializerBeta.mm106
1 files changed, 53 insertions, 53 deletions
diff --git a/Firestore/Source/Remote/FSTSerializerBeta.mm b/Firestore/Source/Remote/FSTSerializerBeta.mm
index f862ec3..ab40dd6 100644
--- a/Firestore/Source/Remote/FSTSerializerBeta.mm
+++ b/Firestore/Source/Remote/FSTSerializerBeta.mm
@@ -41,7 +41,6 @@
#import "Firestore/Source/Model/FSTMutationBatch.h"
#import "Firestore/Source/Remote/FSTExistenceFilter.h"
#import "Firestore/Source/Remote/FSTWatchChange.h"
-#import "Firestore/Source/Util/FSTAssert.h"
#include "Firestore/core/src/firebase/firestore/model/database_id.h"
#include "Firestore/core/src/firebase/firestore/model/document_key.h"
@@ -51,6 +50,7 @@
#include "Firestore/core/src/firebase/firestore/model/precondition.h"
#include "Firestore/core/src/firebase/firestore/model/resource_path.h"
#include "Firestore/core/src/firebase/firestore/model/transform_operations.h"
+#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
#include "Firestore/core/src/firebase/firestore/util/string_apple.h"
#include "absl/memory/memory.h"
#include "absl/types/optional.h"
@@ -128,10 +128,10 @@ NS_ASSUME_NONNULL_BEGIN
- (DocumentKey)decodedDocumentKey:(NSString *)name {
const ResourcePath path = [self decodedResourcePathWithDatabaseID:name];
- FSTAssert(path[1] == self.databaseID->project_id(),
- @"Tried to deserialize key from different project.");
- FSTAssert(path[3] == self.databaseID->database_id(),
- @"Tried to deserialize key from different datbase.");
+ HARD_ASSERT(path[1] == self.databaseID->project_id(),
+ "Tried to deserialize key from different project.");
+ HARD_ASSERT(path[3] == self.databaseID->database_id(),
+ "Tried to deserialize key from different datbase.");
return DocumentKey{[self localResourcePathForQualifiedResourcePath:path]};
}
@@ -145,8 +145,8 @@ NS_ASSUME_NONNULL_BEGIN
- (ResourcePath)decodedResourcePathWithDatabaseID:(NSString *)name {
const ResourcePath path = ResourcePath::FromString(util::MakeStringView(name));
- FSTAssert([self validQualifiedResourcePath:path], @"Tried to deserialize invalid key %s",
- path.CanonicalString().c_str());
+ HARD_ASSERT([self validQualifiedResourcePath:path], "Tried to deserialize invalid key %s",
+ path.CanonicalString());
return path;
}
@@ -172,8 +172,8 @@ NS_ASSUME_NONNULL_BEGIN
}
- (ResourcePath)localResourcePathForQualifiedResourcePath:(const ResourcePath &)resourceName {
- FSTAssert(resourceName.size() > 4 && resourceName[4] == "documents",
- @"Tried to deserialize invalid key %s", resourceName.CanonicalString().c_str());
+ HARD_ASSERT(resourceName.size() > 4 && resourceName[4] == "documents",
+ "Tried to deserialize invalid key %s", resourceName.CanonicalString());
return resourceName.PopFirst(5);
}
@@ -229,7 +229,7 @@ NS_ASSUME_NONNULL_BEGIN
return result;
} else {
- FSTFail(@"Unhandled type %@ on %@", NSStringFromClass([fieldValue class]), fieldValue);
+ HARD_FAIL("Unhandled type %s on %s", NSStringFromClass([fieldValue class]), fieldValue);
}
}
@@ -273,7 +273,7 @@ NS_ASSUME_NONNULL_BEGIN
return [self decodedMapValue:valueProto.mapValue];
default:
- FSTFail(@"Unhandled type %d on %@", valueProto.valueTypeOneOfCase, valueProto);
+ HARD_FAIL("Unhandled type %s on %s", valueProto.valueTypeOneOfCase, valueProto);
}
}
@@ -327,9 +327,9 @@ NS_ASSUME_NONNULL_BEGIN
- (GCFSValue *)encodedReferenceValueForDatabaseID:(const DatabaseId *)databaseID
key:(const DocumentKey &)key {
- FSTAssert(*databaseID == *self.databaseID, @"Database %s:%s cannot encode reference from %s:%s",
- self.databaseID->project_id().c_str(), self.databaseID->database_id().c_str(),
- databaseID->project_id().c_str(), databaseID->database_id().c_str());
+ HARD_ASSERT(*databaseID == *self.databaseID, "Database %s:%s cannot encode reference from %s:%s",
+ self.databaseID->project_id(), self.databaseID->database_id(),
+ databaseID->project_id(), databaseID->database_id());
GCFSValue *result = [GCFSValue message];
result.referenceValue = [self encodedResourcePathForDatabaseID:databaseID path:key.path()];
return result;
@@ -342,9 +342,9 @@ NS_ASSUME_NONNULL_BEGIN
const DocumentKey key{[self localResourcePathForQualifiedResourcePath:path]};
const DatabaseId database_id(project, database);
- FSTAssert(database_id == *self.databaseID, @"Database %s:%s cannot encode reference from %s:%s",
- self.databaseID->project_id().c_str(), self.databaseID->database_id().c_str(),
- database_id.project_id().c_str(), database_id.database_id().c_str());
+ HARD_ASSERT(database_id == *self.databaseID, "Database %s:%s cannot encode reference from %s:%s",
+ self.databaseID->project_id(), self.databaseID->database_id(),
+ database_id.project_id(), database_id.database_id());
return [FSTReferenceValue referenceValue:key databaseID:self.databaseID];
}
@@ -425,27 +425,27 @@ NS_ASSUME_NONNULL_BEGIN
case GCFSBatchGetDocumentsResponse_Result_OneOfCase_Missing:
return [self decodedDeletedDocument:response];
default:
- FSTFail(@"Unknown document type: %@", response);
+ HARD_FAIL("Unknown document type: %s", response);
}
}
- (FSTDocument *)decodedFoundDocument:(GCFSBatchGetDocumentsResponse *)response {
- FSTAssert(!!response.found, @"Tried to deserialize a found document from a deleted document.");
+ HARD_ASSERT(!!response.found, "Tried to deserialize a found document from a deleted document.");
const DocumentKey key = [self decodedDocumentKey:response.found.name];
FSTObjectValue *value = [self decodedFields:response.found.fields];
SnapshotVersion version = [self decodedVersion:response.found.updateTime];
- FSTAssert(version != SnapshotVersion::None(),
- @"Got a document response with no snapshot version");
+ HARD_ASSERT(version != SnapshotVersion::None(),
+ "Got a document response with no snapshot version");
return [FSTDocument documentWithData:value key:key version:version hasLocalMutations:NO];
}
- (FSTDeletedDocument *)decodedDeletedDocument:(GCFSBatchGetDocumentsResponse *)response {
- FSTAssert(!!response.missing, @"Tried to deserialize a deleted document from a found document.");
+ HARD_ASSERT(!!response.missing, "Tried to deserialize a deleted document from a found document.");
const DocumentKey key = [self decodedDocumentKey:response.missing];
SnapshotVersion version = [self decodedVersion:response.readTime];
- FSTAssert(version != SnapshotVersion::None(),
- @"Got a no document response with no snapshot version");
+ HARD_ASSERT(version != SnapshotVersion::None(),
+ "Got a no document response with no snapshot version");
return [FSTDeletedDocument documentWithKey:key version:version];
}
@@ -480,7 +480,7 @@ NS_ASSUME_NONNULL_BEGIN
proto.delete_p = [self encodedDocumentKey:deleteMutation.key];
} else {
- FSTFail(@"Unknown mutation type %@", NSStringFromClass(mutationClass));
+ HARD_FAIL("Unknown mutation type %s", NSStringFromClass(mutationClass));
}
if (!mutation.precondition.IsNone()) {
@@ -513,8 +513,8 @@ NS_ASSUME_NONNULL_BEGIN
precondition:precondition];
case GCFSWrite_Operation_OneOfCase_Transform: {
- FSTAssert(precondition == Precondition::Exists(true),
- @"Transforms must have precondition \"exists == true\"");
+ HARD_ASSERT(precondition == Precondition::Exists(true),
+ "Transforms must have precondition \"exists == true\"");
return [[FSTTransformMutation alloc]
initWithKey:[self decodedDocumentKey:mutation.transform.document]
@@ -523,19 +523,19 @@ NS_ASSUME_NONNULL_BEGIN
default:
// Note that insert is intentionally unhandled, since we don't ever deal in them.
- FSTFail(@"Unknown mutation operation: %d", mutation.operationOneOfCase);
+ HARD_FAIL("Unknown mutation operation: %s", mutation.operationOneOfCase);
}
}
- (GCFSPrecondition *)encodedPrecondition:(const Precondition &)precondition {
- FSTAssert(!precondition.IsNone(), @"Can't serialize an empty precondition");
+ HARD_ASSERT(!precondition.IsNone(), "Can't serialize an empty precondition");
GCFSPrecondition *message = [GCFSPrecondition message];
if (precondition.type() == Precondition::Type::UpdateTime) {
message.updateTime = [self encodedVersion:precondition.update_time()];
} else if (precondition.type() == Precondition::Type::Exists) {
message.exists = precondition == Precondition::Exists(true);
} else {
- FSTFail(@"Unknown precondition: %@", precondition.description());
+ HARD_FAIL("Unknown precondition: %s", precondition.description());
}
return message;
}
@@ -552,7 +552,7 @@ NS_ASSUME_NONNULL_BEGIN
return Precondition::UpdateTime([self decodedVersion:precondition.updateTime]);
default:
- FSTFail(@"Unrecognized Precondition one-of case %@", precondition);
+ HARD_FAIL("Unrecognized Precondition one-of case %s", precondition);
}
}
@@ -599,7 +599,7 @@ NS_ASSUME_NONNULL_BEGIN
encodedArrayTransformElements:ArrayTransform::Elements(fieldTransform.transformation())];
} else {
- FSTFail(@"Unknown transform: %d type", fieldTransform.transformation().type());
+ HARD_FAIL("Unknown transform: %s type", fieldTransform.transformation().type());
}
return proto;
}
@@ -623,9 +623,9 @@ NS_ASSUME_NONNULL_BEGIN
for (GCFSDocumentTransform_FieldTransform *proto in protos) {
switch (proto.transformTypeOneOfCase) {
case GCFSDocumentTransform_FieldTransform_TransformType_OneOfCase_SetToServerValue: {
- FSTAssert(
+ HARD_ASSERT(
proto.setToServerValue == GCFSDocumentTransform_FieldTransform_ServerValue_RequestTime,
- @"Unknown transform setToServerValue: %d", proto.setToServerValue);
+ "Unknown transform setToServerValue: %s", proto.setToServerValue);
fieldTransforms.emplace_back(
FieldPath::FromServerFormat(util::MakeStringView(proto.fieldPath)),
absl::make_unique<ServerTimestampTransform>(ServerTimestampTransform::Get()));
@@ -653,7 +653,7 @@ NS_ASSUME_NONNULL_BEGIN
}
default:
- FSTFail(@"Unknown transform: %@", proto);
+ HARD_FAIL("Unknown transform: %s", proto);
}
}
@@ -711,7 +711,7 @@ NS_ASSUME_NONNULL_BEGIN
case FSTQueryPurposeLimboResolution:
return @"limbo-document";
default:
- FSTFail(@"Unrecognized query purpose: %lu", (unsigned long)purpose);
+ HARD_FAIL("Unrecognized query purpose: %s", purpose);
}
}
@@ -742,8 +742,8 @@ NS_ASSUME_NONNULL_BEGIN
- (FSTQuery *)decodedQueryFromDocumentsTarget:(GCFSTarget_DocumentsTarget *)target {
NSArray<NSString *> *documents = target.documentsArray;
- FSTAssert(documents.count == 1, @"DocumentsTarget contained other than 1 document %lu",
- (unsigned long)documents.count);
+ HARD_ASSERT(documents.count == 1, "DocumentsTarget contained other than 1 document %s",
+ (unsigned long)documents.count);
NSString *name = documents[0];
return [FSTQuery queryWithPath:[self decodedQueryPath:name]];
@@ -756,7 +756,7 @@ NS_ASSUME_NONNULL_BEGIN
queryTarget.parent = [self encodedQueryPath:query.path];
} else {
const ResourcePath &path = query.path;
- FSTAssert(path.size() % 2 != 0, @"Document queries with filters are not supported.");
+ HARD_ASSERT(path.size() % 2 != 0, "Document queries with filters are not supported.");
queryTarget.parent = [self encodedQueryPath:path.PopLast()];
GCFSStructuredQuery_CollectionSelector *from = [GCFSStructuredQuery_CollectionSelector message];
from.collectionId = util::WrapNSString(path.last_segment());
@@ -795,8 +795,8 @@ NS_ASSUME_NONNULL_BEGIN
GCFSStructuredQuery *query = target.structuredQuery;
NSUInteger fromCount = query.fromArray_Count;
if (fromCount > 0) {
- FSTAssert(fromCount == 1,
- @"StructuredQuery.from with more than one collection is not supported.");
+ HARD_ASSERT(fromCount == 1,
+ "StructuredQuery.from with more than one collection is not supported.");
GCFSStructuredQuery_CollectionSelector *from = query.fromArray[0];
path = path.Append(util::MakeString(from.collectionId));
@@ -870,8 +870,8 @@ NS_ASSUME_NONNULL_BEGIN
NSArray<GCFSStructuredQuery_Filter *> *filters;
if (proto.filterTypeOneOfCase ==
GCFSStructuredQuery_Filter_FilterType_OneOfCase_CompositeFilter) {
- FSTAssert(proto.compositeFilter.op == GCFSStructuredQuery_CompositeFilter_Operator_And,
- @"Only AND-type composite filters are supported, got %d", proto.compositeFilter.op);
+ HARD_ASSERT(proto.compositeFilter.op == GCFSStructuredQuery_CompositeFilter_Operator_And,
+ "Only AND-type composite filters are supported, got %s", proto.compositeFilter.op);
filters = proto.compositeFilter.filtersArray;
} else {
filters = @[ proto ];
@@ -880,7 +880,7 @@ NS_ASSUME_NONNULL_BEGIN
for (GCFSStructuredQuery_Filter *filter in filters) {
switch (filter.filterTypeOneOfCase) {
case GCFSStructuredQuery_Filter_FilterType_OneOfCase_CompositeFilter:
- FSTFail(@"Nested composite filters are not supported");
+ HARD_FAIL("Nested composite filters are not supported");
case GCFSStructuredQuery_Filter_FilterType_OneOfCase_FieldFilter:
[result addObject:[self decodedRelationFilter:filter.fieldFilter]];
@@ -891,7 +891,7 @@ NS_ASSUME_NONNULL_BEGIN
break;
default:
- FSTFail(@"Unrecognized Filter.filterType %d", filter.filterTypeOneOfCase);
+ HARD_FAIL("Unrecognized Filter.filterType %s", filter.filterTypeOneOfCase);
}
}
return result;
@@ -921,7 +921,7 @@ NS_ASSUME_NONNULL_BEGIN
} else if ([filter isKindOfClass:[FSTNullFilter class]]) {
proto.unaryFilter.op = GCFSStructuredQuery_UnaryFilter_Operator_IsNull;
} else {
- FSTFail(@"Unrecognized filter: %@", filter);
+ HARD_FAIL("Unrecognized filter: %s", static_cast<id>(filter));
}
return proto;
}
@@ -936,7 +936,7 @@ NS_ASSUME_NONNULL_BEGIN
return [[FSTNullFilter alloc] initWithField:field];
default:
- FSTFail(@"Unrecognized UnaryFilter.operator %d", proto.op);
+ HARD_FAIL("Unrecognized UnaryFilter.operator %s", proto.op);
}
}
@@ -962,7 +962,7 @@ NS_ASSUME_NONNULL_BEGIN
case FSTRelationFilterOperatorArrayContains:
return GCFSStructuredQuery_FieldFilter_Operator_ArrayContains;
default:
- FSTFail(@"Unhandled FSTRelationFilterOperator: %ld", (long)filterOperator);
+ HARD_FAIL("Unhandled FSTRelationFilterOperator: %s", filterOperator);
}
}
@@ -982,7 +982,7 @@ NS_ASSUME_NONNULL_BEGIN
case GCFSStructuredQuery_FieldFilter_Operator_ArrayContains:
return FSTRelationFilterOperatorArrayContains;
default:
- FSTFail(@"Unhandled FieldFilter.operator: %d", filterOperator);
+ HARD_FAIL("Unhandled FieldFilter.operator: %s", filterOperator);
}
}
@@ -1026,7 +1026,7 @@ NS_ASSUME_NONNULL_BEGIN
ascending = NO;
break;
default:
- FSTFail(@"Unrecognized GCFSStructuredQuery_Direction %d", proto.direction);
+ HARD_FAIL("Unrecognized GCFSStructuredQuery_Direction %s", proto.direction);
}
return [FSTSortOrder sortOrderWithFieldPath:fieldPath ascending:ascending];
}
@@ -1074,7 +1074,7 @@ NS_ASSUME_NONNULL_BEGIN
return [self decodedExistenceFilterWatchChange:watchChange.filter];
default:
- FSTFail(@"Unknown WatchChange.changeType %" PRId32, watchChange.responseTypeOneOfCase);
+ HARD_FAIL("Unknown WatchChange.changeType %s", watchChange.responseTypeOneOfCase);
}
}
@@ -1127,7 +1127,7 @@ NS_ASSUME_NONNULL_BEGIN
case GCFSTargetChange_TargetChangeType_Reset:
return FSTWatchTargetChangeStateReset;
default:
- FSTFail(@"Unexpected TargetChange.state: %" PRId32, state);
+ HARD_FAIL("Unexpected TargetChange.state: %s", state);
}
}
@@ -1143,7 +1143,7 @@ NS_ASSUME_NONNULL_BEGIN
FSTObjectValue *value = [self decodedFields:change.document.fields];
const DocumentKey key = [self decodedDocumentKey:change.document.name];
SnapshotVersion version = [self decodedVersion:change.document.updateTime];
- FSTAssert(version != SnapshotVersion::None(), @"Got a document change with no snapshot version");
+ HARD_ASSERT(version != SnapshotVersion::None(), "Got a document change with no snapshot version");
FSTMaybeDocument *document =
[FSTDocument documentWithData:value key:key version:version hasLocalMutations:NO];