diff options
author | Mathias Stearn <mathias@10gen.com> | 2013-08-07 18:14:21 -0400 |
---|---|---|
committer | Mathias Stearn <mathias@10gen.com> | 2013-08-09 13:38:27 -0400 |
commit | 6b7cce6be7d9fbec8b0b262654b9a5512bd06746 (patch) | |
tree | 745572fe02baf49d788124021132ed53d4b9323b /src/mongo/db/pipeline/document.h | |
parent | cc5dd54b64ffece231ba7ec917e8a92252b7be63 (diff) | |
download | mongo-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.h | 23 |
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). */ |