Skip to content

Commit 6f784d0

Browse files
committed
delegate to underlying impl.
1 parent 974c1b9 commit 6f784d0

File tree

6 files changed

+34
-2
lines changed

6 files changed

+34
-2
lines changed

firestore/src/android/document_change_android.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,11 @@ std::size_t DocumentChangeInternal::new_index() const {
5555
return env.Call(obj_, kNewIndex);
5656
}
5757

58+
bool operator==(const DocumentChangeInternal& lhs,
59+
const DocumentChangeInternal& rhs) {
60+
Env env = FirestoreInternal::GetEnv();
61+
return Object::Equals(env, lhs.ToJava(), rhs.ToJava());
62+
}
63+
5864
} // namespace firestore
5965
} // namespace firebase

firestore/src/android/document_change_android.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ class DocumentChangeInternal : public Wrapper {
2424
std::size_t new_index() const;
2525
};
2626

27+
bool operator==(const DocumentChangeInternal& lhs,
28+
const DocumentChangeInternal& rhs);
29+
30+
inline bool operator!=(const DocumentChangeInternal& lhs,
31+
const DocumentChangeInternal& rhs) {
32+
return !(lhs == rhs);
33+
}
34+
2735
} // namespace firestore
2836
} // namespace firebase
2937

firestore/src/common/document_change.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,11 @@ std::size_t DocumentChange::new_index() const {
105105
}
106106

107107
bool operator==(const DocumentChange& lhs, const DocumentChange& rhs) {
108-
return lhs.type() == rhs.type() && lhs.old_index() == rhs.old_index() &&
109-
lhs.new_index() == rhs.new_index() && lhs.document() == rhs.document();
108+
if (!lhs.internal_ || !rhs.internal_) {
109+
return lhs.internal_ == rhs.internal_;
110+
}
111+
112+
return lhs.internal_ == rhs.internal_ || *lhs.internal_ == *rhs.internal_;
110113
}
111114

112115
} // namespace firestore

firestore/src/include/firebase/firestore/document_change.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ class DocumentChange {
173173
bool is_valid() const { return internal_ != nullptr; }
174174

175175
private:
176+
friend bool operator==(const DocumentChange& lhs, const DocumentChange& rhs);
177+
176178
friend class FirestoreInternal;
177179
friend class Wrapper;
178180
friend struct ConverterImpl;

firestore/src/main/document_change_main.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,10 @@ std::size_t DocumentChangeInternal::new_index() const {
4646
return change_.new_index();
4747
}
4848

49+
bool operator==(const DocumentChangeInternal& lhs,
50+
const DocumentChangeInternal& rhs) {
51+
return lhs.change_ == rhs.change_;
52+
}
53+
4954
} // namespace firestore
5055
} // namespace firebase

firestore/src/main/document_change_main.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,18 @@ class DocumentChangeInternal {
2727
std::size_t old_index() const;
2828
std::size_t new_index() const;
2929

30+
friend bool operator==(const DocumentChangeInternal& lhs,
31+
const DocumentChangeInternal& rhs);
32+
3033
private:
3134
api::DocumentChange change_;
3235
};
3336

37+
inline bool operator!=(const DocumentChangeInternal& lhs,
38+
const DocumentChangeInternal& rhs) {
39+
return !(lhs == rhs);
40+
}
41+
3442
} // namespace firestore
3543
} // namespace firebase
3644

0 commit comments

Comments
 (0)