diff options
author | Dwight <dmerriman@gmail.com> | 2009-02-10 14:23:01 -0500 |
---|---|---|
committer | Dwight <dmerriman@gmail.com> | 2009-02-10 14:23:01 -0500 |
commit | 693a5607646976a25834fe36e521ff2147d9cc61 (patch) | |
tree | cb793d1edfe5e938aa5b54b4994e616eff77de40 | |
parent | 75d201f000377a99df231c2b18ac21eed0cf8c09 (diff) | |
parent | 975682a74f1163f2a59d62fa7c55a0f96bd50055 (diff) | |
download | mongo-693a5607646976a25834fe36e521ff2147d9cc61.tar.gz |
Merge branch 'master' of git.10gen.com:/data/gitroot/p
-rw-r--r-- | SConstruct | 4 | ||||
-rw-r--r-- | client/connpool.h | 2 | ||||
-rw-r--r-- | client/dbclient.h | 7 | ||||
-rw-r--r-- | client/gridfs.h | 2 | ||||
-rw-r--r-- | client/model.h | 2 | ||||
-rw-r--r-- | db/jsobj.cpp | 1 | ||||
-rw-r--r-- | db/jsobj.h | 8 | ||||
-rw-r--r-- | db/json.h | 2 | ||||
-rw-r--r-- | shell/MongoJS.cpp | 6 | ||||
-rw-r--r-- | shell/dbshell.cpp | 51 |
10 files changed, 66 insertions, 19 deletions
diff --git a/SConstruct b/SConstruct index a7e111cc183..8320729ebe2 100644 --- a/SConstruct +++ b/SConstruct @@ -505,7 +505,9 @@ if release and ( ( darwin and force64 ) or linux64 ): shellEnv["LIBS"] = env["LIBS_CLEAN"] shellEnv["SLIBS"] = "" -shellEnv.Append( LIBS=[ "v8" , "readline" ] ) +shellEnv.Append( LIBS=[ "v8" ] ) +if not windows: + shellEnv.Append( LIBS=["readline" ] ) shellEnv.JSConcat( "shell/mongo.jsall" , Glob( "shell/*.js" ) ) shellEnv.JSHeader( "shell/mongo.jsall" ) diff --git a/client/connpool.h b/client/connpool.h index 30b86a06241..c5c91b58519 100644 --- a/client/connpool.h +++ b/client/connpool.h @@ -1,4 +1,4 @@ -/* connpool.h */ +/** @file connpool.h */ /** * Copyright (C) 2008 10gen Inc. diff --git a/client/dbclient.h b/client/dbclient.h index b4775f111c4..5949cde1f00 100644 --- a/client/dbclient.h +++ b/client/dbclient.h @@ -1,4 +1,4 @@ -// dbclient.h - connect to a Mongo database as a database, from C++ +/** @file dbclient.h - connect to a Mongo database as a database, from C++ */ /** * Copyright (C) 2008 10gen Inc. @@ -75,7 +75,7 @@ namespace mongo { }; #pragma pack() - /** Represents a query. Typically one uses the QUERY(...) macro to construct a query object. + /** Represents a query. Typically one uses the QUERY(...) macro to construct a Query object. Example: QUERY( "age" << 33 << "school" << "UCLA" ).sort("name") */ @@ -135,6 +135,9 @@ namespace mongo { Query& where(const char *jscode) { return where(jscode, BSONObj()); } }; +/** Typically one uses the QUERY(...) macro to construct a Query object. + Example: QUERY( "age" << 33 << "school" << "UCLA" ) +*/ #define QUERY(x) Query( BSON(x) ) /** diff --git a/client/gridfs.h b/client/gridfs.h index 3a8428e2cb0..9aeab0257fd 100644 --- a/client/gridfs.h +++ b/client/gridfs.h @@ -1,4 +1,4 @@ -// gridfs.h +/** @file gridfs.h */ #pragma once diff --git a/client/model.h b/client/model.h index 3437d3bdd5e..1089eb06a11 100644 --- a/client/model.h +++ b/client/model.h @@ -1,4 +1,4 @@ -// model.h +/** @file model.h */ /** * Copyright (C) 2008 10gen Inc. diff --git a/db/jsobj.cpp b/db/jsobj.cpp index 23831829e41..16bbbdd4b1f 100644 --- a/db/jsobj.cpp +++ b/db/jsobj.cpp @@ -1095,6 +1095,5 @@ namespace mongo { Labeler::Label LT( "$lt" ); Labeler::Label LTE( "$lte" ); Labeler::Label NE( "$ne" ); - Labeler::Label In( "$in" ); } // namespace mongo diff --git a/db/jsobj.h b/db/jsobj.h index f6a8f8a954d..b032e614320 100644 --- a/db/jsobj.h +++ b/db/jsobj.h @@ -1,4 +1,4 @@ -/* jsobj.h */ +/** @file jsobj.h */ /** BSONObj and its helpers @@ -732,6 +732,11 @@ namespace mongo { /** Use BSON macro to build a BSONObj from a stream e.g., BSON( "name" << "joe" << "age" << 33 ) + + The labels GT, GTE, LT, LTE, NE can be helpful for stream-oriented construction + of a BSONObj, particularly when assembling a Query. For example, + BSON( "a" << GT << 23.4 << NE << 3 << "b" << 2 ) produces the object + { a: { \$gt: 23.4, \$ne: 3 }, b: 2 }. */ #define BSON(x) (( BSONObjBuilder() << x ).obj()) @@ -754,7 +759,6 @@ namespace mongo { extern Labeler::Label LT; extern Labeler::Label LTE; extern Labeler::Label NE; - extern Labeler::Label In; class BSONObjBuilderValueStream { public: diff --git a/db/json.h b/db/json.h index af9c81d4150..c65785aa060 100644 --- a/db/json.h +++ b/db/json.h @@ -1,4 +1,4 @@ -// json.h +/** @file json.h */ /** * Copyright (C) 2008 10gen Inc. diff --git a/shell/MongoJS.cpp b/shell/MongoJS.cpp index 8184e80db63..3fbdc999ca1 100644 --- a/shell/MongoJS.cpp +++ b/shell/MongoJS.cpp @@ -260,7 +260,11 @@ BSONObj v8ToMongo( v8::Handle<v8::Object> o ){ return b.obj(); } +#ifdef _WIN32 +#define GETNS char * ns = new char[args[0]->ToString()->Utf8Length()]; args[0]->ToString()->WriteUtf8( ns ); +#else #define GETNS char ns[args[0]->ToString()->Utf8Length()]; args[0]->ToString()->WriteUtf8( ns ); +#endif DBClientConnection * getConnection( const Arguments& args ){ Local<External> c = External::Cast( *(args.This()->Get( CONN_STRING )) ); @@ -316,7 +320,7 @@ v8::Handle<v8::Value> mongoInsert(const v8::Arguments& args){ v8::Handle<v8::Object> in = args[1]->ToObject(); if ( ! in->Has( String::New( "_id" ) ) ){ - v8::Handle<v8::Value> argv[0]; + v8::Handle<v8::Value> argv[1]; in->Set( String::New( "_id" ) , getObjectIdCons()->NewInstance( 0 , argv ) ); } diff --git a/shell/dbshell.cpp b/shell/dbshell.cpp index 67750b857a9..7cbe5bf32ef 100644 --- a/shell/dbshell.cpp +++ b/shell/dbshell.cpp @@ -2,8 +2,15 @@ #include <v8.h> +#ifdef _WIN32 +#else +#define USE_READLINE +#endif + +#ifdef USE_READLINE #include <readline/readline.h> #include <readline/history.h> +#endif #include "ShellUtils.h" #include "MongoJS.h" @@ -11,8 +18,36 @@ #include "mongo.jsh" -void quitNicely( int sig ){ +void shellHistoryInit(){ +#ifdef USE_READLINE + using_history(); + read_history( ".dbshell" ); +#endif +} +void shellHistoryDone(){ +#ifdef USE_READLINE write_history( ".dbshell" ); +#endif +} +void shellHistoryAdd( const char * line ){ + if ( strlen(line) == 0 ) + return; +#ifdef USE_READLINE + add_history( line ); +#endif +} +char * shellReadline( const char * prompt ){ +#ifdef USE_READLINE + return readline( "> " ); +#else + printf( "> " ); + char * buf = new char[1024]; + return fgets( buf , 1024 , stdin ); +#endif +} + +void quitNicely( int sig ){ + shellHistoryDone(); exit(0); } @@ -22,6 +57,7 @@ void quitAbruptly( int sig ) { } void setupSignals() { +#ifndef _WIN32 signal( SIGINT , quitNicely ); signal( SIGTERM , quitNicely ); signal( SIGPIPE , quitNicely ); // Maybe just log and continue? @@ -29,6 +65,7 @@ void setupSignals() { signal( SIGSEGV , quitAbruptly ); signal( SIGBUS , quitAbruptly ); signal( SIGFPE , quitAbruptly ); +#endif } string fixHost( string url , string host , string port ){ @@ -242,9 +279,8 @@ int main(int argc, char* argv[]) { if ( runShell ){ MongodScope s; - - using_history(); - read_history( ".dbshell" ); + + shellHistoryInit(); cout << "type \"help\" for help" << endl; @@ -252,7 +288,7 @@ int main(int argc, char* argv[]) { while ( 1 ){ - char * line = readline( "> " ); + char * line = shellReadline( "> " ); if ( ! line || ( strlen(line) == 4 && strstr( line , "exit" ) ) ){ cout << "bye" << endl; @@ -281,11 +317,10 @@ int main(int argc, char* argv[]) { true); - if ( strlen( line ) ) - add_history( line ); + shellHistoryAdd( line ); } - write_history( ".dbshell" ); + shellHistoryDone(); } return 0; |