diff options
author | Eliot Horowitz <eliot@10gen.com> | 2011-12-24 15:33:26 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2011-12-24 15:33:45 -0500 |
commit | ae1ecd9c786911f9f1f0242f0f7d702b3e5dfeba (patch) | |
tree | 92f8e1649e6f080b251ff5f1763679a72eb59b34 /src/mongo/db/driverHelpers.cpp | |
parent | dfa4cd7e2cf109b072440155fabc08a93c8045a0 (diff) | |
download | mongo-ae1ecd9c786911f9f1f0242f0f7d702b3e5dfeba.tar.gz |
bulk move of code to src/ SERVER-4551
Diffstat (limited to 'src/mongo/db/driverHelpers.cpp')
-rw-r--r-- | src/mongo/db/driverHelpers.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/mongo/db/driverHelpers.cpp b/src/mongo/db/driverHelpers.cpp new file mode 100644 index 00000000000..12aa01886c4 --- /dev/null +++ b/src/mongo/db/driverHelpers.cpp @@ -0,0 +1,62 @@ +// driverHelpers.cpp + +/** + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +/** + this file has dbcommands that are for drivers + mostly helpers +*/ + + +#include "pch.h" +#include "jsobj.h" +#include "pdfile.h" +#include "namespace-inl.h" +#include "commands.h" +#include "cmdline.h" +#include "btree.h" +#include "curop-inl.h" +#include "../util/background.h" +#include "../scripting/engine.h" + +namespace mongo { + + class BasicDriverHelper : public Command { + public: + BasicDriverHelper( const char * name ) : Command( name ) {} + + virtual LockType locktype() const { return NONE; } + virtual bool slaveOk() const { return true; } + virtual bool slaveOverrideOk() { return true; } + }; + + class ObjectIdTest : public BasicDriverHelper { + public: + ObjectIdTest() : BasicDriverHelper( "driverOIDTest" ) {} + virtual bool run(const string& , BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl) { + if ( cmdObj.firstElement().type() != jstOID ) { + errmsg = "not oid"; + return false; + } + + const OID& oid = cmdObj.firstElement().__oid(); + result.append( "oid" , oid ); + result.append( "str" , oid.str() ); + + return true; + } + } driverObjectIdTest; +} |