summaryrefslogtreecommitdiff
path: root/src/mongo/bson/bsonelement.h
diff options
context:
space:
mode:
authorTess Avitabile <tess.avitabile@mongodb.com>2016-03-16 18:09:25 -0400
committerTess Avitabile <tess.avitabile@mongodb.com>2016-03-24 16:18:46 -0400
commit0a412aaa51a81325465837e712faaaaaca27e922 (patch)
tree114138897ef7de572de6baafa8a29eb0eb0d8ff6 /src/mongo/bson/bsonelement.h
parent3fb60720a0df562d176887f95925f7562bb50f8c (diff)
downloadmongo-0a412aaa51a81325465837e712faaaaaca27e922.tar.gz
SERVER-22735 Extend woCompare() to optionally accept a StringData::ComparatorInterface
Diffstat (limited to 'src/mongo/bson/bsonelement.h')
-rw-r--r--src/mongo/bson/bsonelement.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/mongo/bson/bsonelement.h b/src/mongo/bson/bsonelement.h
index 9b77a8d2964..45a217a6498 100644
--- a/src/mongo/bson/bsonelement.h
+++ b/src/mongo/bson/bsonelement.h
@@ -39,6 +39,7 @@
#include "mongo/base/data_view.h"
#include "mongo/bson/bsontypes.h"
#include "mongo/bson/oid.h"
+#include "mongo/base/string_data_comparator_interface.h"
#include "mongo/bson/timestamp.h"
#include "mongo/config.h"
#include "mongo/platform/decimal128.h"
@@ -54,8 +55,12 @@ typedef BSONElement be;
typedef BSONObj bo;
typedef BSONObjBuilder bob;
-/* l and r MUST have same type when called: check that first. */
-int compareElementValues(const BSONElement& l, const BSONElement& r);
+/** l and r MUST have same type when called: check that first.
+ If comparator is non-null, it is used for all comparisons between two strings.
+*/
+int compareElementValues(const BSONElement& l,
+ const BSONElement& r,
+ StringData::ComparatorInterface* comparator = nullptr);
/** BSONElement represents an "element" in a BSONObj. So for the object { a : 3, b : "abc" },
'a : 3' is the first element (key+value).
@@ -485,8 +490,11 @@ public:
@return <0: l<r. 0:l==r. >0:l>r
order by type, field name, and field value.
If considerFieldName is true, pay attention to the field name.
+ If comparator is non-null, it is used for all comparisons between two strings.
*/
- int woCompare(const BSONElement& e, bool considerFieldName = true) const;
+ int woCompare(const BSONElement& e,
+ bool considerFieldName = true,
+ StringData::ComparatorInterface* comparator = nullptr) const;
/**
* Functor compatible with std::hash for std::unordered_{map,set}