diff options
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(); } |