diff options
-rw-r--r-- | client/dbclient.cpp | 10 | ||||
-rw-r--r-- | client/examples/clientTest.cpp | 44 | ||||
-rw-r--r-- | client/examples/first.cpp | 10 | ||||
-rw-r--r-- | client/gridfs.cpp | 6 | ||||
-rw-r--r-- | client/model.cpp | 4 | ||||
-rw-r--r-- | db/btreecursor.cpp | 4 | ||||
-rw-r--r-- | db/cloner.cpp | 2 | ||||
-rw-r--r-- | db/curop.h | 4 | ||||
-rw-r--r-- | db/db.sln | 23 | ||||
-rw-r--r-- | db/dbcommands.cpp | 2 | ||||
-rw-r--r-- | db/dbwebserver.cpp | 2 | ||||
-rw-r--r-- | db/jsobj.cpp | 8 | ||||
-rw-r--r-- | db/jsobj.h | 10 | ||||
-rw-r--r-- | db/json.cpp | 2 | ||||
-rw-r--r-- | db/pdfile.cpp | 4 | ||||
-rw-r--r-- | db/query.cpp | 6 | ||||
-rw-r--r-- | db/repl.cpp | 2 | ||||
-rw-r--r-- | dbtests/btreetests.cpp | 2 | ||||
-rw-r--r-- | dbtests/jsobjtests.cpp | 8 | ||||
-rw-r--r-- | dbtests/jsontests.cpp | 70 | ||||
-rw-r--r-- | dbtests/mockdbclient.h | 2 | ||||
-rw-r--r-- | dbtests/namespacetests.cpp | 34 | ||||
-rw-r--r-- | dbtests/pairingtests.cpp | 2 | ||||
-rw-r--r-- | dbtests/repltests.cpp | 2 | ||||
-rw-r--r-- | shell/MongoJS.cpp | 2 | ||||
-rw-r--r-- | tools/export.cpp | 2 | ||||
-rw-r--r-- | tools/files.cpp | 4 |
27 files changed, 147 insertions, 124 deletions
diff --git a/client/dbclient.cpp b/client/dbclient.cpp index ddefc817065..10eba7050b9 100644 --- a/client/dbclient.cpp +++ b/client/dbclient.cpp @@ -34,7 +34,7 @@ namespace mongo { BSONObjBuilder b; b.appendElements(obj); b.appendWhere(jscode, scope); - obj = b.doneAndDecouple(); + obj = b.obj(); return *this; } @@ -45,7 +45,7 @@ namespace mongo { else b.append("query", obj); b.append("orderby", s); - obj = b.doneAndDecouple(); + obj = b.obj(); return *this; } @@ -56,7 +56,7 @@ namespace mongo { else b.append("query", obj); b.append("$hint", keyPattern); - obj = b.doneAndDecouple(); + obj = b.obj(); return *this; } @@ -67,7 +67,7 @@ namespace mongo { else b.append("query", obj); b.append("$explain", true); - obj = b.doneAndDecouple(); + obj = b.obj(); return *this; } @@ -520,7 +520,7 @@ namespace mongo { return 0; _seenIndexes.insert( cacheKey ); - insert( Namespace( ns.c_str() ).getSisterNS( "system.indexes" ).c_str() , toSave.doneAndDecouple() ); + insert( Namespace( ns.c_str() ).getSisterNS( "system.indexes" ).c_str() , toSave.obj() ); return 1; } diff --git a/client/examples/clientTest.cpp b/client/examples/clientTest.cpp index b3136272732..36288da4d3f 100644 --- a/client/examples/clientTest.cpp +++ b/client/examples/clientTest.cpp @@ -25,22 +25,22 @@ int main() { conn.dropCollection(ns); // clean up old data from any previous tests - conn.remove( ns, BSONObjBuilder().doneAndDecouple() ); - assert( conn.findOne( ns , BSONObjBuilder().doneAndDecouple() ).isEmpty() ); + conn.remove( ns, BSONObjBuilder().obj() ); + assert( conn.findOne( ns , BSONObjBuilder().obj() ).isEmpty() ); // test insert - conn.insert( ns ,BSONObjBuilder().append( "name" , "eliot" ).append( "num" , 1 ).doneAndDecouple() ); - assert( ! conn.findOne( ns , BSONObjBuilder().doneAndDecouple() ).isEmpty() ); + conn.insert( ns ,BSONObjBuilder().append( "name" , "eliot" ).append( "num" , 1 ).obj() ); + assert( ! conn.findOne( ns , BSONObjBuilder().obj() ).isEmpty() ); // test remove - conn.remove( ns, BSONObjBuilder().doneAndDecouple() ); - assert( conn.findOne( ns , BSONObjBuilder().doneAndDecouple() ).isEmpty() ); + conn.remove( ns, BSONObjBuilder().obj() ); + assert( conn.findOne( ns , BSONObjBuilder().obj() ).isEmpty() ); // insert, findOne testing - conn.insert( ns , BSONObjBuilder().append( "name" , "eliot" ).append( "num" , 1 ).doneAndDecouple() ); + conn.insert( ns , BSONObjBuilder().append( "name" , "eliot" ).append( "num" , 1 ).obj() ); { - BSONObj res = conn.findOne( ns , BSONObjBuilder().doneAndDecouple() ); + BSONObj res = conn.findOne( ns , BSONObjBuilder().obj() ); assert( strstr( res.getStringField( "name" ) , "eliot" ) ); assert( ! strstr( res.getStringField( "name2" ) , "eliot" ) ); assert( 1 == res.getIntField( "num" ) ); @@ -48,9 +48,9 @@ int main() { // cursor - conn.insert( ns ,BSONObjBuilder().append( "name" , "sara" ).append( "num" , 2 ).doneAndDecouple() ); + conn.insert( ns ,BSONObjBuilder().append( "name" , "sara" ).append( "num" , 2 ).obj() ); { - auto_ptr<DBClientCursor> cursor = conn.query( ns , BSONObjBuilder().doneAndDecouple() ); + auto_ptr<DBClientCursor> cursor = conn.query( ns , BSONObjBuilder().obj() ); int count = 0; while ( cursor->more() ) { count++; @@ -60,7 +60,7 @@ int main() { } { - auto_ptr<DBClientCursor> cursor = conn.query( ns , BSONObjBuilder().append( "num" , 1 ).doneAndDecouple() ); + auto_ptr<DBClientCursor> cursor = conn.query( ns , BSONObjBuilder().append( "num" , 1 ).obj() ); int count = 0; while ( cursor->more() ) { count++; @@ -70,7 +70,7 @@ int main() { } { - auto_ptr<DBClientCursor> cursor = conn.query( ns , BSONObjBuilder().append( "num" , 3 ).doneAndDecouple() ); + auto_ptr<DBClientCursor> cursor = conn.query( ns , BSONObjBuilder().append( "num" , 3 ).obj() ); int count = 0; while ( cursor->more() ) { count++; @@ -81,25 +81,25 @@ int main() { // update { - BSONObj res = conn.findOne( ns , BSONObjBuilder().append( "name" , "eliot" ).doneAndDecouple() ); + BSONObj res = conn.findOne( ns , BSONObjBuilder().append( "name" , "eliot" ).obj() ); assert( ! strstr( res.getStringField( "name2" ) , "eliot" ) ); - BSONObj after = BSONObjBuilder().appendElements( res ).append( "name2" , "h" ).doneAndDecouple(); + BSONObj after = BSONObjBuilder().appendElements( res ).append( "name2" , "h" ).obj(); - conn.update( ns , BSONObjBuilder().append( "name" , "eliot2" ).doneAndDecouple() , after ); - res = conn.findOne( ns , BSONObjBuilder().append( "name" , "eliot" ).doneAndDecouple() ); + conn.update( ns , BSONObjBuilder().append( "name" , "eliot2" ).obj() , after ); + res = conn.findOne( ns , BSONObjBuilder().append( "name" , "eliot" ).obj() ); assert( ! strstr( res.getStringField( "name2" ) , "eliot" ) ); - assert( conn.findOne( ns , BSONObjBuilder().append( "name" , "eliot2" ).doneAndDecouple() ).isEmpty() ); + assert( conn.findOne( ns , BSONObjBuilder().append( "name" , "eliot2" ).obj() ).isEmpty() ); - conn.update( ns , BSONObjBuilder().append( "name" , "eliot" ).doneAndDecouple() , after ); - res = conn.findOne( ns , BSONObjBuilder().append( "name" , "eliot" ).doneAndDecouple() ); + conn.update( ns , BSONObjBuilder().append( "name" , "eliot" ).obj() , after ); + res = conn.findOne( ns , BSONObjBuilder().append( "name" , "eliot" ).obj() ); assert( strstr( res.getStringField( "name" ) , "eliot" ) ); assert( strstr( res.getStringField( "name2" ) , "h" ) ); - assert( conn.findOne( ns , BSONObjBuilder().append( "name" , "eliot2" ).doneAndDecouple() ).isEmpty() ); + assert( conn.findOne( ns , BSONObjBuilder().append( "name" , "eliot2" ).obj() ).isEmpty() ); // upsert - conn.update( ns , BSONObjBuilder().append( "name" , "eliot2" ).doneAndDecouple() , after , 1 ); - assert( ! conn.findOne( ns , BSONObjBuilder().append( "name" , "eliot" ).doneAndDecouple() ).isEmpty() ); + conn.update( ns , BSONObjBuilder().append( "name" , "eliot2" ).obj() , after , 1 ); + assert( ! conn.findOne( ns , BSONObjBuilder().append( "name" , "eliot" ).obj() ).isEmpty() ); } diff --git a/client/examples/first.cpp b/client/examples/first.cpp index 570eb1992f4..0fdb1fa8151 100644 --- a/client/examples/first.cpp +++ b/client/examples/first.cpp @@ -12,7 +12,7 @@ void insert( mongo::DBClientConnection & conn , const char * name , int num ) { mongo::BSONObjBuilder obj; obj.append( "name" , name ); obj.append( "num" , num ); - conn.insert( "test.people" , obj.doneAndDecouple() ); + conn.insert( "test.people" , obj.obj() ); } int main() { @@ -26,7 +26,7 @@ int main() { { // clean up old data from any previous tests mongo::BSONObjBuilder query; - conn.remove( "test.people" , query.doneAndDecouple() ); + conn.remove( "test.people" , query.obj() ); } insert( conn , "eliot" , 15 ); @@ -34,7 +34,7 @@ int main() { { mongo::BSONObjBuilder query; - auto_ptr<mongo::DBClientCursor> cursor = conn.query( "test.people" , query.doneAndDecouple() ); + auto_ptr<mongo::DBClientCursor> cursor = conn.query( "test.people" , query.obj() ); cout << "using cursor" << endl; while ( cursor->more() ) { mongo::BSONObj obj = cursor->next(); @@ -46,14 +46,14 @@ int main() { { mongo::BSONObjBuilder query; query.append( "name" , "eliot" ); - mongo::BSONObj res = conn.findOne( "test.people" , query.doneAndDecouple() ); + mongo::BSONObj res = conn.findOne( "test.people" , query.obj() ); cout << res.isEmpty() << "\t" << res.jsonString() << endl; } { mongo::BSONObjBuilder query; query.append( "name" , "asd" ); - mongo::BSONObj res = conn.findOne( "test.people" , query.doneAndDecouple() ); + mongo::BSONObj res = conn.findOne( "test.people" , query.obj() ); cout << res.isEmpty() << "\t" << res.jsonString() << endl; } diff --git a/client/gridfs.cpp b/client/gridfs.cpp index 93c907b9a43..987f6c49b51 100644 --- a/client/gridfs.cpp +++ b/client/gridfs.cpp @@ -21,7 +21,7 @@ namespace mongo { b.appendAs( fileId , "files_id" ); b.appendInt( "n" , chunkNumber ); b.appendBinDataArray( "data" , data , len ); - _data = b.doneAndDecouple(); + _data = b.obj(); } @@ -54,7 +54,7 @@ namespace mongo { id.init(); b.appendOID( "_id" , &id ); - fileObject = b.doneAndDecouple(); + fileObject = b.obj(); } char buf[DEFAULT_CHUNK_SIZE]; @@ -104,7 +104,7 @@ namespace mongo { b.appendAs( _obj["_id"] , "files_id" ); b.appendInt( "n" , n ); - BSONObj o = _grid->_client.findOne( _grid->_chunksNS.c_str() , b.doneAndDecouple() ); + BSONObj o = _grid->_client.findOne( _grid->_chunksNS.c_str() , b.obj() ); assert( ! o.isEmpty() ); return Chunk(o); } diff --git a/client/model.cpp b/client/model.cpp index d740b44f574..7f47e187ad4 100644 --- a/client/model.cpp +++ b/client/model.cpp @@ -47,7 +47,7 @@ namespace mongo { OID oid; b.appendOID( "_id" , &oid ); - BSONObj o = b.doneAndDecouple(); + BSONObj o = b.obj(); conn.insert( getNS() , o ); _id = o["_id"]; @@ -57,7 +57,7 @@ namespace mongo { b.append( _id ); BSONObjBuilder id; id.append( _id ); - conn.update( getNS() , id.doneAndDecouple() , b.doneAndDecouple() ); + conn.update( getNS() , id.obj() , b.obj() ); log(4) << "updated old model" << endl; } diff --git a/db/btreecursor.cpp b/db/btreecursor.cpp index dc1d5ad685d..62b73aa30cf 100644 --- a/db/btreecursor.cpp +++ b/db/btreecursor.cpp @@ -100,8 +100,8 @@ namespace mongo { startBuilder.appendAs( forward ? lowest : highest, "" ); endBuilder.appendAs( forward ? highest : lowest, "" ); } - startKey = startBuilder.doneAndDecouple(); - endKey = endBuilder.doneAndDecouple(); + startKey = startBuilder.obj(); + endKey = endBuilder.obj(); } // Find lowest and highest possible key values given all $gt, $gte, $lt, and diff --git a/db/cloner.cpp b/db/cloner.cpp index c7daf5c8037..324fb1a84a7 100644 --- a/db/cloner.cpp +++ b/db/cloner.cpp @@ -69,7 +69,7 @@ namespace mongo { else b.append(e); } - BSONObj res= b.doneAndDecouple(); + BSONObj res= b.obj(); /* if( mod ) { out() << "before: " << o.toString() << endl; diff --git a/db/curop.h b/db/curop.h index 3b878a046c4..e3b35619155 100644 --- a/db/curop.h +++ b/db/curop.h @@ -36,7 +36,7 @@ namespace mongo { AuthenticationInfo *ai = authInfo.get(); if( ai == 0 || !ai->isAuthorized("admin") ) { b.append("err", "unauthorized"); - return b.doneAndDecouple(); + return b.obj(); } b.append("opid", opNum);
@@ -58,7 +58,7 @@ namespace mongo { b.append("ns", ns);
b.append("query", query);
b.append("inLock", dbMutexInfo.isLocked());
- return b.doneAndDecouple();
+ return b.obj();
}
} currentOp;
diff --git a/db/db.sln b/db/db.sln index 4eba708344e..c2e08932b3d 100644 --- a/db/db.sln +++ b/db/db.sln @@ -20,15 +20,38 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dbtests", "dbtests", "{C72EBEDD-342D-4371-8B0D-D7505902FA69}"
ProjectSection(SolutionItems) = preProject
..\dbtests\btreetests.cpp = ..\dbtests\btreetests.cpp
+ ..\dbtests\dbtests.cpp = ..\dbtests\dbtests.cpp
+ ..\dbtests\javajstests.cpp = ..\dbtests\javajstests.cpp
+ ..\dbtests\jsobjtests.cpp = ..\dbtests\jsobjtests.cpp
+ ..\dbtests\jsontests.cpp = ..\dbtests\jsontests.cpp
..\dbtests\matchertests.cpp = ..\dbtests\matchertests.cpp
..\dbtests\namespacetests.cpp = ..\dbtests\namespacetests.cpp
..\dbtests\pairingtests.cpp = ..\dbtests\pairingtests.cpp
+ ..\dbtests\pdfiletests.cpp = ..\dbtests\pdfiletests.cpp
..\dbtests\querytests.cpp = ..\dbtests\querytests.cpp
+ ..\dbtests\repltests.cpp = ..\dbtests\repltests.cpp
..\dbtests\socktests.cpp = ..\dbtests\socktests.cpp
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tutorial", "..\client\examples\tutorial\tutorial.vcproj", "{C5EC52B2-1E28-4AF1-A244-CBB514C361C0}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "shell", "shell", "{2CABB3B8-C9A6-478D-9463-0B37799ED708}"
+ ProjectSection(SolutionItems) = preProject
+ ..\shell\dbshell.cpp = ..\shell\dbshell.cpp
+ ..\shell\MongoJS.cpp = ..\shell\MongoJS.cpp
+ ..\shell\ShellUtils.cpp = ..\shell\ShellUtils.cpp
+ EndProjectSection
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{2B262D59-9DC7-4BF1-A431-1BD4966899A5}"
+ ProjectSection(SolutionItems) = preProject
+ ..\tools\dump.cpp = ..\tools\dump.cpp
+ ..\tools\export.cpp = ..\tools\export.cpp
+ ..\tools\files.cpp = ..\tools\files.cpp
+ ..\tools\importJSON.cpp = ..\tools\importJSON.cpp
+ ..\tools\restore.cpp = ..\tools\restore.cpp
+ ..\tools\Tool.cpp = ..\tools\Tool.cpp
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug Recstore|Win32 = Debug Recstore|Win32
diff --git a/db/dbcommands.cpp b/db/dbcommands.cpp index 35796209e72..ba4437bd75c 100644 --- a/db/dbcommands.cpp +++ b/db/dbcommands.cpp @@ -677,7 +677,7 @@ namespace mongo { BSONObjBuilder b; b.append( "name", i->c_str() ); b.append( "sizeOnDisk", (double) dbSize( i->c_str() ) ); - dbInfos.push_back( b.doneAndDecouple() ); + dbInfos.push_back( b.obj() ); seen.insert( i->c_str() ); } diff --git a/db/dbwebserver.cpp b/db/dbwebserver.cpp index 8407fd18f9f..29a97b65058 100644 --- a/db/dbwebserver.cpp +++ b/db/dbwebserver.cpp @@ -366,7 +366,7 @@ namespace mongo { queryBuilder.append( field , val ); } - BSONObj query = queryBuilder.doneAndDecouple(); + BSONObj query = queryBuilder.obj(); auto_ptr<DBClientCursor> cursor = db.query( ns.c_str() , query, num , skip ); diff --git a/db/jsobj.cpp b/db/jsobj.cpp index 93de84be27f..1b309838db3 100644 --- a/db/jsobj.cpp +++ b/db/jsobj.cpp @@ -751,7 +751,7 @@ namespace mongo { return BSONObj(); b.appendAs(x, ""); } - return b.doneAndDecouple(); + return b.obj(); } BSONObj BSONObj::extractFields(BSONObj& pattern) { @@ -766,7 +766,7 @@ namespace mongo { return BSONObj(); b.append(x); } - return b.doneAndDecouple(); + return b.obj(); } int BSONObj::getIntField(const char *name) const { @@ -877,7 +877,7 @@ namespace mongo { b.append( e ); } } - return b.doneAndDecouple(); + return b.obj(); } BSONObj BSONObj::replaceFieldNames( const vector< string > &names ) const { @@ -895,7 +895,7 @@ namespace mongo { b.append( e ); } } - return b.doneAndDecouple(); + return b.obj(); } string BSONObj::hexDump() const { diff --git a/db/jsobj.h b/db/jsobj.h index a3d7fac9a2f..2e363bb7a06 100644 --- a/db/jsobj.h +++ b/db/jsobj.h @@ -728,7 +728,7 @@ namespace mongo { e.g., BSON( "name" << "joe" << "age" << 33 ) */ -#define BSON(x) (( BSONObjBuilder() << x ).doneAndDecouple()) +#define BSON(x) (( BSONObjBuilder() << x ).obj()) class BSONObjBuilderValueStream { public: @@ -946,15 +946,15 @@ namespace mongo { marshalArray( fieldName, arrBuilder.done() ); } - /** BSONObj will free the buffer when it is finished. */ - BSONObj doneAndDecouple() { + /** The returned BSONObj will free the buffer when it is finished. */ + BSONObj obj() { int l; return BSONObj(decouple(l), true); } /** Fetch the object we have built. BSONObjBuilder still frees the object when the builder goes out of - scope -- very important to keep in mind. Use doneAndDecouple() if you + scope -- very important to keep in mind. Use obj() if you would like the BSONObj to last longer than the builder. */ BSONObj done() { @@ -1125,7 +1125,7 @@ namespace mongo { inline BSONObj BSONElement::wrap() { BSONObjBuilder b; b.append(*this); - return b.doneAndDecouple(); + return b.obj(); } inline bool BSONObj::hasElement(const char *name) const { diff --git a/db/json.cpp b/db/json.cpp index 5cd72d9d0fa..595ab76599d 100644 --- a/db/json.cpp +++ b/db/json.cpp @@ -39,7 +39,7 @@ namespace mongo { indexes.push_back( 0 ); } BSONObj pop() { - BSONObj ret = back()->doneAndDecouple(); + BSONObj ret = back()->obj(); builders.pop_back(); fieldNames.pop_back(); indexes.pop_back(); diff --git a/db/pdfile.cpp b/db/pdfile.cpp index 3fa39696dc5..3d152299077 100644 --- a/db/pdfile.cpp +++ b/db/pdfile.cpp @@ -507,7 +507,7 @@ namespace mongo { break; b.append( f ); } - BSONObj o = b.doneAndDecouple(); + BSONObj o = b.obj(); assert( !o.isEmpty() ); keys.insert(o); return; @@ -536,7 +536,7 @@ namespace mongo { b.appendAs( e, "" ); } - BSONObj o = b.doneAndDecouple(); + BSONObj o = b.obj(); assert( !o.isEmpty() ); keys.insert(o); } diff --git a/db/query.cpp b/db/query.cpp index c3c01795253..20507ccd2a4 100644 --- a/db/query.cpp +++ b/db/query.cpp @@ -243,7 +243,7 @@ namespace mongo { if( js.getObjectID( e ) ) { BSONObjBuilder b; b.append( e ); - *deletedId = b.doneAndDecouple(); + *deletedId = b.obj(); } } break; @@ -385,7 +385,7 @@ namespace mongo { // if there's no id. if ( js.getObjectID( id ) ) { idPattern.append( id ); - pattern = idPattern.doneAndDecouple(); + pattern = idPattern.obj(); } } @@ -619,7 +619,7 @@ namespace mongo { uassert("too many ordering elements", *p <= '9'); } - return b.doneAndDecouple(); + return b.obj(); } QueryResult* runQuery(Message& message, const char *ns, int ntoskip, int _ntoreturn, BSONObj jsobj, diff --git a/db/repl.cpp b/db/repl.cpp index 504716d2379..5fe55c3fa75 100644 --- a/db/repl.cpp +++ b/db/repl.cpp @@ -450,7 +450,7 @@ namespace mongo { if ( n ) b.append("dbs", dbs_builder.done()); - return b.doneAndDecouple(); + return b.obj(); } void ReplSource::save() { diff --git a/dbtests/btreetests.cpp b/dbtests/btreetests.cpp index f2d7883ed54..be1ceea6f38 100644 --- a/dbtests/btreetests.cpp +++ b/dbtests/btreetests.cpp @@ -75,7 +75,7 @@ namespace BtreeTests { BSONObjBuilder builder; string val( n, c ); builder.append( "a", val ); - return builder.doneAndDecouple(); + return builder.obj(); } void locate( BSONObj &key, int expectedPos, bool expectedFound, const DiskLoc &expectedLocation, diff --git a/dbtests/jsobjtests.cpp b/dbtests/jsobjtests.cpp index 4433a4b1d97..abcfa3f8047 100644 --- a/dbtests/jsobjtests.cpp +++ b/dbtests/jsobjtests.cpp @@ -37,18 +37,18 @@ namespace JsobjTests { static BSONObj basic( const char *name, int val ) { BSONObjBuilder b; b.appendInt( name, val ); - return b.doneAndDecouple(); + return b.obj(); } static BSONObj basic( const char *name, vector< int > val ) { BSONObjBuilder b; b.appendIntArray( name, val ); - return b.doneAndDecouple(); + return b.obj(); } template< class T > static BSONObj basic( const char *name, T val ) { BSONObjBuilder b; b.append( name, val ); - return b.doneAndDecouple(); + return b.obj(); } }; @@ -314,7 +314,7 @@ namespace JsobjTests { BSONObjBuilder scope; scope.append( "a", "b" ); b.appendCodeWScope( "c", "d", scope.done() ); - return b.doneAndDecouple(); + return b.obj(); } BSONObj invalid() const { BSONObj ret = valid(); diff --git a/dbtests/jsontests.cpp b/dbtests/jsontests.cpp index 9d9f130de72..e78d6f29d83 100644 --- a/dbtests/jsontests.cpp +++ b/dbtests/jsontests.cpp @@ -358,7 +358,7 @@ namespace JsonTests { class Empty : public Base { virtual BSONObj bson() const { BSONObjBuilder b; - return b.doneAndDecouple(); + return b.obj(); } virtual string json() const { return "{}"; @@ -368,7 +368,7 @@ namespace JsonTests { class EmptyWithSpace : public Base { virtual BSONObj bson() const { BSONObjBuilder b; - return b.doneAndDecouple(); + return b.obj(); } virtual string json() const { return "{ }"; @@ -379,7 +379,7 @@ namespace JsonTests { virtual BSONObj bson() const { BSONObjBuilder b; b.append( "a", "b" ); - return b.doneAndDecouple(); + return b.obj(); } virtual string json() const { return "{ \"a\" : \"b\" }"; @@ -390,7 +390,7 @@ namespace JsonTests { virtual BSONObj bson() const { BSONObjBuilder b; b.append( "", "" ); - return b.doneAndDecouple(); + return b.obj(); } virtual string json() const { return "{ \"\" : \"\" }"; @@ -407,7 +407,7 @@ namespace JsonTests { virtual BSONObj bson() const { BSONObjBuilder b; b.append( "$where", 1 ); - return b.doneAndDecouple(); + return b.obj(); } virtual string json() const { return "{ \"$where\" : 1 }"; @@ -418,7 +418,7 @@ namespace JsonTests { virtual BSONObj bson() const { BSONObjBuilder b; b.append( "a", 1 ); - return b.doneAndDecouple(); + return b.obj(); } virtual string json() const { return "{ \"a\" : 1 }"; @@ -434,7 +434,7 @@ namespace JsonTests { virtual BSONObj bson() const { BSONObjBuilder b; b.append( "a", -4.4433e-2 ); - return b.doneAndDecouple(); + return b.obj(); } virtual string json() const { return "{ \"a\" : -4.4433e-2 }"; @@ -446,7 +446,7 @@ namespace JsonTests { BSONObjBuilder b; b.append( "a", 1 ); b.append( "b", "foo" ); - return b.doneAndDecouple(); + return b.obj(); } virtual string json() const { return "{ \"a\" : 1, \"b\" : \"foo\" }"; @@ -459,7 +459,7 @@ namespace JsonTests { b.append( "a", 1 ); BSONObjBuilder c; c.append( "z", b.done() ); - return c.doneAndDecouple(); + return c.obj(); } virtual string json() const { return "{ \"z\" : { \"a\" : 1 } }"; @@ -471,7 +471,7 @@ namespace JsonTests { vector< int > arr; BSONObjBuilder b; b.append( "a", arr ); - return b.doneAndDecouple(); + return b.obj(); } virtual string json() const { return "{ \"a\" : [] }"; @@ -486,7 +486,7 @@ namespace JsonTests { arr.push_back( 3 ); BSONObjBuilder b; b.append( "a", arr ); - return b.doneAndDecouple(); + return b.obj(); } virtual string json() const { return "{ \"a\" : [ 1, 2, 3 ] }"; @@ -497,7 +497,7 @@ namespace JsonTests { virtual BSONObj bson() const { BSONObjBuilder b; b.appendBool( "a", true ); - return b.doneAndDecouple(); + return b.obj(); } virtual string json() const { return "{ \"a\" : true }"; @@ -508,7 +508,7 @@ namespace JsonTests { virtual BSONObj bson() const { BSONObjBuilder b; b.appendBool( "a", false ); - return b.doneAndDecouple(); + return b.obj(); } virtual string json() const { return "{ \"a\" : false }"; @@ -519,7 +519,7 @@ namespace JsonTests { virtual BSONObj bson() const { BSONObjBuilder b; b.appendNull( "a" ); - return b.doneAndDecouple(); + return b.obj(); } virtual string json() const { return "{ \"a\" : null }"; @@ -530,7 +530,7 @@ namespace JsonTests { virtual BSONObj bson() const { BSONObjBuilder b; b.append( "a", "\" \\ / \b \f \n \r \t" ); - return b.doneAndDecouple(); + return b.obj(); } virtual string json() const { return "{ \"a\" : \"\\\" \\\\ \\/ \\b \\f \\n \\r \\t\" }"; @@ -541,7 +541,7 @@ namespace JsonTests { virtual BSONObj bson() const { BSONObjBuilder b; b.append( "a", "\x7f" ); - return b.doneAndDecouple(); + return b.obj(); } virtual string json() const { return "{ \"a\" : \"\x7f\" }"; @@ -552,7 +552,7 @@ namespace JsonTests { virtual BSONObj bson() const { BSONObjBuilder b; b.append( "\n", "b" ); - return b.doneAndDecouple(); + return b.obj(); } virtual string json() const { return "{ \"\\n\" : \"b\" }"; @@ -572,7 +572,7 @@ namespace JsonTests { u[ 6 ] = 0; b.append( "a", u ); ASSERT_EQUALS( string( u ), b.done().firstElement().valuestr() ); - return b.doneAndDecouple(); + return b.obj(); } virtual string json() const { return "{ \"a\" : \"\\ua000\\uA000\" }"; @@ -597,7 +597,7 @@ namespace JsonTests { u[ 7 ] = 0; b.append( "a", u ); - return b.doneAndDecouple(); + return b.obj(); } virtual string json() const { return "{ \"a\" : \"\\u0001\\u007f\\u07ff\\uffff\" }"; @@ -618,7 +618,7 @@ namespace JsonTests { u[ 5 ] = 0; b.append( "a", u ); - return b.doneAndDecouple(); + return b.obj(); } virtual string json() const { return "{ \"a\" : \"\\u0700\\uff00\" }"; @@ -631,7 +631,7 @@ namespace JsonTests { OID o; memset( &o, 0, 12 ); b.appendDBRef( "a", "foo", o ); - return b.doneAndDecouple(); + return b.obj(); } // NOTE Testing other formats handled by by Base class. virtual string json() const { @@ -643,7 +643,7 @@ namespace JsonTests { virtual BSONObj bson() const { BSONObjBuilder b; b.appendOID( "_id" ); - return b.doneAndDecouple(); + return b.obj(); } virtual string json() const { return "{ \"_id\" : \"000000000000000000000000\" }"; @@ -656,7 +656,7 @@ namespace JsonTests { OID o; memset( &o, 0x0f, 12 ); b.appendOID( "_id", &o ); - return b.doneAndDecouple(); + return b.obj(); } virtual string json() const { return "{ \"_id\" : \"0f0f0f0f0f0f0f0f0f0f0f0f\" }"; @@ -671,7 +671,7 @@ namespace JsonTests { z[ 2 ] = 'c'; BSONObjBuilder b; b.appendBinData( "a", 3, ByteArray, z ); - return b.doneAndDecouple(); + return b.obj(); } virtual string json() const { return "{ \"a\" : { \"$binary\" : \"YWJj\", \"$type\" : \"02\" } }"; @@ -685,7 +685,7 @@ namespace JsonTests { z[ 1 ] = 'b'; BSONObjBuilder b; b.appendBinData( "a", 2, ByteArray, z ); - return b.doneAndDecouple(); + return b.obj(); } virtual string json() const { return "{ \"a\" : { \"$binary\" : \"YWI=\", \"$type\" : \"02\" } }"; @@ -698,7 +698,7 @@ namespace JsonTests { z[ 0 ] = 'a'; BSONObjBuilder b; b.appendBinData( "a", 1, ByteArray, z ); - return b.doneAndDecouple(); + return b.obj(); } virtual string json() const { return "{ \"a\" : { \"$binary\" : \"YQ==\", \"$type\" : \"02\" } }"; @@ -716,7 +716,7 @@ namespace JsonTests { }; BSONObjBuilder b; b.appendBinData( "a", 48, ByteArray, z ); - return b.doneAndDecouple(); + return b.obj(); } virtual string json() const { return "{ \"a\" : { \"$binary\" : \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\", \"$type\" : \"02\" } }"; @@ -727,7 +727,7 @@ namespace JsonTests { virtual BSONObj bson() const { BSONObjBuilder b; b.appendDate( "a", 0 ); - return b.doneAndDecouple(); + return b.obj(); } virtual string json() const { return "{ \"a\" : { \"$date\" : 0 } }"; @@ -738,7 +738,7 @@ namespace JsonTests { virtual BSONObj bson() const { BSONObjBuilder b; b.appendDate( "a", 100 ); - return b.doneAndDecouple(); + return b.obj(); } virtual string json() const { return "{ \"a\" : { \"$date\" : 100 } }"; @@ -757,7 +757,7 @@ namespace JsonTests { virtual BSONObj bson() const { BSONObjBuilder b; b.appendRegex( "a", "b", "i" ); - return b.doneAndDecouple(); + return b.obj(); } virtual string json() const { return "{ \"a\" : { \"$regex\" : \"b\", \"$options\" : \"i\" } }"; @@ -768,7 +768,7 @@ namespace JsonTests { virtual BSONObj bson() const { BSONObjBuilder b; b.appendRegex( "a", "\t", "i" ); - return b.doneAndDecouple(); + return b.obj(); } virtual string json() const { return "{ \"a\" : { \"$regex\" : \"\\t\", \"$options\" : \"i\" } }"; @@ -779,7 +779,7 @@ namespace JsonTests { virtual BSONObj bson() const { BSONObjBuilder b; b.appendRegex( "a", "\"", "" ); - return b.doneAndDecouple(); + return b.obj(); } virtual string json() const { return "{ \"a\" : /\"/ }"; @@ -808,7 +808,7 @@ namespace JsonTests { virtual BSONObj bson() const { BSONObjBuilder b; b.append( "a_b", 1 ); - return b.doneAndDecouple(); + return b.obj(); } virtual string json() const { return "{ a_b : 1 }"; @@ -819,7 +819,7 @@ namespace JsonTests { virtual BSONObj bson() const { BSONObjBuilder b; b.append( "$a_b", 1 ); - return b.doneAndDecouple(); + return b.obj(); } virtual string json() const { return "{ $a_b : 1 }"; @@ -830,7 +830,7 @@ namespace JsonTests { virtual BSONObj bson() const { BSONObjBuilder b; b.append( "ab'c\"", "bb\b '\"" ); - return b.doneAndDecouple(); + return b.obj(); } virtual string json() const { return "{ 'ab\\'c\"' : 'bb\\b \\'\"' }"; diff --git a/dbtests/mockdbclient.h b/dbtests/mockdbclient.h index 739e7e5d666..af9149c51e6 100644 --- a/dbtests/mockdbclient.h +++ b/dbtests/mockdbclient.h @@ -67,7 +67,7 @@ public: BSONObjBuilder result; result.append( "ok", runCommandAgainstRegistered( "admin.$cmd", query.obj, result ) ? 1.0 : 0.0 ); if ( cc_ ) cc_->afterCommand(); - return result.doneAndDecouple(); + return result.obj(); } virtual bool connect( const char *serverHostname, string& errmsg ) { return true; diff --git a/dbtests/namespacetests.cpp b/dbtests/namespacetests.cpp index 486348a4cef..4bd8e3c3a4a 100644 --- a/dbtests/namespacetests.cpp +++ b/dbtests/namespacetests.cpp @@ -58,18 +58,18 @@ namespace NamespaceTests { virtual BSONObj key() const { BSONObjBuilder k; k.append( "a", 1 ); - return k.doneAndDecouple(); + return k.obj(); } BSONObj aDotB() const { BSONObjBuilder k; k.append( "a.b", 1 ); - return k.doneAndDecouple(); + return k.obj(); } BSONObj aAndB() const { BSONObjBuilder k; k.append( "a", 1 ); k.append( "b", 1 ); - return k.doneAndDecouple(); + return k.obj(); } static vector< int > shortArray() { vector< int > a; @@ -82,7 +82,7 @@ namespace NamespaceTests { BSONObjBuilder b; b.append( "b", i ); b.append( "c", 4 ); - return b.doneAndDecouple(); + return b.obj(); } static void checkSize( int expected, const BSONObjSetDefaultOrder &objs ) { ASSERT_EQUALS( BSONObjSetDefaultOrder::size_type( expected ), objs.size() ); @@ -120,7 +120,7 @@ namespace NamespaceTests { BSONObjSetDefaultOrder keys; id().getKeysFromObject( b.done(), keys ); checkSize( 1, keys ); - assertEquals( e.doneAndDecouple(), *keys.begin() ); + assertEquals( e.obj(), *keys.begin() ); } }; @@ -136,7 +136,7 @@ namespace NamespaceTests { BSONObjSetDefaultOrder keys; id().getKeysFromObject( a.done(), keys ); checkSize( 1, keys ); - assertEquals( e.doneAndDecouple(), *keys.begin() ); + assertEquals( e.obj(), *keys.begin() ); } private: virtual BSONObj key() const { @@ -158,7 +158,7 @@ namespace NamespaceTests { for ( BSONObjSetDefaultOrder::iterator i = keys.begin(); i != keys.end(); ++i, ++j ) { BSONObjBuilder b; b.append( "", j ); - assertEquals( b.doneAndDecouple(), *i ); + assertEquals( b.obj(), *i ); } } }; @@ -179,7 +179,7 @@ namespace NamespaceTests { BSONObjBuilder b; b.append( "", j ); b.append( "", 2 ); - assertEquals( b.doneAndDecouple(), *i ); + assertEquals( b.obj(), *i ); } } private: @@ -204,7 +204,7 @@ namespace NamespaceTests { BSONObjBuilder b; b.append( "", 5 ); b.append( "", j ); - assertEquals( b.doneAndDecouple(), *i ); + assertEquals( b.obj(), *i ); } } private: @@ -212,7 +212,7 @@ namespace NamespaceTests { BSONObjBuilder k; k.append( "first", 1 ); k.append( "a", 1 ); - return k.doneAndDecouple(); + return k.obj(); } }; @@ -232,7 +232,7 @@ namespace NamespaceTests { for ( BSONObjSetDefaultOrder::iterator i = keys.begin(); i != keys.end(); ++i, ++j ) { BSONObjBuilder b; b.append( "", j ); - assertEquals( b.doneAndDecouple(), *i ); + assertEquals( b.obj(), *i ); } } private: @@ -276,7 +276,7 @@ namespace NamespaceTests { for ( BSONObjSetDefaultOrder::iterator i = keys.begin(); i != keys.end(); ++i, ++j ) { BSONObjBuilder b; b.append( "", j ); - assertEquals( b.doneAndDecouple(), *i ); + assertEquals( b.obj(), *i ); } } private: @@ -304,7 +304,7 @@ namespace NamespaceTests { BSONObjBuilder c; c.append( "", j ); c.append( "", 99 ); - assertEquals( c.doneAndDecouple(), *i ); + assertEquals( c.obj(), *i ); } } private: @@ -312,7 +312,7 @@ namespace NamespaceTests { BSONObjBuilder k; k.append( "a.b", 1 ); k.append( "d", 1 ); - return k.doneAndDecouple(); + return k.obj(); } }; @@ -323,7 +323,7 @@ namespace NamespaceTests { vector< BSONObj > elts; BSONObjBuilder s; s.append( "foo", 41 ); - elts.push_back( s.doneAndDecouple() ); + elts.push_back( s.obj() ); for ( int i = 1; i < 4; ++i ) elts.push_back( simpleBC( i ) ); BSONObjBuilder b; @@ -336,7 +336,7 @@ namespace NamespaceTests { for ( BSONObjSetDefaultOrder::iterator i = keys.begin(); i != keys.end(); ++i, ++j ) { BSONObjBuilder b; b.append( "", j ); - assertEquals( b.doneAndDecouple(), *i ); + assertEquals( b.obj(), *i ); } } private: @@ -428,7 +428,7 @@ namespace NamespaceTests { string as( 187, 'a' ); BSONObjBuilder b; b.append( "a", as ); - return b.doneAndDecouple(); + return b.obj(); } private: const char *ns_; diff --git a/dbtests/pairingtests.cpp b/dbtests/pairingtests.cpp index 541b0fd9959..27d92a9b932 100644 --- a/dbtests/pairingtests.cpp +++ b/dbtests/pairingtests.cpp @@ -177,7 +177,7 @@ namespace PairingTests { BSONObjBuilder b; b.appendInt( "ok", ok ); b.appendInt( "you_are", youAre ); - return b.doneAndDecouple(); + return b.obj(); } }; diff --git a/dbtests/repltests.cpp b/dbtests/repltests.cpp index e3c69fcb9ac..9b35e471c57 100644 --- a/dbtests/repltests.cpp +++ b/dbtests/repltests.cpp @@ -143,7 +143,7 @@ namespace ReplTests { id.init(); b.appendOID( "_id", &id ); b.appendElements( fromjson( json ) ); - return b.doneAndDecouple(); + return b.obj(); } private: static DBDirectClient client_; diff --git a/shell/MongoJS.cpp b/shell/MongoJS.cpp index f6f95b78425..8184e80db63 100644 --- a/shell/MongoJS.cpp +++ b/shell/MongoJS.cpp @@ -257,7 +257,7 @@ BSONObj v8ToMongo( v8::Handle<v8::Object> o ){ v8ToMongoElement( b , name , sname , value ); } - return b.doneAndDecouple(); + return b.obj(); } #define GETNS char ns[args[0]->ToString()->Utf8Length()]; args[0]->ToString()->WriteUtf8( ns ); diff --git a/tools/export.cpp b/tools/export.cpp index fd7525d3232..e4828bda5e3 100644 --- a/tools/export.cpp +++ b/tools/export.cpp @@ -63,7 +63,7 @@ public: b.append( f.c_str() , 1 ); } - realFieldsToReturn = b.doneAndDecouple(); + realFieldsToReturn = b.obj(); fieldsToReturn = &realFieldsToReturn; } diff --git a/tools/files.cpp b/tools/files.cpp index 79fe43a28b1..53531d92c91 100644 --- a/tools/files.cpp +++ b/tools/files.cpp @@ -72,7 +72,7 @@ public: BSONObjBuilder b; if ( filename.size() ) b.appendRegex( "filename" , ( (string)"^" + filename ).c_str() ); - display( &g , b.doneAndDecouple() ); + display( &g , b.obj() ); return 0; } @@ -84,7 +84,7 @@ public: if ( cmd == "search" ){ BSONObjBuilder b; b.appendRegex( "filename" , filename.c_str() ); - display( &g , b.doneAndDecouple() ); + display( &g , b.obj() ); return 0; } |