summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDwight Merriman <dwight@10gen.com>2010-04-24 18:25:58 -0400
committerDwight Merriman <dwight@10gen.com>2010-04-24 18:25:58 -0400
commitc4bd46504276f7b7da07b8ab2bc1c5685004a29d (patch)
treebdf788366d6b91b2a979829421dbdfed61f8a3a6
parent96b58977fcc6cad83a79589162843659221ea1ab (diff)
downloadmongo-c4bd46504276f7b7da07b8ab2bc1c5685004a29d.tar.gz
towards 3
-rw-r--r--.gitignore5
-rw-r--r--bson/bson.h12
-rw-r--r--bson/bson_db.h18
-rw-r--r--bson/bsondemo/bsondemo.vcproj14
-rw-r--r--bson/bsoninlines.h8
-rw-r--r--bson/bsonmisc.h2
-rw-r--r--bson/bsonobj.h17
-rw-r--r--bson/bsonobjbuilder.h13
-rw-r--r--bson/bsontypes.h2
-rw-r--r--bson/util/builder.h (renamed from util/builder.h)9
-rw-r--r--bson/util/misc.h (renamed from bson/util.h)0
-rw-r--r--client/dbclient.cpp2
-rw-r--r--db/cloner.cpp2
-rw-r--r--db/dbcommands.cpp2
-rw-r--r--db/dbeval.cpp2
-rw-r--r--db/introspect.cpp2
-rw-r--r--db/jsobj.cpp12
-rw-r--r--db/jsobj.h2
-rw-r--r--db/json.cpp2
-rw-r--r--db/query.cpp2
-rw-r--r--dbtests/basictests.cpp9
-rw-r--r--dbtests/jstests.cpp7
-rw-r--r--tools/sniffer.cpp2
-rw-r--r--util/goodies.h2
-rw-r--r--util/httpclient.cpp2
25 files changed, 100 insertions, 50 deletions
diff --git a/.gitignore b/.gitignore
index e7e00154b9f..58425f6f22c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,12 +28,15 @@
*.pdb
*.manifest
*.gch
+*.vcproj.*
*#
.#*
shell/mongo.cpp
shell/mongo-server.cpp
-db/Debug
+*/Debug/
+*/*/Debug/
+*/Release/
db/.gdb*
db/makefile.local
config.log
diff --git a/bson/bson.h b/bson/bson.h
index fefe40fcefa..a55699a5505 100644
--- a/bson/bson.h
+++ b/bson/bson.h
@@ -39,15 +39,15 @@
namespace mongo {
#if !defined(assert)
- void assert(bool expr) {
+ inline void assert(bool expr) {
if(!expr) std::cout << "assertion failure in bson library" << std::endl;
}
#endif
#if !defined(uassert)
- void uassert(unsigned msgid, const char *msg, bool expr) {
+ inline void uassert(unsigned msgid, const char *msg, bool expr) {
if(!expr) std::cout << "assertion failure in bson library: " << msgid << ' ' << msg << std::endl;
}
- void massert(unsigned msgid, const char *msg, bool expr) {
+ inline void massert(unsigned msgid, std::string msg, bool expr) {
if(!expr) std::cout << "assertion failure in bson library: " << msgid << ' ' << msg << std::endl;
}
#endif
@@ -55,18 +55,18 @@ namespace mongo {
}
/*
-#include "../util/builder.h"
+#include "../bson/util/builder.h"
#include "boost/utility.hpp"
#include <set>
*/
#include "../bson/bsontypes.h"
#include "../bson/oid.h"
#include "../bson/bsonelement.h"
-/*
#include "../bson/bsonobj.h"
#include "../bson/bsonmisc.h"
#include "../bson/bsonobjbuilder.h"
#include "../bson/bsonobjiterator.h"
#include "../bson/bsoninlines.h"
+/*
#include "../bson/ordering.h"
-*/ \ No newline at end of file
+*/
diff --git a/bson/bson_db.h b/bson/bson_db.h
index 2b86295571f..cbb3ed18179 100644
--- a/bson/bson_db.h
+++ b/bson/bson_db.h
@@ -29,6 +29,17 @@
namespace mongo {
+ /**
+ Timestamps are a special BSON datatype that is used internally for replication.
+ Append a timestamp element to the object being ebuilt.
+ @param time - in millis (but stored in seconds)
+ */
+ inline BSONObjBuilder& BSONObjBuilder::appendTimestamp( const char *fieldName , unsigned long long time , unsigned int inc ){
+ OpTime t( (unsigned) (time / 1000) , inc );
+ appendTimestamp( fieldName , t.asDate() );
+ return *this;
+ }
+
inline OpTime BSONElement::_opTime() const {
return OpTime( *reinterpret_cast< const unsigned long long* >( value() ) );
}
@@ -47,4 +58,11 @@ namespace mongo {
return "";
}
+ inline BSONObjBuilder& BSONObjBuilderValueStream::operator<<(DateNowLabeler& id){
+ _builder->appendDate(_fieldName, jsTime());
+ _fieldName = 0;
+ return *_builder;
+ }
+
+
}
diff --git a/bson/bsondemo/bsondemo.vcproj b/bson/bsondemo/bsondemo.vcproj
index 4d73def6096..946a8c25b6c 100644
--- a/bson/bsondemo/bsondemo.vcproj
+++ b/bson/bsondemo/bsondemo.vcproj
@@ -222,10 +222,18 @@
RelativePath="..\ordering.h"
>
</File>
- <File
- RelativePath="..\util.h"
+ <Filter
+ Name="util"
>
- </File>
+ <File
+ RelativePath="..\util\builder.h"
+ >
+ </File>
+ <File
+ RelativePath="..\util\misc.h"
+ >
+ </File>
+ </Filter>
</Filter>
</Files>
<Globals>
diff --git a/bson/bsoninlines.h b/bson/bsoninlines.h
index e940c80f766..14a4770e955 100644
--- a/bson/bsoninlines.h
+++ b/bson/bsoninlines.h
@@ -17,6 +17,8 @@
#pragma once
+#include <map>
+
namespace mongo {
inline BSONObj BSONElement::embeddedObjectUserCheck() const {
@@ -120,12 +122,6 @@ namespace mongo {
return *_builder;
}
- inline BSONObjBuilder& BSONObjBuilderValueStream::operator<<(DateNowLabeler& id){
- _builder->appendDate(_fieldName, jsTime());
- _fieldName = 0;
- return *_builder;
- }
-
inline Labeler BSONObjBuilderValueStream::operator<<( const Labeler::Label &l ) {
return Labeler( l, this );
}
diff --git a/bson/bsonmisc.h b/bson/bsonmisc.h
index 29e68e8e559..a9d2a64af69 100644
--- a/bson/bsonmisc.h
+++ b/bson/bsonmisc.h
@@ -17,6 +17,8 @@
#pragma once
+#include <boost/utility.hpp>
+
namespace mongo {
int getGtLtOp(const BSONElement& e);
diff --git a/bson/bsonobj.h b/bson/bsonobj.h
index 9469234956c..9bdf406cdea 100644
--- a/bson/bsonobj.h
+++ b/bson/bsonobj.h
@@ -17,6 +17,9 @@
#pragma once
+#include <set>
+#include "util/builder.h"
+
namespace mongo {
typedef set< BSONElement, BSONElementCmpWithoutField > BSONElementSet;
@@ -211,17 +214,7 @@ namespace mongo {
return objsize() <= 5;
}
- void dump() const {
- out() << hex;
- const char *p = objdata();
- for ( int i = 0; i < objsize(); i++ ) {
- out() << i << '\t' << ( 0xff & ( (unsigned) *p ) );
- if ( *p >= 'A' && *p <= 'z' )
- out() << '\t' << *p;
- out() << endl;
- p++;
- }
- }
+ void dump() const;
/** Alternative output format */
string hexDump() const;
@@ -361,7 +354,7 @@ private:
}
catch ( ... ){}
string s = ss.str();
- massert( 10334 , s , 0 );
+ massert( 10334 , s , 0 );
}
}
#pragma pack(1)
diff --git a/bson/bsonobjbuilder.h b/bson/bsonobjbuilder.h
index 7fb06485ae6..8be2bd1f3b7 100644
--- a/bson/bsonobjbuilder.h
+++ b/bson/bsonobjbuilder.h
@@ -22,8 +22,15 @@
#pragma once
+#include <limits>
+
namespace mongo {
+#if defined(_WIN32)
+// warning: 'this' : used in base member initializer list
+#pragma warning( disable : 4355 )
+#endif
+
/** Utility for creating a BSONObj.
See also the BSON() and BSON_ARRAY() macros.
*/
@@ -349,11 +356,7 @@ namespace mongo {
Append a timestamp element to the object being ebuilt.
@param time - in millis (but stored in seconds)
*/
- BSONObjBuilder& appendTimestamp( const char *fieldName , unsigned long long time , unsigned int inc ){
- OpTime t( (unsigned) (time / 1000) , inc );
- appendTimestamp( fieldName , t.asDate() );
- return *this;
- }
+ BSONObjBuilder& appendTimestamp( const char *fieldName , unsigned long long time , unsigned int inc );
/*
Append an element of the deprecated DBRef type.
diff --git a/bson/bsontypes.h b/bson/bsontypes.h
index 58dc8153200..eb3599a31d5 100644
--- a/bson/bsontypes.h
+++ b/bson/bsontypes.h
@@ -17,7 +17,7 @@
#pragma once
-#include "util.h"
+#include "util/misc.h"
namespace mongo {
diff --git a/util/builder.h b/bson/util/builder.h
index e918f6f4a7e..56196b8c855 100644
--- a/util/builder.h
+++ b/bson/util/builder.h
@@ -17,8 +17,9 @@
#pragma once
-#include "../stdafx.h"
#include <string.h>
+#include <stdio.h>
+#include <boost/shared_ptr.hpp>
namespace mongo {
@@ -29,7 +30,7 @@ namespace mongo {
BufBuilder(int initsize = 512) : size(initsize) {
if ( size > 0 ) {
data = (char *) malloc(size);
- assert(data);
+ assert(data != 0);
} else {
data = 0;
}
@@ -135,6 +136,10 @@ namespace mongo {
friend class StringBuilder;
};
+#if defined(_WIN32)
+#pragma warning( disable : 4996 )
+#endif
+
class StringBuilder {
public:
StringBuilder( int initsize=256 )
diff --git a/bson/util.h b/bson/util/misc.h
index 008549e1e38..008549e1e38 100644
--- a/bson/util.h
+++ b/bson/util/misc.h
diff --git a/client/dbclient.cpp b/client/dbclient.cpp
index a155dbcd942..ecc5fa31a57 100644
--- a/client/dbclient.cpp
+++ b/client/dbclient.cpp
@@ -18,7 +18,7 @@
#include "stdafx.h"
#include "../db/pdfile.h"
#include "dbclient.h"
-#include "../util/builder.h"
+#include "../bson/util/builder.h"
#include "../db/jsobj.h"
#include "../db/json.h"
#include "../db/instance.h"
diff --git a/db/cloner.cpp b/db/cloner.cpp
index 12b57ce2e95..fa12b3d0250 100644
--- a/db/cloner.cpp
+++ b/db/cloner.cpp
@@ -19,7 +19,7 @@
#include "stdafx.h"
#include "pdfile.h"
#include "../client/dbclient.h"
-#include "../util/builder.h"
+#include "../bson/util/builder.h"
#include "jsobj.h"
#include "query.h"
#include "commands.h"
diff --git a/db/dbcommands.cpp b/db/dbcommands.cpp
index 8d978f9edeb..6f8d2c811fb 100644
--- a/db/dbcommands.cpp
+++ b/db/dbcommands.cpp
@@ -19,7 +19,7 @@
#include "query.h"
#include "pdfile.h"
#include "jsobj.h"
-#include "../util/builder.h"
+#include "../bson/util/builder.h"
#include <time.h>
#include "introspect.h"
#include "btree.h"
diff --git a/db/dbeval.cpp b/db/dbeval.cpp
index ab7e1db69db..c6ab52ad624 100644
--- a/db/dbeval.cpp
+++ b/db/dbeval.cpp
@@ -21,7 +21,7 @@
#include "query.h"
#include "pdfile.h"
#include "jsobj.h"
-#include "../util/builder.h"
+#include "../bson/util/builder.h"
#include <time.h>
#include "introspect.h"
#include "btree.h"
diff --git a/db/introspect.cpp b/db/introspect.cpp
index a041d489ffa..1332db4e4ea 100644
--- a/db/introspect.cpp
+++ b/db/introspect.cpp
@@ -18,7 +18,7 @@
#include "stdafx.h"
#include "introspect.h"
-#include "../util/builder.h"
+#include "../bson/util/builder.h"
#include "../util/goodies.h"
#include "pdfile.h"
#include "jsobj.h"
diff --git a/db/jsobj.cpp b/db/jsobj.cpp
index 17233beff4c..208719fb0c4 100644
--- a/db/jsobj.cpp
+++ b/db/jsobj.cpp
@@ -1243,6 +1243,18 @@ namespace mongo {
return true;
}
+ void BSONObj::dump() const {
+ out() << hex;
+ const char *p = objdata();
+ for ( int i = 0; i < objsize(); i++ ) {
+ out() << i << '\t' << ( 0xff & ( (unsigned) *p ) );
+ if ( *p >= 'A' && *p <= 'z' )
+ out() << '\t' << *p;
+ out() << endl;
+ p++;
+ }
+ }
+
string BSONObj::hexDump() const {
stringstream ss;
const char *d = objdata();
diff --git a/db/jsobj.h b/db/jsobj.h
index 65a3ee5d2b9..a8d1fc5e6eb 100644
--- a/db/jsobj.h
+++ b/db/jsobj.h
@@ -29,7 +29,7 @@
#pragma once
#include "../stdafx.h"
-#include "../util/builder.h"
+#include "../bson/util/builder.h"
#include "../util/optime.h"
#include "boost/utility.hpp"
#include <set>
diff --git a/db/json.cpp b/db/json.cpp
index 7645b6b1e3a..2df9ce2379b 100644
--- a/db/json.cpp
+++ b/db/json.cpp
@@ -18,7 +18,7 @@
#include "stdafx.h"
#include "json.h"
-#include "../util/builder.h"
+#include "../bson/util/builder.h"
#include "../util/base64.h"
#include "../util/hex.h"
diff --git a/db/query.cpp b/db/query.cpp
index feee76d9bf3..5929d665624 100644
--- a/db/query.cpp
+++ b/db/query.cpp
@@ -20,7 +20,7 @@
#include "query.h"
#include "pdfile.h"
#include "jsobjmanipulator.h"
-#include "../util/builder.h"
+#include "../bson/util/builder.h"
#include <time.h>
#include "introspect.h"
#include "btree.h"
diff --git a/dbtests/basictests.cpp b/dbtests/basictests.cpp
index ceeb87e5836..996077c6c38 100644
--- a/dbtests/basictests.cpp
+++ b/dbtests/basictests.cpp
@@ -221,6 +221,8 @@ namespace BasicTests {
};
+/* [dm] this test doesn't apply anymore as ussert is no longer a macro
+
class AssertTests {
public:
@@ -236,7 +238,9 @@ namespace BasicTests {
}
void run(){
uassert( -1 , foo() , 1 );
- ASSERT_EQUALS( 0 , x );
+ if( x != 0 ) {
+ ASSERT_EQUALS( 0 , x );
+ }
try {
uassert( -1 , foo() , 0 );
}
@@ -244,6 +248,7 @@ namespace BasicTests {
ASSERT_EQUALS( 1 , x );
}
};
+*/
namespace ArrayTests {
class basic1 {
@@ -348,7 +353,7 @@ namespace BasicTests {
add< stringbuildertests::reset2 >();
add< sleeptest >();
- add< AssertTests >();
+// add< AssertTests >();
add< ArrayTests::basic1 >();
add< LexNumCmp >();
diff --git a/dbtests/jstests.cpp b/dbtests/jstests.cpp
index 454dcdc1d07..0ecfd4297ad 100644
--- a/dbtests/jstests.cpp
+++ b/dbtests/jstests.cpp
@@ -531,7 +531,12 @@ namespace JSTests {
ASSERT( s->exec( "printjson( a ); b = {b:a.a}", "foo", false, true, false ) );
out = s->getObject( "b" );
ASSERT_EQUALS( mongo::NumberLong, out.firstElement().type() );
- ASSERT_EQUALS( val, out.firstElement().numberLong() );
+ if( val != out.firstElement().numberLong() ) {
+ cout << val << endl;
+ cout << out.firstElement().numberLong() << endl;
+ cout << out.toString() << endl;
+ ASSERT_EQUALS( val, out.firstElement().numberLong() );
+ }
ASSERT( s->exec( "c = {c:a.a.toString()}", "foo", false, true, false ) );
out = s->getObject( "c" );
diff --git a/tools/sniffer.cpp b/tools/sniffer.cpp
index 14d32bdb8b1..070b902d859 100644
--- a/tools/sniffer.cpp
+++ b/tools/sniffer.cpp
@@ -34,7 +34,7 @@
#undef max
#endif
-#include "../util/builder.h"
+#include "../bson/util/builder.h"
#include "../util/message.h"
#include "../util/mmap.h"
#include "../db/dbmessage.h"
diff --git a/util/goodies.h b/util/goodies.h
index 2313f17f615..819b97213e2 100644
--- a/util/goodies.h
+++ b/util/goodies.h
@@ -18,7 +18,7 @@
#pragma once
-#include "../bson/util.h"
+#include "../bson/util/misc.h"
namespace mongo {
diff --git a/util/httpclient.cpp b/util/httpclient.cpp
index f93f1adf85b..9c5ff125d95 100644
--- a/util/httpclient.cpp
+++ b/util/httpclient.cpp
@@ -19,7 +19,7 @@
#include "httpclient.h"
#include "sock.h"
#include "message.h"
-#include "builder.h"
+#include "../bson/util/builder.h"
namespace mongo {