From 1e689145e6ca7907fd458c71a3c0543c23d52a21 Mon Sep 17 00:00:00 2001 From: Eliot Horowitz Date: Wed, 19 Aug 2009 11:32:08 -0400 Subject: couple of helpers MINOR --- db/jsobj.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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: @@ -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; } -- cgit v1.2.1