diff options
author | Eric Milkie <milkie@10gen.com> | 2012-04-02 14:55:19 -0400 |
---|---|---|
committer | Eric Milkie <milkie@10gen.com> | 2012-04-02 14:59:48 -0400 |
commit | 45f30389a9128fe2216371cabbe8426b634d68e9 (patch) | |
tree | a3f0fc2b758e58c0ec61a27110f1e7b26f034f76 /src/mongo | |
parent | 8b1c9bd361bd002980266c5269e5eab4ba62a7f5 (diff) | |
download | mongo-45f30389a9128fe2216371cabbe8426b634d68e9.tar.gz |
SERVER-5348 make dbclient.h the main C++ driver include file
This change fixes some #defines of common C functions so that their
definitions do not leak into consumer code.
I also had to change Labeler SIZE because it conflicts with Windows
SIZE.
pch.h is on its way out, but for now it's hanging around.
Diffstat (limited to 'src/mongo')
115 files changed, 234 insertions, 181 deletions
diff --git a/src/mongo/bson/bsonmisc.h b/src/mongo/bson/bsonmisc.h index 29a32d53bde..5f6b725251c 100644 --- a/src/mongo/bson/bsonmisc.h +++ b/src/mongo/bson/bsonmisc.h @@ -127,7 +127,7 @@ namespace mongo { extern Labeler::Label LTE; extern Labeler::Label NE; extern Labeler::Label NIN; - extern Labeler::Label SIZE; + extern Labeler::Label BSIZE; // $or helper: OR(BSON("x" << GT << 7), BSON("y" << LT << 6)); diff --git a/src/mongo/client/clientAndShell.cpp b/src/mongo/client/clientAndShell.cpp index 02a603c4e82..f98031fa89f 100644 --- a/src/mongo/client/clientAndShell.cpp +++ b/src/mongo/client/clientAndShell.cpp @@ -16,7 +16,6 @@ */ #include "pch.h" -#include "../client/dbclient.h" #include "../db/cmdline.h" #include "../db/client_common.h" #include "../s/shard.h" diff --git a/src/mongo/client/connpool.cpp b/src/mongo/client/connpool.cpp index 41ff1c0aa2d..120329e5488 100644 --- a/src/mongo/client/connpool.cpp +++ b/src/mongo/client/connpool.cpp @@ -20,7 +20,6 @@ #include "pch.h" #include "connpool.h" -//#include "../db/commands.h" #include "syncclusterconnection.h" #include "../s/shard.h" diff --git a/src/mongo/client/connpool.h b/src/mongo/client/connpool.h index 2c7618bc630..142fc95f75c 100644 --- a/src/mongo/client/connpool.h +++ b/src/mongo/client/connpool.h @@ -18,10 +18,9 @@ #pragma once #include <stack> -#include "dbclient.h" -#include "redef_macros.h" -#include "../util/background.h" +#include "mongo/util/background.h" +#include "mongo/client/dbclientinterface.h" namespace mongo { @@ -287,5 +286,3 @@ namespace mongo { }; } // namespace mongo - -#include "undef_macros.h" diff --git a/src/mongo/client/dbclient.cpp b/src/mongo/client/dbclient.cpp index b9534a85bb2..27eaf5efadd 100644 --- a/src/mongo/client/dbclient.cpp +++ b/src/mongo/client/dbclient.cpp @@ -17,8 +17,6 @@ #include "pch.h" -#include "mongo/client/dbclient.h" - #include "mongo/bson/util/builder.h" #include "mongo/client/constants.h" #include "mongo/client/dbclient_rs.h" diff --git a/src/mongo/client/dbclient.h b/src/mongo/client/dbclient.h index 698f091874b..d9558a1ac91 100644 --- a/src/mongo/client/dbclient.h +++ b/src/mongo/client/dbclient.h @@ -21,10 +21,20 @@ #pragma once +#ifdef MONGO_EXPOSE_MACROS +#error dbclient.h is for C++ driver consumer use only +#endif + #include "mongo/client/redef_macros.h" +#include "pch.h" + +#include "mongo/client/connpool.h" #include "mongo/client/dbclient_rs.h" #include "mongo/client/dbclientcursor.h" #include "mongo/client/dbclientinterface.h" +#include "mongo/client/gridfs.h" +#include "mongo/client/model.h" +#include "mongo/client/syncclusterconnection.h" #include "mongo/client/undef_macros.h" diff --git a/src/mongo/client/dbclient_rs.cpp b/src/mongo/client/dbclient_rs.cpp index 439f0ff8bec..d4dfee2506d 100644 --- a/src/mongo/client/dbclient_rs.cpp +++ b/src/mongo/client/dbclient_rs.cpp @@ -23,7 +23,6 @@ #include "mongo/bson/util/builder.h" #include "mongo/client/connpool.h" -#include "mongo/client/dbclient.h" #include "mongo/client/dbclientcursor.h" #include "mongo/db/dbmessage.h" #include "mongo/db/jsobj.h" diff --git a/src/mongo/client/dbclientcursor.cpp b/src/mongo/client/dbclientcursor.cpp index ab80830adf3..50bad05302e 100644 --- a/src/mongo/client/dbclientcursor.cpp +++ b/src/mongo/client/dbclientcursor.cpp @@ -20,7 +20,6 @@ #include "mongo/client/dbclientcursor.h" #include "mongo/client/connpool.h" -#include "mongo/client/dbclient.h" #include "mongo/db/cmdline.h" #include "mongo/db/dbmessage.h" #include "mongo/s/shard.h" diff --git a/src/mongo/client/dbclientcursor.h b/src/mongo/client/dbclientcursor.h index 321559b6d98..63fe07c980b 100644 --- a/src/mongo/client/dbclientcursor.h +++ b/src/mongo/client/dbclientcursor.h @@ -24,7 +24,6 @@ #include "mongo/client/dbclientinterface.h" #include "mongo/db/jsobj.h" #include "mongo/db/json.h" -#include "mongo/util/assert_util.h" #include "mongo/util/net/message.h" namespace mongo { @@ -250,4 +249,3 @@ namespace mongo { } // namespace mongo -#include "undef_macros.h" diff --git a/src/mongo/client/dbclientinterface.h b/src/mongo/client/dbclientinterface.h index 6f05424b348..3227c8cbabe 100644 --- a/src/mongo/client/dbclientinterface.h +++ b/src/mongo/client/dbclientinterface.h @@ -1054,3 +1054,5 @@ namespace mongo { } } // namespace mongo + +#include "mongo/client/dbclientcursor.h" diff --git a/src/mongo/client/distlock.cpp b/src/mongo/client/distlock.cpp index 389c6ac93bf..726c613b1a0 100644 --- a/src/mongo/client/distlock.cpp +++ b/src/mongo/client/distlock.cpp @@ -19,7 +19,6 @@ #include "mongo/client/distlock.h" -#include "mongo/client/dbclient.h" #include "mongo/client/dbclientcursor.h" diff --git a/src/mongo/client/distlock.h b/src/mongo/client/distlock.h index f8b55cc66f8..953aefeeaa6 100644 --- a/src/mongo/client/distlock.h +++ b/src/mongo/client/distlock.h @@ -18,9 +18,7 @@ #pragma once #include "../pch.h" -#include "dbclient.h" #include "connpool.h" -#include "redef_macros.h" #include "syncclusterconnection.h" #define LOCK_TIMEOUT (15 * 60 * 1000) diff --git a/src/mongo/client/distlock_test.cpp b/src/mongo/client/distlock_test.cpp index 9f78bbbb2c3..e3cfe4472c1 100644 --- a/src/mongo/client/distlock_test.cpp +++ b/src/mongo/client/distlock_test.cpp @@ -1,4 +1,4 @@ -// distlock_test.h +// distlock_test.cpp /* Copyright 2009 10gen Inc. * @@ -16,8 +16,7 @@ */ #include <iostream> -#include "../pch.h" -#include "dbclient.h" +#include "pch.h" #include "distlock.h" #include "../db/commands.h" #include "../util/bson_util.h" diff --git a/src/mongo/client/examples/mongoperf.cpp b/src/mongo/client/examples/mongoperf.cpp index 95d8dfa1428..96d6878a9b3 100644 --- a/src/mongo/client/examples/mongoperf.cpp +++ b/src/mongo/client/examples/mongoperf.cpp @@ -10,17 +10,22 @@ // so we define the following macro #define MONGO_EXPOSE_MACROS 1 +#include "pch.h" + #include <iostream> -#include "../dbclient.h" // the mongo c++ driver -#include "../../util/mmap.h" -#include <assert.h> -#include "../../util/logfile.h" -#include "../../util/timer.h" -#include "../../util/time_support.h" -#include "../../bson/util/atomic_int.h" #include <boost/filesystem/operations.hpp> +#include "mongo/bson/util/atomic_int.h" +#include "mongo/db/jsobj.h" +#include "mongo/db/json.h" +#include "mongo/util/logfile.h" +#include "mongo/util/mmap.h" +#include "mongo/util/mongoutils/str.h" +#include "mongo/util/time_support.h" +#include "mongo/util/timer.h" + + using namespace std; using namespace mongo; using namespace bson; @@ -228,7 +233,7 @@ cout << } string s = input; - str::stripTrailing(s, " \n\r\0x1a"); + mongoutils::str::stripTrailing(s, " \n\r\0x1a"); try { options = fromjson(s); } diff --git a/src/mongo/client/examples/rs.cpp b/src/mongo/client/examples/rs.cpp index 3307d87b56b..bb1ded70a24 100644 --- a/src/mongo/client/examples/rs.cpp +++ b/src/mongo/client/examples/rs.cpp @@ -19,10 +19,11 @@ * example of using replica sets from c++ */ -#include "client/dbclient.h" #include <iostream> #include <vector> +#include "mongo/client/dbclient.h" + using namespace mongo; using namespace std; diff --git a/src/mongo/client/gridfs.h b/src/mongo/client/gridfs.h index 5a19aa142ca..49a76a5e55f 100644 --- a/src/mongo/client/gridfs.h +++ b/src/mongo/client/gridfs.h @@ -17,8 +17,9 @@ #pragma once -#include "dbclient.h" -#include "redef_macros.h" +#include "mongo/bson/bsonelement.h" +#include "mongo/bson/bsonobj.h" +#include "mongo/client/dbclientinterface.h" namespace mongo { @@ -201,5 +202,3 @@ namespace mongo { friend class GridFS; }; } - -#include "undef_macros.h" diff --git a/src/mongo/client/model.h b/src/mongo/client/model.h index 7dd31434f49..249a78c3640 100644 --- a/src/mongo/client/model.h +++ b/src/mongo/client/model.h @@ -17,8 +17,8 @@ #pragma once -#include "dbclient.h" -#include "redef_macros.h" +#include "mongo/bson/bsonelement.h" +#include "mongo/bson/bsonobj.h" namespace mongo { @@ -59,4 +59,3 @@ namespace mongo { } // namespace mongo -#include "undef_macros.h" diff --git a/src/mongo/client/parallel.cpp b/src/mongo/client/parallel.cpp index eab7d6c3be9..82a71d60e27 100644 --- a/src/mongo/client/parallel.cpp +++ b/src/mongo/client/parallel.cpp @@ -25,6 +25,7 @@ #include "../s/chunk.h" #include "../s/config.h" #include "../s/grid.h" +#include "mongo/client/dbclientcursor.h" namespace mongo { diff --git a/src/mongo/client/parallel.h b/src/mongo/client/parallel.h index c566d92c046..d424f6cda3e 100644 --- a/src/mongo/client/parallel.h +++ b/src/mongo/client/parallel.h @@ -21,12 +21,6 @@ #pragma once -#include "pch.h" - -#include "mongo/client/dbclient.h" - -#include "mongo/client/redef_macros.h" - #include "mongo/db/dbmessage.h" #include "mongo/db/matcher.h" #include "mongo/db/namespacestring.h" @@ -466,4 +460,3 @@ namespace mongo { } -#include "mongo/client/undef_macros.h" diff --git a/src/mongo/client/redef_macros.h b/src/mongo/client/redef_macros.h index 46c9ffb80b8..15e838cf6d5 100644 --- a/src/mongo/client/redef_macros.h +++ b/src/mongo/client/redef_macros.h @@ -1,4 +1,4 @@ -/** @file redef_macros.h macros the implementation uses. +/** @file redef_macros.h macros for mongo internals @see undef_macros.h undefines these after use to minimize name pollution. */ @@ -20,42 +20,58 @@ // If you define a new global un-prefixed macro, please add it here and in undef_macros -// #pragma once // this file is intended to be processed multiple times - -#if defined(MONGO_MACROS_CLEANED) +#define MONGO_MACROS_PUSHED 1 // util/allocator.h #pragma push_macro("malloc") #define malloc MONGO_malloc +#pragma push_macro("realloc") #define realloc MONGO_realloc // util/assert_util.h +#pragma push_macro("verify") #define verify MONGO_verify +#pragma push_macro("dassert") #define dassert MONGO_dassert +#pragma push_macro("wassert") #define wassert MONGO_wassert +#pragma push_macro("massert") #define massert MONGO_massert +#pragma push_macro("uassert") #define uassert MONGO_uassert +#pragma push_macro("DESTRUCTOR_GUARD") #define DESTRUCTOR_GUARD MONGO_DESTRUCTOR_GUARD // util/goodies.h +#pragma push_macro("PRINT") #define PRINT MONGO_PRINT +#pragma push_macro("PRINTFL") #define PRINTFL MONGO_PRINTFL +#pragma push_macro("asctime") #define asctime MONGO_asctime +#pragma push_macro("gmtime") #define gmtime MONGO_gmtime +#pragma push_macro("localtime") #define localtime MONGO_localtime +#pragma push_macro("ctime") #define ctime MONGO_ctime // util/debug_util.h +#pragma push_macro("DEV") #define DEV MONGO_DEV +#pragma push_macro("DEBUGGING") #define DEBUGGING MONGO_DEBUGGING +#pragma push_macro("SOMETIMES") #define SOMETIMES MONGO_SOMETIMES +#pragma push_macro("OCCASIONALLY") #define OCCASIONALLY MONGO_OCCASIONALLY +#pragma push_macro("RARELY") #define RARELY MONGO_RARELY +#pragma push_macro("ONCE") #define ONCE MONGO_ONCE // util/log.h +#pragma push_macro("LOG") #define LOG MONGO_LOG -#undef MONGO_MACROS_CLEANED -#endif diff --git a/src/mongo/client/syncclusterconnection.h b/src/mongo/client/syncclusterconnection.h index b3ed36fe83b..b3fac66e5f8 100644 --- a/src/mongo/client/syncclusterconnection.h +++ b/src/mongo/client/syncclusterconnection.h @@ -18,9 +18,10 @@ #pragma once -#include "../pch.h" -#include "dbclient.h" -#include "redef_macros.h" + +#include "mongo/bson/bsonelement.h" +#include "mongo/bson/bsonobj.h" +#include "mongo/client/dbclientinterface.h" namespace mongo { @@ -146,5 +147,3 @@ namespace mongo { }; }; - -#include "undef_macros.h" diff --git a/src/mongo/client/undef_macros.h b/src/mongo/client/undef_macros.h index 60d4f1f58a6..65345d6d486 100644 --- a/src/mongo/client/undef_macros.h +++ b/src/mongo/client/undef_macros.h @@ -19,43 +19,59 @@ // #pragma once // this file is intended to be processed multiple times - -/** MONGO_EXPOSE_MACROS - when defined, indicates that you are compiling a mongo program rather - than just using the C++ driver. -*/ -#if !defined(MONGO_EXPOSE_MACROS) && !defined(MONGO_MACROS_CLEANED) +#ifdef MONGO_MACROS_PUSHED // util/allocator.h +#undef malloc #pragma pop_macro("malloc") -//#undef malloc #undef realloc +#pragma pop_macro("realloc") // util/assert_util.h #undef dassert +#pragma pop_macro("dassert") #undef wassert +#pragma pop_macro("wassert") #undef massert +#pragma pop_macro("massert") #undef uassert +#pragma pop_macro("uassert") #undef verify +#pragma pop_macro("verify") #undef DESTRUCTOR_GUARD +#pragma pop_macro("DESTRUCTOR_GUARD") // util/goodies.h #undef PRINT +#pragma pop_macro("PRINT") #undef PRINTFL +#pragma pop_macro("PRINTFL") #undef asctime +#pragma pop_macro("asctime") #undef gmtime +#pragma pop_macro("gmtime") #undef localtime +#pragma pop_macro("localtime") #undef ctime +#pragma pop_macro("ctime") // util/debug_util.h #undef DEV +#pragma pop_macro("DEV") #undef DEBUGGING +#pragma pop_macro("DEBUGGING") #undef SOMETIMES +#pragma pop_macro("SOMETIMES") #undef OCCASIONALLY +#pragma pop_macro("OCCASIONALLY") #undef RARELY +#pragma pop_macro("RARELY") #undef ONCE +#pragma pop_macro("ONCE") // util/log.h #undef LOG +#pragma pop_macro("LOG") -#define MONGO_MACROS_CLEANED +#undef MONGO_MACROS_PUSHED #endif diff --git a/src/mongo/db/clientcursor.cpp b/src/mongo/db/clientcursor.cpp index e2b41883db7..24b4ee5944b 100644 --- a/src/mongo/db/clientcursor.cpp +++ b/src/mongo/db/clientcursor.cpp @@ -31,6 +31,7 @@ #include "repl_block.h" #include "../util/processinfo.h" #include "../util/timer.h" +#include "mongo/client/dbclientinterface.h" namespace mongo { diff --git a/src/mongo/db/clientcursor.h b/src/mongo/db/clientcursor.h index 9865879e6f3..e413bb1862e 100644 --- a/src/mongo/db/clientcursor.h +++ b/src/mongo/db/clientcursor.h @@ -33,7 +33,6 @@ #include "diskloc.h" #include "dbhelpers.h" #include "matcher.h" -#include "../client/dbclient.h" #include "projection.h" #include "s/d_chunk_manager.h" diff --git a/src/mongo/db/cloner.cpp b/src/mongo/db/cloner.cpp index 82ff9c7429f..dd46837c430 100644 --- a/src/mongo/db/cloner.cpp +++ b/src/mongo/db/cloner.cpp @@ -19,7 +19,6 @@ #include "pch.h" #include "cloner.h" #include "pdfile.h" -#include "../client/dbclient.h" #include "../bson/util/builder.h" #include "jsobj.h" #include "ops/query.h" diff --git a/src/mongo/db/commands/isself.cpp b/src/mongo/db/commands/isself.cpp index ebf6d5bceec..97f9b5def69 100644 --- a/src/mongo/db/commands/isself.cpp +++ b/src/mongo/db/commands/isself.cpp @@ -3,8 +3,9 @@ #include "pch.h" #include "../../util/net/listen.h" #include "../commands.h" -#include "../../client/dbclient.h" #include "../security.h" +#include "mongo/util/net/hostandport.h" +#include "mongo/client/dbclientinterface.h" #include <boost/algorithm/string.hpp> diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp index 420249a007c..42210090a3c 100644 --- a/src/mongo/db/commands/mr.cpp +++ b/src/mongo/db/commands/mr.cpp @@ -20,7 +20,6 @@ #include "../instance.h" #include "../commands.h" #include "../../scripting/engine.h" -#include "../../client/dbclient.h" #include "../../client/connpool.h" #include "../../client/parallel.h" #include "../matcher.h" diff --git a/src/mongo/db/dbhelpers.cpp b/src/mongo/db/dbhelpers.cpp index e34027d01e2..b2b1a5213d1 100644 --- a/src/mongo/db/dbhelpers.cpp +++ b/src/mongo/db/dbhelpers.cpp @@ -26,6 +26,7 @@ #include "ops/update.h" #include "ops/delete.h" #include "queryoptimizercursor.h" +#include "mongo/client/dbclientinterface.h" #include <fstream> diff --git a/src/mongo/db/dbmessage.cpp b/src/mongo/db/dbmessage.cpp index c86b5a05240..00743d4910f 100644 --- a/src/mongo/db/dbmessage.cpp +++ b/src/mongo/db/dbmessage.cpp @@ -18,7 +18,6 @@ #include "pch.h" #include "dbmessage.h" -#include "../client/dbclient.h" namespace mongo { diff --git a/src/mongo/db/instance.h b/src/mongo/db/instance.h index 090250ace0a..38d4e8e697c 100644 --- a/src/mongo/db/instance.h +++ b/src/mongo/db/instance.h @@ -20,11 +20,11 @@ #pragma once -#include "mongo/client/dbclient.h" #include "curop-inl.h" #include "security.h" #include "cmdline.h" #include "client.h" +#include "mongo/client/dbclientinterface.h" namespace mongo { diff --git a/src/mongo/db/jsobj.cpp b/src/mongo/db/jsobj.cpp index 9fbc613b8ab..d5ae90a8c02 100644 --- a/src/mongo/db/jsobj.cpp +++ b/src/mongo/db/jsobj.cpp @@ -1072,7 +1072,7 @@ namespace mongo { Labeler::Label LTE( "$lte" ); Labeler::Label NE( "$ne" ); Labeler::Label NIN( "$nin" ); - Labeler::Label SIZE( "$size" ); + Labeler::Label BSIZE( "$size" ); void BSONObjBuilder::appendMinForType( const StringData& fieldName , int t ) { switch ( t ) { diff --git a/src/mongo/db/jsobj.h b/src/mongo/db/jsobj.h index ae039529fbf..1d531657a46 100644 --- a/src/mongo/db/jsobj.h +++ b/src/mongo/db/jsobj.h @@ -31,8 +31,6 @@ #include "../pch.h" #include "../bson/util/builder.h" #include "../util/optime.h" -//#include "boost/utility.hpp" -//#include <set> #include "../bson/bsontypes.h" #include "../bson/oid.h" #include "../bson/bsonelement.h" diff --git a/src/mongo/db/oplog.h b/src/mongo/db/oplog.h index 6a7a64d530b..1cc693f8551 100644 --- a/src/mongo/db/oplog.h +++ b/src/mongo/db/oplog.h @@ -27,7 +27,6 @@ #include "db.h" #include "dbhelpers.h" #include "clientcursor.h" -#include "../client/dbclient.h" #include "../util/optime.h" #include "../util/timer.h" diff --git a/src/mongo/db/oplogreader.h b/src/mongo/db/oplogreader.h index fb8d607b01c..93c4bcdc156 100644 --- a/src/mongo/db/oplogreader.h +++ b/src/mongo/db/oplogreader.h @@ -2,15 +2,16 @@ #pragma once -#include "../client/dbclient.h" #include "../client/constants.h" #include "dbhelpers.h" +#include "mongo/client/dbclientcursor.h" namespace mongo { /* started abstracting out the querying of the primary/master's oplog still fairly awkward but a start. */ + class OplogReader { shared_ptr<DBClientConnection> _conn; shared_ptr<DBClientCursor> cursor; diff --git a/src/mongo/db/ops/count.cpp b/src/mongo/db/ops/count.cpp index 2ac5452688c..44bfbac984c 100644 --- a/src/mongo/db/ops/count.cpp +++ b/src/mongo/db/ops/count.cpp @@ -22,6 +22,7 @@ #include "../clientcursor.h" #include "../namespace.h" #include "../queryutil.h" +#include "mongo/client/dbclientinterface.h" namespace mongo { diff --git a/src/mongo/db/ops/delete.cpp b/src/mongo/db/ops/delete.cpp index 02ce88f010e..641ccf5b73a 100644 --- a/src/mongo/db/ops/delete.cpp +++ b/src/mongo/db/ops/delete.cpp @@ -20,6 +20,7 @@ #include "delete.h" #include "../queryutil.h" #include "../oplog.h" +#include "mongo/client/dbclientinterface.h" namespace mongo { diff --git a/src/mongo/db/ops/query.h b/src/mongo/db/ops/query.h index f1e4871452c..d9f75df15f1 100644 --- a/src/mongo/db/ops/query.h +++ b/src/mongo/db/ops/query.h @@ -29,7 +29,6 @@ #include "../../s/d_chunk_manager.h" // struct QueryOptions, QueryResult, QueryResultFlags in: -#include "../../client/dbclient.h" namespace mongo { diff --git a/src/mongo/db/queryoptimizercursorimpl.cpp b/src/mongo/db/queryoptimizercursorimpl.cpp index 87746bf302c..a0a3c8ce86d 100644 --- a/src/mongo/db/queryoptimizercursorimpl.cpp +++ b/src/mongo/db/queryoptimizercursorimpl.cpp @@ -23,6 +23,7 @@ #include "clientcursor.h" #include "btree.h" #include "explain.h" +#include "mongo/client/dbclientinterface.h" namespace mongo { diff --git a/src/mongo/db/repl.cpp b/src/mongo/db/repl.cpp index c805ef8bff2..ba8a22247a8 100644 --- a/src/mongo/db/repl.cpp +++ b/src/mongo/db/repl.cpp @@ -32,7 +32,6 @@ #include "repl.h" #include "../util/net/message.h" #include "../util/background.h" -#include "../client/dbclient.h" #include "../client/connpool.h" #include "pdfile.h" #include "ops/query.h" diff --git a/src/mongo/db/repl.h b/src/mongo/db/repl.h index 83242d0a4ce..f621262989c 100644 --- a/src/mongo/db/repl.h +++ b/src/mongo/db/repl.h @@ -30,7 +30,6 @@ #include "pdfile.h" #include "db.h" #include "dbhelpers.h" -#include "../client/dbclient.h" #include "../util/optime.h" #include "oplog.h" #include "../util/concurrency/thread_pool.h" diff --git a/src/mongo/db/repl/connections.h b/src/mongo/db/repl/connections.h index 2e807446dab..4c2daf2c5d3 100644 --- a/src/mongo/db/repl/connections.h +++ b/src/mongo/db/repl/connections.h @@ -19,7 +19,6 @@ #pragma once #include <map> -#include "../../client/dbclient.h" #include "../security_common.h" namespace mongo { diff --git a/src/mongo/db/repl/health.cpp b/src/mongo/db/repl/health.cpp index 49332005881..a0260c85f48 100644 --- a/src/mongo/db/repl/health.cpp +++ b/src/mongo/db/repl/health.cpp @@ -18,7 +18,6 @@ #include "rs.h" #include "health.h" #include "../../util/background.h" -#include "../../client/dbclient.h" #include "../../client/connpool.h" #include "../commands.h" #include "../../util/concurrency/value.h" diff --git a/src/mongo/db/repl/heartbeat.cpp b/src/mongo/db/repl/heartbeat.cpp index 9713ab8a438..d341c031f76 100644 --- a/src/mongo/db/repl/heartbeat.cpp +++ b/src/mongo/db/repl/heartbeat.cpp @@ -18,7 +18,7 @@ #include "rs.h" #include "health.h" #include "../../util/background.h" -#include "../../client/dbclient.h" + #include "../commands.h" #include "../../util/concurrency/value.h" #include "../../util/concurrency/task.h" diff --git a/src/mongo/db/repl/replset_commands.cpp b/src/mongo/db/repl/replset_commands.cpp index 62c21f92612..a9c57375ad2 100644 --- a/src/mongo/db/repl/replset_commands.cpp +++ b/src/mongo/db/repl/replset_commands.cpp @@ -23,7 +23,6 @@ #include "rs_config.h" #include "../dbwebserver.h" #include "../../util/mongoutils/html.h" -#include "../../client/dbclient.h" #include "../repl_block.h" using namespace bson; diff --git a/src/mongo/db/repl/rs.cpp b/src/mongo/db/repl/rs.cpp index 6fed4c7ce31..b5af09c70f1 100644 --- a/src/mongo/db/repl/rs.cpp +++ b/src/mongo/db/repl/rs.cpp @@ -18,7 +18,6 @@ #include "../cmdline.h" #include "../../util/net/sock.h" #include "../client.h" -#include "../../client/dbclient.h" #include "../dbhelpers.h" #include "../../s/d_logic.h" #include "rs.h" diff --git a/src/mongo/db/repl/rs_config.cpp b/src/mongo/db/repl/rs_config.cpp index a7e483cec2c..01fed3357e8 100644 --- a/src/mongo/db/repl/rs_config.cpp +++ b/src/mongo/db/repl/rs_config.cpp @@ -18,7 +18,6 @@ #include "pch.h" #include "rs.h" -#include "../../client/dbclient.h" #include "../../client/syncclusterconnection.h" #include "../../util/net/hostandport.h" #include "../dbhelpers.h" diff --git a/src/mongo/db/repl/rs_initialsync.cpp b/src/mongo/db/repl/rs_initialsync.cpp index 2a751b8f3cc..11defecdcdb 100644 --- a/src/mongo/db/repl/rs_initialsync.cpp +++ b/src/mongo/db/repl/rs_initialsync.cpp @@ -17,7 +17,6 @@ #include "pch.h" #include "mongo/db/repl.h" #include "mongo/db/client.h" -#include "mongo/client/dbclient.h" #include "rs.h" #include "mongo/db/oplogreader.h" #include "mongo/util/mongoutils/str.h" diff --git a/src/mongo/db/repl/rs_rollback.cpp b/src/mongo/db/repl/rs_rollback.cpp index 1e640e4cc2a..f762bf2a252 100644 --- a/src/mongo/db/repl/rs_rollback.cpp +++ b/src/mongo/db/repl/rs_rollback.cpp @@ -17,7 +17,6 @@ #include "pch.h" #include "../client.h" -#include "../../client/dbclient.h" #include "rs.h" #include "../repl.h" #include "../ops/query.h" diff --git a/src/mongo/db/repl/rs_sync.cpp b/src/mongo/db/repl/rs_sync.cpp index 40818feef6a..80e62ccdc67 100644 --- a/src/mongo/db/repl/rs_sync.cpp +++ b/src/mongo/db/repl/rs_sync.cpp @@ -16,7 +16,6 @@ #include "pch.h" #include "mongo/db/client.h" -#include "mongo/client/dbclient.h" #include "rs.h" #include "mongo/db/repl.h" #include "connections.h" diff --git a/src/mongo/db/repl_block.cpp b/src/mongo/db/repl_block.cpp index c34eb1b6470..27aff0dd672 100644 --- a/src/mongo/db/repl_block.cpp +++ b/src/mongo/db/repl_block.cpp @@ -23,7 +23,6 @@ #include "dbhelpers.h" #include "../util/background.h" #include "../util/mongoutils/str.h" -#include "../client/dbclient.h" #include "replutil.h" //#define REPLDEBUG(x) log() << "replBlock: " << x << endl; diff --git a/src/mongo/db/replutil.h b/src/mongo/db/replutil.h index aa8c25ad5f5..896af6a8e9a 100644 --- a/src/mongo/db/replutil.h +++ b/src/mongo/db/replutil.h @@ -19,7 +19,6 @@ #include "db.h" #include "dbhelpers.h" #include "json.h" -#include "../client/dbclient.h" #include "repl.h" #include "cmdline.h" #include "repl/rs.h" diff --git a/src/mongo/db/security_common.cpp b/src/mongo/db/security_common.cpp index da7078b6ebe..55eba491161 100644 --- a/src/mongo/db/security_common.cpp +++ b/src/mongo/db/security_common.cpp @@ -22,14 +22,17 @@ */ #include "pch.h" + +#include <sys/stat.h> + #include "security.h" #include "security_common.h" -#include "../client/dbclient.h" #include "commands.h" #include "nonce.h" #include "../util/md5.hpp" #include "client_common.h" -#include <sys/stat.h> +#include "mongo/client/dbclientinterface.h" + namespace mongo { diff --git a/src/mongo/dbtests/btreetests.cpp b/src/mongo/dbtests/btreetests.cpp index efa42b1d5c1..aff1e80ee5b 100644 --- a/src/mongo/dbtests/btreetests.cpp +++ b/src/mongo/dbtests/btreetests.cpp @@ -21,6 +21,7 @@ #include "../db/db.h" #include "../db/btree.h" +#include "mongo/db/json.h" #include "dbtests.h" diff --git a/src/mongo/dbtests/chunktests.cpp b/src/mongo/dbtests/chunktests.cpp index 822046a6a15..080a80fe237 100644 --- a/src/mongo/dbtests/chunktests.cpp +++ b/src/mongo/dbtests/chunktests.cpp @@ -19,6 +19,7 @@ #include "pch.h" #include "../s/chunk.h" +#include "mongo/db/json.h" #include "dbtests.h" diff --git a/src/mongo/dbtests/clienttests.cpp b/src/mongo/dbtests/clienttests.cpp index a64894b43c1..1b60ef7d429 100644 --- a/src/mongo/dbtests/clienttests.cpp +++ b/src/mongo/dbtests/clienttests.cpp @@ -17,9 +17,9 @@ // client.cpp #include "pch.h" -#include "../client/dbclient.h" #include "dbtests.h" #include "../db/concurrency.h" +#include "mongo/client/dbclientcursor.h" namespace ClientTests { diff --git a/src/mongo/dbtests/commandtests.cpp b/src/mongo/dbtests/commandtests.cpp index fa6204d25fd..31f39f8b45f 100644 --- a/src/mongo/dbtests/commandtests.cpp +++ b/src/mongo/dbtests/commandtests.cpp @@ -15,7 +15,6 @@ */ #include "pch.h" -#include "../client/dbclient.h" #include "dbtests.h" #include "../db/concurrency.h" diff --git a/src/mongo/dbtests/counttests.cpp b/src/mongo/dbtests/counttests.cpp index 92c886868c9..dcd2b808178 100644 --- a/src/mongo/dbtests/counttests.cpp +++ b/src/mongo/dbtests/counttests.cpp @@ -20,6 +20,7 @@ #include "../db/cursor.h" #include "../db/pdfile.h" +#include "mongo/db/json.h" #include "dbtests.h" diff --git a/src/mongo/dbtests/jsobjtests.cpp b/src/mongo/dbtests/jsobjtests.cpp index a39c749fd53..e295a2e54d0 100644 --- a/src/mongo/dbtests/jsobjtests.cpp +++ b/src/mongo/dbtests/jsobjtests.cpp @@ -1251,7 +1251,7 @@ namespace JsobjTests { return BSON( "a" << BSON( "$size" << 4 ) ); } BSONObj actual() { - return BSON( "a" << mongo::SIZE << 4 ); + return BSON( "a" << mongo::BSIZE << 4 ); } }; diff --git a/src/mongo/dbtests/jstests.cpp b/src/mongo/dbtests/jstests.cpp index dd728132216..b1f974d9feb 100644 --- a/src/mongo/dbtests/jstests.cpp +++ b/src/mongo/dbtests/jstests.cpp @@ -19,6 +19,7 @@ #include "pch.h" #include "../db/instance.h" +#include "mongo/db/json.h" #include "../pch.h" #include "../scripting/engine.h" diff --git a/src/mongo/dbtests/macrotests.cpp b/src/mongo/dbtests/macrotests.cpp index 27515296830..901de923300 100644 --- a/src/mongo/dbtests/macrotests.cpp +++ b/src/mongo/dbtests/macrotests.cpp @@ -16,7 +16,7 @@ #undef MONGO_EXPOSE_MACROS -#include "../client/dbclient.h" +#include "mongo/client/dbclient.h" #ifdef malloc # error malloc defined 0 @@ -26,19 +26,13 @@ # error verify defined 1 #endif -#include "../client/parallel.h" //uses verify - -#ifdef verify -# error verify defined 2 -#endif - -#include "../client/redef_macros.h" +#include "mongo/client/redef_macros.h" #ifndef verify # error verify not defined 3 #endif -#include "../client/undef_macros.h" +#include "mongo/client/undef_macros.h" #ifdef verify # error verify defined 3 diff --git a/src/mongo/dbtests/perf/perftest.cpp b/src/mongo/dbtests/perf/perftest.cpp index 10e6727f602..03e62bba084 100644 --- a/src/mongo/dbtests/perf/perftest.cpp +++ b/src/mongo/dbtests/perf/perftest.cpp @@ -19,11 +19,12 @@ #include "pch.h" -#include "../../client/dbclient.h" #include "../../db/instance.h" #include "../../db/ops/query.h" #include "../../db/queryoptimizer.h" #include "../../util/file_allocator.h" +#include "mongo/db/json.h" +#include "mongo/client/dbclientcursor.h" #include "../framework.h" #include <boost/date_time/posix_time/posix_time.hpp> diff --git a/src/mongo/dbtests/queryoptimizercursortests.cpp b/src/mongo/dbtests/queryoptimizercursortests.cpp index 55c539bb2ed..dcdc657b9c0 100644 --- a/src/mongo/dbtests/queryoptimizercursortests.cpp +++ b/src/mongo/dbtests/queryoptimizercursortests.cpp @@ -23,6 +23,8 @@ #include "../db/queryoptimizer.h" #include "../db/instance.h" #include "../db/ops/delete.h" +#include "mongo/db/json.h" +#include "mongo/client/dbclientcursor.h" #include "dbtests.h" namespace mongo { diff --git a/src/mongo/dbtests/queryoptimizertests.cpp b/src/mongo/dbtests/queryoptimizertests.cpp index 8e836bac79b..f6b065ec37a 100644 --- a/src/mongo/dbtests/queryoptimizertests.cpp +++ b/src/mongo/dbtests/queryoptimizertests.cpp @@ -23,6 +23,7 @@ #include "../db/ops/count.h" #include "../db/ops/query.h" #include "../db/ops/delete.h" +#include "mongo/db/json.h" #include "dbtests.h" diff --git a/src/mongo/dbtests/querytests.cpp b/src/mongo/dbtests/querytests.cpp index 533d960f9b4..5882511a25e 100644 --- a/src/mongo/dbtests/querytests.cpp +++ b/src/mongo/dbtests/querytests.cpp @@ -23,6 +23,7 @@ #include "../db/dbhelpers.h" #include "../db/clientcursor.h" +#include "mongo/client/dbclientcursor.h" #include "../db/instance.h" #include "../db/json.h" @@ -656,7 +657,7 @@ namespace QueryTests { const char *ns = "unittests.querytests.Size"; client().insert( ns, fromjson( "{a:[1,2,3]}" ) ); client().ensureIndex( ns, BSON( "a" << 1 ) ); - ASSERT( client().query( ns, QUERY( "a" << mongo::SIZE << 3 ).hint( BSON( "a" << 1 ) ) )->more() ); + ASSERT( client().query( ns, QUERY( "a" << mongo::BSIZE << 3 ).hint( BSON( "a" << 1 ) ) )->more() ); } }; diff --git a/src/mongo/dbtests/queryutiltests.cpp b/src/mongo/dbtests/queryutiltests.cpp index 60eb292630e..ea28f9d0ddc 100644 --- a/src/mongo/dbtests/queryutiltests.cpp +++ b/src/mongo/dbtests/queryutiltests.cpp @@ -22,6 +22,7 @@ #include "../db/querypattern.h" #include "../db/instance.h" #include "../db/pdfile.h" +#include "mongo/db/json.h" #include "dbtests.h" namespace QueryUtilTests { diff --git a/src/mongo/dbtests/removetests.cpp b/src/mongo/dbtests/removetests.cpp index b46681c1fb8..f86b21c8255 100644 --- a/src/mongo/dbtests/removetests.cpp +++ b/src/mongo/dbtests/removetests.cpp @@ -18,6 +18,7 @@ */ #include "../db/dbhelpers.h" +#include "mongo/client/dbclientcursor.h" #include "dbtests.h" diff --git a/src/mongo/dbtests/updatetests.cpp b/src/mongo/dbtests/updatetests.cpp index 64c1ae19f4b..47480f207d1 100644 --- a/src/mongo/dbtests/updatetests.cpp +++ b/src/mongo/dbtests/updatetests.cpp @@ -19,6 +19,7 @@ #include "pch.h" #include "../db/ops/query.h" +#include "mongo/client/dbclientcursor.h" #include "../db/db.h" #include "../db/instance.h" diff --git a/src/mongo/pch.h b/src/mongo/pch.h index 8a419c5e6fc..b1db1664979 100644 --- a/src/mongo/pch.h +++ b/src/mongo/pch.h @@ -21,6 +21,8 @@ #ifndef MONGO_PCH_H #define MONGO_PCH_H +// MONGO_EXPOSE_MACROS is defined for internal mongo programs. +// C++ driver consumers do not define this. #if defined(MONGO_EXPOSE_MACROS) # define JS_C_STRINGS_ARE_UTF8 @@ -30,22 +32,27 @@ # define SUPPORT_UTF8 # undef _CRT_SECURE_NO_WARNINGS # define _CRT_SECURE_NO_WARNINGS + #endif +// our #define macros must not be active when we include +// system headers and boost headers +#include "mongo/client/undef_macros.h" + #if defined(_WIN32) // for rand_s() usage: # define _CRT_RAND_S # ifndef NOMINMAX # define NOMINMAX # endif -#define WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN # include <winsock2.h> //this must be included before the first windows.h include # include <ws2tcpip.h> # include <wspiapi.h> # include <windows.h> #endif -#if defined(__linux__) && defined(MONGO_EXPOSE_MACROS) +#if defined(__linux__) // glibc's optimized versions are better than g++ builtins # define __builtin_strcmp strcmp # define __builtin_strlen strlen @@ -56,7 +63,6 @@ # define __builtin_memmove memmove #endif - #include <ctime> #include <cstring> #include <string> @@ -88,6 +94,8 @@ #include <boost/thread/recursive_mutex.hpp> #include <boost/thread/xtime.hpp> +#include "mongo/client/redef_macros.h" + namespace mongo { using namespace std; @@ -141,8 +149,8 @@ namespace mongo { #include "util/assert_util.h" #include "util/debug_util.h" #include "util/goodies.h" -#include "util/log.h" #include "util/allocator.h" +#include "util/log.h" namespace mongo { diff --git a/src/mongo/s/balance.cpp b/src/mongo/s/balance.cpp index a97636ae958..2814aad9c8e 100644 --- a/src/mongo/s/balance.cpp +++ b/src/mongo/s/balance.cpp @@ -22,6 +22,7 @@ #include "../db/cmdline.h" #include "../client/distlock.h" +#include "mongo/client/dbclientcursor.h" #include "balance.h" #include "server.h" diff --git a/src/mongo/s/balance.h b/src/mongo/s/balance.h index 562ba80970e..e2a723734dc 100644 --- a/src/mongo/s/balance.h +++ b/src/mongo/s/balance.h @@ -20,7 +20,6 @@ #include "../pch.h" #include "../util/background.h" -#include "../client/dbclient.h" #include "balancer_policy.h" namespace mongo { diff --git a/src/mongo/s/balancer_policy.cpp b/src/mongo/s/balancer_policy.cpp index 03defa5678a..bde49da8ecb 100644 --- a/src/mongo/s/balancer_policy.cpp +++ b/src/mongo/s/balancer_policy.cpp @@ -20,7 +20,6 @@ #include "config.h" -#include "../client/dbclient.h" #include "../util/stringutils.h" #include "../util/unittest.h" diff --git a/src/mongo/s/chunk.cpp b/src/mongo/s/chunk.cpp index c68630be64d..21ef0cc44b6 100644 --- a/src/mongo/s/chunk.cpp +++ b/src/mongo/s/chunk.cpp @@ -23,6 +23,7 @@ #include "../db/queryutil.h" #include "../util/unittest.h" #include "../util/timer.h" +#include "mongo/client/dbclientcursor.h" #include "chunk.h" #include "config.h" diff --git a/src/mongo/s/chunk.h b/src/mongo/s/chunk.h index 122c42f8825..0cfdb135f9e 100644 --- a/src/mongo/s/chunk.h +++ b/src/mongo/s/chunk.h @@ -21,7 +21,6 @@ #include "../pch.h" #include "../bson/util/atomic_int.h" -#include "../client/dbclient.h" #include "../client/distlock.h" #include "shardkey.h" diff --git a/src/mongo/s/commands_admin.cpp b/src/mongo/s/commands_admin.cpp index 5d191a98b45..72205648bdb 100644 --- a/src/mongo/s/commands_admin.cpp +++ b/src/mongo/s/commands_admin.cpp @@ -34,6 +34,7 @@ #include "../util/timer.h" #include "../client/connpool.h" +#include "mongo/client/dbclientcursor.h" #include "../db/dbmessage.h" #include "../db/commands.h" diff --git a/src/mongo/s/config.cpp b/src/mongo/s/config.cpp index f062a9d4f3d..71fdafa03b7 100644 --- a/src/mongo/s/config.cpp +++ b/src/mongo/s/config.cpp @@ -22,9 +22,11 @@ #include "../util/unittest.h" #include "../client/connpool.h" #include "../client/model.h" +#include "mongo/client/dbclientcursor.h" #include "../db/pdfile.h" #include "../db/cmdline.h" + #include "chunk.h" #include "config.h" #include "grid.h" diff --git a/src/mongo/s/config.h b/src/mongo/s/config.h index 39c99a756a5..5808b623df0 100644 --- a/src/mongo/s/config.h +++ b/src/mongo/s/config.h @@ -24,7 +24,6 @@ #pragma once #include "../db/namespace.h" -#include "../client/dbclient.h" #include "../client/model.h" #include "chunk.h" diff --git a/src/mongo/s/config_migrate.cpp b/src/mongo/s/config_migrate.cpp index b95d0ae4bda..45376a1bb69 100644 --- a/src/mongo/s/config_migrate.cpp +++ b/src/mongo/s/config_migrate.cpp @@ -21,6 +21,7 @@ #include "../util/unittest.h" #include "../client/connpool.h" #include "../client/model.h" +#include "mongo/client/dbclientcursor.h" #include "../db/pdfile.h" #include "../db/cmdline.h" diff --git a/src/mongo/s/cursors.h b/src/mongo/s/cursors.h index ee27421983d..ec2fd026136 100644 --- a/src/mongo/s/cursors.h +++ b/src/mongo/s/cursors.h @@ -22,7 +22,6 @@ #include "../db/jsobj.h" #include "../db/dbmessage.h" -#include "../client/dbclient.h" #include "../client/parallel.h" #include "request.h" diff --git a/src/mongo/s/d_chunk_manager.h b/src/mongo/s/d_chunk_manager.h index fd5974e4953..807537cc0a5 100644 --- a/src/mongo/s/d_chunk_manager.h +++ b/src/mongo/s/d_chunk_manager.h @@ -26,7 +26,7 @@ namespace mongo { class ClientCursor; - + class DBClientCursorInterface; /** * Controls the boundaries of all the chunks for a given collection that live in this shard. * diff --git a/src/mongo/s/d_migrate.cpp b/src/mongo/s/d_migrate.cpp index af7b4dd7272..a8ad29255e7 100644 --- a/src/mongo/s/d_migrate.cpp +++ b/src/mongo/s/d_migrate.cpp @@ -38,6 +38,7 @@ #include "../client/connpool.h" #include "../client/distlock.h" +#include "mongo/client/dbclientcursor.h" #include "../util/queue.h" #include "../util/unittest.h" diff --git a/src/mongo/s/d_split.cpp b/src/mongo/s/d_split.cpp index 11b7b42e8e9..b682f56f61a 100644 --- a/src/mongo/s/d_split.cpp +++ b/src/mongo/s/d_split.cpp @@ -26,6 +26,7 @@ #include "../db/instance.h" #include "../db/queryoptimizer.h" #include "../db/clientcursor.h" +#include "mongo/client/dbclientcursor.h" #include "../client/connpool.h" #include "../client/distlock.h" diff --git a/src/mongo/s/grid.cpp b/src/mongo/s/grid.cpp index 7731104e9f7..0a910ed8a47 100644 --- a/src/mongo/s/grid.cpp +++ b/src/mongo/s/grid.cpp @@ -23,6 +23,7 @@ #include "../util/stringutils.h" #include "../util/unittest.h" #include "../db/namespacestring.h" +#include "mongo/db/json.h" #include "grid.h" #include "shard.h" diff --git a/src/mongo/s/s_only.cpp b/src/mongo/s/s_only.cpp index 85fc9c18e8b..25cb102dfa6 100644 --- a/src/mongo/s/s_only.cpp +++ b/src/mongo/s/s_only.cpp @@ -18,7 +18,6 @@ #include "pch.h" #include "request.h" #include "client.h" -#include "../client/dbclient.h" #include "../db/dbhelpers.h" #include "../db/matcher.h" #include "../db/commands.h" diff --git a/src/mongo/s/shard.cpp b/src/mongo/s/shard.cpp index e40bb8de41b..c5203a7f1c6 100644 --- a/src/mongo/s/shard.cpp +++ b/src/mongo/s/shard.cpp @@ -22,6 +22,7 @@ #include "request.h" #include "client.h" #include "../db/commands.h" +#include "mongo/client/dbclientcursor.h" #include <set> namespace mongo { diff --git a/src/mongo/s/shardkey.cpp b/src/mongo/s/shardkey.cpp index f926bba314b..ff6bafa0cad 100644 --- a/src/mongo/s/shardkey.cpp +++ b/src/mongo/s/shardkey.cpp @@ -19,6 +19,7 @@ #include "pch.h" #include "chunk.h" #include "../db/jsobj.h" +#include "mongo/db/json.h" #include "../util/unittest.h" #include "../util/timer.h" diff --git a/src/mongo/s/shardkey.h b/src/mongo/s/shardkey.h index ed426e31f05..02f6b5b18d3 100644 --- a/src/mongo/s/shardkey.h +++ b/src/mongo/s/shardkey.h @@ -18,8 +18,6 @@ #pragma once -#include "../client/dbclient.h" - namespace mongo { class Chunk; diff --git a/src/mongo/s/strategy_shard.cpp b/src/mongo/s/strategy_shard.cpp index 10b99e339e9..38e1e0f37bd 100644 --- a/src/mongo/s/strategy_shard.cpp +++ b/src/mongo/s/strategy_shard.cpp @@ -20,6 +20,7 @@ #include "mongo/bson/util/builder.h" #include "mongo/client/connpool.h" +#include "mongo/client/dbclientcursor.h" #include "mongo/db/commands.h" #include "mongo/db/index.h" #include "mongo/s/client.h" diff --git a/src/mongo/s/util.h b/src/mongo/s/util.h index 2f0354a96da..c814daa0ce9 100644 --- a/src/mongo/s/util.h +++ b/src/mongo/s/util.h @@ -18,10 +18,9 @@ #pragma once -#include "../pch.h" -#include "../client/dbclient.h" -#include "../db/jsobj.h" - +#include "mongo/pch.h" +#include "mongo/db/jsobj.h" +#include "mongo/util/mongoutils/str.h" /** some generic sharding utils that can be used in mongod or mongos */ @@ -105,7 +104,7 @@ namespace mongo { _combined = 0; break; default: - massert( 13657 , str::stream() << "unknown type for ShardChunkVersion: " << elem , 0 ); + massert( 13657 , mongoutils::str::stream() << "unknown type for ShardChunkVersion: " << elem , 0 ); } return *this; } @@ -123,7 +122,7 @@ namespace mongo { public: StaleConfigException( const string& ns , const string& raw , int code, ShardChunkVersion received, ShardChunkVersion wanted, bool justConnection = false ) : AssertionException( - str::stream() << raw << " ( ns : " << ns << + mongoutils::str::stream() << raw << " ( ns : " << ns << ", received : " << received.toString() << ", wanted : " << wanted.toString() << ", " << ( code == SendStaleConfigCode ? "send" : "recv" ) << " )", @@ -137,7 +136,7 @@ namespace mongo { // Preferred if we're rebuilding this from a thrown exception StaleConfigException( const string& raw , int code, const BSONObj& error, bool justConnection = false ) : AssertionException( - str::stream() << raw << " ( ns : " << error["ns"].String() << // Note, this will fail if we don't have a ns + mongoutils::str::stream() << raw << " ( ns : " << error["ns"].String() << // Note, this will fail if we don't have a ns ", received : " << ShardChunkVersion( error["vReceived"] ).toString() << ", wanted : " << ShardChunkVersion( error["vWanted"] ).toString() << ", " << ( code == SendStaleConfigCode ? "send" : "recv" ) << " )", @@ -210,6 +209,7 @@ namespace mongo { }; class ShardConnection; + class DBClientBase; class VersionManager { public: VersionManager(){}; diff --git a/src/mongo/scripting/bench.cpp b/src/mongo/scripting/bench.cpp index 2c4fbd38857..32f811ecd9a 100644 --- a/src/mongo/scripting/bench.cpp +++ b/src/mongo/scripting/bench.cpp @@ -20,8 +20,8 @@ #include "engine.h" #include "../util/md5.hpp" #include "../util/version.h" -#include "../client/dbclient.h" #include "../client/connpool.h" +#include "mongo/client/dbclientcursor.h" #include <pcrecpp.h> // --------------------------------- diff --git a/src/mongo/scripting/engine.cpp b/src/mongo/scripting/engine.cpp index 9efa4e37d05..78232ea5195 100644 --- a/src/mongo/scripting/engine.cpp +++ b/src/mongo/scripting/engine.cpp @@ -18,8 +18,8 @@ #include "pch.h" #include "engine.h" #include "../util/file.h" -#include "../client/dbclient.h" - +#include "mongo/client/dbclientinterface.h" +#include "mongo/client/dbclientcursor.h" #include <boost/filesystem/operations.hpp> namespace mongo { diff --git a/src/mongo/scripting/engine_spidermonkey.cpp b/src/mongo/scripting/engine_spidermonkey.cpp index e3feb8dabd6..2b6b36a298f 100644 --- a/src/mongo/scripting/engine_spidermonkey.cpp +++ b/src/mongo/scripting/engine_spidermonkey.cpp @@ -17,7 +17,7 @@ #include "pch.h" #include "engine_spidermonkey.h" -#include "../client/dbclient.h" +#include "mongo/util/mongoutils/str.h" #ifndef _WIN32 #include <boost/date_time/posix_time/posix_time.hpp> @@ -1553,7 +1553,7 @@ namespace mongo { } } - uassert( 10228 , str::stream() << name + " exec failed: " << _error , worked || ! assertOnError ); + uassert( 10228 , mongoutils::str::stream() << name + " exec failed: " << _error , worked || ! assertOnError ); if ( reportError && ! _error.empty() ) { // cout << "exec error: " << _error << endl; @@ -1760,5 +1760,5 @@ namespace mongo { } } - +#include "mongo/client/dbclientcursor.h" #include "sm_db.cpp" diff --git a/src/mongo/scripting/v8_db.h b/src/mongo/scripting/v8_db.h index bba6885b605..935976febdf 100644 --- a/src/mongo/scripting/v8_db.h +++ b/src/mongo/scripting/v8_db.h @@ -23,7 +23,6 @@ #include <cstdlib> #include "engine_v8.h" -#include "../client/dbclient.h" namespace mongo { diff --git a/src/mongo/shell/dbshell.cpp b/src/mongo/shell/dbshell.cpp index 78ef31bc39a..bc31fff64cd 100644 --- a/src/mongo/shell/dbshell.cpp +++ b/src/mongo/shell/dbshell.cpp @@ -21,15 +21,14 @@ #include "../third_party/linenoise/linenoise.h" #include "../scripting/engine.h" -#include "../client/dbclient.h" #include "../util/unittest.h" #include "../db/cmdline.h" #include "utils.h" #include "../util/password.h" #include "../util/version.h" -#include "../util/goodies.h" #include "../util/file.h" #include "../db/repl/rs_member.h" +#include "mongo/client/dbclientinterface.h" #include <boost/filesystem/operations.hpp> diff --git a/src/mongo/shell/shell_utils.cpp b/src/mongo/shell/shell_utils.cpp index f0561547e09..e72a542dd6e 100644 --- a/src/mongo/shell/shell_utils.cpp +++ b/src/mongo/shell/shell_utils.cpp @@ -44,7 +44,6 @@ #endif #include "utils.h" -#include "../client/dbclient.h" #include "../util/md5.hpp" #include "../util/processinfo.h" #include "../util/text.h" @@ -52,6 +51,8 @@ #include "../util/time_support.h" #include "../util/file.h" #include "../client/clientOnly-private.h" +#include "mongo/util/net/sock.h" +#include "mongo/client/dbclientinterface.h" namespace mongo { diff --git a/src/mongo/tools/bridge.cpp b/src/mongo/tools/bridge.cpp index 491453e35dc..b6a1795ed5c 100644 --- a/src/mongo/tools/bridge.cpp +++ b/src/mongo/tools/bridge.cpp @@ -19,7 +19,6 @@ #include "pch.h" #include "../util/net/message.h" #include "../util/net/listen.h" -#include "../client/dbclient.h" #include "../db/dbmessage.h" using namespace mongo; diff --git a/src/mongo/tools/bsondump.cpp b/src/mongo/tools/bsondump.cpp index d6392e25e4c..16f9ea39198 100644 --- a/src/mongo/tools/bsondump.cpp +++ b/src/mongo/tools/bsondump.cpp @@ -17,7 +17,7 @@ */ #include "../pch.h" -#include "../client/dbclient.h" +#include "mongo/client/dbclientcursor.h" #include "../util/mmap.h" #include "../util/text.h" #include "tool.h" diff --git a/src/mongo/tools/dump.cpp b/src/mongo/tools/dump.cpp index efde62eef30..3f02c269535 100644 --- a/src/mongo/tools/dump.cpp +++ b/src/mongo/tools/dump.cpp @@ -17,8 +17,8 @@ */ #include "../pch.h" -#include "../client/dbclient.h" #include "../db/db.h" +#include "mongo/client/dbclientcursor.h" #include "tool.h" #include <fcntl.h> diff --git a/src/mongo/tools/export.cpp b/src/mongo/tools/export.cpp index 7f10dc1e2f5..0461415b1b9 100644 --- a/src/mongo/tools/export.cpp +++ b/src/mongo/tools/export.cpp @@ -17,8 +17,8 @@ */ #include "pch.h" -#include "client/dbclient.h" #include "db/json.h" +#include "mongo/client/dbclientcursor.h" #include "tool.h" diff --git a/src/mongo/tools/files.cpp b/src/mongo/tools/files.cpp index 67619827611..b22d13fa779 100644 --- a/src/mongo/tools/files.cpp +++ b/src/mongo/tools/files.cpp @@ -18,7 +18,7 @@ #include "pch.h" #include "client/gridfs.h" -#include "client/dbclient.h" +#include "mongo/client/dbclientcursor.h" #include "tool.h" #include "pcrecpp.h" diff --git a/src/mongo/tools/import.cpp b/src/mongo/tools/import.cpp index 781e7c5a643..666cc4a23e9 100644 --- a/src/mongo/tools/import.cpp +++ b/src/mongo/tools/import.cpp @@ -17,7 +17,6 @@ */ #include "pch.h" -#include "client/dbclient.h" #include "db/json.h" #include "tool.h" diff --git a/src/mongo/tools/oplog.cpp b/src/mongo/tools/oplog.cpp index 7b5eee55f38..679ae0cb92b 100644 --- a/src/mongo/tools/oplog.cpp +++ b/src/mongo/tools/oplog.cpp @@ -17,7 +17,6 @@ */ #include "pch.h" -#include "client/dbclient.h" #include "db/json.h" #include "db/oplogreader.h" diff --git a/src/mongo/tools/restore.cpp b/src/mongo/tools/restore.cpp index e5b122cc5cd..00970dcf4de 100644 --- a/src/mongo/tools/restore.cpp +++ b/src/mongo/tools/restore.cpp @@ -25,11 +25,12 @@ #include <fstream> #include <set> -#include "mongo/client/dbclient.h" #include "mongo/db/namespacestring.h" #include "mongo/tools/tool.h" #include "mongo/util/mmap.h" #include "mongo/util/version.h" +#include "mongo/db/json.h" +#include "mongo/client/dbclientcursor.h" using namespace mongo; diff --git a/src/mongo/tools/sniffer.cpp b/src/mongo/tools/sniffer.cpp index 5f160e3adce..b1a614a7d87 100644 --- a/src/mongo/tools/sniffer.cpp +++ b/src/mongo/tools/sniffer.cpp @@ -38,7 +38,6 @@ #include "../util/net/message.h" #include "../util/mmap.h" #include "../db/dbmessage.h" -#include "../client/dbclient.h" #include <stdio.h> #include <string.h> diff --git a/src/mongo/tools/stat.cpp b/src/mongo/tools/stat.cpp index fa4095532e4..300d9f36a8a 100644 --- a/src/mongo/tools/stat.cpp +++ b/src/mongo/tools/stat.cpp @@ -17,10 +17,10 @@ */ #include "pch.h" -#include "client/dbclient.h" #include "db/json.h" #include "../util/net/httpclient.h" #include "../util/text.h" +#include "mongo/client/dbclientcursor.h" #include "tool.h" #include "stat_util.h" #include <fstream> diff --git a/src/mongo/tools/tool.cpp b/src/mongo/tools/tool.cpp index 12eaaa26b08..691a9f1d197 100644 --- a/src/mongo/tools/tool.cpp +++ b/src/mongo/tools/tool.cpp @@ -27,6 +27,8 @@ #include "mongo/util/file_allocator.h" #include "mongo/util/password.h" #include "mongo/util/version.h" +#include "mongo/client/dbclient_rs.h" +#include "mongo/db/json.h" #include <boost/filesystem/operations.hpp> diff --git a/src/mongo/tools/tool.h b/src/mongo/tools/tool.h index 040f4ac4d6c..65765eba940 100644 --- a/src/mongo/tools/tool.h +++ b/src/mongo/tools/tool.h @@ -26,7 +26,6 @@ #include <io.h> #endif -#include "client/dbclient.h" #include "db/instance.h" #include "db/matcher.h" #include "db/security.h" diff --git a/src/mongo/tools/top.cpp b/src/mongo/tools/top.cpp index 3fd162bf29d..dad86f5709b 100644 --- a/src/mongo/tools/top.cpp +++ b/src/mongo/tools/top.cpp @@ -17,7 +17,7 @@ */ #include "pch.h" -#include "client/dbclient.h" + #include "db/json.h" #include "../util/text.h" #include "tool.h" diff --git a/src/mongo/util/allocator.h b/src/mongo/util/allocator.h index 27406bfd402..fae1364546f 100644 --- a/src/mongo/util/allocator.h +++ b/src/mongo/util/allocator.h @@ -17,6 +17,9 @@ #pragma once +// we need the "real" malloc here +#include "mongo/client/undef_macros.h" + namespace mongo { inline void * ourmalloc(size_t size) { @@ -34,9 +37,8 @@ namespace mongo { #define MONGO_malloc mongo::ourmalloc #define MONGO_realloc mongo::ourrealloc -#ifdef MONGO_EXPOSE_MACROS -# define malloc MONGO_malloc -# define realloc MONGO_realloc -#endif +// this redefines 'malloc' to 'MONGO_malloc', etc +#include "mongo/client/redef_macros.h" + } // namespace mongo diff --git a/src/mongo/util/assert_util.h b/src/mongo/util/assert_util.h index d46df42d934..a5e2b358c2f 100644 --- a/src/mongo/util/assert_util.h +++ b/src/mongo/util/assert_util.h @@ -17,9 +17,11 @@ #pragma once -#include "../bson/inline_decls.h" +#include <iostream> #include <typeinfo> +#include "mongo/bson/inline_decls.h" + // MONGO_NORETURN undefed at end of file #ifdef __GNUC__ # define MONGO_NORETURN __attribute__((__noreturn__)) @@ -182,16 +184,11 @@ namespace mongo { inline void fassert( int msgid , bool testOK ) { if ( ! testOK ) fassertFailed( msgid ); } -#define MONGO_verify(_Expression) (void)( MONGO_likely(!!(_Expression)) || (mongo::asserted(#_Expression, __FILE__, __LINE__), 0) ) -#define verify MONGO_verify - /* "user assert". if asserts, user did something wrong, not our code */ #define MONGO_uassert(msgid, msg, expr) (void)( MONGO_likely(!!(expr)) || (mongo::uasserted(msgid, msg), 0) ) -#define uassert MONGO_uassert /* warning only - keeps going */ #define MONGO_wassert(_Expression) (void)( MONGO_likely(!!(_Expression)) || (mongo::wasserted(#_Expression, __FILE__, __LINE__), 0) ) -#define wassert MONGO_wassert /* display a message, no context, and throw assertionexception @@ -199,7 +196,8 @@ namespace mongo { display happening. */ #define MONGO_massert(msgid, msg, expr) (void)( MONGO_likely(!!(expr)) || (mongo::msgasserted(msgid, msg), 0) ) -#define massert MONGO_massert + /* same as massert except no msgid */ +#define MONGO_verify(_Expression) (void)( MONGO_likely(!!(_Expression)) || (mongo::asserted(#_Expression, __FILE__, __LINE__), 0) ) /* dassert is 'debug assert' -- might want to turn off for production as these could be slow. @@ -209,7 +207,15 @@ namespace mongo { #else # define MONGO_dassert(x) #endif -#define dassert MONGO_dassert + + +#ifdef MONGO_EXPOSE_MACROS +# define dassert MONGO_dassert +# define verify MONGO_verify +# define uassert MONGO_uassert +# define wassert MONGO_wassert +# define massert MONGO_massert +#endif // some special ids that we want to duplicate @@ -225,7 +231,7 @@ namespace mongo { if( !myios.good() ) streamNotGood(msgid, msg, myios); } - std::string demangleName( const type_info& typeinfo ); + std::string demangleName( const std::type_info& typeinfo ); } // namespace mongo diff --git a/src/mongo/util/background.h b/src/mongo/util/background.h index 496a1f44f88..88d5b84ed6a 100644 --- a/src/mongo/util/background.h +++ b/src/mongo/util/background.h @@ -17,6 +17,9 @@ #pragma once +#include <string> +#include <vector> + #include "concurrency/spin_lock.h" namespace mongo { @@ -50,7 +53,7 @@ namespace mongo { */ explicit BackgroundJob(bool selfDelete = false); - virtual string name() const = 0; + virtual std::string name() const = 0; /** * define this to do your work. @@ -110,7 +113,7 @@ namespace mongo { * instantiate statically * class MyTask : public PeriodicTask { * public: - * virtual string name() const { return "MyTask; " } + * virtual std::string name() const { return "MyTask; " } * virtual void doWork() { log() << "hi" << endl; } * } myTask; */ @@ -120,13 +123,13 @@ namespace mongo { virtual ~PeriodicTask(); virtual void taskDoWork() = 0; - virtual string taskName() const = 0; + virtual std::string taskName() const = 0; class Runner : public BackgroundJob { public: virtual ~Runner(){} - virtual string name() const { return "PeriodicTask::Runner"; } + virtual std::string name() const { return "PeriodicTask::Runner"; } virtual void run(); @@ -141,7 +144,7 @@ namespace mongo { // Runner will not delete these // this never gets smaller // only fields replaced with nulls - vector<PeriodicTask*> _tasks; + std::vector< PeriodicTask* > _tasks; }; diff --git a/src/mongo/util/concurrency/mutex.h b/src/mongo/util/concurrency/mutex.h index 4ae6c78c9c6..4adf2c85b09 100644 --- a/src/mongo/util/concurrency/mutex.h +++ b/src/mongo/util/concurrency/mutex.h @@ -71,11 +71,7 @@ namespace mongo { public: try_lock( mongo::mutex &m , int millis = 0 ) : _l( m.boost() , incxtimemillis( millis ) ) , -#if BOOST_VERSION >= 103500 ok( _l.owns_lock() ) -#else - ok( _l.locked() ) -#endif { } private: boost::timed_mutex::scoped_timed_lock _l; diff --git a/src/mongo/util/concurrency/mutexdebugger.h b/src/mongo/util/concurrency/mutexdebugger.h index 8c41a687490..f3e93a2d703 100644 --- a/src/mongo/util/concurrency/mutexdebugger.h +++ b/src/mongo/util/concurrency/mutexdebugger.h @@ -2,6 +2,20 @@ #pragma once +#include "mongo/client/undef_macros.h" + +#include <iostream> +#include <map> +#include <set> +#include <sstream> +#include <string> + +#include "boost/thread/mutex.hpp" + +#include "mongo/client/redef_macros.h" + +#include "mongo/util/assert_util.h" + namespace mongo { /** only used on _DEBUG builds. @@ -10,10 +24,10 @@ namespace mongo { */ class MutexDebugger { typedef const char * mid; // mid = mutex ID - typedef map<mid,int> Preceeding; - map< mid, int > maxNest; + typedef std::map<mid,int> Preceeding; + std::map< mid, int > maxNest; boost::thread_specific_ptr< Preceeding > us; - map< mid, set<mid> > followers; + std::map< mid, std::set<mid> > followers; boost::mutex &x; unsigned magic; void aBreakPoint() { } // for debugging @@ -24,19 +38,19 @@ namespace mongo { // a.lock(); b.lock(); is fine // b.lock(); alone is fine too // only checked on _DEBUG builds. - string a,b; + std::string a,b; /** outputs some diagnostic info on mutexes (on _DEBUG builds) */ void programEnding(); MutexDebugger(); - string currentlyLocked() const { + std::string currentlyLocked() const { Preceeding *_preceeding = us.get(); if( _preceeding == 0 ) return ""; Preceeding &preceeding = *_preceeding; - stringstream q; + std::stringstream q; for( Preceeding::const_iterator i = preceeding.begin(); i != preceeding.end(); i++ ) { if( i->second > 0 ) q << " " << i->first << ' ' << i->second << '\n'; @@ -56,7 +70,7 @@ namespace mongo { if( a == m ) { aBreakPoint(); if( preceeding[b.c_str()] ) { - cout << "****** MutexDebugger error! warning " << b << " was locked before " << a << endl; + std::cout << "****** MutexDebugger error! warning " << b << " was locked before " << a << std::endl; verify(false); } } @@ -70,7 +84,7 @@ namespace mongo { } bool failed = false; - string err; + std::string err; { boost::mutex::scoped_lock lk(x); followers[m]; @@ -79,18 +93,18 @@ namespace mongo { followers[i->first].insert(m); if( followers[m].count(i->first) != 0 ) { failed = true; - stringstream ss; + std::stringstream ss; mid bad = i->first; ss << "mutex problem" << "\n when locking " << m << "\n " << bad << " was already locked and should not be." "\n set a and b above to debug.\n"; - stringstream q; + std::stringstream q; for( Preceeding::iterator i = preceeding.begin(); i != preceeding.end(); i++ ) { if( i->first != m && i->first != bad && i->second > 0 ) q << " " << i->first << '\n'; } - string also = q.str(); + std::string also = q.str(); if( !also.empty() ) ss << "also locked before " << m << " in this thread (no particular order):\n" << also; err = ss.str(); @@ -100,7 +114,7 @@ namespace mongo { } } if( failed ) { - cout << err << endl; + std::cout << err << std::endl; verify( 0 ); } } @@ -109,7 +123,7 @@ namespace mongo { Preceeding& preceeding = *us.get(); preceeding[m]--; if( preceeding[m] < 0 ) { - cout << "ERROR: lock count for " << m << " is " << preceeding[m] << endl; + std::cout << "ERROR: lock count for " << m << " is " << preceeding[m] << std::endl; verify( preceeding[m] >= 0 ); } } diff --git a/src/mongo/util/concurrency/threadlocal.h b/src/mongo/util/concurrency/threadlocal.h index 5b8e033f60e..22ffa1b2f71 100644 --- a/src/mongo/util/concurrency/threadlocal.h +++ b/src/mongo/util/concurrency/threadlocal.h @@ -16,7 +16,10 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "mongo/client/undef_macros.h" #include <boost/thread/tss.hpp> +#include "mongo/client/redef_macros.h" + namespace mongo { diff --git a/src/mongo/util/net/message.cpp b/src/mongo/util/net/message.cpp index 7c5aa4b9f89..8acaf601916 100644 --- a/src/mongo/util/net/message.cpp +++ b/src/mongo/util/net/message.cpp @@ -26,7 +26,7 @@ #include "listen.h" #include "../goodies.h" -#include "../../client/dbclient.h" + namespace mongo { diff --git a/src/mongo/util/net/message_port.cpp b/src/mongo/util/net/message_port.cpp index 9a5a3ab1462..cd084183acc 100644 --- a/src/mongo/util/net/message_port.cpp +++ b/src/mongo/util/net/message_port.cpp @@ -28,7 +28,6 @@ #include "../background.h" #include "../time_support.h" #include "../../db/cmdline.h" -#include "../../client/dbclient.h" #include "../scopeguard.h" |