Skip to content

Commit 96724cd

Browse files
authored
Finish porting FSTFilter classes to C++ Filter classes (#3352)
* Implement RelationFilter::CanonicalId() * Add NanFilter * Add NullFilter * Implement Filter equality * Add ToString() to Filters * Add IsInequality() to Filters * Port the rest of RelationFilter's matching * Implement Filter::Hash
1 parent 2e2208b commit 96724cd

File tree

12 files changed

+477
-28
lines changed

12 files changed

+477
-28
lines changed

Firestore/Example/Firestore.xcodeproj/project.pbxproj

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
036F975093414351FE952F08 /* index_manager_test.mm in Sources */ = {isa = PBXBuildFile; fileRef = 73F1F73B2210F3D800E1F692 /* index_manager_test.mm */; };
2828
041CF73F67F6A22BF317625A /* FIRTimestampTest.m in Sources */ = {isa = PBXBuildFile; fileRef = B65D34A7203C99090076A5E1 /* FIRTimestampTest.m */; };
2929
0455FC6E2A281BD755FD933A /* precondition_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 549CCA5520A36E1F00BCEB75 /* precondition_test.cc */; };
30+
047F5209AB055A884D795B8A /* filter_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = E8551D6C6FB0B1BACE9E5BAD /* filter_test.cc */; };
3031
0500A324CEC854C5B0CF364C /* FIRCollectionReferenceTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E045202154AA00B64F25 /* FIRCollectionReferenceTests.mm */; };
3132
051D3E20184AF195266EF678 /* no_document_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = AB6B908720322E8800CC290A /* no_document_test.cc */; };
3233
0535C1B65DADAE1CE47FA3CA /* string_format_apple_test.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9CFD366B783AE27B9E79EE7A /* string_format_apple_test.mm */; };
@@ -51,6 +52,7 @@
5152
0A6FBE65A7FE048BAD562A15 /* FSTGoogleTestTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 54764FAE1FAA21B90085E60A /* FSTGoogleTestTests.mm */; };
5253
0A800CA749750B01E36A6787 /* field_value_benchmark.cc in Sources */ = {isa = PBXBuildFile; fileRef = 6D0EE49C1D5AF75664D0EBE4 /* field_value_benchmark.cc */; };
5354
0AE084A7886BC11B8C305122 /* string_util_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = AB380CFC201A2EE200D97691 /* string_util_test.cc */; };
55+
0B071E9044CEEF666D829354 /* filter_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = E8551D6C6FB0B1BACE9E5BAD /* filter_test.cc */; };
5456
0B4D2668C1E81DF6D62BA9BF /* field_value_benchmark.cc in Sources */ = {isa = PBXBuildFile; fileRef = 6D0EE49C1D5AF75664D0EBE4 /* field_value_benchmark.cc */; };
5557
0B7B24194E2131F5C325FE0E /* async_queue_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = B6FB467B208E9A8200554BA2 /* async_queue_test.cc */; };
5658
0B9BD73418289EFF91917934 /* bits_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = AB380D01201BC69F00D97691 /* bits_test.cc */; };
@@ -270,6 +272,7 @@
270272
3FD3DC939514674C9F07958A /* FSTLevelDBMutationQueueTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E0872021552A00B64F25 /* FSTLevelDBMutationQueueTests.mm */; };
271273
3FFFC1FE083D8BE9C4D9A148 /* string_util_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = AB380CFC201A2EE200D97691 /* string_util_test.cc */; };
272274
4008AF7585844F12207FC2F5 /* credentials_provider_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = AB38D9342023966E000A432D /* credentials_provider_test.cc */; };
275+
401BBE4D4572EEBAA80E0B89 /* filter_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = E8551D6C6FB0B1BACE9E5BAD /* filter_test.cc */; };
273276
40431BF2A368D0C891229F6E /* FSTMemorySpecTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E02F20213FFC00B64F25 /* FSTMemorySpecTests.mm */; };
274277
4061DCDB57DF1015629669B8 /* leveldb_index_manager_test.mm in Sources */ = {isa = PBXBuildFile; fileRef = 73F1F7402211FEF300E1F692 /* leveldb_index_manager_test.mm */; };
275278
406939B62E5A6A22ADAB6FE6 /* FSTTreeSortedDictionaryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DE2EF0841F3D0B6E003D0CDC /* FSTTreeSortedDictionaryTests.m */; };
@@ -570,6 +573,7 @@
570573
62DA31B79FE97A90EEF28B0B /* delayed_constructor_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = D0A6E9136804A41CEC9D55D4 /* delayed_constructor_test.cc */; };
571574
62F86BBE7DDA5B295B57C8DA /* string_apple_test.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0EE5300F8233D14025EF0456 /* string_apple_test.mm */; };
572575
6300709ECDE8E0B5A8645F8D /* time_testing.cc in Sources */ = {isa = PBXBuildFile; fileRef = 5497CB76229DECDE000FB92F /* time_testing.cc */; };
576+
6369DE4E258556FE3382DD78 /* filter_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = E8551D6C6FB0B1BACE9E5BAD /* filter_test.cc */; };
573577
63B91FC476F3915A44F00796 /* query.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = 544129D621C2DDC800EFB9CC /* query.pb.cc */; };
574578
63BB61B6366E7F80C348419D /* FSTLevelDBTransactionTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 132E36BB104830BD806351AC /* FSTLevelDBTransactionTests.mm */; };
575579
65FC1A102890C02EF1A65213 /* database_info_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = AB38D92E20235D22000A432D /* database_info_test.cc */; };
@@ -759,6 +763,7 @@
759763
96552D8E218F68DDCFE210A0 /* status_apple_test.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5493A423225F9990006DE7BA /* status_apple_test.mm */; };
760764
9664E5831CE35D515CDBC12A /* FSTRemoteDocumentCacheTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5492E09C2021552D00B64F25 /* FSTRemoteDocumentCacheTests.mm */; };
761765
974FF09E6AFD24D5A39B898B /* local_serializer_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = F8043813A5D16963EC02B182 /* local_serializer_test.cc */; };
766+
97729B53698C0E52EB165003 /* filter_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = E8551D6C6FB0B1BACE9E5BAD /* filter_test.cc */; };
762767
9774A6C2AA02A12D80B34C3C /* database_id_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = AB71064B201FA60300344F18 /* database_id_test.cc */; };
763768
9783FAEA4CF758E8C4C2D76E /* hashing_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 54511E8D209805F8005BD28F /* hashing_test.cc */; };
764769
9794E074439ABE5457E60F35 /* xcgmock_test.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4425A513895DEC60325A139E /* xcgmock_test.mm */; };
@@ -1052,6 +1057,7 @@
10521057
DE435F33CE563E238868D318 /* query_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = B9C261C26C5D311E1E3C0CB9 /* query_test.cc */; };
10531058
DE8C47B973526A20D88F785D /* token_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = ABC1D7DF2023A3EF00BA84F0 /* token_test.cc */; };
10541059
DEF036EA1ECEECD8E3ECC362 /* FSTImmutableSortedSet+Testing.m in Sources */ = {isa = PBXBuildFile; fileRef = DE2EF0821F3D0B6E003D0CDC /* FSTImmutableSortedSet+Testing.m */; };
1060+
DF27137C8EA7D095D68851B4 /* filter_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = E8551D6C6FB0B1BACE9E5BAD /* filter_test.cc */; };
10551061
E07668A892EABDDE5B24095A /* FSTArraySortedDictionaryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DE2EF07E1F3D0B6E003D0CDC /* FSTArraySortedDictionaryTests.m */; };
10561062
E08297B35E12106105F448EB /* ordered_code_benchmark.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0473AFFF5567E667A125347B /* ordered_code_benchmark.cc */; };
10571063
E084921EFB7CF8CB1E950D6C /* iterator_adaptors_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 54A0353420A3D8CB003E0143 /* iterator_adaptors_test.cc */; };
@@ -1556,6 +1562,7 @@
15561562
DF148C0D5EEC4A2CD9FA484C /* Pods-Firestore_Example_macOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Firestore_Example_macOS.release.xcconfig"; path = "Pods/Target Support Files/Pods-Firestore_Example_macOS/Pods-Firestore_Example_macOS.release.xcconfig"; sourceTree = "<group>"; };
15571563
E42355285B9EF55ABD785792 /* Pods_Firestore_Example_macOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Firestore_Example_macOS.framework; sourceTree = BUILT_PRODUCTS_DIR; };
15581564
E592181BFD7C53C305123739 /* Pods-Firestore_Tests_iOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Firestore_Tests_iOS.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Firestore_Tests_iOS/Pods-Firestore_Tests_iOS.debug.xcconfig"; sourceTree = "<group>"; };
1565+
E8551D6C6FB0B1BACE9E5BAD /* filter_test.cc */ = {isa = PBXFileReference; includeInIndex = 1; path = filter_test.cc; sourceTree = "<group>"; };
15591566
ECEBABC7E7B693BE808A1052 /* Pods_Firestore_IntegrationTests_iOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Firestore_IntegrationTests_iOS.framework; sourceTree = BUILT_PRODUCTS_DIR; };
15601567
ED4B3E3EA0EBF3ED19A07060 /* grpc_stream_tester.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = grpc_stream_tester.h; sourceTree = "<group>"; };
15611568
F354C0FE92645B56A6C6FD44 /* Pods-Firestore_IntegrationTests_iOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Firestore_IntegrationTests_iOS.release.xcconfig"; path = "Pods/Target Support Files/Pods-Firestore_IntegrationTests_iOS/Pods-Firestore_IntegrationTests_iOS.release.xcconfig"; sourceTree = "<group>"; };
@@ -2199,6 +2206,7 @@
21992206
isa = PBXGroup;
22002207
children = (
22012208
AB38D92E20235D22000A432D /* database_info_test.cc */,
2209+
E8551D6C6FB0B1BACE9E5BAD /* filter_test.cc */,
22022210
B9C261C26C5D311E1E3C0CB9 /* query_test.cc */,
22032211
AB380CF82019382300D97691 /* target_id_generator_test.cc */,
22042212
);
@@ -3467,6 +3475,7 @@
34673475
C591407ABE1394B4042AB7CA /* field_value_benchmark.cc in Sources */,
34683476
9D0E720F5A6DBD48FF325016 /* field_value_test.cc in Sources */,
34693477
60C72F86D2231B1B6592A5E6 /* filesystem_test.cc in Sources */,
3478+
401BBE4D4572EEBAA80E0B89 /* filter_test.cc in Sources */,
34703479
A61AE3D94C975A87EFA82ADA /* firebase_credentials_provider_test.mm in Sources */,
34713480
C5655568EC2A9F6B5E6F9141 /* firestore.pb.cc in Sources */,
34723481
B8062EBDB8E5B680E46A6DD1 /* geo_point_test.cc in Sources */,
@@ -3643,6 +3652,7 @@
36433652
0EF74A344612147DE4261A4B /* field_value_benchmark.cc in Sources */,
36443653
E4EEF6AAFCD33303CE9E5408 /* field_value_test.cc in Sources */,
36453654
AAF2F02E77A80C9CDE2C0C7A /* filesystem_test.cc in Sources */,
3655+
6369DE4E258556FE3382DD78 /* filter_test.cc in Sources */,
36463656
DAC43DD1FDFBAB1FE1AD6BE5 /* firebase_credentials_provider_test.mm in Sources */,
36473657
8683BBC3AC7B01937606A83B /* firestore.pb.cc in Sources */,
36483658
F7718C43D3A8FCCDB4BB0071 /* geo_point_test.cc in Sources */,
@@ -3830,6 +3840,7 @@
38303840
0B4D2668C1E81DF6D62BA9BF /* field_value_benchmark.cc in Sources */,
38313841
DDBC6DB41D1A43CFF01288A2 /* field_value_test.cc in Sources */,
38323842
D6486C7FFA8BE6F9C7D2F4C4 /* filesystem_test.cc in Sources */,
3843+
DF27137C8EA7D095D68851B4 /* filter_test.cc in Sources */,
38333844
3DF1AB74036BD8AEF4430FA6 /* firebase_credentials_provider_test.mm in Sources */,
38343845
8C602DAD4E8296AB5EFB962A /* firestore.pb.cc in Sources */,
38353846
6ABB82D43C0728EB095947AF /* geo_point_test.cc in Sources */,
@@ -4017,6 +4028,7 @@
40174028
0A800CA749750B01E36A6787 /* field_value_benchmark.cc in Sources */,
40184029
2D3401180516B739494C7EFC /* field_value_test.cc in Sources */,
40194030
199B778D5820495797E0BE02 /* filesystem_test.cc in Sources */,
4031+
0B071E9044CEEF666D829354 /* filter_test.cc in Sources */,
40204032
D148475D7F26BFEE6E05CCDA /* firebase_credentials_provider_test.mm in Sources */,
40214033
D756A1A63E626572EE8DF592 /* firestore.pb.cc in Sources */,
40224034
8B31F63673F3B5238DE95AFB /* geo_point_test.cc in Sources */,
@@ -4215,6 +4227,7 @@
42154227
85D301119D7175F82E12892E /* field_value_benchmark.cc in Sources */,
42164228
AB356EF7200EA5EB0089B766 /* field_value_test.cc in Sources */,
42174229
D94A1862B8FB778225DB54A1 /* filesystem_test.cc in Sources */,
4230+
047F5209AB055A884D795B8A /* filter_test.cc in Sources */,
42184231
ABC1D7E42024AFDE00BA84F0 /* firebase_credentials_provider_test.mm in Sources */,
42194232
544129DB21C2DDC800EFB9CC /* firestore.pb.cc in Sources */,
42204233
AB7BAB342012B519001E0872 /* geo_point_test.cc in Sources */,
@@ -4421,6 +4434,7 @@
44214434
D541EA6C61FBB8913BA5C3C3 /* field_value_benchmark.cc in Sources */,
44224435
DA9FA01D1A4D7EC7ACA14DAB /* field_value_test.cc in Sources */,
44234436
280A282BE9AF4DCF4E855EAB /* filesystem_test.cc in Sources */,
4437+
97729B53698C0E52EB165003 /* filter_test.cc in Sources */,
44244438
D085EA576C763E4146C9988E /* firebase_credentials_provider_test.mm in Sources */,
44254439
920B6ABF76FDB3547F1CCD84 /* firestore.pb.cc in Sources */,
44264440
5FE84472E5369DA866193C45 /* geo_point_test.cc in Sources */,

