diff options
author | Eliot Horowitz <eliot@10gen.com> | 2009-08-19 11:32:08 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2009-08-19 11:32:08 -0400 |
commit | 1e689145e6ca7907fd458c71a3c0543c23d52a21 (patch) | |
tree | 6abf740f06a8cc008ad12b0fdd01b5b97d96e7e8 | |
parent | 12766072240a39e09394b1425cee3ec4e18872b0 (diff) | |
download | mongo-1e689145e6ca7907fd458c71a3c0543c23d52a21.tar.gz |
couple of helpers MINOR
-rw-r--r-- | db/jsobj.h | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/db/jsobj.h b/db/jsobj.h index ad3d70118cf..9fd2a1b88ec 100644 --- a/db/jsobj.h +++ b/db/jsobj.h @@ -413,6 +413,20 @@ namespace mongo { BSONObj codeWScopeObject() const; + string ascode() const { + switch( type() ){ + case String: + case Code: + return valuestr(); + case CodeWScope: + return codeWScopeCode(); + default: + log() << "can't convert type: " << (int)(type()) << " to code" << endl; + } + uassert( "not code" , 0 ); + return ""; + } + /** Get binary data. Element must be of type BinData */ const char *binData(int& len) const { // BinData: <int len> <byte subtype> <byte[len] data> @@ -894,7 +908,7 @@ namespace mongo { class BSONObjCmp { public: - BSONObjCmp( const BSONObj &_order ) : order( _order ) {} + BSONObjCmp( const BSONObj &_order = BSONObj() ) : order( _order ) {} bool operator()( const BSONObj &l, const BSONObj &r ) const { return l.woCompare( r, order ) < 0; } |