diff options
author | rsgowman <rgowman@google.com> | 2018-07-13 16:22:07 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-13 16:22:07 -0400 |
commit | 920cfbfa998ca9d04cce5f7731aced7e950a3477 (patch) | |
tree | 76f62fa05240d533477707bb4cd26df6808cd523 /Firestore/core/src/firebase/firestore/model/field_value.cc | |
parent | 81ec26d4ff2f9cc295bf057167a649a34a7a11aa (diff) |
Initial (incomplete) implementation of f:f:core::Filter (#1495)
And RelationFilter subclass.
Used to implement the next step in core::Query.
Diffstat (limited to 'Firestore/core/src/firebase/firestore/model/field_value.cc')
-rw-r--r-- | Firestore/core/src/firebase/firestore/model/field_value.cc | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/Firestore/core/src/firebase/firestore/model/field_value.cc b/Firestore/core/src/firebase/firestore/model/field_value.cc index 4f92c8b..d2fadc8 100644 --- a/Firestore/core/src/firebase/firestore/model/field_value.cc +++ b/Firestore/core/src/firebase/firestore/model/field_value.cc @@ -35,25 +35,6 @@ using Type = FieldValue::Type; using firebase::firestore::util::ComparisonResult; namespace { -/** - * This deviates from the other platforms that define TypeOrder. Since - * we already define Type for union types, we use it together with this - * function to achieve the equivalent order of types i.e. - * i) if two types are comparable, then they are of equal order; - * ii) otherwise, their order is the same as the order of their Type. - */ -bool Comparable(Type lhs, Type rhs) { - switch (lhs) { - case Type::Integer: - case Type::Double: - return rhs == Type::Integer || rhs == Type::Double; - case Type::Timestamp: - case Type::ServerTimestamp: - return rhs == Type::Timestamp || rhs == Type::ServerTimestamp; - default: - return lhs == rhs; - } -} // Makes a copy excluding the specified child, which is expected to be assigned // different value afterwards. @@ -165,6 +146,19 @@ FieldValue& FieldValue::operator=(FieldValue&& value) { } } +bool FieldValue::Comparable(Type lhs, Type rhs) { + switch (lhs) { + case Type::Integer: + case Type::Double: + return rhs == Type::Integer || rhs == Type::Double; + case Type::Timestamp: + case Type::ServerTimestamp: + return rhs == Type::Timestamp || rhs == Type::ServerTimestamp; + default: + return lhs == rhs; + } +} + FieldValue FieldValue::Set(const FieldPath& field_path, FieldValue value) const { HARD_ASSERT(type() == Type::Object, @@ -379,7 +373,7 @@ FieldValue FieldValue::ObjectValueFromMap(ObjectValue::Map&& value) { } bool operator<(const FieldValue& lhs, const FieldValue& rhs) { - if (!Comparable(lhs.type(), rhs.type())) { + if (!FieldValue::Comparable(lhs.type(), rhs.type())) { return lhs.type() < rhs.type(); } |