Firestore/core/src/firebase/firestore/core/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,16 @@ cc_library(
2222
filter.cc
2323
filter.h
2424
listen_options.h
25-
target_id_generator.cc
26-
target_id_generator.h
25+
nan_filter.cc
26+
nan_filter.h
27+
null_filter.cc
28+
null_filter.h
2729
query.cc
2830
query.h
2931
relation_filter.cc
3032
relation_filter.h
33+
target_id_generator.cc
34+
target_id_generator.h
3135
user_data.h
3236
user_data.mm
3337
DEPENDS

Firestore/core/src/firebase/firestore/core/filter.cc

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,47 @@
1616

1717
#include "Firestore/core/src/firebase/firestore/core/filter.h"
1818

19+
#include <ostream>
1920
#include <utility>
2021

22+
#include "Firestore/core/src/firebase/firestore/api/input_validation.h"
23+
#include "Firestore/core/src/firebase/firestore/core/nan_filter.h"
24+
#include "Firestore/core/src/firebase/firestore/core/null_filter.h"
2125
#include "Firestore/core/src/firebase/firestore/core/relation_filter.h"
2226

2327
namespace firebase {
2428
namespace firestore {
2529
namespace core {
2630

31+
using api::ThrowInvalidArgument;
2732
using model::FieldPath;
2833
using model::FieldValue;
2934

3035
std::shared_ptr<Filter> Filter::Create(FieldPath path,
3136
Operator op,
3237
FieldValue value_rhs) {
33-
// TODO(rsgowman): Java performs a number of checks here, and then invokes the
34-
// ctor of the relevant Filter subclass. Port those checks here.
35-
return std::make_shared<RelationFilter>(std::move(path), op,
36-
std::move(value_rhs));
38+
if (value_rhs.type() == FieldValue::Type::Null) {
39+
if (op != Filter::Operator::Equal) {
40+
ThrowInvalidArgument(
41+
"Invalid Query. Null supports only equality comparisons.");
42+
}
43+
return std::make_shared<NullFilter>(std::move(path));
44+
45+
} else if (value_rhs.is_nan()) {
46+
if (op != Filter::Operator::Equal) {
47+
ThrowInvalidArgument(
48+
"Invalid Query. NaN supports only equality comparisons.");
49+
}
50+
return std::make_shared<NanFilter>(std::move(path));
51+
52+
} else {
53+
return std::make_shared<RelationFilter>(std::move(path), op,
54+
std::move(value_rhs));
55+
}
56+
}
57+
58+
std::ostream& operator<<(std::ostream& os, const Filter& filter) {
59+
return os << filter.ToString();
3760
}
3861

3962
} // namespace core

Firestore/core/src/firebase/firestore/core/filter.h

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#ifndef FIRESTORE_CORE_SRC_FIREBASE_FIRESTORE_CORE_FILTER_H_
1818
#define FIRESTORE_CORE_SRC_FIREBASE_FIRESTORE_CORE_FILTER_H_
1919

20+
#include <iosfwd>
2021
#include <memory>
2122
#include <string>
2223

@@ -45,19 +46,28 @@ class Filter {
4546
ArrayContains,
4647
};
4748

49+
// For lack of RTTI, all subclasses must identify themselves so that
50+
// comparisons properly take type into account.
51+
enum class Type {
52+
kRelationFilter,
53+
kNanFilter,
54+
kNullFilter,
55+
};
56+
4857
/**
4958
* Creates a Filter instance for the provided path, operator, and value.
5059
*
5160
* Note that if the relational operator is Equal and the value is NullValue or
52-
* NaN, then this will return the appropriate NullFilter or NaNFilter class
61+
* NaN, then this will return the appropriate NullFilter or NanFilter class
5362
* instead of a RelationFilter.
5463
*/
5564
static std::shared_ptr<Filter> Create(model::FieldPath path,
5665
Operator op,
5766
model::FieldValue value_rhs);
5867

59-
virtual ~Filter() {
60-
}
68+
virtual ~Filter() = default;
69+
70+
virtual Type type() const = 0;
6171

6272
/** Returns the field the Filter operates over. */
6373
virtual const model::FieldPath& field() const = 0;
@@ -67,8 +77,30 @@ class Filter {
6777

6878
/** A unique ID identifying the filter; used when serializing queries. */
6979
virtual std::string CanonicalId() const = 0;
80+
81+
/** A debug description of the Filter. */
82+
virtual std::string ToString() const = 0;
83+
84+
virtual size_t Hash() const = 0;
85+
86+
virtual bool IsInequality() const {
87+
return false;
88+
}
89+
90+
friend bool operator==(const Filter& lhs, const Filter& rhs) {
91+
return lhs.Equals(rhs);
92+
}
93+
94+
private:
95+
virtual bool Equals(const Filter& other) const = 0;
7096
};
7197

98+
inline bool operator!=(const Filter& lhs, const Filter& rhs) {
99+
return !(lhs == rhs);
100+
}
101+
102+
std::ostream& operator<<(std::ostream& os, const Filter& filter);
103+
72104
} // namespace core
73105
} // namespace firestore
74106
} // namespace firebase
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright 2019 Google
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#include "Firestore/core/src/firebase/firestore/core/nan_filter.h"
18+
19+
#include <utility>
20+
21+
namespace firebase {
22+
namespace firestore {
23+
namespace core {
24+
25+
using model::FieldPath;
26+
using model::FieldValue;
27+
28+
NanFilter::NanFilter(FieldPath field) : field_(std::move(field)) {
29+
}
30+
31+
bool NanFilter::Matches(const model::Document& doc) const {
32+
absl::optional<FieldValue> doc_field_value = doc.field(field_);
33+
return doc_field_value && doc_field_value->is_nan();
34+
}
35+
36+
std::string NanFilter::CanonicalId() const {
37+
return field().CanonicalString() + " IS NaN";
38+
}
39+
40+
std::string NanFilter::ToString() const {
41+
return CanonicalId();
42+
}
43+
44+
size_t NanFilter::Hash() const {
45+
return field_.Hash();
46+
}
47+
48+
bool NanFilter::Equals(const Filter& other) const {
49+
if (other.type() != Type::kNanFilter) return false;
50+
51+
const auto& other_filter = static_cast<const NanFilter&>(other);
52+
return field() == other_filter.field();
53+
}
54+
55+
} // namespace core
56+
} // namespace firestore
57+
} // namespace firebase
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright 2019 Google
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef FIRESTORE_CORE_SRC_FIREBASE_FIRESTORE_CORE_NAN_FILTER_H_
18+
#define FIRESTORE_CORE_SRC_FIREBASE_FIRESTORE_CORE_NAN_FILTER_H_
19+
20+
#include <string>
21+
22+
#include "Firestore/core/src/firebase/firestore/core/filter.h"
23+
#include "Firestore/core/src/firebase/firestore/model/field_path.h"
24+
25+
namespace firebase {
26+
namespace firestore {
27+
namespace core {
28+
29+
/** Filter that matches NaN (not-a-number) values. */
30+
class NanFilter : public Filter {
31+
public:
32+
explicit NanFilter(model::FieldPath field);
33+
34+
Type type() const override {
35+
return Type::kNanFilter;
36+
}
37+
38+
const model::FieldPath& field() const override {
39+
return field_;
40+
}
41+
42+
bool Matches(const model::Document& doc) const override;
43+
44+
std::string CanonicalId() const override;
45+
46+
std::string ToString() const override;
47+
48+
size_t Hash() const override;
49+
50+
protected:
51+
bool Equals(const Filter& other) const override;
52+
53+
private:
54+
model::FieldPath field_;
55+
};
56+
57+
} // namespace core
58+
} // namespace firestore
59+
} // namespace firebase
60+
61+
#endif // FIRESTORE_CORE_SRC_FIREBASE_FIRESTORE_CORE_NAN_FILTER_H_

0 commit comments

Comments
 (0)