From 920cfbfa998ca9d04cce5f7731aced7e950a3477 Mon Sep 17 00:00:00 2001 From: rsgowman Date: Fri, 13 Jul 2018 16:22:07 -0400 Subject: Initial (incomplete) implementation of f:f:core::Filter (#1495) And RelationFilter subclass. Used to implement the next step in core::Query. --- .../src/firebase/firestore/model/field_value.cc | 34 +++++++++------------- 1 file changed, 14 insertions(+), 20 deletions(-) (limited to 'Firestore/core/src/firebase/firestore/model/field_value.cc') 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(); } -- cgit v1.2.3