summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/document.h
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2013-08-07 18:14:21 -0400
committerMathias Stearn <mathias@10gen.com>2013-08-09 13:38:27 -0400
commit6b7cce6be7d9fbec8b0b262654b9a5512bd06746 (patch)
tree745572fe02baf49d788124021132ed53d4b9323b /src/mongo/db/pipeline/document.h
parentcc5dd54b64ffece231ba7ec917e8a92252b7be63 (diff)
downloadmongo-6b7cce6be7d9fbec8b0b262654b9a5512bd06746.tar.gz
Add relational operators to Document
Diffstat (limited to 'src/mongo/db/pipeline/document.h')
-rw-r--r--src/mongo/db/pipeline/document.h23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/mongo/db/pipeline/document.h b/src/mongo/db/pipeline/document.h
index 1f5d966c4fd..9c72d56cda0 100644
--- a/src/mongo/db/pipeline/document.h
+++ b/src/mongo/db/pipeline/document.h
@@ -161,9 +161,6 @@ namespace mongo {
size_t getFieldCount() const { return size(); }
Value getValue(StringData fieldName) const { return getField(fieldName); }
- // TODO: replace with logical equality once all current usages are fixed
- bool operator== (const Document& lhs) const { return _storage == lhs._storage; }
-
explicit Document(const DocumentStorage* ptr) : _storage(ptr) {};
private:
@@ -177,6 +174,26 @@ namespace mongo {
intrusive_ptr<const DocumentStorage> _storage;
};
+ inline bool operator== (const Document& l, const Document& r) {
+ return Document::compare(l, r) == 0;
+ }
+ inline bool operator!= (const Document& l, const Document& r) {
+ return Document::compare(l, r) != 0;
+ }
+ inline bool operator< (const Document& l, const Document& r) {
+ return Document::compare(l, r) < 0;
+ }
+ inline bool operator<= (const Document& l, const Document& r) {
+ return Document::compare(l, r) <= 0;
+ }
+ inline bool operator> (const Document& l, const Document& r) {
+ return Document::compare(l, r) > 0;
+ }
+ inline bool operator>= (const Document& l, const Document& r) {
+ return Document::compare(l, r) >= 0;
+ }
+
+
/** This class is returned by MutableDocument to allow you to modify its values.
* You are not allowed to hold variables of this type (enforced by the type system).
*/