summaryrefslogtreecommitdiff
path: root/bson/ordering.h
diff options
context:
space:
mode:
Diffstat (limited to 'bson/ordering.h')
-rw-r--r--bson/ordering.h23
1 files changed, 15 insertions, 8 deletions
diff --git a/bson/ordering.h b/bson/ordering.h
index 749e20d..bca3296 100644
--- a/bson/ordering.h
+++ b/bson/ordering.h
@@ -19,15 +19,22 @@
namespace mongo {
- /** A precomputation of a BSON key pattern.
+ // todo: ideally move to db/ instead of bson/, but elim any dependencies first
+
+ /** A precomputation of a BSON index or sort key pattern. That is something like:
+ { a : 1, b : -1 }
The constructor is private to make conversion more explicit so we notice where we call make().
Over time we should push this up higher and higher.
- */
+ */
class Ordering {
- const unsigned bits;
- const unsigned nkeys;
- Ordering(unsigned b,unsigned n) : bits(b),nkeys(n) { }
+ unsigned bits;
+ Ordering(unsigned b) : bits(b) { }
public:
+ Ordering(const Ordering& r) : bits(r.bits) { }
+ void operator=(const Ordering& r) {
+ bits = r.bits;
+ }
+
/** so, for key pattern { a : 1, b : -1 }
get(0) == 1
get(1) == -1
@@ -39,12 +46,12 @@ namespace mongo {
// for woCompare...
unsigned descending(unsigned mask) const { return bits & mask; }
- operator string() const {
+ /*operator string() const {
StringBuilder buf(32);
for ( unsigned i=0; i<nkeys; i++)
buf.append( get(i) > 0 ? "+" : "-" );
return buf.str();
- }
+ }*/
static Ordering make(const BSONObj& obj) {
unsigned b = 0;
@@ -59,7 +66,7 @@ namespace mongo {
b |= (1 << n);
n++;
}
- return Ordering(b,n);
+ return Ordering(b);
}
};