summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2010-07-07 01:21:45 -0400
committerMathias Stearn <mathias@10gen.com>2010-07-07 01:22:33 -0400
commit13c6875815fdcb2d677c76905819d99a99a2d5d3 (patch)
tree50cca9cf3665e9b6e742bc89c32a5771ade85ac9
parente7cb7ecb5c8d17c622ca1f701a3ba31d04ff5c1a (diff)
downloadmongo-13c6875815fdcb2d677c76905819d99a99a2d5d3.tar.gz
temporarily Revert "git rid of "operator string""
This reverts commit 95fa51a1df4e5965d467b6afa244520288fbc35b.
-rw-r--r--bson/bsonelement.h1
-rw-r--r--bson/bsonobj.h1
-rw-r--r--bson/bsonobjbuilder.h7
-rw-r--r--bson/ordering.h3
-rw-r--r--bson/util/builder.h14
-rw-r--r--client/dbclient.cpp4
-rw-r--r--client/dbclient.h6
-rw-r--r--client/parallel.h4
-rw-r--r--db/cloner.cpp8
-rw-r--r--db/curop.h2
-rw-r--r--db/dbcommands.cpp6
-rw-r--r--db/diskloc.h2
-rw-r--r--db/geo/2d.cpp4
-rw-r--r--db/index.h4
-rw-r--r--db/namespace.cpp2
-rw-r--r--db/namespace.h4
-rw-r--r--db/repl.h2
-rw-r--r--dbtests/jstests.cpp2
-rw-r--r--dbtests/queryoptimizertests.cpp2
-rw-r--r--s/chunk.cpp6
-rw-r--r--s/chunk.h13
-rw-r--r--s/shard.h14
-rw-r--r--s/shardkey.h4
-rw-r--r--s/strategy.cpp2
-rw-r--r--util/array.h5
-rw-r--r--util/assert_util.h10
-rw-r--r--util/goodies.h4
-rw-r--r--util/hostandport.h2
-rw-r--r--util/httpclient.cpp4
-rw-r--r--util/log.h12
-rw-r--r--util/optime.h2
-rw-r--r--util/sock.h4
-rw-r--r--util/util.cpp2
33 files changed, 73 insertions, 89 deletions
diff --git a/bson/bsonelement.h b/bson/bsonelement.h
index 56898f8119f..19b7ef32e1e 100644
--- a/bson/bsonelement.h
+++ b/bson/bsonelement.h
@@ -86,6 +86,7 @@ public:
bool ok() const { return !eoo(); }
string toString( bool includeFieldName = true ) const;
+ operator string() const { return toString(); }
string jsonString( JsonStringFormat format, bool includeFieldNames = true, int pretty = 0 ) const;
/** Returns the type of the element */
diff --git a/bson/bsonobj.h b/bson/bsonobj.h
index 6a68b6bb3e4..c29f9e39a07 100644
--- a/bson/bsonobj.h
+++ b/bson/bsonobj.h
@@ -88,6 +88,7 @@ namespace mongo {
This is an abbreviated representation which might be used for logging.
*/
string toString( bool isArray = false ) const;
+ operator string() const { return toString(); }
/** Properly formatted JSON string.
@param pretty if true we try to add some lf's and indentation
diff --git a/bson/bsonobjbuilder.h b/bson/bsonobjbuilder.h
index 11f28fd6834..1535a553936 100644
--- a/bson/bsonobjbuilder.h
+++ b/bson/bsonobjbuilder.h
@@ -55,8 +55,7 @@ namespace mongo {
BSONField( const string& name , const string& longName="" )
: _name(name), _longName(longName){}
const string& name() const { return _name; }
- string toString() const { return _name; }
- friend ostream& operator << (ostream& out, const BSONField& f) { return (out << f._name); }
+ operator string() const { return _name; }
BSONFieldValue<T> make( const T& t ) const {
return BSONFieldValue<T>( _name , t );
@@ -372,10 +371,6 @@ namespace mongo {
BSONObjBuilder& append(const char *fieldName, string str) {
return append(fieldName, str.c_str(), (int) str.size()+1);
}
- /** Append a string element */
- BSONObjBuilder& append(const char *fieldName, ThreadSafeString tss) {
- return append(fieldName, tss.toString());
- }
BSONObjBuilder& appendSymbol(const char *fieldName, const char *symbol) {
_b.append((char) Symbol);
_b.append(fieldName);
diff --git a/bson/ordering.h b/bson/ordering.h
index 614c56e050c..fbbfbece5e3 100644
--- a/bson/ordering.h
+++ b/bson/ordering.h
@@ -39,13 +39,12 @@ namespace mongo {
// for woCompare...
unsigned descending(unsigned mask) const { return bits & mask; }
- string toString() const {
+ operator string() const {
StringBuilder buf(32);
for ( unsigned i=0; i<nkeys; i++)
buf.append( get(i) > 0 ? "+" : "-" );
return buf.str();
}
- friend ostream& operator << (ostream& out, const Ordering& o) { return (out << o.toString()); }
static Ordering make(const BSONObj& obj) {
unsigned b = 0;
diff --git a/bson/util/builder.h b/bson/util/builder.h
index e7c1044b9a0..dc15f8960b8 100644
--- a/bson/util/builder.h
+++ b/bson/util/builder.h
@@ -148,7 +148,7 @@ namespace mongo {
class StringBuilder {
public:
- explicit StringBuilder( int initsize=256 )
+ StringBuilder( int initsize=256 )
: _buf( initsize ){
}
@@ -188,18 +188,16 @@ namespace mongo {
}
#undef SBNUM
- void append( const char * str){
- append(str, strlen(str));
- }
- void append( const char * str, int len){
- memcpy( _buf.grow( len ) , str , len );
+ void append( const char * str ){
+ int x = (int) strlen( str );
+ memcpy( _buf.grow( x ) , str , x );
}
StringBuilder& operator<<( const char * str ){
- append( str, strlen(str) );
+ append( str );
return *this;
}
StringBuilder& operator<<( const std::string& s ){
- append( s.c_str(), s.size() );
+ append( s.c_str() );
return *this;
}
diff --git a/client/dbclient.cpp b/client/dbclient.cpp
index 0086fc83766..b4b7fb890c4 100644
--- a/client/dbclient.cpp
+++ b/client/dbclient.cpp
@@ -36,7 +36,7 @@ namespace mongo {
case MASTER: {
DBClientConnection * c = new DBClientConnection(true);
log(2) << "creating new connection to:" << _servers[0] << endl;
- if ( ! c->connect( _servers[0].toString() , errmsg ) ) {
+ if ( ! c->connect( _servers[0] , errmsg ) ) {
delete c;
return 0;
}
@@ -45,7 +45,7 @@ namespace mongo {
case SET: {
DBClientPaired *p = new DBClientPaired();
- if( !p->connect( _servers[0].toString() , _servers[1].toString() ) ){
+ if( !p->connect( _servers[0] , _servers[1] ) ){
delete p;
errmsg = "connect failed";
return 0;
diff --git a/client/dbclient.h b/client/dbclient.h
index 18ececbe985..8e7fc066320 100644
--- a/client/dbclient.h
+++ b/client/dbclient.h
@@ -129,7 +129,9 @@ namespace mongo {
return _string;
}
- friend ostream& operator << (ostream& out, const ConnectionString& cs) { return (out << cs.toString()); }
+ operator string() const {
+ return toString();
+ }
DBClientBase* connect( string& errmsg ) const;
@@ -267,7 +269,7 @@ namespace mongo {
bool isExplain() const;
string toString() const;
- friend ostream& operator << (ostream& out, const Query& q) { return (out << q.toString()); }
+ operator string() const { return toString(); }
private:
void makeComplex();
template< class T >
diff --git a/client/parallel.h b/client/parallel.h
index 5be041eb56f..5bee6b89339 100644
--- a/client/parallel.h
+++ b/client/parallel.h
@@ -54,7 +54,9 @@ namespace mongo {
return ss.str();
}
- friend ostream& operator << (ostream& out, const ServerAndQuery& sq) { return (out << sq.toString()); }
+ operator string() const {
+ return toString();
+ }
string _server;
BSONObj _extra;
diff --git a/db/cloner.cpp b/db/cloner.cpp
index 517359132bc..5859b04cd99 100644
--- a/db/cloner.cpp
+++ b/db/cloner.cpp
@@ -333,7 +333,7 @@ namespace mongo {
cmdSpec << "logSizeMb" << logSizeMb;
BSONObj info;
if ( !conn->runCommand( db, cmdSpec.done(), info ) ) {
- errmsg = "logCollection failed: " + info.toString();
+ errmsg = "logCollection failed: " + (string)info;
return false;
}
}
@@ -410,7 +410,7 @@ namespace mongo {
dbtemprelease t;
BSONObj info;
if ( !conn->runCommand( db, BSON( "logCollection" << ns << "validateComplete" << 1 ), info ) ) {
- errmsg = "logCollection failed: " + info.toString();
+ errmsg = "logCollection failed: " + (string)info;
return false;
}
}
@@ -642,7 +642,7 @@ namespace mongo {
if ( !authConn_->connect( fromhost, errmsg ) )
return false;
if( !authConn_->runCommand( "admin", BSON( "getnonce" << 1 ), ret ) ) {
- errmsg = "couldn't get nonce " + ret.toString();
+ errmsg = "couldn't get nonce " + string( ret );
return false;
}
}
@@ -692,7 +692,7 @@ namespace mongo {
{
dbtemprelease t;
if ( !authConn_->runCommand( fromdb, BSON( "authenticate" << 1 << "user" << username << "nonce" << nonce << "key" << key ), ret ) ) {
- errmsg = "unable to login " + ret.toString();
+ errmsg = "unable to login " + string( ret );
return false;
}
}
diff --git a/db/curop.h b/db/curop.h
index 4c9457775d0..ad86716f283 100644
--- a/db/curop.h
+++ b/db/curop.h
@@ -264,7 +264,7 @@ namespace mongo {
return _progressMeter;
}
- string getMessage() const { return _message.toString(); }
+ string getMessage() const { return _message; }
ProgressMeter& getProgressMeter() { return _progressMeter; }
friend class Client;
diff --git a/db/dbcommands.cpp b/db/dbcommands.cpp
index d4ed00aabcb..2654084c1da 100644
--- a/db/dbcommands.cpp
+++ b/db/dbcommands.cpp
@@ -721,7 +721,7 @@ namespace mongo {
int idxId = d->findIndexByKeyPattern( f.embeddedObject() );
if ( idxId < 0 ){
errmsg = "can't find index with key:";
- errmsg += f.embeddedObject().toString();
+ errmsg += f.embeddedObject();
return false;
}
else {
@@ -1261,7 +1261,7 @@ namespace mongo {
if ( !client.runCommand( dbname ,
BSON( "cloneCollectionAsCapped" << from << "toCollection" << ( from + ".$temp_convertToCapped" ) << "size" << double( size ) ),
info ) ) {
- errmsg = "cloneCollectionAsCapped failed: " + info.toString();
+ errmsg = "cloneCollectionAsCapped failed: " + string(info);
return false;
}
@@ -1274,7 +1274,7 @@ namespace mongo {
BSON( "renameCollection" << ( dbname + "." + from + ".$temp_convertToCapped" )
<< "to" << ( dbname + "." + from ) ),
info ) ) {
- errmsg = "renameCollection failed: " + info.toString();
+ errmsg = "renameCollection failed: " + string(info);
return false;
}
diff --git a/db/diskloc.h b/db/diskloc.h
index d289bb7ecc6..93ef78b7957 100644
--- a/db/diskloc.h
+++ b/db/diskloc.h
@@ -86,7 +86,7 @@ namespace mongo {
ss << hex << fileNo << ':' << ofs;
return ss.str();
}
- friend ostream& operator << (ostream& out, const DiskLoc& dl) { return (out << dl.toString()); }
+ operator string() const { return toString(); }
BSONObj toBSONObj() const {
return BSON( "file" << fileNo << "offset" << ofs );
diff --git a/db/geo/2d.cpp b/db/geo/2d.cpp
index 8cfa485cc89..31b5d4d2a2f 100644
--- a/db/geo/2d.cpp
+++ b/db/geo/2d.cpp
@@ -277,7 +277,9 @@ namespace mongo {
return buf.str();
}
- friend ostream& operator << (ostream& out, const Point& p) { return (out << p.toString()); }
+ operator string() const {
+ return toString();
+ }
bool between( double min , double max , double val , double fudge=0) const {
return val + fudge >= min && val <= max + fudge;
diff --git a/db/index.h b/db/index.h
index 27a4682bbf1..b70a6bc3aa9 100644
--- a/db/index.h
+++ b/db/index.h
@@ -131,7 +131,9 @@ namespace mongo {
const IndexSpec& getSpec() const;
- friend ostream& operator << (ostream& out, const IndexDetails& id) { return (out << id.info.obj().toString()); }
+ operator string() const {
+ return info.obj().toString();
+ }
};
struct IndexChanges/*on an update*/ {
diff --git a/db/namespace.cpp b/db/namespace.cpp
index cd054b7c00f..d9f0e2ae9c1 100644
--- a/db/namespace.cpp
+++ b/db/namespace.cpp
@@ -162,7 +162,7 @@ namespace mongo {
static void namespaceGetNamespacesCallback( const Namespace& k , NamespaceDetails& v , void * extra ) {
list<string> * l = (list<string>*)extra;
if ( ! k.hasDollarSign() )
- l->push_back( k.toString() );
+ l->push_back( (string)k );
}
void NamespaceIndex::getNamespaces( list<string>& tofill , bool onlyCollections ) const {
diff --git a/db/namespace.h b/db/namespace.h
index 407d185bfcc..8f888212158 100644
--- a/db/namespace.h
+++ b/db/namespace.h
@@ -139,8 +139,8 @@ namespace mongo {
return old + "." + local;
}
- string toString() const {
- return buf;
+ operator string() const {
+ return (string)buf;
}
char buf[MaxNsLen];
diff --git a/db/repl.h b/db/repl.h
index 01c3860ffed..c2d1afd443a 100644
--- a/db/repl.h
+++ b/db/repl.h
@@ -234,7 +234,7 @@ namespace mongo {
bool operator==(const ReplSource&r) const {
return hostName == r.hostName && sourceName() == r.sourceName();
}
- string toString() const { return sourceName() + "@" + hostName; }
+ operator string() const { return sourceName() + "@" + hostName; }
bool haveMoreDbsToSync() const { return !addDbNextPass.empty(); }
int sleepAdvice() const {
diff --git a/dbtests/jstests.cpp b/dbtests/jstests.cpp
index 73cadf2a96a..0b664f1c082 100644
--- a/dbtests/jstests.cpp
+++ b/dbtests/jstests.cpp
@@ -632,7 +632,7 @@ namespace JSTests {
private:
void check( const BSONObj &one, const BSONObj &two ) {
if ( one.woCompare( two ) != 0 ) {
- static string fail = string( "Assertion failure expected " ) + one.toString() + ", got " + two.toString();
+ static string fail = string( "Assertion failure expected " ) + string( one ) + ", got " + string( two );
FAIL( fail.c_str() );
}
}
diff --git a/dbtests/queryoptimizertests.cpp b/dbtests/queryoptimizertests.cpp
index 1764fee82f5..c3dfe720826 100644
--- a/dbtests/queryoptimizertests.cpp
+++ b/dbtests/queryoptimizertests.cpp
@@ -338,7 +338,7 @@ namespace QueryOptimizerTests {
public:
virtual ~DiffBase() {}
void run() {
- FieldRangeSet frs( "", fromjson( obj().toString() ) );
+ FieldRangeSet frs( "", fromjson( obj() ) );
FieldRange ret = frs.range( "a" );
ret -= frs.range( "b" );
check( ret );
diff --git a/s/chunk.cpp b/s/chunk.cpp
index 0eca81b89e7..b4b3bb237ec 100644
--- a/s/chunk.cpp
+++ b/s/chunk.cpp
@@ -794,7 +794,7 @@ namespace mongo {
for ( set<Shard>::iterator i=seen.begin(); i!=seen.end(); i++ ){
ScopedDbConnection conn( *i );
BSONObj res;
- if ( ! setShardVersion( conn.conn() , _ns , SCV(0) , true , res ) )
+ if ( ! setShardVersion( conn.conn() , _ns , 0 , true , res ) )
throw UserException( 8071 , (string)"OH KNOW, cleaning up after drop failed: " + res.toString() );
conn.done();
}
@@ -898,7 +898,7 @@ namespace mongo {
rwlock lk( _lock , false );
// TODO: cache or something?
- ShardChunkVersion max(0);
+ ShardChunkVersion max = 0;
for ( ChunkMap::const_iterator i=_chunkMap.begin(); i!=_chunkMap.end(); ++i ){
ChunkPtr c = i->second;
@@ -917,7 +917,7 @@ namespace mongo {
}
ShardChunkVersion ChunkManager::getVersion_inlock() const{
- ShardChunkVersion max(0);
+ ShardChunkVersion max = 0;
for ( ChunkMap::const_iterator i=_chunkMap.begin(); i!=_chunkMap.end(); ++i ){
ChunkPtr c = i->second;
diff --git a/s/chunk.h b/s/chunk.h
index 08b3813ed82..5b4d02b39fb 100644
--- a/s/chunk.h
+++ b/s/chunk.h
@@ -49,11 +49,11 @@ namespace mongo {
unsigned long long _combined;
};
- explicit ShardChunkVersion( int major=0, int minor=0 )
+ ShardChunkVersion( int major=0, int minor=0 )
: _minor(minor),_major(major){
}
- explicit ShardChunkVersion( unsigned long long ll )
+ ShardChunkVersion( unsigned long long ll )
: _combined( ll ){
}
@@ -80,7 +80,7 @@ namespace mongo {
}
operator unsigned long long() const { return _combined; }
- friend ostream& operator << (ostream& out, const ShardChunkVersion& scv){ return (out << scv.toString()); }
+ operator string() const { return toString(); }
ShardChunkVersion& operator=( const BSONElement& elem ){
switch ( elem.type() ){
@@ -98,8 +98,6 @@ namespace mongo {
return *this;
}
};
-
- typedef ShardChunkVersion SCV; // shortcut for constructors
typedef shared_ptr<Chunk> ChunkPtr;
@@ -139,6 +137,7 @@ namespace mongo {
bool contains( const BSONObj& obj ) const;
string toString() const;
+ operator string() const { return toString(); }
friend ostream& operator << (ostream& out, const Chunk& c){ return (out << c.toString()); }
bool operator==(const Chunk& s) const;
@@ -182,7 +181,7 @@ namespace mongo {
bool moveAndCommit( const Shard& to , string& errmsg );
const char * getNS(){ return "config.chunks"; }
- void serialize(BSONObjBuilder& to, ShardChunkVersion myLastMod=SCV(0));
+ void serialize(BSONObjBuilder& to, ShardChunkVersion myLastMod=0);
void unserialize(const BSONObj& from);
string modelServer();
@@ -345,7 +344,7 @@ namespace mongo {
void save();
string toString() const;
- friend ostream& operator<<(ostream& out, const ChunkManager& cm) { return (out << cm.toString()); }
+ operator string() const { return toString(); }
ShardChunkVersion getVersion( const Shard& shard ) const;
ShardChunkVersion getVersion() const;
diff --git a/s/shard.h b/s/shard.h
index dec2bc8a828..be2878d7d3a 100644
--- a/s/shard.h
+++ b/s/shard.h
@@ -152,15 +152,15 @@ namespace mongo {
ShardStatus( const Shard& shard , const BSONObj& obj );
- string toString() const {
- stringstream ss;
- ss << *this;
- return ss.str();
+ friend ostream& operator << (ostream& out, const ShardStatus& s) {
+ out << (string)s;
+ return out;
}
- friend ostream& operator << (ostream& out, const ShardStatus& ss){
- out << "shard: " << ss._shard << " mapped: " << ss._mapped << " writeLock: " << ss._writeLock;
- return out;
+ operator string() const {
+ stringstream ss;
+ ss << "shard: " << _shard << " mapped: " << _mapped << " writeLock: " << _writeLock;
+ return ss.str();
}
bool operator<( const ShardStatus& other ) const{
diff --git a/s/shardkey.h b/s/shardkey.h
index be693299c98..80d49fce87a 100644
--- a/s/shardkey.h
+++ b/s/shardkey.h
@@ -104,8 +104,8 @@ namespace mongo {
*/
bool isPrefixOf( const BSONObj& otherPattern ) const;
- friend ostream& operator << (ostream& out, const ShardKeyPattern& pattern){
- return (out << pattern.toString());
+ operator string() const {
+ return pattern.toString();
}
private:
BSONObj pattern;
diff --git a/s/strategy.cpp b/s/strategy.cpp
index e524f687856..37ce28d7950 100644
--- a/s/strategy.cpp
+++ b/s/strategy.cpp
@@ -180,7 +180,7 @@ namespace mongo {
if ( ! conf )
return false;
- ShardChunkVersion version(0);
+ ShardChunkVersion version = 0;
unsigned long long officialSequenceNumber = 0;
ChunkManagerPtr manager;
diff --git a/util/array.h b/util/array.h
index e4822a15300..e285139d451 100644
--- a/util/array.h
+++ b/util/array.h
@@ -86,10 +86,9 @@ namespace mongo {
return _it->_data[_pos];
}
- friend ostream& operator << (ostream& out, const iterator& i) { return (out << i._pos); }
- string toString() const {
+ operator string() const {
stringstream ss;
- ss << *this;
+ ss << _pos;
return ss.str();
}
private:
diff --git a/util/assert_util.h b/util/assert_util.h
index a241575b034..67b8c83f7dc 100644
--- a/util/assert_util.h
+++ b/util/assert_util.h
@@ -93,13 +93,7 @@ namespace mongo {
void append( BSONObjBuilder& b , const char * m = "$err" , const char * c = "code" ) const ;
- friend ostream& operator << (ostream& out, const ExceptionInfo& ei) { return (out << "exception: " << ei.code << " " << ei.msg); }
-
- string toString() const{
- stringstream ss;
- ss << (*this);
- return ss.str();
- }
+ operator string() const { stringstream ss; ss << "exception: " << code << " " << msg; return ss.str(); }
bool empty() const { return msg.empty(); }
@@ -125,7 +119,7 @@ namespace mongo {
return ss.str();
}
- friend ostream& operator << (ostream& out, const DBException& e) { return (out << e.toString()); }
+ operator string() const { return toString(); }
const ExceptionInfo& getInfo() const { return _ei; }
diff --git a/util/goodies.h b/util/goodies.h
index 3023c1c8550..e7b700932f6 100644
--- a/util/goodies.h
+++ b/util/goodies.h
@@ -601,13 +601,11 @@ namespace mongo {
_buf = 0;
}
- string toString() const {
+ operator string() const {
string s = _buf;
return s;
}
- operator string() const { return toString(); }
-
ThreadSafeString& operator=( const char * str ){
size_t s = strlen(str);
if ( s >= _size - 2 )
diff --git a/util/hostandport.h b/util/hostandport.h
index a6256166d68..6b2eb3b6c9c 100644
--- a/util/hostandport.h
+++ b/util/hostandport.h
@@ -56,7 +56,7 @@ namespace mongo {
// @returns host:port
string toString() const;
- friend ostream& operator << (ostream& out, const HostAndPort& hp) { return (out << hp.toString()); }
+ operator string() const { return toString(); }
string host() const { return _host; }
diff --git a/util/httpclient.cpp b/util/httpclient.cpp
index 0aeca280740..4f78029f36e 100644
--- a/util/httpclient.cpp
+++ b/util/httpclient.cpp
@@ -108,11 +108,11 @@ namespace mongo {
StringBuilder sb;
if ( result )
- sb << (const char*)buf;
+ sb << buf;
while ( ( got = p.unsafe_recv( buf , 4096 ) ) > 0){
if ( result )
- sb << (const char*)buf;
+ sb << buf;
}
if ( result ){
diff --git a/util/log.h b/util/log.h
index 57caff5be66..8a26bd8f6a9 100644
--- a/util/log.h
+++ b/util/log.h
@@ -57,17 +57,11 @@ namespace mongo {
class LazyStringImpl : public LazyString {
public:
LazyStringImpl( const T &t ) : t_( t ) {}
- virtual string val() const { return t_.toString(); }
+ virtual string val() const { return (string)t_; }
private:
const T& t_;
};
- inline StringBuilder& operator << (StringBuilder& out, const LazyString& ls) { return (out << ls.val()); }
- template <typename T>
- inline StringBuilder& operator << (StringBuilder& out, const T &t) {
- return ( out << LazyStringImpl<T>(t).val() );
- }
-
class Tee {
public:
virtual ~Tee(){}
@@ -80,9 +74,6 @@ namespace mongo {
return *this;
}
virtual ~Nullstream() {}
- virtual Nullstream& operator<<(string) {
- return *this;
- }
virtual Nullstream& operator<<(const char *) {
return *this;
}
@@ -198,7 +189,6 @@ namespace mongo {
}
/** note these are virtual */
- Logstream& operator<<(string x) { ss << x; return *this; }
Logstream& operator<<(const char *x) { ss << x; return *this; }
Logstream& operator<<(char *x) { ss << x; return *this; }
Logstream& operator<<(char x) { ss << x; return *this; }
diff --git a/util/optime.h b/util/optime.h
index 274ee51511f..5b0dc0f56c1 100644
--- a/util/optime.h
+++ b/util/optime.h
@@ -123,7 +123,7 @@ namespace mongo {
ss << hex << secs << ':' << i;
return ss.str();
}
- friend ostream& operator << (ostream& out, const OpTime& ot) { return (out << ot.toString()); }
+ operator string() const { return toString(); }
bool operator==(const OpTime& r) const {
return i == r.i && secs == r.secs;
}
diff --git a/util/sock.h b/util/sock.h
index d94c6a16452..11948fad29d 100644
--- a/util/sock.h
+++ b/util/sock.h
@@ -155,7 +155,9 @@ namespace mongo {
return out;
}
- friend ostream& operator << (ostream& out, const SockAddr& sa) { return (out << sa.toString()); }
+ operator string() const{
+ return toString();
+ }
// returns one of AF_INET, AF_INET6, or AF_UNIX
sa_family_t getType() const {
diff --git a/util/util.cpp b/util/util.cpp
index 2b97b070970..4030e2d7d10 100644
--- a/util/util.cpp
+++ b/util/util.cpp
@@ -178,7 +178,7 @@ namespace mongo {
}
ostream& operator<<( ostream &s, const ThreadSafeString &o ){
- s << o.toString();
+ s << (string)o;
return s;
}