diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2014-05-19 12:46:52 -0400 |
---|---|---|
committer | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2014-05-19 14:43:05 -0400 |
commit | f2bfd36a6f3eb7e7e2587268be3cc12636703d42 (patch) | |
tree | 6436772fbceb28f07bbfaee528d700159beb0cec /src | |
parent | c10e8282a7af38f8512e911a14889e14df8a2c6a (diff) | |
download | mongo-f2bfd36a6f3eb7e7e2587268be3cc12636703d42.tar.gz |
SERVER-13256: Remove pch - qualify std in headers
Diffstat (limited to 'src')
288 files changed, 1792 insertions, 1792 deletions
diff --git a/src/mongo/base/init.h b/src/mongo/base/init.h index ea7836a7931..5bcc074ef70 100644 --- a/src/mongo/base/init.h +++ b/src/mongo/base/init.h @@ -97,8 +97,8 @@ * dependents. * * NAME is any legitimate name for a C++ symbol. - * PREREQUISITES is a tuple of 0 or more string literals, i.e., ("a", "b", "c"), or () - * DEPENDENTS is a tuple of 0 or more string literals. + * PREREQUISITES is a tuple of 0 or more std::string literals, i.e., ("a", "b", "c"), or () + * DEPENDENTS is a tuple of 0 or more std::string literals. * * At run time, the full set of prerequisites for NAME will be computed as the union of the * explicit PREREQUISITES and the set of all other mongo initializers that name NAME in their diff --git a/src/mongo/base/parse_number.h b/src/mongo/base/parse_number.h index dc6aa03c25f..f5729eac840 100644 --- a/src/mongo/base/parse_number.h +++ b/src/mongo/base/parse_number.h @@ -47,7 +47,7 @@ namespace mongo { * on the number", as in strtol. Returns Status::BadValue if an illegal value is supplied for * "base". * - * The entirety of the string must consist of digits in the given base, except optionally the + * The entirety of the std::string must consist of digits in the given base, except optionally the * first character may be "+" or "-", and hexadecimal numbers may begin "0x". Same as strtol, * without the property of stripping whitespace at the beginning, and fails to parse if there * are non-digit characters at the end of the string. diff --git a/src/mongo/base/status_with.h b/src/mongo/base/status_with.h index 112dce42e2a..6014e5921d2 100644 --- a/src/mongo/base/status_with.h +++ b/src/mongo/base/status_with.h @@ -81,7 +81,7 @@ namespace mongo { bool isOK() const { return _status.isOK(); } - string toString() const { return _status.toString(); } + std::string toString() const { return _status.toString(); } private: Status _status; T _t; diff --git a/src/mongo/base/string_data-inl.h b/src/mongo/base/string_data-inl.h index 8d2e4eeda05..8c1c86208b7 100644 --- a/src/mongo/base/string_data-inl.h +++ b/src/mongo/base/string_data-inl.h @@ -75,11 +75,11 @@ namespace mongo { inline size_t StringData::find( char c, size_t fromPos ) const { if ( fromPos >= size() ) - return string::npos; + return std::string::npos; const void* x = memchr( _data + fromPos, c, _size - fromPos ); if ( x == 0 ) - return string::npos; + return std::string::npos; return static_cast<size_t>( static_cast<const char*>(x) - _data ); } @@ -90,7 +90,7 @@ namespace mongo { if ( needleSize == 0 ) return 0; else if ( needleSize > mx ) - return string::npos; + return std::string::npos; mx -= needleSize; @@ -98,7 +98,7 @@ namespace mongo { if ( memcmp( _data + i, needle._data, needleSize ) == 0 ) return i; } - return string::npos; + return std::string::npos; } @@ -111,7 +111,7 @@ namespace mongo { if ( *(cur - 1) == c ) return (cur - _data) - 1; } - return string::npos; + return std::string::npos; } inline StringData StringData::substr( size_t pos, size_t n ) const { diff --git a/src/mongo/base/string_data.h b/src/mongo/base/string_data.h index 55649fa9096..5cbc97d46c6 100644 --- a/src/mongo/base/string_data.h +++ b/src/mongo/base/string_data.h @@ -40,7 +40,7 @@ namespace mongo { using std::string; /** - * A StringData object wraps a 'const string&' or a 'const char*' without copying its + * A StringData object wraps a 'const std::string&' or a 'const char*' without copying its * contents. The most common usage is as a function argument that takes any of the two * forms of strings above. Fundamentally, this class tries go around the fact that string * literals in C++ are char[N]'s. @@ -49,25 +49,25 @@ namespace mongo { * * + The object StringData wraps around must be alive while the StringData is. * - * + Because string data can be used to pass a substring around, one should never assume a + * + Because std::string data can be used to pass a substring around, one should never assume a * rawData() terminates with a null. */ class StringData { public: - /** Constructs an empty string data */ + /** Constructs an empty std::string data */ StringData() : _data(NULL), _size(0) {} /** - * Constructs a StringData, for the case where the length of string is not known. 'c' + * Constructs a StringData, for the case where the length of std::string is not known. 'c' * must be a pointer to a null-terminated string. */ StringData( const char* c ) - : _data(c), _size((c == NULL) ? 0 : string::npos) {} + : _data(c), _size((c == NULL) ? 0 : std::string::npos) {} /** - * Constructs a StringData explicitly, for the case where the length of the string is + * Constructs a StringData explicitly, for the case where the length of the std::string is * already known. 'c' must be a pointer to a null-terminated string, and len must * be the length that strlen(c) would return, a.k.a the index of the terminator in c. */ @@ -110,7 +110,7 @@ namespace mongo { size_t find( char c , size_t fromPos = 0 ) const; size_t find( const StringData& needle ) const; - size_t rfind( char c, size_t fromPos = string::npos ) const; + size_t rfind( char c, size_t fromPos = std::string::npos ) const; /** * Returns true if 'prefix' is a substring of this instance, anchored at position 0. @@ -135,7 +135,7 @@ namespace mongo { size_t size() const { fillSize(); return _size; } bool empty() const { return size() == 0; } - string toString() const { return string(_data, size()); } + std::string toString() const { return std::string(_data, size()); } char operator[] ( unsigned pos ) const { return _data[pos]; } /** @@ -161,7 +161,7 @@ namespace mongo { mutable size_t _size; // 'size' does not include the null terminator void fillSize() const { - if (_size == string::npos) { + if (_size == std::string::npos) { _size = strlen(_data); } } diff --git a/src/mongo/bson/bson-inl.h b/src/mongo/bson/bson-inl.h index e77318dcc64..ddab8a0f603 100644 --- a/src/mongo/bson/bson-inl.h +++ b/src/mongo/bson/bson-inl.h @@ -117,7 +117,7 @@ dodouble: int res = memcmp(l.valuestr(), r.valuestr(), common); if( res ) return res; - // longer string is the greater one + // longer std::string is the greater one return lsz-rsz; } case Object: @@ -772,7 +772,7 @@ dodouble: BSONElement e = getField(name); if (e.eoo()) { size_t dot_offset = name.find('.'); - if (dot_offset != string::npos) { + if (dot_offset != std::string::npos) { StringData left = name.substr(0, dot_offset); StringData right = name.substr(dot_offset + 1); BSONObj sub = getObjectField(left); diff --git a/src/mongo/bson/bson_field.h b/src/mongo/bson/bson_field.h index cf20044fb48..eea8fa7027d 100644 --- a/src/mongo/bson/bson_field.h +++ b/src/mongo/bson/bson_field.h @@ -41,18 +41,18 @@ namespace mongo { * * In a header file: * // Determines the types for the fields used in a collection. - * static const string MyColl; + * static const std::string MyColl; * struct MyCollFields { - * static BSONField<string> name; + * static BSONField<std::string> name; * static BSONField<bool> draining; * static BSONField<int> count; * }; * * In a cpp file: - * const string MyColl = "my_collection_name"; + * const std::string MyColl = "my_collection_name"; * * // determines the names used for the fields - * BSONField<string> MyCollFields::name("_id"); + * BSONField<std::string> MyCollFields::name("_id"); * BSONField<bool> MyCollFields::draining("draining"); * BSONField<int> MyCollFields::count("count"); * diff --git a/src/mongo/bson/bsonelement.h b/src/mongo/bson/bsonelement.h index 981ecc24a2f..be13d9c17d4 100644 --- a/src/mongo/bson/bsonelement.h +++ b/src/mongo/bson/bsonelement.h @@ -248,9 +248,9 @@ namespace mongo { return type() == jstNULL; } - /** Size (length) of a string element. - You must assure of type String first. - @return string size including terminating null + /** Size (length) of a std::string element. + You must assure of type std::string first. + @return std::string size including terminating null */ int valuestrsize() const { return *reinterpret_cast< const int* >( value() ); @@ -268,11 +268,11 @@ namespace mongo { return value() + 4; } - /** Get the string value of the element. If not a string returns "". */ + /** Get the std::string value of the element. If not a std::string returns "". */ const char *valuestrsafe() const { return type() == mongo::String ? valuestr() : ""; } - /** Get the string value of the element. If not a string returns "". */ + /** Get the std::string value of the element. If not a std::string returns "". */ std::string str() const { return type() == mongo::String ? std::string(valuestr(), valuestrsize()-1) : std::string(); } @@ -347,7 +347,7 @@ namespace mongo { return (BinDataType)c; } - /** Retrieve the regex string for a Regex element */ + /** Retrieve the regex std::string for a Regex element */ const char *regex() const { verify(type() == RegEx); return value(); diff --git a/src/mongo/bson/bsonmisc.h b/src/mongo/bson/bsonmisc.h index da31e649b72..e7580c3330e 100644 --- a/src/mongo/bson/bsonmisc.h +++ b/src/mongo/bson/bsonmisc.h @@ -150,13 +150,13 @@ namespace mongo { BSONObjBuilderValueStream *s_; }; - // Utility class to allow adding a string to BSON as a Symbol + // Utility class to allow adding a std::string to BSON as a Symbol struct BSONSymbol { explicit BSONSymbol(const StringData& sym) :symbol(sym) {} StringData symbol; }; - // Utility class to allow adding a string to BSON as Code + // Utility class to allow adding a std::string to BSON as Code struct BSONCode { explicit BSONCode(const StringData& str) :code(str) {} StringData code; diff --git a/src/mongo/bson/bsonobj.h b/src/mongo/bson/bsonobj.h index 618afab466b..18082e562ad 100644 --- a/src/mongo/bson/bsonobj.h +++ b/src/mongo/bson/bsonobj.h @@ -425,7 +425,7 @@ namespace mongo { // Return a version of this object where top level elements of types // that are not part of the bson wire protocol are replaced with - // string identifier equivalents. + // std::string identifier equivalents. // TODO Support conversion of element types other than min and max. BSONObj clientReadable() const; diff --git a/src/mongo/bson/bsonobjbuilder.h b/src/mongo/bson/bsonobjbuilder.h index 245ce5a3293..65f8bfdd044 100644 --- a/src/mongo/bson/bsonobjbuilder.h +++ b/src/mongo/bson/bsonobjbuilder.h @@ -375,7 +375,7 @@ namespace mongo { return appendCode(fieldName, code.code); } - /** Append a string element. + /** Append a std::string element. @param sz size includes terminating null character */ BSONObjBuilder& append(const StringData& fieldName, const char *str, int sz) { _b.appendNum((char) String); @@ -384,15 +384,15 @@ namespace mongo { _b.appendBuf(str, sz); return *this; } - /** Append a string element */ + /** Append a std::string element */ BSONObjBuilder& append(const StringData& fieldName, const char *str) { return append(fieldName, str, (int) strlen(str)+1); } - /** Append a string element */ + /** Append a std::string element */ BSONObjBuilder& append(const StringData& fieldName, const std::string& str) { return append(fieldName, str.c_str(), (int) str.size()+1); } - /** Append a string element */ + /** Append a std::string element */ BSONObjBuilder& append(const StringData& fieldName, const StringData& str) { _b.appendNum((char) String); _b.appendStr(fieldName); @@ -863,7 +863,7 @@ namespace mongo { long int n; Status status = parseNumberFromStringWithBase( name, 10, &n ); uassert( 13048, - (string)"can't append to array using string field name: " + name.toString(), + (std::string)"can't append to array using std::string field name: " + name.toString(), status.isOK() ); fill(n); } diff --git a/src/mongo/bson/mutable/document.h b/src/mongo/bson/mutable/document.h index 0ff5fe8c2ef..2b73b96737a 100644 --- a/src/mongo/bson/mutable/document.h +++ b/src/mongo/bson/mutable/document.h @@ -313,7 +313,7 @@ namespace mutablebson { /** Create a new double Element with the given value and field name. */ Element makeElementDouble(const StringData& fieldName, double value); - /** Create a new string Element with the given value and field name. */ + /** Create a new std::string Element with the given value and field name. */ Element makeElementString(const StringData& fieldName, const StringData& value); /** Create a new empty object Element with the given field name. */ diff --git a/src/mongo/bson/mutable/element.h b/src/mongo/bson/mutable/element.h index de7cc3700ad..fa94c63035c 100644 --- a/src/mongo/bson/mutable/element.h +++ b/src/mongo/bson/mutable/element.h @@ -283,7 +283,7 @@ namespace mutablebson { /** Get the value from a double valued Element. */ inline double getValueDouble() const; - /** Get the value from a string valued Element. */ + /** Get the value from a std::string valued Element. */ inline StringData getValueString() const; /** Get the value from an object valued Element. Note that this may not always be @@ -508,7 +508,7 @@ namespace mutablebson { /** Append the provided double value as a new field with the provided name. */ Status appendDouble(const StringData& fieldName, double value); - /** Append the provided string value as a new field with the provided name. */ + /** Append the provided std::string value as a new field with the provided name. */ Status appendString(const StringData& fieldName, const StringData& value); /** Append the provided object as a new field with the provided name. The data in diff --git a/src/mongo/bson/oid.h b/src/mongo/bson/oid.h index 7904891e829..5e612ab9b89 100644 --- a/src/mongo/bson/oid.h +++ b/src/mongo/bson/oid.h @@ -60,7 +60,7 @@ namespace mongo { kIncSize = 3 }; - /** init from a 24 char hex string */ + /** init from a 24 char hex std::string */ explicit OID(const std::string &s) { init(s); } /** init from a reference to a 12-byte array */ @@ -97,7 +97,7 @@ namespace mongo { * */ void initSequential(); - /** init from a 24 char hex string */ + /** init from a 24 char hex std::string */ void init( const std::string& s ); /** Set to the min/max OID that could be generated at given timestamp. */ diff --git a/src/mongo/bson/optime.h b/src/mongo/bson/optime.h index 93093ab0be0..099520b6c41 100644 --- a/src/mongo/bson/optime.h +++ b/src/mongo/bson/optime.h @@ -102,20 +102,20 @@ namespace mongo { bool isNull() const { return secs == 0; } - string toStringLong() const { + std::string toStringLong() const { std::stringstream ss; ss << time_t_to_String_short(secs) << ' '; ss << std::hex << secs << ':' << i; return ss.str(); } - string toStringPretty() const { + std::string toStringPretty() const { std::stringstream ss; ss << time_t_to_String_short(secs) << ':' << std::hex << i; return ss.str(); } - string toString() const { + std::string toString() const { std::stringstream ss; ss << std::hex << secs << ':' << i; return ss.str(); diff --git a/src/mongo/bson/util/bson_extract.h b/src/mongo/bson/util/bson_extract.h index 00b0cf7effe..eb047e8ffb6 100644 --- a/src/mongo/bson/util/bson_extract.h +++ b/src/mongo/bson/util/bson_extract.h @@ -90,7 +90,7 @@ namespace mongo { /** * Finds a string-typed element named "fieldName" in "object" and stores its value in "out". * - * Returns Status::OK() and sets *out to the found element's string value on success. Returns + * Returns Status::OK() and sets *out to the found element's std::string value on success. Returns * ErrorCodes::NoSuchKey if there are no matches for "fieldName", and ErrorCodes::TypeMismatch * if the type of the matching element is not String. For return values other than * Status::OK(), the resulting value of "*out" is undefined. @@ -130,7 +130,7 @@ namespace mongo { long long* out); /** - * Finds a string element named "fieldName" in "object". + * Finds a std::string element named "fieldName" in "object". * * If a field named "fieldName" is present, and is a string, stores the value of the field into * "*out". If no field named fieldName is present, sets "*out" to "defaultValue". In these diff --git a/src/mongo/bson/util/builder.h b/src/mongo/bson/util/builder.h index 3a87a8bb871..00924458e7a 100644 --- a/src/mongo/bson/util/builder.h +++ b/src/mongo/bson/util/builder.h @@ -203,7 +203,7 @@ namespace mongo { str.copyTo( grow(len), includeEndingNull ); } - /** @return length of current string */ + /** @return length of current std::string */ int len() const { return l; } void setlen( int newLen ) { l = newLen; } /** @return size of the buffer */ @@ -264,7 +264,7 @@ namespace mongo { #define snprintf _snprintf #endif - /** stringstream deals with locale so this is a lot faster than std::stringstream for UTF8 */ + /** std::stringstream deals with locale so this is a lot faster than std::stringstream for UTF8 */ template <typename Allocator> class StringBuilderImpl { public: @@ -332,7 +332,7 @@ namespace mongo { std::string str() const { return std::string(_buf.data, _buf.l); } - /** size of current string */ + /** size of current std::string */ int len() const { return _buf.l; } private: diff --git a/src/mongo/client/connpool.h b/src/mongo/client/connpool.h index 09d5fb78b52..e7213abaa48 100644 --- a/src/mongo/client/connpool.h +++ b/src/mongo/client/connpool.h @@ -99,7 +99,7 @@ namespace mongo { void flush(); - void getStaleConnections( vector<DBClientBase*>& stale ); + void getStaleConnections( std::vector<DBClientBase*>& stale ); /** * Sets the lower bound for creation times that can be considered as @@ -171,7 +171,7 @@ namespace mongo { ~DBConnectionPool(); /** right now just controls some asserts. defaults to "dbconnectionpool" */ - void setName( const string& name ) { _name = name; } + void setName( const std::string& name ) { _name = name; } /** * Returns the maximum number of connections pooled per-host @@ -195,10 +195,10 @@ namespace mongo { void flush(); - DBClientBase *get(const string& host, double socketTimeout = 0); + DBClientBase *get(const std::string& host, double socketTimeout = 0); DBClientBase *get(const ConnectionString& host, double socketTimeout = 0); - void release(const string& host, DBClientBase *c); + void release(const std::string& host, DBClientBase *c); void addHook( DBConnectionHook * hook ); // we take ownership void appendInfo( BSONObjBuilder& b ); @@ -217,29 +217,29 @@ namespace mongo { * @return true if the connection is not bad, meaning, it is good to keep it for * future use. */ - bool isConnectionGood(const string& host, DBClientBase* conn); + bool isConnectionGood(const std::string& host, DBClientBase* conn); // Removes and deletes all connections from the pool for the host (regardless of timeout) - void removeHost( const string& host ); + void removeHost( const std::string& host ); /** compares server namees, but is smart about replica set names */ struct serverNameCompare { - bool operator()( const string& a , const string& b ) const; + bool operator()( const std::string& a , const std::string& b ) const; }; - virtual string taskName() const { return "DBConnectionPool-cleaner"; } + virtual std::string taskName() const { return "DBConnectionPool-cleaner"; } virtual void taskDoWork(); private: DBConnectionPool( DBConnectionPool& p ); - DBClientBase* _get( const string& ident , double socketTimeout ); + DBClientBase* _get( const std::string& ident , double socketTimeout ); - DBClientBase* _finishCreate( const string& ident , double socketTimeout, DBClientBase* conn ); + DBClientBase* _finishCreate( const std::string& ident , double socketTimeout, DBClientBase* conn ); struct PoolKey { PoolKey( const std::string& i , double t ) : ident( i ) , timeout( t ) {} - string ident; + std::string ident; double timeout; }; @@ -247,10 +247,10 @@ namespace mongo { bool operator()( const PoolKey& a , const PoolKey& b ) const; }; - typedef map<PoolKey,PoolForHost,poolKeyCompare> PoolMap; // servername -> pool + typedef std::map<PoolKey,PoolForHost,poolKeyCompare> PoolMap; // servername -> pool mongo::mutex _mutex; - string _name; + std::string _name; // The maximum number of connections we'll save in the pool per-host // PoolForHost::kPoolSizeUnlimited is a sentinel value meaning "no limit" @@ -261,7 +261,7 @@ namespace mongo { // pointers owned by me, right now they leak on shutdown // _hooks itself also leaks because it creates a shutdown race condition - list<DBConnectionHook*> * _hooks; + std::list<DBConnectionHook*> * _hooks; }; @@ -274,7 +274,7 @@ namespace mongo { virtual DBClientBase* get() = 0; virtual void done() = 0; - virtual string getHost() const = 0; + virtual std::string getHost() const = 0; /** * @return true iff this has a connection to the db @@ -299,7 +299,7 @@ namespace mongo { /** the main constructor you want to use throws UserException if can't connect */ - explicit ScopedDbConnection(const string& host, double socketTimeout = 0) : _host(host), _conn( pool.get(host, socketTimeout) ), _socketTimeout( socketTimeout ) { + explicit ScopedDbConnection(const std::string& host, double socketTimeout = 0) : _host(host), _conn( pool.get(host, socketTimeout) ), _socketTimeout( socketTimeout ) { _setSocketTimeout(); } @@ -310,7 +310,7 @@ namespace mongo { ScopedDbConnection() : _host( "" ) , _conn(0), _socketTimeout( 0 ) {} /* @param conn - bind to an existing connection */ - ScopedDbConnection(const string& host, DBClientBase* conn, double socketTimeout = 0 ) : _host( host ) , _conn( conn ), _socketTimeout( socketTimeout ) { + ScopedDbConnection(const std::string& host, DBClientBase* conn, double socketTimeout = 0 ) : _host( host ) , _conn( conn ), _socketTimeout( socketTimeout ) { _setSocketTimeout(); } @@ -338,7 +338,7 @@ namespace mongo { bool ok() const { return _conn != NULL; } - string getHost() const { return _host; } + std::string getHost() const { return _host; } /** Force closure of the connection. You should call this if you leave it in a bad state. Destructor will do this too, but it is verbose. @@ -371,7 +371,7 @@ namespace mongo { void _setSocketTimeout(); - const string _host; + const std::string _host; DBClientBase *_conn; const double _socketTimeout; diff --git a/src/mongo/client/dbclient_rs.h b/src/mongo/client/dbclient_rs.h index f9e3ad2fb48..17d9f49beb9 100644 --- a/src/mongo/client/dbclient_rs.h +++ b/src/mongo/client/dbclient_rs.h @@ -58,7 +58,7 @@ namespace mongo { using DBClientBase::remove; /** Call connect() after constructing. autoReconnect is always on for DBClientReplicaSet connections. */ - DBClientReplicaSet( const string& name , const vector<HostAndPort>& servers, double so_timeout=0 ); + DBClientReplicaSet( const std::string& name , const std::vector<HostAndPort>& servers, double so_timeout=0 ); virtual ~DBClientReplicaSet(); /** @@ -75,26 +75,26 @@ namespace mongo { * @param info the result object for the logout command (provided for backwards * compatibility with mongo shell) */ - virtual void logout(const string& dbname, BSONObj& info); + virtual void logout(const std::string& dbname, BSONObj& info); // ----------- simple functions -------------- /** throws userassertion "no master found" */ - virtual auto_ptr<DBClientCursor> query(const string &ns, Query query, int nToReturn = 0, int nToSkip = 0, + virtual std::auto_ptr<DBClientCursor> query(const std::string &ns, Query query, int nToReturn = 0, int nToSkip = 0, const BSONObj *fieldsToReturn = 0, int queryOptions = 0 , int batchSize = 0 ); /** throws userassertion "no master found" */ - virtual BSONObj findOne(const string &ns, const Query& query, const BSONObj *fieldsToReturn = 0, int queryOptions = 0); + virtual BSONObj findOne(const std::string &ns, const Query& query, const BSONObj *fieldsToReturn = 0, int queryOptions = 0); - virtual void insert( const string &ns , BSONObj obj , int flags=0); + virtual void insert( const std::string &ns , BSONObj obj , int flags=0); /** insert multiple objects. Note that single object insert is asynchronous, so this version is only nominally faster and not worth a special effort to try to use. */ - virtual void insert( const string &ns, const vector< BSONObj >& v , int flags=0); + virtual void insert( const std::string &ns, const std::vector< BSONObj >& v , int flags=0); - virtual void remove( const string &ns , Query obj , int flags ); + virtual void remove( const std::string &ns , Query obj , int flags ); - virtual void update( const string &ns , Query query , BSONObj obj , int flags ); + virtual void update( const std::string &ns , Query query , BSONObj obj , int flags ); virtual void killCursor( long long cursorID ); @@ -119,9 +119,9 @@ namespace mongo { // ---- callback pieces ------- - virtual void say( Message &toSend, bool isRetry = false , string* actualServer = 0); + virtual void say( Message &toSend, bool isRetry = false , std::string* actualServer = 0); virtual bool recv( Message &toRecv ); - virtual void checkResponse( const char* data, int nReturned, bool* retry = NULL, string* targetHost = NULL ); + virtual void checkResponse( const char* data, int nReturned, bool* retry = NULL, std::string* targetHost = NULL ); /* this is the callback from our underlying connections to notify us that we got a "not master" error. */ @@ -140,16 +140,16 @@ namespace mongo { double getSoTimeout() const { return _so_timeout; } - string toString() const { return getServerAddress(); } + std::string toString() const { return getServerAddress(); } - string getServerAddress() const; + std::string getServerAddress() const; virtual ConnectionString::ConnectionType type() const { return ConnectionString::SET; } virtual bool lazySupported() const { return true; } // ---- low level ------ - virtual bool call( Message &toSend, Message &response, bool assertOk=true , string * actualServer = 0 ); + virtual bool call( Message &toSend, Message &response, bool assertOk=true , std::string * actualServer = 0 ); virtual bool callRead( Message& toSend , Message& response ) { return checkMaster()->callRead( toSend , response ); } /** @@ -162,7 +162,7 @@ namespace mongo { * * @return true if the query/cmd could potentially be sent to a secondary, false otherwise */ - static bool isSecondaryQuery( const string& ns, + static bool isSecondaryQuery( const std::string& ns, const BSONObj& queryObj, int queryOptions ); @@ -184,7 +184,7 @@ namespace mongo { * @throws DBException if the directed node cannot accept the query because it * is not a master */ - auto_ptr<DBClientCursor> checkSlaveQueryResult( auto_ptr<DBClientCursor> result ); + std::auto_ptr<DBClientCursor> checkSlaveQueryResult( std::auto_ptr<DBClientCursor> result ); DBClientConnection * checkMaster(); @@ -224,7 +224,7 @@ namespace mongo { // Throws a DBException if the monitor doesn't exist and there isn't a cached seed to use. ReplicaSetMonitorPtr _getMonitor() const; - string _setName; + std::string _setName; HostAndPort _masterHost; // Note: reason why this is a shared_ptr is because we want _lastSlaveOkConn to @@ -247,7 +247,7 @@ namespace mongo { // we can re-auth // this could be a security issue, as the password is stored in memory // not sure if/how we should handle - std::map<string, BSONObj> _auths; // dbName -> auth parameters + std::map<std::string, BSONObj> _auths; // dbName -> auth parameters protected: diff --git a/src/mongo/client/dbclientcursor.h b/src/mongo/client/dbclientcursor.h index 2bcc8411049..527829a42ea 100644 --- a/src/mongo/client/dbclientcursor.h +++ b/src/mongo/client/dbclientcursor.h @@ -73,7 +73,7 @@ namespace mongo { /** next @return next object in the result cursor. on an error at the remote server, you will get back: - { $err: <string> } + { $err: <std::string> } if you do not want to handle that yourself, call nextSafe(). Warning: The returned BSONObj will become invalid after the next batch @@ -90,7 +90,7 @@ namespace mongo { BSONObj nextSafe() { BSONObj o = next(); if( strcmp(o.firstElementFieldName(), "$err") == 0 ) { - string s = "nextSafe(): " + o.toString(); + std::string s = "nextSafe(): " + o.toString(); LOG(5) << s; uasserted(13106, s); } @@ -102,7 +102,7 @@ namespace mongo { with what is already buffered. WARNING: no support for _putBack yet! */ - void peek(vector<BSONObj>&, int atMost); + void peek(std::vector<BSONObj>&, int atMost); // Peeks at first element, if exists BSONObj peekFirst(); @@ -145,7 +145,7 @@ namespace mongo { /// Change batchSize after construction. Can change after requesting first batch. void setBatchSize(int newBatchSize) { batchSize = newBatchSize; } - DBClientCursor( DBClientBase* client, const string &_ns, BSONObj _query, int _nToReturn, + DBClientCursor( DBClientBase* client, const std::string &_ns, BSONObj _query, int _nToReturn, int _nToSkip, const BSONObj *_fieldsToReturn, int queryOptions , int bs ) : _client(client), ns(_ns), @@ -163,7 +163,7 @@ namespace mongo { _finishConsInit(); } - DBClientCursor( DBClientBase* client, const string &_ns, long long _cursorId, int _nToReturn, int options ) : + DBClientCursor( DBClientBase* client, const std::string &_ns, long long _cursorId, int _nToReturn, int options ) : _client(client), ns(_ns), nToReturn( _nToReturn ), @@ -190,9 +190,9 @@ namespace mongo { void attach( AScopedConnection * conn ); - string originalHost() const { return _originalHost; } + std::string originalHost() const { return _originalHost; } - string getns() const { return ns; } + std::string getns() const { return ns; } Message* getMessage(){ return batch.m.get(); } @@ -216,7 +216,7 @@ namespace mongo { class Batch : boost::noncopyable { friend class DBClientCursor; - auto_ptr<Message> m; + std::auto_ptr<Message> m; int nReturned; int pos; const char *data; @@ -233,8 +233,8 @@ namespace mongo { Batch batch; DBClientBase* _client; - string _originalHost; - string ns; + std::string _originalHost; + std::string ns; BSONObj query; int nToReturn; bool haveLimit; @@ -242,16 +242,16 @@ namespace mongo { const BSONObj *fieldsToReturn; int opts; int batchSize; - stack< BSONObj > _putBack; + std::stack< BSONObj > _putBack; int resultFlags; long long cursorId; bool _ownCursor; // see decouple() - string _scopedHost; - string _lazyHost; + std::string _scopedHost; + std::string _lazyHost; bool wasError; - void dataReceived() { bool retry; string lazyHost; dataReceived( retry, lazyHost ); } - void dataReceived( bool& retry, string& lazyHost ); + void dataReceived() { bool retry; std::string lazyHost; dataReceived( retry, lazyHost ); } + void dataReceived( bool& retry, std::string& lazyHost ); void requestMore(); void exhaustReceiveMore(); // for exhaust diff --git a/src/mongo/client/dbclientinterface.h b/src/mongo/client/dbclientinterface.h index a9a34ec4662..e9b00610070 100644 --- a/src/mongo/client/dbclientinterface.h +++ b/src/mongo/client/dbclientinterface.h @@ -195,7 +195,7 @@ namespace mongo { * See syncclusterconnection.h for more info. * * tyipcal use - * string errmsg, + * std::string errmsg, * ConnectionString cs = ConnectionString::parse( url , errmsg ); * if ( ! cs.isValid() ) throw "bad: " + errmsg; * DBClientBase * conn = cs.connect( errmsg ); @@ -217,7 +217,7 @@ namespace mongo { _finishInit(); } - ConnectionString( ConnectionType type , const string& s , const string& setName = "" ) { + ConnectionString( ConnectionType type , const std::string& s , const std::string& setName = "" ) { _type = type; _setName = setName; _fillServers( s ); @@ -240,7 +240,7 @@ namespace mongo { _finishInit(); } - ConnectionString( const string& s , ConnectionType favoredMultipleType ) { + ConnectionString( const std::string& s , ConnectionType favoredMultipleType ) { _type = INVALID; _fillServers( s ); @@ -259,13 +259,13 @@ namespace mongo { bool isValid() const { return _type != INVALID; } - string toString() const { return _string; } + std::string toString() const { return _string; } - DBClientBase* connect( string& errmsg, double socketTimeout = 0 ) const; + DBClientBase* connect( std::string& errmsg, double socketTimeout = 0 ) const; - string getSetName() const { return _setName; } + std::string getSetName() const { return _setName; } - vector<HostAndPort> getServers() const { return _servers; } + std::vector<HostAndPort> getServers() const { return _servers; } ConnectionType type() const { return _type; } @@ -277,9 +277,9 @@ namespace mongo { */ bool sameLogicalEndpoint( const ConnectionString& other ) const; - static ConnectionString parse( const string& url , string& errmsg ); + static ConnectionString parse( const std::string& url , std::string& errmsg ); - static string typeToString( ConnectionType type ); + static std::string typeToString( ConnectionType type ); // // Allow overriding the default connection behavior @@ -293,7 +293,7 @@ namespace mongo { // Returns an alternative connection object for a string virtual DBClientBase* connect( const ConnectionString& c, - string& errmsg, + std::string& errmsg, double socketTimeout ) = 0; }; @@ -313,7 +313,7 @@ namespace mongo { } // - // FOR TESTING ONLY - useful to be able to directly mock a connection string without + // FOR TESTING ONLY - useful to be able to directly mock a connection std::string without // including the entire client library. // @@ -326,13 +326,13 @@ namespace mongo { private: - void _fillServers( string s ); + void _fillServers( std::string s ); void _finishInit(); ConnectionType _type; - vector<HostAndPort> _servers; - string _string; - string _setName; + std::vector<HostAndPort> _servers; + std::string _string; + std::string _setName; static mutex _connectHookMutex; static ConnectionHook* _connectHook; @@ -367,7 +367,7 @@ namespace mongo { BSONObj obj; Query() : obj(BSONObj()) { } Query(const BSONObj& b) : obj(b) { } - Query(const string &json); + Query(const std::string &json); Query(const char * json); /** Add a sort (ORDER BY) criteria to the query expression. @@ -385,7 +385,7 @@ namespace mongo { @param asc = 1 for ascending order asc = -1 for descending order */ - Query& sort(const string &field, int asc = 1) { sort( BSON( field << asc ) ); return *this; } + Query& sort(const std::string &field, int asc = 1) { sort( BSON( field << asc ) ); return *this; } /** Provide a hint to the query. @param keyPattern Key pattern for the index to use. @@ -393,7 +393,7 @@ namespace mongo { hint("{ts:1}") */ Query& hint(BSONObj keyPattern); - Query& hint(const string &jsonKeyPatt); + Query& hint(const std::string &jsonKeyPatt); /** Provide min and/or max index limits for the query. min <= x < max @@ -435,8 +435,8 @@ namespace mongo { conn.findOne("test.coll", Query("{a:3}").where("this.b == 2 || this.c == 3")); Query badBalance = Query().where("this.debits - this.credits < 0"); */ - Query& where(const string &jscode, BSONObj scope); - Query& where(const string &jscode) { return where(jscode, BSONObj()); } + Query& where(const std::string &jscode, BSONObj scope); + Query& where(const std::string &jscode) { return where(jscode, BSONObj()); } /** * Sets the read preference for this query. @@ -462,8 +462,8 @@ namespace mongo { */ static bool hasReadPreference(const BSONObj& queryObj); - string toString() const; - operator string() const { return toString(); } + std::string toString() const; + operator std::string() const { return toString(); } private: void makeComplex(); template< class T > @@ -482,7 +482,7 @@ namespace mongo { */ class MONGO_CLIENT_API QuerySpec { - string _ns; + std::string _ns; int _ntoskip; int _ntoreturn; int _options; @@ -492,7 +492,7 @@ namespace mongo { public: - QuerySpec( const string& ns, + QuerySpec( const std::string& ns, const BSONObj& query, const BSONObj& fields, int ntoskip, int ntoreturn, int options ) : _ns( ns ), _ntoskip( ntoskip ), _ntoreturn( ntoreturn ), _options( options ), @@ -515,14 +515,14 @@ namespace mongo { // don't love this, but needed downstrem const BSONObj* fieldsPtr() const { return &_fields; } - string ns() const { return _ns; } + std::string ns() const { return _ns; } int ntoskip() const { return _ntoskip; } int ntoreturn() const { return _ntoreturn; } int options() const { return _options; } void setFields( BSONObj& o ) { _fields = o.getOwned(); } - string toString() const { + std::string toString() const { return str::stream() << "QSpec " << BSON( "ns" << _ns << "n2skip" << _ntoskip << "n2return" << _ntoreturn << "options" << _options << "query" << _query << "fields" << _fields ); @@ -537,11 +537,11 @@ namespace mongo { #define QUERY(x) ::mongo::Query( BSON(x) ) // Useful utilities for namespaces - /** @return the database name portion of an ns string */ - MONGO_CLIENT_API string nsGetDB( const string &ns ); + /** @return the database name portion of an ns std::string */ + MONGO_CLIENT_API std::string nsGetDB( const std::string &ns ); - /** @return the collection name portion of an ns string */ - MONGO_CLIENT_API string nsGetCollection( const string &ns ); + /** @return the collection name portion of an ns std::string */ + MONGO_CLIENT_API std::string nsGetCollection( const std::string &ns ); /** interface that handles communication with the db @@ -550,13 +550,13 @@ namespace mongo { public: virtual ~DBConnector() {} /** actualServer is set to the actual server where they call went if there was a choice (SlaveOk) */ - virtual bool call( Message &toSend, Message &response, bool assertOk=true , string * actualServer = 0 ) = 0; - virtual void say( Message &toSend, bool isRetry = false , string * actualServer = 0 ) = 0; + virtual bool call( Message &toSend, Message &response, bool assertOk=true , std::string * actualServer = 0 ) = 0; + virtual void say( Message &toSend, bool isRetry = false , std::string * actualServer = 0 ) = 0; virtual void sayPiggyBack( Message &toSend ) = 0; /* used by QueryOption_Exhaust. To use that your subclass must implement this. */ virtual bool recv( Message& m ) { verify(false); return false; } // In general, for lazy queries, we'll need to say, recv, then checkResponse - virtual void checkResponse( const char* data, int nReturned, bool* retry = NULL, string* targetHost = NULL ) { + virtual void checkResponse( const char* data, int nReturned, bool* retry = NULL, std::string* targetHost = NULL ) { if( retry ) *retry = false; if( targetHost ) *targetHost = ""; } virtual bool lazySupported() const = 0; @@ -567,23 +567,23 @@ namespace mongo { */ class MONGO_CLIENT_API DBClientInterface : boost::noncopyable { public: - virtual auto_ptr<DBClientCursor> query(const string &ns, Query query, int nToReturn = 0, int nToSkip = 0, + virtual std::auto_ptr<DBClientCursor> query(const std::string &ns, Query query, int nToReturn = 0, int nToSkip = 0, const BSONObj *fieldsToReturn = 0, int queryOptions = 0 , int batchSize = 0 ) = 0; - virtual void insert( const string &ns, BSONObj obj , int flags=0) = 0; + virtual void insert( const std::string &ns, BSONObj obj , int flags=0) = 0; - virtual void insert( const string &ns, const vector< BSONObj >& v , int flags=0) = 0; + virtual void insert( const std::string &ns, const std::vector< BSONObj >& v , int flags=0) = 0; - virtual void remove( const string &ns , Query query, bool justOne = 0 ) = 0; + virtual void remove( const std::string &ns , Query query, bool justOne = 0 ) = 0; - virtual void remove( const string &ns , Query query, int flags ) = 0; + virtual void remove( const std::string &ns , Query query, int flags ) = 0; - virtual void update( const string &ns, + virtual void update( const std::string &ns, Query query, BSONObj obj, bool upsert = false, bool multi = false ) = 0; - virtual void update( const string &ns, Query query, BSONObj obj, int flags ) = 0; + virtual void update( const std::string &ns, Query query, BSONObj obj, int flags ) = 0; virtual ~DBClientInterface() { } @@ -591,17 +591,17 @@ namespace mongo { @return a single object that matches the query. if none do, then the object is empty @throws AssertionException */ - virtual BSONObj findOne(const string &ns, const Query& query, const BSONObj *fieldsToReturn = 0, int queryOptions = 0); + virtual BSONObj findOne(const std::string &ns, const Query& query, const BSONObj *fieldsToReturn = 0, int queryOptions = 0); /** query N objects from the database into an array. makes sense mostly when you want a small number of results. if a huge number, use query() and iterate the cursor. */ - void findN(vector<BSONObj>& out, const string&ns, Query query, int nToReturn, int nToSkip = 0, const BSONObj *fieldsToReturn = 0, int queryOptions = 0); + void findN(std::vector<BSONObj>& out, const std::string &ns, Query query, int nToReturn, int nToSkip = 0, const BSONObj *fieldsToReturn = 0, int queryOptions = 0); - virtual string getServerAddress() const = 0; + virtual std::string getServerAddress() const = 0; /** don't use this - called automatically by DBClientCursor for you */ - virtual auto_ptr<DBClientCursor> getMore( const string &ns, long long cursorId, int nToReturn = 0, int options = 0 ) = 0; + virtual std::auto_ptr<DBClientCursor> getMore( const std::string &ns, long long cursorId, int nToReturn = 0, int options = 0 ) = 0; }; /** @@ -609,7 +609,7 @@ namespace mongo { Basically just invocations of connection.$cmd.findOne({...}); */ class MONGO_CLIENT_API DBClientWithCommands : public DBClientInterface { - set<string> _seenIndexes; + std::set<std::string> _seenIndexes; public: /** controls how chatty the client is about network errors & such. See log.h */ logger::LogSeverity _logLevel; @@ -624,7 +624,7 @@ namespace mongo { @param command -- command name @return true if the command returned "ok". */ - bool simpleCommand(const string &dbname, BSONObj *info, const string &command); + bool simpleCommand(const std::string &dbname, BSONObj *info, const std::string &command); /** Run a database command. Database commands are represented as BSON objects. Common database commands have prebuilt helper functions -- see below. If a helper is not available you can @@ -639,7 +639,7 @@ namespace mongo { @return true if the command returned "ok". */ - virtual bool runCommand(const string &dbname, const BSONObj& cmd, BSONObj &info, + virtual bool runCommand(const std::string &dbname, const BSONObj& cmd, BSONObj &info, int options=0); /** @@ -648,8 +648,8 @@ namespace mongo { * The "params" BSONObj should be initialized with some of the fields below. Which fields * are required depends on the mechanism, which is mandatory. * - * "mechanism": The string name of the sasl mechanism to use. Mandatory. - * "user": The string name of the user to authenticate. Mandatory. + * "mechanism": The std::string name of the sasl mechanism to use. Mandatory. + * "user": The std::string name of the user to authenticate. Mandatory. * "db": The database target of the auth command, which identifies the location * of the credential information for the user. May be "$external" if * credential information is stored outside of the mongo cluster. Mandatory. @@ -676,7 +676,7 @@ namespace mongo { @param[out] authLevel level of authentication for the given user @return true if successful */ - bool auth(const string &dbname, const string &username, const string &pwd, string& errmsg, bool digestPassword = true); + bool auth(const std::string &dbname, const std::string &username, const std::string &pwd, std::string& errmsg, bool digestPassword = true); /** * Logs out the connection for the given database. @@ -685,14 +685,14 @@ namespace mongo { * @param info the result object for the logout command (provided for backwards * compatibility with mongo shell) */ - virtual void logout(const string& dbname, BSONObj& info); + virtual void logout(const std::string& dbname, BSONObj& info); /** count number of objects in collection ns that match the query criteria specified throws UserAssertion if database returns an error */ - virtual unsigned long long count(const string &ns, const BSONObj& query = BSONObj(), int options=0, int limit=0, int skip=0 ); + virtual unsigned long long count(const std::string &ns, const BSONObj& query = BSONObj(), int options=0, int limit=0, int skip=0 ); - static string createPasswordDigest(const string &username, const string &clearTextPassword); + static std::string createPasswordDigest(const std::string &username, const std::string &clearTextPassword); /** returns true in isMaster parm if this db is the current master of a replica pair. @@ -720,13 +720,13 @@ namespace mongo { returns true if successful. */ - bool createCollection(const string &ns, long long size = 0, bool capped = false, int max = 0, BSONObj *info = 0); + bool createCollection(const std::string &ns, long long size = 0, bool capped = false, int max = 0, BSONObj *info = 0); /** Get error result from the last write operation (insert/update/delete) on this connection. db doesn't change the command's behavior - it is just for auth checks. - @return error message text, or empty string if no error. + @return error message text, or empty std::string if no error. */ - string getLastError(const std::string& db, + std::string getLastError(const std::string& db, bool fsync = false, bool j = false, int w = 0, @@ -734,7 +734,7 @@ namespace mongo { /** * Same as the form of getLastError that takes a dbname, but just uses the admin DB. */ - string getLastError(bool fsync = false, bool j = false, int w = 0, int wtimeout = 0); + std::string getLastError(bool fsync = false, bool j = false, int w = 0, int wtimeout = 0); /** Get error result from the last write operation (insert/update/delete) on this connection. db doesn't change the command's behavior - it is just for auth checks. @@ -756,7 +756,7 @@ namespace mongo { /** Can be called with the returned value from getLastErrorDetailed to extract an error string. If all you need is the string, just call getLastError() instead. */ - static string getLastErrorString( const BSONObj& res ); + static std::string getLastErrorString( const BSONObj& res ); /** Return the last error which has occurred, even if not the very last operation. @@ -776,9 +776,9 @@ namespace mongo { * @param info An optional output parameter that receives the result object the database * returns from the drop command. May be null if the caller doesn't need that info. */ - virtual bool dropCollection( const string &ns, BSONObj* info = NULL ) { - string db = nsGetDB( ns ); - string coll = nsGetCollection( ns ); + virtual bool dropCollection( const std::string &ns, BSONObj* info = NULL ) { + std::string db = nsGetDB( ns ); + std::string coll = nsGetCollection( ns ); uassert( 10011 , "no collection name", coll.size() ); BSONObj temp; @@ -794,7 +794,7 @@ namespace mongo { /** Perform a repair and compaction of the specified database. May take a long time to run. Disk space must be available equal to the size of the database while repairing. */ - bool repairDatabase(const string &dbname, BSONObj *info = 0) { + bool repairDatabase(const std::string &dbname, BSONObj *info = 0) { return simpleCommand(dbname, info, "repairDatabase"); } @@ -817,7 +817,7 @@ namespace mongo { returns true if successful */ - bool copyDatabase(const string &fromdb, const string &todb, const string &fromhost = "", BSONObj *info = 0); + bool copyDatabase(const std::string &fromdb, const std::string &todb, const std::string &fromhost = "", BSONObj *info = 0); /** The Mongo database provides built-in performance profiling capabilities. Uset setDbProfilingLevel() to enable. Profiling information is then written to the system.profile collection, which one can @@ -829,8 +829,8 @@ namespace mongo { ProfileAll = 2 }; - bool setDbProfilingLevel(const string &dbname, ProfilingLevel level, BSONObj *info = 0); - bool getDbProfilingLevel(const string &dbname, ProfilingLevel& level, BSONObj *info = 0); + bool setDbProfilingLevel(const std::string &dbname, ProfilingLevel level, BSONObj *info = 0); + bool getDbProfilingLevel(const std::string &dbname, ProfilingLevel& level, BSONObj *info = 0); /** This implicitly converts from char*, string, and BSONObj to be an argument to mapreduce @@ -838,7 +838,7 @@ namespace mongo { */ struct MROutput { MROutput(const char* collection) : out(BSON("replace" << collection)) {} - MROutput(const string& collection) : out(BSON("replace" << collection)) {} + MROutput(const std::string& collection) : out(BSON("replace" << collection)) {} MROutput(const BSONObj& obj) : out(obj) {} BSONObj out; @@ -853,7 +853,7 @@ namespace mongo { jsmapf javascript map function code jsreducef javascript reduce function code. query optional query filter for the input - output either a string collection name or an object representing output type + output either a std::string collection name or an object representing output type if not specified uses inline output type returns a result object which contains: @@ -868,7 +868,7 @@ namespace mongo { result.getField("ok").trueValue() on the result to check if ok. */ - BSONObj mapreduce(const string &ns, const string &jsmapf, const string &jsreducef, BSONObj query = BSONObj(), MROutput output = MRInline); + BSONObj mapreduce(const std::string &ns, const std::string &jsmapf, const std::string &jsreducef, BSONObj query = BSONObj(), MROutput output = MRInline); /** Run javascript code on the database server. dbname database SavedContext in which the code runs. The javascript variable 'db' will be assigned @@ -885,12 +885,12 @@ namespace mongo { See testDbEval() in dbclient.cpp for an example of usage. */ - bool eval(const string &dbname, const string &jscode, BSONObj& info, BSONElement& retValue, BSONObj *args = 0); + bool eval(const std::string &dbname, const std::string &jscode, BSONObj& info, BSONElement& retValue, BSONObj *args = 0); /** validate a collection, checking for errors and reporting back statistics. this operation is slow and blocking. */ - bool validate( const string &ns , bool scandata=true ) { + bool validate( const std::string &ns , bool scandata=true ) { BSONObj cmd = BSON( "validate" << nsGetCollection( ns ) << "scandata" << scandata ); BSONObj info; return runCommand( nsGetDB( ns ).c_str() , cmd , info ); @@ -899,9 +899,9 @@ namespace mongo { /* The following helpers are simply more convenient forms of eval() for certain common cases */ /* invocation with no return value of interest -- with or without one simple parameter */ - bool eval(const string &dbname, const string &jscode); + bool eval(const std::string &dbname, const std::string &jscode); template< class T > - bool eval(const string &dbname, const string &jscode, T parm1) { + bool eval(const std::string &dbname, const std::string &jscode, T parm1) { BSONObj info; BSONElement retValue; BSONObjBuilder b; @@ -912,7 +912,7 @@ namespace mongo { /** eval invocation with one parm to server and one numeric field (either int or double) returned */ template< class T, class NumType > - bool eval(const string &dbname, const string &jscode, T parm1, NumType& ret) { + bool eval(const std::string &dbname, const std::string &jscode, T parm1, NumType& ret) { BSONObj info; BSONElement retValue; BSONObjBuilder b; @@ -929,14 +929,14 @@ namespace mongo { uses the { listDatabases : 1 } command. throws on error */ - list<string> getDatabaseNames(); + std::list<std::string> getDatabaseNames(); /** get a list of all the current collections in db */ - list<string> getCollectionNames( const string& db ); + std::list<std::string> getCollectionNames( const std::string& db ); - bool exists( const string& ns ); + bool exists( const std::string& ns ); /** Create an index if it does not already exist. ensureIndex calls are remembered so it is safe/fast to call this function many @@ -952,10 +952,10 @@ namespace mongo { @return whether or not sent message to db. should be true on first call, false on subsequent unless resetIndexCache was called */ - virtual bool ensureIndex( const string &ns, + virtual bool ensureIndex( const std::string &ns, BSONObj keys, bool unique = false, - const string &name = "", + const std::string &name = "", bool cache = true, bool background = false, int v = -1, @@ -965,28 +965,28 @@ namespace mongo { */ virtual void resetIndexCache(); - virtual auto_ptr<DBClientCursor> getIndexes( const string &ns ); + virtual std::auto_ptr<DBClientCursor> getIndexes( const std::string &ns ); - virtual void dropIndex( const string& ns , BSONObj keys ); - virtual void dropIndex( const string& ns , const string& indexName ); + virtual void dropIndex( const std::string& ns , BSONObj keys ); + virtual void dropIndex( const std::string& ns , const std::string& indexName ); /** drops all indexes for the collection */ - virtual void dropIndexes( const string& ns ); + virtual void dropIndexes( const std::string& ns ); - virtual void reIndex( const string& ns ); + virtual void reIndex( const std::string& ns ); - string genIndexName( const BSONObj& keys ); + std::string genIndexName( const BSONObj& keys ); /** Erase / drop an entire database */ - virtual bool dropDatabase(const string &dbname, BSONObj *info = 0) { + virtual bool dropDatabase(const std::string &dbname, BSONObj *info = 0) { bool ret = simpleCommand(dbname, info, "dropDatabase"); resetIndexCache(); return ret; } - virtual string toString() const = 0; + virtual std::string toString() const = 0; /** * A function type for runCommand hooking; the function takes a pointer @@ -1019,7 +1019,7 @@ namespace mongo { /** if the element contains a not master error */ bool isNotMasterErrorString( const BSONElement& e ); - BSONObj _countCmd(const string &ns, const BSONObj& query, int options, int limit, int skip ); + BSONObj _countCmd(const std::string &ns, const BSONObj& query, int options, int limit, int skip ); /** * Look up the options available on this client. Caches the answer from @@ -1036,9 +1036,9 @@ namespace mongo { * with the given password. If digestPassword is false, the password is assumed to be * pre-digested. Returns false on failure, and sets "errmsg". */ - bool _authMongoCR(const string &dbname, - const string &username, - const string &pwd, + bool _authMongoCR(const std::string &dbname, + const std::string &username, + const std::string &pwd, BSONObj *info, bool digestPassword); @@ -1047,8 +1047,8 @@ namespace mongo { * has already been communicated automatically as part of the connect call. * Returns false on failure and set "errmsg". */ - bool _authX509(const string&dbname, - const string &username, + bool _authX509(const std::string &dbname, + const std::string &username, BSONObj *info); /** @@ -1109,7 +1109,7 @@ namespace mongo { @return cursor. 0 if error (connection failure) @throws AssertionException */ - virtual auto_ptr<DBClientCursor> query(const string &ns, Query query, int nToReturn = 0, int nToSkip = 0, + virtual std::auto_ptr<DBClientCursor> query(const std::string &ns, Query query, int nToReturn = 0, int nToSkip = 0, const BSONObj *fieldsToReturn = 0, int queryOptions = 0 , int batchSize = 0 ); @@ -1122,13 +1122,13 @@ namespace mongo { blocks, perhaps to avoid granular locking and such. */ virtual unsigned long long query( stdx::function<void(const BSONObj&)> f, - const string& ns, + const std::string& ns, Query query, const BSONObj *fieldsToReturn = 0, int queryOptions = 0 ); virtual unsigned long long query( stdx::function<void(DBClientCursorBatchIterator&)> f, - const string& ns, + const std::string& ns, Query query, const BSONObj *fieldsToReturn = 0, int queryOptions = 0 ); @@ -1139,35 +1139,35 @@ namespace mongo { @return an handle to a previously allocated cursor @throws AssertionException */ - virtual auto_ptr<DBClientCursor> getMore( const string &ns, long long cursorId, int nToReturn = 0, int options = 0 ); + virtual std::auto_ptr<DBClientCursor> getMore( const std::string &ns, long long cursorId, int nToReturn = 0, int options = 0 ); /** insert an object into the database */ - virtual void insert( const string &ns , BSONObj obj , int flags=0); + virtual void insert( const std::string &ns , BSONObj obj , int flags=0); /** insert a vector of objects into the database */ - virtual void insert( const string &ns, const vector< BSONObj >& v , int flags=0); + virtual void insert( const std::string &ns, const std::vector< BSONObj >& v , int flags=0); /** updates objects matching query */ - virtual void update( const string &ns, + virtual void update( const std::string &ns, Query query, BSONObj obj, bool upsert = false, bool multi = false ); - virtual void update( const string &ns, Query query, BSONObj obj, int flags ); + virtual void update( const std::string &ns, Query query, BSONObj obj, int flags ); /** remove matching objects from the database @param justOne if this true, then once a single match is found will stop */ - virtual void remove( const string &ns , Query q , bool justOne = 0 ); + virtual void remove( const std::string &ns , Query q , bool justOne = 0 ); - virtual void remove( const string &ns , Query query, int flags ); + virtual void remove( const std::string &ns , Query query, int flags ); virtual bool isFailed() const = 0; @@ -1195,7 +1195,7 @@ namespace mongo { class MONGO_CLIENT_API ConnectException : public UserException { public: - ConnectException(string msg) : UserException(9000,msg) { } + ConnectException(std::string msg) : UserException(9000,msg) { } }; /** @@ -1232,7 +1232,7 @@ namespace mongo { @deprecated please use HostAndPort @return false if fails to connect. */ - virtual bool connect(const char * hostname, string& errmsg) { + virtual bool connect(const char * hostname, std::string& errmsg) { // TODO: remove this method HostAndPort t( hostname ); return connect( t , errmsg ); @@ -1247,7 +1247,7 @@ namespace mongo { @param errmsg any relevant error message will appended to the string @return false if fails to connect. */ - virtual bool connect(const HostAndPort& server, string& errmsg); + virtual bool connect(const HostAndPort& server, std::string& errmsg); /** Connect to a Mongo database server. Exception throwing version. Throws a UserException if cannot connect. @@ -1257,10 +1257,10 @@ namespace mongo { @param serverHostname host to connect to. can include port number ( 127.0.0.1 , 127.0.0.1:5555 ) */ - void connect(const string& serverHostname) { - string errmsg; + void connect(const std::string& serverHostname) { + std::string errmsg; if( !connect(HostAndPort(serverHostname), errmsg) ) - throw ConnectException(string("can't connect ") + errmsg); + throw ConnectException(std::string("can't connect ") + errmsg); } /** @@ -1270,21 +1270,21 @@ namespace mongo { * @param info the result object for the logout command (provided for backwards * compatibility with mongo shell) */ - virtual void logout(const string& dbname, BSONObj& info); + virtual void logout(const std::string& dbname, BSONObj& info); - virtual auto_ptr<DBClientCursor> query(const string &ns, Query query=Query(), int nToReturn = 0, int nToSkip = 0, + virtual std::auto_ptr<DBClientCursor> query(const std::string &ns, Query query=Query(), int nToReturn = 0, int nToSkip = 0, const BSONObj *fieldsToReturn = 0, int queryOptions = 0 , int batchSize = 0 ) { checkConnection(); return DBClientBase::query( ns, query, nToReturn, nToSkip, fieldsToReturn, queryOptions , batchSize ); } virtual unsigned long long query( stdx::function<void(DBClientCursorBatchIterator &)> f, - const string& ns, + const std::string& ns, Query query, const BSONObj *fieldsToReturn, int queryOptions ); - virtual bool runCommand(const string &dbname, + virtual bool runCommand(const std::string &dbname, const BSONObj& cmd, BSONObj &info, int options=0); @@ -1299,22 +1299,22 @@ namespace mongo { MessagingPort& port() { verify(p); return *p; } - string toString() const { - stringstream ss; + std::string toString() const { + std::stringstream ss; ss << _serverString; if ( !_serverAddrString.empty() ) ss << " (" << _serverAddrString << ")"; if ( _failed ) ss << " failed"; return ss.str(); } - string getServerAddress() const { return _serverString; } + std::string getServerAddress() const { return _serverString; } virtual void killCursor( long long cursorID ); virtual bool callRead( Message& toSend , Message& response ) { return call( toSend , response ); } - virtual void say( Message &toSend, bool isRetry = false , string * actualServer = 0 ); + virtual void say( Message &toSend, bool isRetry = false , std::string * actualServer = 0 ); virtual bool recv( Message& m ); - virtual void checkResponse( const char *data, int nReturned, bool* retry = NULL, string* host = NULL ); - virtual bool call( Message &toSend, Message &response, bool assertOk = true , string * actualServer = 0 ); + virtual void checkResponse( const char *data, int nReturned, bool* retry = NULL, std::string* host = NULL ); + virtual bool call( Message &toSend, Message &response, bool assertOk = true , std::string * actualServer = 0 ); virtual ConnectionString::ConnectionType type() const { return ConnectionString::MASTER; } void setSoTimeout(double timeout); double getSoTimeout() const { return _so_timeout; } @@ -1354,16 +1354,16 @@ namespace mongo { const bool autoReconnect; Backoff autoReconnectBackoff; HostAndPort _server; // remember for reconnects - string _serverString; // server host and port - string _serverAddrString; // resolved ip of server + std::string _serverString; // server host and port + std::string _serverAddrString; // resolved ip of server void _checkConnection(); // throws SocketException if in failed state and not reconnecting or if waiting to reconnect void checkConnection() { if( _failed ) _checkConnection(); } - map<string, BSONObj> authCache; + std::map<std::string, BSONObj> authCache; double _so_timeout; - bool _connect( string& errmsg ); + bool _connect( std::string& errmsg ); static AtomicInt32 _numConnections; static bool _lazyKillCursor; // lazy means we piggy back kill cursors on next op @@ -1375,7 +1375,7 @@ namespace mongo { /** pings server to check if it's up */ - MONGO_CLIENT_API bool serverAlive( const string &uri ); + MONGO_CLIENT_API bool serverAlive( const std::string &uri ); MONGO_CLIENT_API DBClientBase * createDirectClient(); diff --git a/src/mongo/client/gridfs.h b/src/mongo/client/gridfs.h index d7f3f3357cb..952b14b3cc7 100644 --- a/src/mongo/client/gridfs.h +++ b/src/mongo/client/gridfs.h @@ -73,7 +73,7 @@ namespace mongo { * @param dbName - root database name * @param prefix - if you want your data somewhere besides <dbname>.fs */ - GridFS( DBClientBase& client , const string& dbName , const string& prefix="fs" ); + GridFS( DBClientBase& client , const std::string& dbName , const std::string& prefix="fs" ); ~GridFS(); /** @@ -92,7 +92,7 @@ namespace mongo { * (default is to omit) * @return the file object */ - BSONObj storeFile( const string& fileName , const string& remoteName="" , const string& contentType=""); + BSONObj storeFile( const std::string& fileName , const std::string& remoteName="" , const std::string& contentType=""); /** * puts the file represented by data into the db @@ -103,14 +103,14 @@ namespace mongo { * (default is to omit) * @return the file object */ - BSONObj storeFile( const char* data , size_t length , const string& remoteName , const string& contentType=""); + BSONObj storeFile( const char* data , size_t length , const std::string& remoteName , const std::string& contentType=""); /** * removes file referenced by fileName from the db * @param fileName filename (in GridFS) of the file to remove * @return the file object */ - void removeFile( const string& fileName ); + void removeFile( const std::string& fileName ); /** * returns a file object matching the query @@ -120,28 +120,28 @@ namespace mongo { /** * equiv to findFile( { filename : filename } ) */ - GridFile findFile( const string& fileName ) const; + GridFile findFile( const std::string& fileName ) const; /** * convenience method to get all the files */ - auto_ptr<DBClientCursor> list() const; + std::auto_ptr<DBClientCursor> list() const; /** * convenience method to get all the files with a filter */ - auto_ptr<DBClientCursor> list( BSONObj query ) const; + std::auto_ptr<DBClientCursor> list( BSONObj query ) const; private: DBClientBase& _client; - string _dbName; - string _prefix; - string _filesNS; - string _chunksNS; + std::string _dbName; + std::string _prefix; + std::string _filesNS; + std::string _chunksNS; unsigned int _chunkSize; // insert fileobject. All chunks must be in DB. - BSONObj insertFile(const string& name, const OID& id, gridfs_offset length, const string& contentType); + BSONObj insertFile(const std::string& name, const OID& id, gridfs_offset length, const std::string& contentType); friend class GridFile; }; @@ -159,7 +159,7 @@ namespace mongo { return ! _obj.isEmpty(); } - string getFilename() const { + std::string getFilename() const { return _obj["filename"].str(); } @@ -171,7 +171,7 @@ namespace mongo { return (gridfs_offset)(_obj["length"].number()); } - string getContentType() const { + std::string getContentType() const { return _obj["contentType"].valuestr(); } @@ -179,11 +179,11 @@ namespace mongo { return _obj["uploadDate"].date(); } - string getMD5() const { + std::string getMD5() const { return _obj["md5"].str(); } - BSONElement getFileField( const string& name ) const { + BSONElement getFileField( const std::string& name ) const { return _obj[name]; } @@ -198,12 +198,12 @@ namespace mongo { /** write the file to the output stream */ - gridfs_offset write( ostream & out ) const; + gridfs_offset write( std::ostream & out ) const; /** write the file to this filename */ - gridfs_offset write( const string& where ) const; + gridfs_offset write( const std::string& where ) const; private: GridFile(const GridFS * grid , BSONObj obj ); diff --git a/src/mongo/client/parallel.h b/src/mongo/client/parallel.h index f90e29c0a26..1f9e88f3eb4 100644 --- a/src/mongo/client/parallel.h +++ b/src/mongo/client/parallel.h @@ -48,7 +48,7 @@ namespace mongo { */ class MONGO_CLIENT_API ServerAndQuery { public: - ServerAndQuery( const string& server , BSONObj extra = BSONObj() , BSONObj orderObject = BSONObj() ) : + ServerAndQuery( const std::string& server , BSONObj extra = BSONObj() , BSONObj orderObject = BSONObj() ) : _server( server ) , _extra( extra.getOwned() ) , _orderObject( orderObject.getOwned() ) { } @@ -63,17 +63,17 @@ namespace mongo { return _extra.woCompare( other._extra ) < 0; } - string toString() const { + std::string toString() const { StringBuilder ss; ss << "server:" << _server << " _extra:" << _extra.toString() << " _orderObject:" << _orderObject.toString(); return ss.str(); } - operator string() const { + operator std::string() const { return toString(); } - string _server; + std::string _server; BSONObj _extra; BSONObj _orderObject; }; @@ -83,17 +83,17 @@ namespace mongo { class MONGO_CLIENT_API CommandInfo { public: - string versionedNS; + std::string versionedNS; BSONObj cmdFilter; CommandInfo() {} - CommandInfo( const string& vns, const BSONObj& filter ) : versionedNS( vns ), cmdFilter( filter ) {} + CommandInfo( const std::string& vns, const BSONObj& filter ) : versionedNS( vns ), cmdFilter( filter ) {} bool isEmpty(){ return versionedNS.size() == 0; } - string toString() const { + std::string toString() const { return str::stream() << "CInfo " << BSON( "v_ns" << versionedNS << "filter" << cmdFilter ); } }; @@ -122,7 +122,7 @@ namespace mongo { BSONObj toBSON() const; - string toString() const { + std::string toString() const { return str::stream() << "PCState : " << toBSON(); } }; @@ -154,7 +154,7 @@ namespace mongo { BSONObj toBSON() const; - string toString() const { + std::string toString() const { return str::stream() << "PCMData : " << toBSON(); } }; @@ -180,7 +180,7 @@ namespace mongo { ParallelSortClusteredCursor( const QuerySpec& qSpec, const CommandInfo& cInfo = CommandInfo() ); // DEPRECATED legacy constructor for pure mergesort functionality - do not use - ParallelSortClusteredCursor( const set<ServerAndQuery>& servers , const string& ns , + ParallelSortClusteredCursor( const std::set<ServerAndQuery>& servers , const std::string& ns , const Query& q , int options=0, const BSONObj& fields=BSONObj() ); ~ParallelSortClusteredCursor(); @@ -192,7 +192,7 @@ namespace mongo { bool more(); BSONObj next(); - string type() const { return "ParallelSort"; } + std::string type() const { return "ParallelSort"; } void fullInit(); void startInit(); @@ -204,19 +204,19 @@ namespace mongo { bool isSharded(); ShardPtr getPrimary(); - void getQueryShards( set<Shard>& shards ); + void getQueryShards( std::set<Shard>& shards ); ChunkManagerPtr getChunkManager( const Shard& shard ); DBClientCursorPtr getShardCursor( const Shard& shard ); BSONObj toBSON() const; - string toString() const; + std::string toString() const; void explain(BSONObjBuilder& b); private: void _finishCons(); - void _explain( map< string,list<BSONObj> >& out ); + void _explain( std::map< std::string,std::list<BSONObj> >& out ); void _markStaleNS( const NamespaceString& staleNS, const StaleConfigException& e, bool& forceReload, bool& fullReload ); void _handleStaleNS( const NamespaceString& staleNS, bool forceReload, bool fullReload ); @@ -224,20 +224,20 @@ namespace mongo { bool _didInit; bool _done; - set<Shard> _qShards; + std::set<Shard> _qShards; QuerySpec _qSpec; CommandInfo _cInfo; // Count round-trips req'd for namespaces and total - map<string,int> _staleNSMap; + std::map<std::string,int> _staleNSMap; int _totalTries; - map<Shard,PCMData> _cursorMap; + std::map<Shard,PCMData> _cursorMap; // LEGACY BELOW int _numServers; int _lastFrom; - set<ServerAndQuery> _servers; + std::set<ServerAndQuery> _servers; BSONObj _sortKey; FilteringClientCursor * _cursors; @@ -259,7 +259,7 @@ namespace mongo { void _oldInit(); // LEGACY - Needed ONLY for _oldInit - string _ns; + std::string _ns; BSONObj _query; int _options; BSONObj _fields; @@ -273,7 +273,7 @@ namespace mongo { FilteringClientCursor(); ~FilteringClientCursor(); - void reset( auto_ptr<DBClientCursor> cursor ); + void reset( std::auto_ptr<DBClientCursor> cursor ); void reset( DBClientCursor* cursor, ParallelConnectionMetadata* _pcmData = NULL ); bool more(); @@ -293,7 +293,7 @@ namespace mongo { private: void _advance(); - auto_ptr<DBClientCursor> _cursor; + std::auto_ptr<DBClientCursor> _cursor; ParallelConnectionMetadata* _pcmData; BSONObj _next; @@ -313,7 +313,7 @@ namespace mongo { class CommandResult { public: - string getServer() const { return _server; } + std::string getServer() const { return _server; } bool isDone() const { return _done; } @@ -335,16 +335,16 @@ namespace mongo { private: - CommandResult( const string& server, - const string& db, + CommandResult( const std::string& server, + const std::string& db, const BSONObj& cmd, int options, DBClientBase * conn, bool useShardedConn ); void init(); - string _server; - string _db; + std::string _server; + std::string _db; int _options; BSONObj _cmd; DBClientBase * _conn; @@ -368,8 +368,8 @@ namespace mongo { * @param conn optional connection to use. will use standard pooled if non-specified * @param useShardConn use ShardConnection */ - static shared_ptr<CommandResult> spawnCommand( const string& server, - const string& db, + static shared_ptr<CommandResult> spawnCommand( const std::string& server, + const std::string& db, const BSONObj& cmd, int options, DBClientBase * conn = 0, diff --git a/src/mongo/client/replica_set_monitor.h b/src/mongo/client/replica_set_monitor.h index 5641607ef52..3e289b9c65c 100644 --- a/src/mongo/client/replica_set_monitor.h +++ b/src/mongo/client/replica_set_monitor.h @@ -119,7 +119,7 @@ namespace mongo { std::string getName() const; /** - * Returns a string with the format name/server1,server2. + * Returns a std::string with the format name/server1,server2. * If name is empty, returns just comma-separated list of servers. */ std::string getServerAddress() const; @@ -153,7 +153,7 @@ namespace mongo { /** * Removes the ReplicaSetMonitor for the given set name from _sets, which will delete it. - * If clearSeedCache is true, then the cached seed string for this Replica Set will be + * If clearSeedCache is true, then the cached seed std::string for this Replica Set will be * removed from _seedServers. */ static void remove(const std::string& name, bool clearSeedCache = false); diff --git a/src/mongo/client/sasl_client_authenticate.h b/src/mongo/client/sasl_client_authenticate.h index 062543691b9..e12649bee95 100644 --- a/src/mongo/client/sasl_client_authenticate.h +++ b/src/mongo/client/sasl_client_authenticate.h @@ -49,11 +49,11 @@ namespace mongo { * fields below. Which fields are required depends on the mechanism. Consult the * relevant IETF standards. * - * "mechanism": The string name of the sasl mechanism to use. Mandatory. + * "mechanism": The std::string name of the sasl mechanism to use. Mandatory. * "autoAuthorize": Truthy values tell the server to automatically acquire privileges on * all resources after successful authentication, which is the default. Falsey values * instruct the server to await separate privilege-acquisition commands. - * "user": The string name of the user to authenticate. + * "user": The std::string name of the user to authenticate. * "db": The database target of the auth command, which identifies the location * of the credential information for the user. May be "$external" if credential * information is stored outside of the mongo cluster. @@ -83,10 +83,10 @@ namespace mongo { // Constants - /// String name of the saslStart command. + /// std::string name of the saslStart command. extern MONGO_CLIENT_API const char* const saslStartCommandName; - /// String name of the saslContinue command. + /// std::string name of the saslContinue command. extern MONGO_CLIENT_API const char* const saslContinueCommandName; /// Name of the saslStart parameter indicating that the server should automatically grant the @@ -120,11 +120,11 @@ namespace mongo { /// Field containing sasl payloads passed to and from the server. extern MONGO_CLIENT_API const char* const saslCommandPayloadFieldName; - /// Field containing the string identifier of the user to authenticate in + /// Field containing the std::string identifier of the user to authenticate in /// saslClientAuthenticate(). extern MONGO_CLIENT_API const char* const saslCommandUserFieldName; - /// Field containing the string identifier of the database containing credential information, + /// Field containing the std::string identifier of the database containing credential information, /// or "$external" if the credential information is stored outside of the mongo cluster. extern MONGO_CLIENT_API const char* const saslCommandUserDBFieldName; diff --git a/src/mongo/client/syncclusterconnection.h b/src/mongo/client/syncclusterconnection.h index 959fbe55fde..92c79f50232 100644 --- a/src/mongo/client/syncclusterconnection.h +++ b/src/mongo/client/syncclusterconnection.h @@ -64,8 +64,8 @@ namespace mongo { /** * @param commaSeparated should be 3 hosts comma separated */ - SyncClusterConnection( const list<HostAndPort> &, double socketTimeout = 0); - SyncClusterConnection( string commaSeparated, double socketTimeout = 0); + SyncClusterConnection( const std::list<HostAndPort> &, double socketTimeout = 0); + SyncClusterConnection( std::string commaSeparated, double socketTimeout = 0); SyncClusterConnection( const std::string& a, const std::string& b, const std::string& c, @@ -75,40 +75,40 @@ namespace mongo { /** * @return true if all servers are up and ready for writes */ - bool prepare( string& errmsg ); + bool prepare( std::string& errmsg ); /** * runs fsync on all servers */ - bool fsync( string& errmsg ); + bool fsync( std::string& errmsg ); // --- from DBClientInterface - virtual BSONObj findOne(const string &ns, const Query& query, const BSONObj *fieldsToReturn, int queryOptions); + virtual BSONObj findOne(const std::string &ns, const Query& query, const BSONObj *fieldsToReturn, int queryOptions); - virtual auto_ptr<DBClientCursor> query(const string &ns, Query query, int nToReturn, int nToSkip, + virtual std::auto_ptr<DBClientCursor> query(const std::string &ns, Query query, int nToReturn, int nToSkip, const BSONObj *fieldsToReturn, int queryOptions, int batchSize ); - virtual auto_ptr<DBClientCursor> getMore( const string &ns, long long cursorId, int nToReturn, int options ); + virtual std::auto_ptr<DBClientCursor> getMore( const std::string &ns, long long cursorId, int nToReturn, int options ); - virtual void insert( const string &ns, BSONObj obj, int flags=0); + virtual void insert( const std::string &ns, BSONObj obj, int flags=0); - virtual void insert( const string &ns, const vector< BSONObj >& v, int flags=0); + virtual void insert( const std::string &ns, const std::vector< BSONObj >& v, int flags=0); - virtual void remove( const string &ns , Query query, int flags ); + virtual void remove( const std::string &ns , Query query, int flags ); - virtual void update( const string &ns , Query query , BSONObj obj , int flags ); + virtual void update( const std::string &ns , Query query , BSONObj obj , int flags ); - virtual bool call( Message &toSend, Message &response, bool assertOk , string * actualServer ); - virtual void say( Message &toSend, bool isRetry = false , string * actualServer = 0 ); + virtual bool call( Message &toSend, Message &response, bool assertOk , std::string * actualServer ); + virtual void say( Message &toSend, bool isRetry = false , std::string * actualServer = 0 ); virtual void sayPiggyBack( Message &toSend ); virtual void killCursor( long long cursorID ); - virtual string getServerAddress() const { return _address; } + virtual std::string getServerAddress() const { return _address; } virtual bool isFailed() const { return false; } virtual bool isStillConnected(); - virtual string toString() const { return _toString(); } + virtual std::string toString() const { return _toString(); } virtual BSONObj getLastErrorDetailed(const std::string& db, bool fsync=false, @@ -142,19 +142,19 @@ namespace mongo { private: SyncClusterConnection( SyncClusterConnection& prev, double socketTimeout = 0 ); - string _toString() const; - bool _commandOnActive(const string &dbname, const BSONObj& cmd, BSONObj &info, int options=0); - auto_ptr<DBClientCursor> _queryOnActive(const string &ns, Query query, int nToReturn, int nToSkip, + std::string _toString() const; + bool _commandOnActive(const std::string &dbname, const BSONObj& cmd, BSONObj &info, int options=0); + std::auto_ptr<DBClientCursor> _queryOnActive(const std::string &ns, Query query, int nToReturn, int nToSkip, const BSONObj *fieldsToReturn, int queryOptions, int batchSize ); - int _lockType( const string& name ); + int _lockType( const std::string& name ); void _checkLast(); void _connect( const std::string& host ); - string _address; - vector<string> _connAddresses; - vector<DBClientConnection*> _conns; + std::string _address; + std::vector<std::string> _connAddresses; + std::vector<DBClientConnection*> _conns; - vector<BSONObj> _lastErrors; + std::vector<BSONObj> _lastErrors; // Optionally attached by user scoped_ptr<QueryHandler> _customQueryHandler; @@ -196,7 +196,7 @@ namespace mongo { class MONGO_CLIENT_API UpdateNotTheSame : public UserException { public: - UpdateNotTheSame( int code , const string& msg , const vector<string>& addrs , const vector<BSONObj>& lastErrors ) + UpdateNotTheSame( int code , const std::string& msg , const std::vector<std::string>& addrs , const std::vector<BSONObj>& lastErrors ) : UserException( code , msg ) , _addrs( addrs ) , _lastErrors( lastErrors ) { verify( _addrs.size() == _lastErrors.size() ); } @@ -208,14 +208,14 @@ namespace mongo { return _addrs.size(); } - pair<string,BSONObj> operator[](unsigned i) const { - return make_pair( _addrs[i] , _lastErrors[i] ); + std::pair<std::string,BSONObj> operator[](unsigned i) const { + return std::make_pair( _addrs[i] , _lastErrors[i] ); } private: - vector<string> _addrs; - vector<BSONObj> _lastErrors; + std::vector<std::string> _addrs; + std::vector<BSONObj> _lastErrors; }; }; diff --git a/src/mongo/db/auth/action_set.h b/src/mongo/db/auth/action_set.h index a43ec9fa458..4a5c6ef45d0 100644 --- a/src/mongo/db/auth/action_set.h +++ b/src/mongo/db/auth/action_set.h @@ -66,17 +66,17 @@ namespace mongo { // ActionSet. bool isSupersetOf(const ActionSet& other) const; - // Returns the string representation of this ActionSet + // Returns the std::string representation of this ActionSet std::string toString() const; // Returns a vector of strings representing the actions in the ActionSet. std::vector<std::string> getActionsAsStrings() const; - // Takes a comma-separated string of action type string representations and returns + // Takes a comma-separated std::string of action type std::string representations and returns // an int bitmask of the actions. static Status parseActionSetFromString(const std::string& actionsString, ActionSet* result); - // Takes a vector of action type string representations and returns an ActionSet of the + // Takes a vector of action type std::string representations and returns an ActionSet of the // actions. static Status parseActionSetFromStringVector(const std::vector<std::string>& actionsVector, ActionSet* result); diff --git a/src/mongo/db/auth/authorization_manager.h b/src/mongo/db/auth/authorization_manager.h index bd32cba4224..b3a17c491c5 100644 --- a/src/mongo/db/auth/authorization_manager.h +++ b/src/mongo/db/auth/authorization_manager.h @@ -276,7 +276,7 @@ namespace mongo { * membership and delegation information, a full list of the user's privileges, and a full * list of the user's roles, including those roles held implicitly through other roles * (indirect roles). In the event that some of this information is inconsistent, the - * document will contain a "warnings" array, with string messages describing + * document will contain a "warnings" array, with std::string messages describing * inconsistencies. * * If the user does not exist, returns ErrorCodes::UserNotFound. @@ -290,7 +290,7 @@ namespace mongo { * implicitly through other roles (indirect roles). If "showPrivileges" is true, then the * description documents will also include a full list of the role's privileges. * In the event that some of this information is inconsistent, the document will contain a - * "warnings" array, with string messages describing inconsistencies. + * "warnings" array, with std::string messages describing inconsistencies. * * If the role does not exist, returns ErrorCodes::RoleNotFound. */ @@ -306,13 +306,13 @@ namespace mongo { * contain description documents for all the builtin roles for the given database, if it * is false the result will just include user defined roles. * In the event that some of the information in a given role description is inconsistent, - * the document will contain a "warnings" array, with string messages describing + * the document will contain a "warnings" array, with std::string messages describing * inconsistencies. */ Status getRoleDescriptionsForDB(const std::string dbname, bool showPrivileges, bool showBuiltinRoles, - vector<BSONObj>* result); + std::vector<BSONObj>* result); /** * Returns the User object for the given userName in the out parameter "acquiredUser". diff --git a/src/mongo/db/auth/authorization_session.h b/src/mongo/db/auth/authorization_session.h index 6c32fa697ae..92e4e6f6552 100644 --- a/src/mongo/db/auth/authorization_session.h +++ b/src/mongo/db/auth/authorization_session.h @@ -88,8 +88,8 @@ namespace mongo { // Gets an iterator over the names of all authenticated users stored in this manager. UserNameIterator getAuthenticatedUserNames(); - // Returns a string representing all logged-in users on the current session. - // WARNING: this string will contain NUL bytes so don't call c_str()! + // Returns a std::string representing all logged-in users on the current session. + // WARNING: this std::string will contain NUL bytes so don't call c_str()! std::string getAuthenticatedUserNamesToken(); // Removes any authenticated principals whose authorization credentials came from the given @@ -160,7 +160,7 @@ namespace mongo { // Like isAuthorizedForPrivilege, above, except returns true if the session is authorized // for all of the listed privileges. - bool isAuthorizedForPrivileges(const vector<Privilege>& privileges); + bool isAuthorizedForPrivileges(const std::vector<Privilege>& privileges); // Utility function for isAuthorizedForPrivilege(Privilege(resource, action)). bool isAuthorizedForActionsOnResource(const ResourcePattern& resource, ActionType action); diff --git a/src/mongo/db/auth/authz_manager_external_state.h b/src/mongo/db/auth/authz_manager_external_state.h index 683de53b108..f637415ae91 100644 --- a/src/mongo/db/auth/authz_manager_external_state.h +++ b/src/mongo/db/auth/authz_manager_external_state.h @@ -72,7 +72,7 @@ namespace mongo { * delegation information, a full list of the user's privileges, and a full list of the * user's roles, including those roles held implicitly through other roles (indirect roles). * In the event that some of this information is inconsistent, the document will contain a - * "warnings" array, with string messages describing inconsistencies. + * "warnings" array, with std::string messages describing inconsistencies. * * If the user does not exist, returns ErrorCodes::UserNotFound. */ @@ -85,7 +85,7 @@ namespace mongo { * implicitly through other roles (indirect roles). If "showPrivileges" is true, then the * description documents will also include a full list of the role's privileges. * In the event that some of this information is inconsistent, the document will contain a - * "warnings" array, with string messages describing inconsistencies. + * "warnings" array, with std::string messages describing inconsistencies. * * If the role does not exist, returns ErrorCodes::RoleNotFound. */ @@ -103,13 +103,13 @@ namespace mongo { * contain description documents for all the builtin roles for the given database, if it * is false the result will just include user defined roles. * In the event that some of the information in a given role description is inconsistent, - * the document will contain a "warnings" array, with string messages describing + * the document will contain a "warnings" array, with std::string messages describing * inconsistencies. */ virtual Status getRoleDescriptionsForDB(const std::string dbname, bool showPrivileges, bool showBuiltinRoles, - vector<BSONObj>* result) = 0; + std::vector<BSONObj>* result) = 0; /** * Gets the privilege document for "userName" stored in the system.users collection of diff --git a/src/mongo/db/auth/authz_manager_external_state_local.h b/src/mongo/db/auth/authz_manager_external_state_local.h index 930172c6c1b..2c49c4b7cc7 100644 --- a/src/mongo/db/auth/authz_manager_external_state_local.h +++ b/src/mongo/db/auth/authz_manager_external_state_local.h @@ -61,7 +61,7 @@ namespace mongo { virtual Status getRoleDescriptionsForDB(const std::string dbname, bool showPrivileges, bool showBuiltinRoles, - vector<BSONObj>* result); + std::vector<BSONObj>* result); virtual void logOp( const char* op, diff --git a/src/mongo/db/auth/authz_manager_external_state_s.h b/src/mongo/db/auth/authz_manager_external_state_s.h index 79e39611722..203ce25f5ac 100644 --- a/src/mongo/db/auth/authz_manager_external_state_s.h +++ b/src/mongo/db/auth/authz_manager_external_state_s.h @@ -60,7 +60,7 @@ namespace mongo { virtual Status getRoleDescriptionsForDB(const std::string dbname, bool showPrivileges, bool showBuiltinRoles, - vector<BSONObj>* result); + std::vector<BSONObj>* result); virtual Status getAllDatabaseNames(std::vector<std::string>* dbnames); diff --git a/src/mongo/db/auth/privilege_parser.h b/src/mongo/db/auth/privilege_parser.h index fc39566e311..7c892602032 100644 --- a/src/mongo/db/auth/privilege_parser.h +++ b/src/mongo/db/auth/privilege_parser.h @@ -53,8 +53,8 @@ namespace mongo { static const BSONField<bool> anyResource; static const BSONField<bool> cluster; - static const BSONField<string> db; - static const BSONField<string> collection; + static const BSONField<std::string> db; + static const BSONField<std::string> collection; // // construction / destruction @@ -112,11 +112,11 @@ namespace mongo { bool _isClusterSet; // (O) database portion of the resource - string _db; + std::string _db; bool _isDbSet; // (O) collection portion of the resource - string _collection; + std::string _collection; bool _isCollectionSet; }; @@ -131,7 +131,7 @@ namespace mongo { // schema declarations // - static const BSONField<std::vector<string> > actions; + static const BSONField<std::vector<std::string> > actions; static const BSONField<ParsedResource> resource; // @@ -168,13 +168,13 @@ namespace mongo { // individual field accessors // - void setActions(const std::vector<string>& actions); - void addToActions(const string& actions); + void setActions(const std::vector<std::string>& actions); + void addToActions(const std::string& actions); void unsetActions(); bool isActionsSet() const; size_t sizeActions() const; - const std::vector<string>& getActions() const; - const string& getActionsAt(size_t pos) const; + const std::vector<std::string>& getActions() const; + const std::string& getActionsAt(size_t pos) const; void setResource(const ParsedResource& resource); void unsetResource(); @@ -185,7 +185,7 @@ namespace mongo { // Convention: (M)andatory, (O)ptional // (M) Array of action types - std::vector<string> _actions; + std::vector<std::string> _actions; bool _isActionsSet; // (M) Object describing the resource pattern of this privilege diff --git a/src/mongo/db/auth/role_graph.h b/src/mongo/db/auth/role_graph.h index af31bd3d931..bec12b6d1e2 100644 --- a/src/mongo/db/auth/role_graph.h +++ b/src/mongo/db/auth/role_graph.h @@ -305,7 +305,7 @@ namespace mongo { EdgeSet _roleToMembers; RolePrivilegeMap _directPrivilegesForRole; RolePrivilegeMap _allPrivilegesForRole; - set<RoleName> _allRoles; + std::set<RoleName> _allRoles; }; void swap(RoleGraph& lhs, RoleGraph& rhs); diff --git a/src/mongo/db/auth/user_management_commands_parser.h b/src/mongo/db/auth/user_management_commands_parser.h index 36c122607ca..90f7db97e33 100644 --- a/src/mongo/db/auth/user_management_commands_parser.h +++ b/src/mongo/db/auth/user_management_commands_parser.h @@ -78,7 +78,7 @@ namespace auth { const StringData& cmdName, const std::string& dbname, std::string* parsedName, - vector<RoleName>* parsedRoleNames, + std::vector<RoleName>* parsedRoleNames, BSONObj* parsedWriteConcern); /** diff --git a/src/mongo/db/catalog/database.h b/src/mongo/db/catalog/database.h index 206d28db060..33d9b198517 100644 --- a/src/mongo/db/catalog/database.h +++ b/src/mongo/db/catalog/database.h @@ -73,7 +73,7 @@ namespace mongo { // following 2 are mutually exclusive, can only have one set long long initialNumExtents; - vector<long long> initialExtentSizes; + std::vector<long long> initialExtentSizes; // behavior of _id index creation when collection created void setNoIdIndex() { autoIndexId = NO; } @@ -101,15 +101,15 @@ namespace mongo { Database(OperationContext* txn, const char *nm, /*out*/ bool& newDb, - const string& path = storageGlobalParams.dbpath); + const std::string& path = storageGlobalParams.dbpath); /* you must use this to close - there is essential code in this method that is not in the ~Database destructor. thus the destructor is private. this could be cleaned up one day... */ - static void closeDatabase( const string& db, const string& path ); + static void closeDatabase( const std::string& db, const std::string& path ); - const string& name() const { return _name; } - const string& path() const { return _path; } + const std::string& name() const { return _name; } + const std::string& path() const { return _path; } void clearTmpCollections(OperationContext* txn); @@ -132,7 +132,7 @@ namespace mongo { /** * @return true if success. false if bad level or error creating profile ns */ - bool setProfilingLevel( OperationContext* txn, int newLevel , string& errmsg ); + bool setProfilingLevel( OperationContext* txn, int newLevel , std::string& errmsg ); void flushFiles( bool sync ); @@ -140,7 +140,7 @@ namespace mongo { * @return true if ns is part of the database * ns=foo.bar, db=foo returns true */ - bool ownsNS( const string& ns ) const { + bool ownsNS( const std::string& ns ) const { if ( ! startsWith( ns , _name ) ) return false; return ns[_name.size()] == '.'; @@ -189,14 +189,14 @@ namespace mongo { /** * @return name of an existing database with same text name but different - * casing, if one exists. Otherwise the empty string is returned. If + * casing, if one exists. Otherwise the empty std::string is returned. If * 'duplicates' is specified, it is filled with all duplicate names. */ - static string duplicateUncasedName( bool inholderlockalready, const string &name, const string &path, set< string > *duplicates = 0 ); + static std::string duplicateUncasedName( bool inholderlockalready, const std::string &name, const std::string &path, std::set< std::string > *duplicates = 0 ); static Status validateDBName( const StringData& dbname ); - const string& getSystemIndexesName() const { return _indexesName; } + const std::string& getSystemIndexesName() const { return _indexesName; } private: void _clearCollectionCache( const StringData& fullns ); @@ -231,15 +231,15 @@ namespace mongo { const StringData& toNS, bool stayTemp ); - const string _name; // "alleyinsider" - const string _path; // "/data/db" + const std::string _name; // "alleyinsider" + const std::string _path; // "/data/db" NamespaceIndex _namespaceIndex; boost::scoped_ptr<MmapV1ExtentManager> _extentManager; - const string _profileName; // "alleyinsider.system.profile" - const string _namespacesName; // "alleyinsider.system.namespaces" - const string _indexesName; // "alleyinsider.system.indexes" + const std::string _profileName; // "alleyinsider.system.profile" + const std::string _namespacesName; // "alleyinsider.system.namespaces" + const std::string _indexesName; // "alleyinsider.system.indexes" int _profile; // 0=off. diff --git a/src/mongo/db/catalog/database_holder.h b/src/mongo/db/catalog/database_holder.h index 3f3ea937e06..a2901926db7 100644 --- a/src/mongo/db/catalog/database_holder.h +++ b/src/mongo/db/catalog/database_holder.h @@ -40,8 +40,8 @@ namespace mongo { * path + dbname -> Database */ class DatabaseHolder { - typedef map<string,Database*> DBs; - typedef map<string,DBs> Paths; + typedef std::map<std::string,Database*> DBs; + typedef std::map<std::string,DBs> Paths; // todo: we want something faster than this if called a lot: mutable SimpleMutex _m; Paths _paths; @@ -49,42 +49,42 @@ namespace mongo { public: DatabaseHolder() : _m("dbholder"),_size(0) { } - bool __isLoaded( const string& ns , const string& path ) const { + bool __isLoaded( const std::string& ns , const std::string& path ) const { SimpleMutex::scoped_lock lk(_m); Paths::const_iterator x = _paths.find( path ); if ( x == _paths.end() ) return false; const DBs& m = x->second; - string db = _todb( ns ); + std::string db = _todb( ns ); DBs::const_iterator it = m.find(db); return it != m.end(); } // must be write locked as otherwise isLoaded could go false->true on you // in the background and you might not expect that. - bool _isLoaded( const string& ns , const string& path ) const { + bool _isLoaded( const std::string& ns , const std::string& path ) const { Lock::assertWriteLocked(ns); return __isLoaded(ns,path); } - Database * get( const string& ns , const string& path ) const { + Database * get( const std::string& ns , const std::string& path ) const { SimpleMutex::scoped_lock lk(_m); Lock::assertAtLeastReadLocked(ns); Paths::const_iterator x = _paths.find( path ); if ( x == _paths.end() ) return 0; const DBs& m = x->second; - string db = _todb( ns ); + std::string db = _todb( ns ); DBs::const_iterator it = m.find(db); if ( it != m.end() ) return it->second; return 0; } - Database* getOrCreate( const string& ns , const string& path , bool& justCreated ); + Database* getOrCreate( const std::string& ns , const std::string& path , bool& justCreated ); - void erase( const string& ns , const string& path ) { + void erase( const std::string& ns , const std::string& path ) { SimpleMutex::scoped_lock lk(_m); verify( Lock::isW() ); DBs& m = _paths[path]; @@ -92,7 +92,7 @@ namespace mongo { } /** @param force - force close even if something underway - use at shutdown */ - bool closeAll( const string& path , BSONObjBuilder& result, bool force ); + bool closeAll( const std::string& path , BSONObjBuilder& result, bool force ); // "info" as this is informational only could change on you if you are not write locked int sizeInfo() const { return _size; } @@ -101,7 +101,7 @@ namespace mongo { * gets all unique db names, ignoring paths * need some lock */ - void getAllShortNames( set<string>& all ) const { + void getAllShortNames( std::set<std::string>& all ) const { SimpleMutex::scoped_lock lk(_m); for ( Paths::const_iterator i=_paths.begin(); i!=_paths.end(); i++ ) { DBs m = i->second; @@ -112,14 +112,14 @@ namespace mongo { } private: - static string _todb( const string& ns ) { - string d = __todb( ns ); - uassert( 13280 , (string)"invalid db name: " + ns , NamespaceString::validDBName( d ) ); + static std::string _todb( const std::string& ns ) { + std::string d = __todb( ns ); + uassert( 13280 , (std::string)"invalid db name: " + ns , NamespaceString::validDBName( d ) ); return d; } - static string __todb( const string& ns ) { + static std::string __todb( const std::string& ns ) { size_t i = ns.find( '.' ); - if ( i == string::npos ) { + if ( i == std::string::npos ) { uassert( 13074 , "db name can't be empty" , ns.size() ); return ns; } diff --git a/src/mongo/db/catalog/index_catalog.h b/src/mongo/db/catalog/index_catalog.h index 7cfb607ca06..b45a056cc1a 100644 --- a/src/mongo/db/catalog/index_catalog.h +++ b/src/mongo/db/catalog/index_catalog.h @@ -96,8 +96,8 @@ namespace mongo { IndexDescriptor* findIndexByPrefix( const BSONObj &keyPattern, bool requireSingleKey ) const; - void findIndexByType( const string& type, - vector<IndexDescriptor*>& matches, + void findIndexByType( const std::string& type, + std::vector<IndexDescriptor*>& matches, bool includeUnfinishedIndexes = false ) const; // never returns NULL @@ -160,7 +160,7 @@ namespace mongo { * will drop all incompleted indexes and return specs * after this, the indexes can be rebuilt */ - vector<BSONObj> getAndClearUnfinishedIndexes(OperationContext* txn); + std::vector<BSONObj> getAndClearUnfinishedIndexes(OperationContext* txn); struct IndexKillCriteria { @@ -229,12 +229,12 @@ namespace mongo { Collection* _collection; IndexCatalog* _catalog; - string _ns; + std::string _ns; BSONObj _spec; - string _indexName; - string _indexNamespace; + std::string _indexName; + std::string _indexNamespace; IndexCatalogEntry* _entry; bool _inProgress; @@ -260,12 +260,12 @@ namespace mongo { // ------- temp internal ------- - string getAccessMethodName(const BSONObj& keyPattern) { + std::string getAccessMethodName(const BSONObj& keyPattern) { return _getAccessMethodName( keyPattern ); } Status _upgradeDatabaseMinorVersionIfNeeded( OperationContext* txn, - const string& newPluginName ); + const std::string& newPluginName ); // public static helpers @@ -288,7 +288,7 @@ namespace mongo { * use, not the plugin name inside of the provided key pattern. To understand when these * differ, see shouldOverridePlugin. */ - string _getAccessMethodName(const BSONObj& keyPattern) const; + std::string _getAccessMethodName(const BSONObj& keyPattern) const; IndexDetails* _getIndexDetails( const IndexDescriptor* descriptor ) const; @@ -319,8 +319,8 @@ namespace mongo { // just does disk hanges // doesn't change memory state, etc... void _deleteIndexFromDisk( OperationContext* txn, - const string& indexName, - const string& indexNamespace, + const std::string& indexName, + const std::string& indexNamespace, int idxNo ); // descriptor ownership passes to _setupInMemoryStructures diff --git a/src/mongo/db/client.h b/src/mongo/db/client.h index af634f1e13b..996d4d8b382 100644 --- a/src/mongo/db/client.h +++ b/src/mongo/db/client.h @@ -67,7 +67,7 @@ namespace mongo { class Client : public ClientBasic { public: // always be in clientsMutex when manipulating this. killop stuff uses these. - static set<Client*>& clients; + static std::set<Client*>& clients; static mongo::mutex& clientsMutex; static int getActiveClientCount( int& writers , int& readers ); class Context; @@ -90,7 +90,7 @@ namespace mongo { */ bool shutdown(); - string clientAddress(bool includePort=false) const; + std::string clientAddress(bool includePort=false) const; CurOp* curop() const { return _curOp; } Context* getContext() const { return _context; } const StringData desc() const { return _desc; } @@ -102,7 +102,7 @@ namespace mongo { bool isGod() const { return _god; } /* this is for map/reduce writes */ bool setGod(bool newVal) { const bool prev = _god; _god = newVal; return prev; } - string toString() const; + std::string toString() const; bool gotHandshake( const BSONObj& o ); BSONObj getRemoteID() const { return _remoteId; } BSONObj getHandshake() const { return _handshake; } @@ -125,7 +125,7 @@ namespace mongo { Client(const std::string& desc, AbstractMessagingPort *p = 0); friend class CurOp; ConnectionId _connectionId; // > 0 for things "conn", 0 otherwise - string _threadId; // "" on non support systems + std::string _threadId; // "" on non support systems CurOp * _curOp; Context * _context; bool _shutdown; // to track if Client::shutdown() gets called @@ -161,7 +161,7 @@ namespace mongo { class Context : boost::noncopyable { public: /** this is probably what you want */ - Context(const string& ns, const std::string& path=storageGlobalParams.dbpath, + Context(const std::string& ns, const std::string& path=storageGlobalParams.dbpath, bool doVersion = true); /** note: this does not call finishInit -- i.e., does not call @@ -171,13 +171,13 @@ namespace mongo { Context(const std::string& ns , Database * db); // used by ReadContext - Context(const string& path, const string& ns, Database *db, bool doVersion = true); + Context(const std::string& path, const std::string& ns, Database *db, bool doVersion = true); ~Context(); Client* getClient() const { return _client; } Database* db() const { return _db; } const char * ns() const { return _ns.c_str(); } - bool equals(const string& ns, const string& path=storageGlobalParams.dbpath) const { + bool equals(const std::string& ns, const std::string& path=storageGlobalParams.dbpath) const { return _ns == ns && _path == path; } @@ -185,10 +185,10 @@ namespace mongo { bool justCreated() const { return _justCreated; } /** @return true iff the current Context is using db/path */ - bool inDB(const string& db, const string& path=storageGlobalParams.dbpath) const; + bool inDB(const std::string& db, const std::string& path=storageGlobalParams.dbpath) const; void _clear() { // this is sort of an "early destruct" indication, _ns can never be uncleared - const_cast<string&>(_ns).clear(); + const_cast<std::string&>(_ns).clear(); _db = 0; } @@ -208,10 +208,10 @@ namespace mongo { void checkNsAccess( bool doauth, int lockState ); Client * const _client; Context * const _oldContext; - const string _path; + const std::string _path; bool _justCreated; bool _doVersion; - const string _ns; + const std::string _ns; Database * _db; Timer _timer; @@ -219,7 +219,7 @@ namespace mongo { class WriteContext : boost::noncopyable { public: - WriteContext(const string& ns, + WriteContext(const std::string& ns, const std::string& path=storageGlobalParams.dbpath, bool doVersion = true); Context& ctx() { return _c; } diff --git a/src/mongo/db/clientcursor.h b/src/mongo/db/clientcursor.h index f78cc34c9df..ca8aa95ca23 100644 --- a/src/mongo/db/clientcursor.h +++ b/src/mongo/db/clientcursor.h @@ -69,7 +69,7 @@ namespace mongo { // CursorId cursorid() const { return _cursorid; } - string ns() const { return _ns; } + std::string ns() const { return _ns; } const Collection* collection() const { return _collection; } /** @@ -164,7 +164,7 @@ namespace mongo { unsigned _pinValue; // The namespace we're operating on. - string _ns; + std::string _ns; const Collection* _collection; @@ -227,7 +227,7 @@ namespace mongo { /** thread for timing out old cursors */ class ClientCursorMonitor : public BackgroundJob { public: - string name() const { return "ClientCursorMonitor"; } + std::string name() const { return "ClientCursorMonitor"; } void run(); }; diff --git a/src/mongo/db/cloner.h b/src/mongo/db/cloner.h index 4c1abbf6c42..f6f47885dbf 100644 --- a/src/mongo/db/cloner.h +++ b/src/mongo/db/cloner.h @@ -57,15 +57,15 @@ namespace mongo { /** copy the entire database */ bool go(OperationContext* txn, Client::Context& ctx, - const string& masterHost, + const std::string& masterHost, const CloneOptions& opts, - set<string>* clonedColls, - string& errmsg, int *errCode = 0); + std::set<std::string>* clonedColls, + std::string& errmsg, int *errCode = 0); bool copyCollection(OperationContext* txn, - const string& ns, + const std::string& ns, const BSONObj& query, - string& errmsg, + std::string& errmsg, bool mayYield, bool mayBeInterrupted, bool copyIndexes = true, @@ -76,8 +76,8 @@ namespace mongo { * @param errCode out Error code encountered during the query * @param errmsg out Error message encountered during the query */ - static bool validateQueryResults(const auto_ptr<DBClientCursor>& cur, int32_t* errCode, - string& errmsg); + static bool validateQueryResults(const std::auto_ptr<DBClientCursor>& cur, int32_t* errCode, + std::string& errmsg); /** * @param errmsg out - Error message (if encountered). @@ -87,17 +87,17 @@ namespace mongo { */ static bool cloneFrom(OperationContext* txn, Client::Context& context, - const string& masterHost, + const std::string& masterHost, const CloneOptions& options, - string& errmsg, + std::string& errmsg, int* errCode = 0, - set<string>* clonedCollections = 0); + std::set<std::string>* clonedCollections = 0); /** * Copy a collection (and indexes) from a remote host */ static bool copyCollectionFromRemote(OperationContext* txn, - const string& host, const string& ns, string& errmsg); + const std::string& host, const std::string& ns, std::string& errmsg); private: void copy(OperationContext* txn, @@ -113,7 +113,7 @@ namespace mongo { Query q); struct Fun; - auto_ptr<DBClientBase> _conn; + std::auto_ptr<DBClientBase> _conn; }; struct CloneOptions { @@ -130,8 +130,8 @@ namespace mongo { syncIndexes = true; } - string fromDB; - set<string> collsToIgnore; + std::string fromDB; + std::set<std::string> collsToIgnore; bool logForRepl; bool slaveOk; diff --git a/src/mongo/db/commands.h b/src/mongo/db/commands.h index 992e80cc876..4446020a94c 100644 --- a/src/mongo/db/commands.h +++ b/src/mongo/db/commands.h @@ -58,14 +58,14 @@ namespace mutablebson { protected: // The type of the first field in 'cmdObj' must be mongo::String. The first field is // interpreted as a collection name. - string parseNsFullyQualified(const string& dbname, const BSONObj& cmdObj) const; + std::string parseNsFullyQualified(const std::string& dbname, const BSONObj& cmdObj) const; public: // Return the namespace for the command. If the first field in 'cmdObj' is of type // mongo::String, then that field is interpreted as the collection name, and is // appended to 'dbname' after a '.' character. If the first field is not of type // mongo::String, then 'dbname' is returned unmodified. - virtual string parseNs(const string& dbname, const BSONObj& cmdObj) const; + virtual std::string parseNs(const std::string& dbname, const BSONObj& cmdObj) const; // Utility that returns a ResourcePattern for the namespace returned from // parseNs(dbname, cmdObj). This will be either an exact namespace resource pattern @@ -74,7 +74,7 @@ namespace mutablebson { ResourcePattern parseResourcePattern(const std::string& dbname, const BSONObj& cmdObj) const; - const string name; + const std::string name; /* run the given command implement this... @@ -85,10 +85,10 @@ namespace mutablebson { return value is true if succeeded. if false, set errmsg text. */ virtual bool run(OperationContext* txn, - const string& db, + const std::string& db, BSONObj& cmdObj, int options, - string& errmsg, + std::string& errmsg, BSONObjBuilder& result, bool fromRepl = false ) = 0; @@ -107,7 +107,7 @@ namespace mutablebson { return false; } - void htmlHelp(stringstream&) const; + void htmlHelp(std::stringstream&) const; /* Like adminOnly, but even stricter: we must either be authenticated for admin db, or, if running without auth, on the local interface. Used for things which @@ -135,7 +135,7 @@ namespace mutablebson { */ virtual bool shouldAffectCommandCounter() const { return true; } - virtual void help( stringstream& help ) const; + virtual void help( std::stringstream& help ) const; /** * Checks if the given client is authorized to run this command on database "dbname" @@ -190,25 +190,25 @@ namespace mutablebson { return BSONObj(); } - static void logIfSlow( const Timer& cmdTimer, const string& msg); + static void logIfSlow( const Timer& cmdTimer, const std::string& msg); - static map<string,Command*> * _commands; - static map<string,Command*> * _commandsByBestName; - static map<string,Command*> * _webCommands; + static std::map<std::string,Command*> * _commands; + static std::map<std::string,Command*> * _commandsByBestName; + static std::map<std::string,Command*> * _webCommands; public: // Stops all index builds required to run this command and returns index builds killed. virtual std::vector<BSONObj> stopIndexBuilds(Database* db, const BSONObj& cmdObj); - static const map<string,Command*>* commandsByBestName() { return _commandsByBestName; } - static const map<string,Command*>* webCommands() { return _webCommands; } + static const std::map<std::string,Command*>* commandsByBestName() { return _commandsByBestName; } + static const std::map<std::string,Command*>* webCommands() { return _webCommands; } /** @return if command was found */ static void runAgainstRegistered(const char *ns, BSONObj& jsobj, BSONObjBuilder& anObjBuilder, int queryOptions = 0); - static Command * findCommand( const string& name ); + static Command * findCommand( const std::string& name ); // For mongod and webserver. static void execCommand(OperationContext* txn, Command* c, diff --git a/src/mongo/db/commands/authentication_commands.h b/src/mongo/db/commands/authentication_commands.h index 0b4b0a3242a..096b66b9cab 100644 --- a/src/mongo/db/commands/authentication_commands.h +++ b/src/mongo/db/commands/authentication_commands.h @@ -44,17 +44,17 @@ namespace mongo { return true; } virtual bool isWriteCommandForConfigServer() const { return false; } - virtual void help(stringstream& ss) const { ss << "internal"; } + virtual void help(std::stringstream& ss) const { ss << "internal"; } virtual void addRequiredPrivileges(const std::string& dbname, const BSONObj& cmdObj, std::vector<Privilege>* out) {} // No auth required virtual void redactForLogging(mutablebson::Document* cmdObj); CmdAuthenticate() : Command("authenticate") {} - bool run(OperationContext* txn, const string& dbname, + bool run(OperationContext* txn, const std::string& dbname, BSONObj& cmdObj, int options, - string& errmsg, + std::string& errmsg, BSONObjBuilder& result, bool fromRepl); diff --git a/src/mongo/db/commands/dbhash.h b/src/mongo/db/commands/dbhash.h index 688ccada6a5..71885f17697 100644 --- a/src/mongo/db/commands/dbhash.h +++ b/src/mongo/db/commands/dbhash.h @@ -46,7 +46,7 @@ namespace mongo { const BSONObj& cmdObj, std::vector<Privilege>* out); - virtual bool run(OperationContext* txn, const string& dbname , BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool); + virtual bool run(OperationContext* txn, const std::string& dbname , BSONObj& cmdObj, int, std::string& errmsg, BSONObjBuilder& result, bool); void wipeCacheForCollection( const StringData& ns ); @@ -54,9 +54,9 @@ namespace mongo { bool isCachable( const StringData& ns ) const; - string hashCollection( Database* db, const string& fullCollectionName, bool* fromCache ); + std::string hashCollection( Database* db, const std::string& fullCollectionName, bool* fromCache ); - map<string,string> _cachedHashed; + std::map<std::string,std::string> _cachedHashed; mutex _cachedHashedMutex; }; diff --git a/src/mongo/db/commands/mr.h b/src/mongo/db/commands/mr.h index 9eddac77efc..04d3c6b70d7 100644 --- a/src/mongo/db/commands/mr.h +++ b/src/mongo/db/commands/mr.h @@ -46,7 +46,7 @@ namespace mongo { namespace mr { - typedef vector<BSONObj> BSONList; + typedef std::vector<BSONObj> BSONList; class State; @@ -104,8 +104,8 @@ namespace mongo { ScriptingFunction func() const { return _func; } private: - string _type; - string _code; // actual javascript code + std::string _type; + std::string _code; // actual javascript code BSONObj _wantedScope; // this is for CodeWScope Scope * _scope; // this is not owned by us, and might be shared @@ -164,17 +164,17 @@ namespace mongo { } }; - typedef map< BSONObj,BSONList,TupleKeyCmp > InMemory; // from key to list of tuples + typedef std::map< BSONObj,BSONList,TupleKeyCmp > InMemory; // from key to list of tuples /** * holds map/reduce config information */ class Config { public: - Config( const string& _dbname , const BSONObj& cmdObj ); + Config( const std::string& _dbname , const BSONObj& cmdObj ); - string dbname; - string ns; + std::string dbname; + std::string ns; // options bool verbose; @@ -197,8 +197,8 @@ namespace mongo { BSONObj scopeSetup; // output tables - string incLong; - string tempNamespace; + std::string incLong; + std::string tempNamespace; enum OutputType { REPLACE , // atomically replace the collection @@ -207,15 +207,15 @@ namespace mongo { INMEMORY // only store in memory, limited in size }; struct OutputOptions { - string outDB; - string collectionName; - string finalNamespace; + std::string outDB; + std::string collectionName; + std::string finalNamespace; // if true, no lock during output operation bool outNonAtomic; OutputType outType; } outputOptions; - static OutputOptions parseOutputOptions(const string& dbname, const BSONObj& cmdObj); + static OutputOptions parseOutputOptions(const std::string& dbname, const BSONObj& cmdObj); // max number of keys allowed in JS map before switching mode long jsMaxKeys; @@ -310,7 +310,7 @@ namespace mongo { /** * inserts with correct replication semantics */ - void insert( const string& ns , const BSONObj& o ); + void insert( const std::string& ns , const BSONObj& o ); // ------ simple accessors ----- diff --git a/src/mongo/db/commands/server_status.h b/src/mongo/db/commands/server_status.h index b6313f28eba..adf761cc5a6 100644 --- a/src/mongo/db/commands/server_status.h +++ b/src/mongo/db/commands/server_status.h @@ -40,10 +40,10 @@ namespace mongo { class ServerStatusSection { public: - ServerStatusSection( const string& sectionName ); + ServerStatusSection( const std::string& sectionName ); virtual ~ServerStatusSection(){} - const string& getSectionName() const { return _sectionName; } + const std::string& getSectionName() const { return _sectionName; } /** * if this returns true, if the user doesn't mention this section @@ -77,12 +77,12 @@ namespace mongo { virtual BSONObj generateSection(const BSONElement& configElement) const = 0; private: - const string _sectionName; + const std::string _sectionName; }; class OpCounterServerStatusSection : public ServerStatusSection { public: - OpCounterServerStatusSection( const string& sectionName, OpCounters* counters ); + OpCounterServerStatusSection( const std::string& sectionName, OpCounters* counters ); virtual bool includeByDefault() const { return true; } virtual BSONObj generateSection(const BSONElement& configElement) const; diff --git a/src/mongo/db/commands/shutdown.h b/src/mongo/db/commands/shutdown.h index 3fdf347a50a..b782f4c58f6 100644 --- a/src/mongo/db/commands/shutdown.h +++ b/src/mongo/db/commands/shutdown.h @@ -47,12 +47,12 @@ namespace mongo { const BSONObj& cmdObj, std::vector<Privilege>* out); virtual bool isWriteCommandForConfigServer() const { return false; } - virtual void help( stringstream& help ) const; + virtual void help( std::stringstream& help ) const; CmdShutdown() : Command("shutdown") {} - bool run(OperationContext* txn, const string& dbname, + bool run(OperationContext* txn, const std::string& dbname, BSONObj& cmdObj, int options, - string& errmsg, + std::string& errmsg, BSONObjBuilder& result, bool fromRepl); private: diff --git a/src/mongo/db/commands/user_management_commands.h b/src/mongo/db/commands/user_management_commands.h index 6587e5e1f38..f9350f768ca 100644 --- a/src/mongo/db/commands/user_management_commands.h +++ b/src/mongo/db/commands/user_management_commands.h @@ -40,7 +40,7 @@ namespace mongo { virtual bool isWriteCommandForConfigServer() const; virtual bool slaveOk() const; virtual bool adminOnly() const; - virtual void help(stringstream& ss) const; + virtual void help(std::stringstream& ss) const; virtual Status checkAuthForCommand(ClientBasic* client, const std::string& dbname, diff --git a/src/mongo/db/commands/write_commands/write_commands.h b/src/mongo/db/commands/write_commands/write_commands.h index 42cbc3e7b87..c5f5da37cac 100644 --- a/src/mongo/db/commands/write_commands/write_commands.h +++ b/src/mongo/db/commands/write_commands/write_commands.h @@ -74,10 +74,10 @@ namespace mongo { // Write command entry point. virtual bool run( OperationContext* txn, - const string& dbname, + const std::string& dbname, BSONObj& cmdObj, int options, - string& errmsg, + std::string& errmsg, BSONObjBuilder& result, bool fromRepl); @@ -92,7 +92,7 @@ namespace mongo { void redactForLogging(mutablebson::Document* cmdObj); private: - virtual void help(stringstream& help) const; + virtual void help(std::stringstream& help) const; }; class CmdUpdate : public WriteCmd { @@ -102,7 +102,7 @@ namespace mongo { void redactForLogging(mutablebson::Document* cmdObj); private: - virtual void help(stringstream& help) const; + virtual void help(std::stringstream& help) const; }; class CmdDelete : public WriteCmd { @@ -112,7 +112,7 @@ namespace mongo { void redactForLogging(mutablebson::Document* cmdObj); private: - virtual void help(stringstream& help) const; + virtual void help(std::stringstream& help) const; }; } // namespace mongo diff --git a/src/mongo/db/curop.h b/src/mongo/db/curop.h index 60997afea88..4cc16c803f4 100644 --- a/src/mongo/db/curop.h +++ b/src/mongo/db/curop.h @@ -125,7 +125,7 @@ namespace mongo { void recordStats(); - string report( const CurOp& curop ) const; + std::string report( const CurOp& curop ) const; /** * Appends stored data and information from curop to the builder. @@ -173,7 +173,7 @@ namespace mongo { bool fastmodinsert; // upsert of an $operation. builds a default object bool upsert; // true if the update actually did an insert int keyUpdates; - ThreadSafeString planSummary; // a brief string describing the query solution + ThreadSafeString planSummary; // a brief std::string describing the query solution // New Query Framework debugging/profiling info // TODO: should this really be an opaque BSONObj? Not sure. @@ -291,12 +291,12 @@ namespace mongo { // Fetches less information than "info()"; used to search for ops with certain criteria BSONObj description(); - string getRemoteString( bool includePort = true ) { return _remote.toString(includePort); } + std::string getRemoteString( bool includePort = true ) { return _remote.toString(includePort); } ProgressMeter& setMessage(const char * msg, std::string name = "Progress", unsigned long long progressMeterTotal = 0, int secondsBetween = 3); - string getMessage() const { return _message.toString(); } + std::string getMessage() const { return _message.toString(); } ProgressMeter& getProgressMeter() { return _progressMeter; } CurOp *parent() const { return _wrapped; } void kill(bool* pNotifyFlag = NULL); diff --git a/src/mongo/db/d_concurrency.h b/src/mongo/db/d_concurrency.h index d2dc1f5688f..e51189c0129 100644 --- a/src/mongo/db/d_concurrency.h +++ b/src/mongo/db/d_concurrency.h @@ -175,7 +175,7 @@ namespace mongo { void lockTop(LockState&); void lockNestable(Nestable db); void lockOther(const StringData& db); - void lockDB(const string& ns); + void lockDB(const std::string& ns); void unlockDB(); protected: @@ -190,7 +190,7 @@ namespace mongo { bool _locked_w; bool _locked_W; WrapperForRWLock *_weLocked; - const string _what; + const std::string _what; bool _nested; }; @@ -199,7 +199,7 @@ namespace mongo { void lockTop(LockState&); void lockNestable(Nestable db); void lockOther(const StringData& db); - void lockDB(const string& ns); + void lockDB(const std::string& ns); void unlockDB(); protected: @@ -213,7 +213,7 @@ namespace mongo { private: bool _locked_r; WrapperForRWLock *_weLocked; - string _what; + std::string _what; bool _nested; }; diff --git a/src/mongo/db/dbhelpers.h b/src/mongo/db/dbhelpers.h index 76ef3271c91..758491e0297 100644 --- a/src/mongo/db/dbhelpers.h +++ b/src/mongo/db/dbhelpers.h @@ -91,7 +91,7 @@ namespace mongo { /** * have to be locked already */ - static vector<BSONObj> findAll( const string& ns , const BSONObj& query ); + static std::vector<BSONObj> findAll( const std::string& ns , const BSONObj& query ); /** * @param foundIndex if passed in will be set to 1 if ns and index found @@ -124,7 +124,7 @@ namespace mongo { * o has to have an _id field or will assert */ static void upsert( OperationContext* txn, - const string& ns, + const std::string& ns, const BSONObj& o, bool fromMigrate = false ); @@ -192,7 +192,7 @@ namespace mongo { */ static Status getLocsInRange( const KeyRange& range, long long maxChunkSizeBytes, - set<DiskLoc>* locs, + std::set<DiskLoc>* locs, long long* numDocs, long long* estChunkSizeBytes ); @@ -208,7 +208,7 @@ namespace mongo { */ class RemoveSaver : public boost::noncopyable { public: - RemoveSaver(const string& type, const string& ns, const string& why); + RemoveSaver(const std::string& type, const std::string& ns, const std::string& why); ~RemoveSaver(); void goingToDelete( const BSONObj& o ); @@ -216,7 +216,7 @@ namespace mongo { private: boost::filesystem::path _root; boost::filesystem::path _file; - ofstream* _out; + std::ofstream* _out; }; }; diff --git a/src/mongo/db/dbmessage.h b/src/mongo/db/dbmessage.h index 3e04dccd1ce..cc3df6cd787 100644 --- a/src/mongo/db/dbmessage.h +++ b/src/mongo/db/dbmessage.h @@ -57,20 +57,20 @@ namespace mongo { then for: dbInsert: - string collection; + std::string collection; a series of JSObjects dbDelete: - string collection; + std::string collection; int flags=0; // 1=DeleteSingle JSObject query; dbUpdate: - string collection; + std::string collection; int flags; // 1=upsert JSObject query; JSObject objectToUpdate; objectToUpdate may include { $inc: <field> } or { $set: ... }, see struct Mod. dbQuery: - string collection; + std::string collection; int nToSkip; int nToReturn; // how many you want back as the beginning of the cursor data (0=no limit) // greater than zero is simply a hint on how many objects to send back per "cursor batch". @@ -78,7 +78,7 @@ namespace mongo { JSObject query; [JSObject fieldsToReturn] dbGetMore: - string collection; // redundant, might use for security. + std::string collection; // redundant, might use for security. int nToReturn; int64 cursorID; dbKillCursors=2007: @@ -285,7 +285,7 @@ namespace mongo { struct DbResponse { Message *response; MSGID responseTo; - string exhaustNS; /* points to ns if exhaust mode. 0=normal mode*/ + std::string exhaustNS; /* points to ns if exhaust mode. 0=normal mode*/ DbResponse(Message *r, MSGID rt) : response(r), responseTo(rt){ } DbResponse() { response = 0; diff --git a/src/mongo/db/dbwebserver.h b/src/mongo/db/dbwebserver.h index 42e686b3315..87fd8958ab8 100644 --- a/src/mongo/db/dbwebserver.h +++ b/src/mongo/db/dbwebserver.h @@ -48,55 +48,55 @@ namespace mongo { class DbWebHandler : public Prioritizable { public: - DbWebHandler( const string& name , double priority , bool requiresREST ); + DbWebHandler( const std::string& name , double priority , bool requiresREST ); virtual ~DbWebHandler() {} - virtual bool handles( const string& url ) const { return url == _defaultUrl; } + virtual bool handles( const std::string& url ) const { return url == _defaultUrl; } - virtual bool requiresREST( const string& url ) const { return _requiresREST; } + virtual bool requiresREST( const std::string& url ) const { return _requiresREST; } virtual void handle( OperationContext* txn, const char *rq, // the full request const std::string& url, BSONObj params, // set these and return them: - string& responseMsg, + std::string& responseMsg, int& responseCode, - vector<string>& headers, // if completely empty, content-type: text/html will be added + std::vector<std::string>& headers, // if completely empty, content-type: text/html will be added const SockAddr &from ) = 0; - string toString() const { return _toString; } - static DbWebHandler * findHandler( const string& url ); + std::string toString() const { return _toString; } + static DbWebHandler * findHandler( const std::string& url ); private: - string _name; + std::string _name; bool _requiresREST; - string _defaultUrl; - string _toString; + std::string _defaultUrl; + std::string _toString; - static vector<DbWebHandler*> * _handlers; + static std::vector<DbWebHandler*> * _handlers; }; class WebStatusPlugin : public Prioritizable { public: - WebStatusPlugin( const string& secionName , double priority , const string& subheader = "" ); + WebStatusPlugin( const std::string& secionName , double priority , const std::string& subheader = "" ); virtual ~WebStatusPlugin() {} - virtual void run( stringstream& ss ) = 0; + virtual void run( std::stringstream& ss ) = 0; /** called when web server stats up */ virtual void init() = 0; static void initAll(); - static void runAll( stringstream& ss ); + static void runAll( std::stringstream& ss ); private: - string _name; - string _subHeading; - static vector<WebStatusPlugin*> * _plugins; + std::string _name; + std::string _subHeading; + static std::vector<WebStatusPlugin*> * _plugins; }; void webServerThread( const AdminAccess* admins, OperationContext::Factory transactionFactory ); - string prettyHostName(); + std::string prettyHostName(); }; diff --git a/src/mongo/db/diskloc.h b/src/mongo/db/diskloc.h index a085557138b..13daa5bf750 100644 --- a/src/mongo/db/diskloc.h +++ b/src/mongo/db/diskloc.h @@ -90,11 +90,11 @@ namespace mongo { } bool isValid() const { return _a != -2; } - string toString() const { + std::string toString() const { if ( isNull() ) return "null"; - stringstream ss; - ss << _a << ':' << hex << ofs; + std::stringstream ss; + ss << _a << ':' << std::hex << ofs; return ss.str(); } diff --git a/src/mongo/db/exec/2dcommon.h b/src/mongo/db/exec/2dcommon.h index a3a2c2a9ac2..6986e3d4a7b 100644 --- a/src/mongo/db/exec/2dcommon.h +++ b/src/mongo/db/exec/2dcommon.h @@ -94,7 +94,7 @@ namespace twod_exec { return _loc; } - string toString() const { + std::string toString() const { return str::stream() << "Point from " << _key << " - " << _o << " dist : " << _distance << (_exact ? " (ex)" : " (app)"); } @@ -152,7 +152,7 @@ namespace twod_exec { long long found() const { return _found; } virtual void getPointsFor(const BSONObj& key, const BSONObj& obj, - vector<BSONObj> &locsForNode, bool allPoints = false); + std::vector<BSONObj> &locsForNode, bool allPoints = false); virtual int addSpecific(const GeoIndexEntry& node, const Point& p, bool inBounds, double d, bool newDoc) = 0; @@ -161,7 +161,7 @@ namespace twod_exec { TwoDAccessMethod* _accessMethod; shared_ptr<GeoHashConverter> _converter; - map<DiskLoc, bool> _matched; + std::map<DiskLoc, bool> _matched; MatchExpression* _filter; @@ -185,7 +185,7 @@ namespace twod_exec { DONE } _state; - GeoBrowse(TwoDAccessMethod* accessMethod, string type, MatchExpression* filter); + GeoBrowse(TwoDAccessMethod* accessMethod, std::string type, MatchExpression* filter); virtual bool ok(); virtual bool advance(); @@ -234,9 +234,9 @@ namespace twod_exec { */ bool invalidate(const DiskLoc& dl); - string _type; - list<GeoPoint> _stack; - set<BSONObj> _seenIds; + std::string _type; + std::list<GeoPoint> _stack; + std::set<BSONObj> _seenIds; GeoPoint _cur; bool _firstCall; @@ -253,7 +253,7 @@ namespace twod_exec { GeoHash _prefix; shared_ptr<GeoHash> _lastPrefix; GeoHash _centerPrefix; - list<string> _fringe; + std::list<std::string> _fringe; int recurseDepth; Box _centerBox; @@ -262,7 +262,7 @@ namespace twod_exec { BtreeLocation _max; shared_ptr<GeoHash> _expPrefix; - mutable vector<GeoHash> _expPrefixes; + mutable std::vector<GeoHash> _expPrefixes; const IndexDescriptor* _descriptor; shared_ptr<GeoHashConverter> _converter; TwoDIndexingParams _params; diff --git a/src/mongo/db/exec/2dnear.h b/src/mongo/db/exec/2dnear.h index 5f23f541d93..f7bc255a3ef 100644 --- a/src/mongo/db/exec/2dnear.h +++ b/src/mongo/db/exec/2dnear.h @@ -138,7 +138,7 @@ namespace twod_exec { // Safe to use currently since we don't yield in $near searches. If we do start to yield, // we may need to replace dirtied disklocs in our holder / ensure our logic is correct. - map<DiskLoc, Holder::iterator> _seenPts; + std::map<DiskLoc, Holder::iterator> _seenPts; private: const Collection* _collection; @@ -172,7 +172,7 @@ namespace twod_exec { // Whether the current box overlaps our search area virtual double intersectsBox(Box& cur) { return cur.intersects(_want); } - set< pair<DiskLoc,int> > _seen; + std::set< std::pair<DiskLoc,int> > _seen; GeoHash _start; int _numWanted; double _scanDistance; diff --git a/src/mongo/db/exec/and_sorted.h b/src/mongo/db/exec/and_sorted.h index e8a88e78607..667638b684e 100644 --- a/src/mongo/db/exec/and_sorted.h +++ b/src/mongo/db/exec/and_sorted.h @@ -85,7 +85,7 @@ namespace mongo { const MatchExpression* _filter; // Owned by us. - vector<PlanStage*> _children; + std::vector<PlanStage*> _children; // The current node we're AND-ing against. size_t _targetNode; diff --git a/src/mongo/db/exec/distinct_scan.h b/src/mongo/db/exec/distinct_scan.h index 8b83100b8ad..381a77f99d7 100644 --- a/src/mongo/db/exec/distinct_scan.h +++ b/src/mongo/db/exec/distinct_scan.h @@ -122,8 +122,8 @@ namespace mongo { boost::scoped_ptr<IndexBoundsChecker> _checker; int _keyEltsToUse; bool _movePastKeyElts; - vector<const BSONElement*> _keyElts; - vector<bool> _keyEltsInc; + std::vector<const BSONElement*> _keyElts; + std::vector<bool> _keyEltsInc; // Stats CommonStats _commonStats; diff --git a/src/mongo/db/exec/index_scan.h b/src/mongo/db/exec/index_scan.h index 8e5f4697910..5a029e05990 100644 --- a/src/mongo/db/exec/index_scan.h +++ b/src/mongo/db/exec/index_scan.h @@ -136,8 +136,8 @@ namespace mongo { BtreeIndexCursor* _btreeCursor; int _keyEltsToUse; bool _movePastKeyElts; - vector<const BSONElement*> _keyElts; - vector<bool> _keyEltsInc; + std::vector<const BSONElement*> _keyElts; + std::vector<bool> _keyEltsInc; // Stats CommonStats _commonStats; diff --git a/src/mongo/db/exec/merge_sort.h b/src/mongo/db/exec/merge_sort.h index 7eeb54ae0d0..22adfd21fdf 100644 --- a/src/mongo/db/exec/merge_sort.h +++ b/src/mongo/db/exec/merge_sort.h @@ -88,7 +88,7 @@ namespace mongo { unordered_set<DiskLoc, DiskLoc::Hasher> _seen; // Owned by us. All the children we're reading from. - vector<PlanStage*> _children; + std::vector<PlanStage*> _children; // In order to pick the next smallest value, we need each child work(...) until it produces // a result. This is the queue of children that haven't given us a result yet. @@ -114,7 +114,7 @@ namespace mongo { }; // We have a priority queue of these. - typedef list<StageWithValue>::iterator MergingRef; + typedef std::list<StageWithValue>::iterator MergingRef; // The comparison function used in our priority queue. class StageWithValueComparison { @@ -132,10 +132,10 @@ namespace mongo { }; // The min heap of the results we're returning. - std::priority_queue<MergingRef, vector<MergingRef>, StageWithValueComparison> _merging; + std::priority_queue<MergingRef, std::vector<MergingRef>, StageWithValueComparison> _merging; // The data referred to by the _merging queue above. - list<StageWithValue> _mergingData; + std::list<StageWithValue> _mergingData; // Stats CommonStats _commonStats; diff --git a/src/mongo/db/exec/oplogstart.h b/src/mongo/db/exec/oplogstart.h index 7754ac1534a..c0f74573c48 100644 --- a/src/mongo/db/exec/oplogstart.h +++ b/src/mongo/db/exec/oplogstart.h @@ -111,7 +111,7 @@ namespace mongo { // WorkingSet is not owned by us. WorkingSet* _workingSet; - string _ns; + std::string _ns; MatchExpression* _filter; diff --git a/src/mongo/db/exec/or.h b/src/mongo/db/exec/or.h index fa765f67ea6..9382fbae7f8 100644 --- a/src/mongo/db/exec/or.h +++ b/src/mongo/db/exec/or.h @@ -68,7 +68,7 @@ namespace mongo { const MatchExpression* _filter; // Owned by us. - vector<PlanStage*> _children; + std::vector<PlanStage*> _children; // Which of _children are we calling work(...) on now? size_t _currentChild; diff --git a/src/mongo/db/exec/plan_stage.h b/src/mongo/db/exec/plan_stage.h index 304baf50bf5..b1f85499d2b 100644 --- a/src/mongo/db/exec/plan_stage.h +++ b/src/mongo/db/exec/plan_stage.h @@ -77,7 +77,7 @@ namespace mongo { * case PlanStage::ADVANCED: * // do something with result * WorkingSetMember* member = workingSet.get(result); - * cout << "Result: " << member->obj << endl; + * cout << "Result: " << member->obj << std::endl; * break; * case PlanStage::IS_EOF: * // All done. Will fall out of while loop. @@ -145,7 +145,7 @@ namespace mongo { NEED_FETCH, }; - static string stateStr(const StageState& state) { + static std::string stateStr(const StageState& state) { if (ADVANCED == state) { return "ADVANCED"; } diff --git a/src/mongo/db/exec/projection.h b/src/mongo/db/exec/projection.h index 8398eec6568..5284cfaac02 100644 --- a/src/mongo/db/exec/projection.h +++ b/src/mongo/db/exec/projection.h @@ -138,10 +138,10 @@ namespace mongo { // Field names can be empty in 2.4 and before so we can't use them as a sentinel value. // If the i-th entry is true we include the i-th field in the key. - vector<bool> _includeKey; + std::vector<bool> _includeKey; // If the i-th entry of _includeKey is true this is the field name for the i-th key field. - vector<StringData> _keyFieldNames; + std::vector<StringData> _keyFieldNames; }; } // namespace mongo diff --git a/src/mongo/db/exec/projection_exec.h b/src/mongo/db/exec/projection_exec.h index 9f3cb8f403b..7a4023b831e 100644 --- a/src/mongo/db/exec/projection_exec.h +++ b/src/mongo/db/exec/projection_exec.h @@ -96,12 +96,12 @@ namespace mongo { /** * Add 'field' as a field name that is included or excluded as part of the projection. */ - void add(const string& field, bool include); + void add(const std::string& field, bool include); /** * Add 'field' as a field name that is sliced as part of the projection. */ - void add(const string& field, int skip, int limit); + void add(const std::string& field, int skip, int limit); // // Execution @@ -156,7 +156,7 @@ namespace mongo { bool _special; // We must group projections with common prefixes together. - // TODO: benchmark vector<pair> vs map + // TODO: benchmark std::vector<pair> vs map // // Projection is a rooted tree. If we have {a.b: 1, a.c: 1} we don't want to // double-traverse the document when we're projecting it. Instead, we have an entry in @@ -177,7 +177,7 @@ namespace mongo { Matchers _matchers; // The matchers above point into BSONObjs and this is where those objs live. - vector<BSONObj> _elemMatchObjs; + std::vector<BSONObj> _elemMatchObjs; ArrayOpType _arrayOpType; diff --git a/src/mongo/db/exec/sort.h b/src/mongo/db/exec/sort.h index 4d232b188c1..f0ead740dc2 100644 --- a/src/mongo/db/exec/sort.h +++ b/src/mongo/db/exec/sort.h @@ -239,12 +239,12 @@ namespace mongo { // _dataSet is used instead to maintain an ordered set of the incomplete data set. // When the data set is complete, we copy the items from _dataSet to _data which will // be used to provide the results of this stage through _resultIterator. - vector<SortableDataItem> _data; + std::vector<SortableDataItem> _data; typedef std::set<SortableDataItem, WorkingSetComparator> SortableDataItemSet; scoped_ptr<SortableDataItemSet> _dataSet; // Iterates through _data post-sort returning it. - vector<SortableDataItem>::iterator _resultIterator; + std::vector<SortableDataItem>::iterator _resultIterator; // We buffer a lot of data and we want to look it up by DiskLoc quickly upon invalidation. typedef unordered_map<DiskLoc, WorkingSetID, DiskLoc::Hasher> DataMap; diff --git a/src/mongo/db/exec/working_set.h b/src/mongo/db/exec/working_set.h index 90ef451f75c..2cbdef90c15 100644 --- a/src/mongo/db/exec/working_set.h +++ b/src/mongo/db/exec/working_set.h @@ -115,7 +115,7 @@ namespace mongo { // All WorkingSetIDs are indexes into this, except for INVALID_ID. // Elements are added to _freeList rather than removed when freed. - vector<MemberHolder> _data; + std::vector<MemberHolder> _data; // Index into _data, forming a linked-list using MemberHolder::nextFreeOrSelf as the next // link. INVALID_ID is the list terminator since 0 is a valid index. @@ -221,7 +221,7 @@ namespace mongo { DiskLoc loc; BSONObj obj; - vector<IndexKeyDatum> keyData; + std::vector<IndexKeyDatum> keyData; MemberState state; bool hasLoc() const; @@ -246,7 +246,7 @@ namespace mongo { * * Returns false otherwise. Returning false indicates a query planning error. */ - bool getFieldDotted(const string& field, BSONElement* out) const; + bool getFieldDotted(const std::string& field, BSONElement* out) const; /** * Returns expected memory usage of working set member. diff --git a/src/mongo/db/extsort.h b/src/mongo/db/extsort.h index 76c032bf21d..071e4deaea7 100644 --- a/src/mongo/db/extsort.h +++ b/src/mongo/db/extsort.h @@ -36,7 +36,7 @@ namespace mongo { - typedef pair<BSONObj, DiskLoc> ExternalSortDatum; + typedef std::pair<BSONObj, DiskLoc> ExternalSortDatum; /** * To external sort, you provide a pointer to an implementation of this class. @@ -51,7 +51,7 @@ namespace mongo { // TODO This class will probably disappear in the future or be replaced with a typedef class BSONObjExternalSorter : boost::noncopyable { public: - typedef pair<BSONObj, DiskLoc> Data; + typedef std::pair<BSONObj, DiskLoc> Data; typedef SortIteratorInterface<BSONObj, DiskLoc> Iterator; BSONObjExternalSorter(const ExternalSortComparison* comp, long maxFileSize=100*1024*1024); @@ -60,7 +60,7 @@ namespace mongo { _sorter->add(o.getOwned(), loc); } - auto_ptr<Iterator> iterator() { return auto_ptr<Iterator>(_sorter->done()); } + std::auto_ptr<Iterator> iterator() { return std::auto_ptr<Iterator>(_sorter->done()); } // XXX: do we need this void sort() { } diff --git a/src/mongo/db/field_parser-inl.h b/src/mongo/db/field_parser-inl.h index 67a8ef4b436..cbcf75a504b 100644 --- a/src/mongo/db/field_parser-inl.h +++ b/src/mongo/db/field_parser-inl.h @@ -36,8 +36,8 @@ namespace mongo { template<class T> void _genFieldErrMsg(const BSONElement& elem, const BSONField<T>& field, - const string expected, - string* errMsg) + const std::string expected, + std::string* errMsg) { if (!errMsg) return; *errMsg = stream() << "wrong type for '" << field() << "' field, expected " << expected @@ -48,7 +48,7 @@ namespace mongo { FieldParser::FieldState FieldParser::extract(BSONObj doc, const BSONField<T>& field, T* out, - string* errMsg) + std::string* errMsg) { BSONElement elem = doc[field.name()]; if (elem.eoo()) { @@ -77,12 +77,12 @@ namespace mongo { FieldParser::FieldState FieldParser::extract(BSONObj doc, const BSONField<T*>& field, T** out, - string* errMsg) + std::string* errMsg) { BSONElement elem = doc[field.name()]; if (elem.eoo()) { if (field.hasDefault()) { - auto_ptr<T> temp(new T); + std::auto_ptr<T> temp(new T); field.getDefault()->cloneTo(temp.get()); *out = temp.release(); @@ -98,7 +98,7 @@ namespace mongo { return FIELD_INVALID; } - auto_ptr<T> temp(new T); + std::auto_ptr<T> temp(new T); if (!temp->parseBSON(elem.embeddedObject(), errMsg)) { return FIELD_INVALID; } @@ -111,7 +111,7 @@ namespace mongo { FieldParser::FieldState FieldParser::extract(BSONObj doc, const BSONField<T>& field, T** out, - string* errMsg) + std::string* errMsg) { BSONElement elem = doc[field.name()]; if (elem.eoo()) { @@ -134,7 +134,7 @@ namespace mongo { return FIELD_INVALID; } - auto_ptr<T> temp(new T); + std::auto_ptr<T> temp(new T); if (!temp->parseBSON(elem.embeddedObject(), errMsg)) { return FIELD_INVALID; } @@ -146,17 +146,17 @@ namespace mongo { // Extracts an array into a vector template<typename T> FieldParser::FieldState FieldParser::extract( BSONObj doc, - const BSONField<vector<T> >& field, - vector<T>* out, - string* errMsg ) { + const BSONField<std::vector<T> >& field, + std::vector<T>* out, + std::string* errMsg ) { return extract( doc[field.name()], field, out, errMsg ); } template<typename T> FieldParser::FieldState FieldParser::extract( BSONElement elem, - const BSONField<vector<T> >& field, - vector<T>* out, - string* errMsg ) + const BSONField<std::vector<T> >& field, + std::vector<T>* out, + std::string* errMsg ) { if (elem.eoo()) { if (field.hasDefault()) { @@ -170,7 +170,7 @@ namespace mongo { if (elem.type() == Array) { BSONArray arr = BSONArray(elem.embeddedObject()); - string elErrMsg; + std::string elErrMsg; // Append all the new elements to the end of the vector size_t initialSize = out->size(); @@ -208,9 +208,9 @@ namespace mongo { template<typename T> FieldParser::FieldState FieldParser::extract(BSONObj doc, - const BSONField<vector<T*> >& field, - vector<T*>* out, - string* errMsg) { + const BSONField<std::vector<T*> >& field, + std::vector<T*>* out, + std::string* errMsg) { dassert(!field.hasDefault()); BSONElement elem = doc[field.name()]; @@ -240,7 +240,7 @@ namespace mongo { return FIELD_INVALID; } - auto_ptr<T> toInsert(new T); + std::auto_ptr<T> toInsert(new T); if ( !toInsert->parseBSON( next.embeddedObject(), errMsg ) || !toInsert->isValid( errMsg ) ) { @@ -254,17 +254,17 @@ namespace mongo { } template<typename T> - void FieldParser::clearOwnedVector(vector<T*>* vec) { - for (typename vector<T*>::iterator it = vec->begin(); it != vec->end(); ++it) { + void FieldParser::clearOwnedVector(std::vector<T*>* vec) { + for (typename std::vector<T*>::iterator it = vec->begin(); it != vec->end(); ++it) { delete (*it); } } template<typename T> FieldParser::FieldState FieldParser::extract(BSONObj doc, - const BSONField<vector<T*> >& field, - vector<T*>** out, - string* errMsg) { + const BSONField<std::vector<T*> >& field, + std::vector<T*>** out, + std::string* errMsg) { dassert(!field.hasDefault()); BSONElement elem = doc[field.name()]; @@ -280,7 +280,7 @@ namespace mongo { return FIELD_INVALID; } - auto_ptr<vector<T*> > tempVector(new vector<T*>); + std::auto_ptr<std::vector<T*> > tempVector(new std::vector<T*>); BSONArray arr = BSONArray(elem.embeddedObject()); BSONObjIterator objIt(arr); @@ -297,7 +297,7 @@ namespace mongo { return FIELD_INVALID; } - auto_ptr<T> toInsert(new T); + std::auto_ptr<T> toInsert(new T); if (!toInsert->parseBSON(next.embeddedObject(), errMsg)) { clearOwnedVector(tempVector.get()); return FIELD_INVALID; @@ -313,17 +313,17 @@ namespace mongo { // Extracts an object into a map template<typename K, typename T> FieldParser::FieldState FieldParser::extract( BSONObj doc, - const BSONField<map<K, T> >& field, - map<K, T>* out, - string* errMsg ) { + const BSONField<std::map<K, T> >& field, + std::map<K, T>* out, + std::string* errMsg ) { return extract( doc[field.name()], field, out, errMsg ); } template<typename K, typename T> FieldParser::FieldState FieldParser::extract( BSONElement elem, - const BSONField<map<K, T> >& field, - map<K, T>* out, - string* errMsg ) + const BSONField<std::map<K, T> >& field, + std::map<K, T>* out, + std::string* errMsg ) { if (elem.eoo()) { if (field.hasDefault()) { @@ -337,7 +337,7 @@ namespace mongo { if (elem.type() == Object) { BSONObj obj = elem.embeddedObject(); - string elErrMsg; + std::string elErrMsg; BSONObjIterator objIt(obj); while (objIt.more()) { diff --git a/src/mongo/db/field_parser.h b/src/mongo/db/field_parser.h index cf3511cae92..a0897c16fdd 100644 --- a/src/mongo/db/field_parser.h +++ b/src/mongo/db/field_parser.h @@ -69,92 +69,92 @@ namespace mongo { static FieldState extract( BSONObj doc, const BSONField<bool>& field, bool* out, - string* errMsg = NULL ); + std::string* errMsg = NULL ); static FieldState extract( BSONElement elem, const BSONField<bool>& field, bool* out, - string* errMsg = NULL ); + std::string* errMsg = NULL ); static FieldState extract( BSONObj doc, const BSONField<BSONArray>& field, BSONArray* out, - string* errMsg = NULL ); + std::string* errMsg = NULL ); static FieldState extract( BSONElement elem, const BSONField<BSONArray>& field, BSONArray* out, - string* errMsg = NULL ); + std::string* errMsg = NULL ); static FieldState extract( BSONObj doc, const BSONField<BSONObj>& field, BSONObj* out, - string* errMsg = NULL ); + std::string* errMsg = NULL ); static FieldState extract( BSONElement elem, const BSONField<BSONObj>& field, BSONObj* out, - string* errMsg = NULL ); + std::string* errMsg = NULL ); static FieldState extract( BSONObj doc, const BSONField<Date_t>& field, Date_t* out, - string* errMsg = NULL ); + std::string* errMsg = NULL ); static FieldState extract( BSONElement elem, const BSONField<Date_t>& field, Date_t* out, - string* errMsg = NULL ); + std::string* errMsg = NULL ); static FieldState extract( BSONObj doc, const BSONField<OpTime>& field, OpTime* out, - string* errMsg = NULL ); + std::string* errMsg = NULL ); static FieldState extract( BSONElement elem, const BSONField<OpTime>& field, OpTime* out, - string* errMsg = NULL ); + std::string* errMsg = NULL ); static FieldState extract( BSONObj doc, - const BSONField<string>& field, - string* out, - string* errMsg = NULL ); + const BSONField<std::string>& field, + std::string* out, + std::string* errMsg = NULL ); static FieldState extract( BSONElement elem, - const BSONField<string>& field, - string* out, - string* errMsg = NULL ); + const BSONField<std::string>& field, + std::string* out, + std::string* errMsg = NULL ); static FieldState extract( BSONObj doc, const BSONField<OID>& field, OID* out, - string* errMsg = NULL ); + std::string* errMsg = NULL ); static FieldState extract( BSONElement elem, const BSONField<OID>& field, OID* out, - string* errMsg = NULL ); + std::string* errMsg = NULL ); static FieldState extract( BSONObj doc, const BSONField<int>& field, int* out, - string* errMsg = NULL ); + std::string* errMsg = NULL ); static FieldState extract( BSONElement elem, const BSONField<int>& field, int* out, - string* errMsg = NULL ); + std::string* errMsg = NULL ); static FieldState extract( BSONObj doc, const BSONField<long long>& field, long long* out, - string* errMsg = NULL ); + std::string* errMsg = NULL ); static FieldState extract( BSONElement elem, const BSONField<long long>& field, long long* out, - string* errMsg = NULL ); + std::string* errMsg = NULL ); /** * The following extractNumber methods do implicit conversion between any numeric type and @@ -164,22 +164,22 @@ namespace mongo { static FieldState extractNumber( BSONObj doc, const BSONField<int>& field, int* out, - string* errMsg = NULL ); + std::string* errMsg = NULL ); static FieldState extractNumber( BSONElement elem, const BSONField<int>& field, int* out, - string* errMsg = NULL ); + std::string* errMsg = NULL ); static FieldState extractNumber( BSONObj doc, const BSONField<long long>& field, long long* out, - string* errMsg = NULL ); + std::string* errMsg = NULL ); static FieldState extractNumber( BSONElement elem, const BSONField<long long>& field, long long* out, - string* errMsg = NULL ); + std::string* errMsg = NULL ); /** * Extracts a document id from a particular field name, which may be of any type but Array. @@ -188,12 +188,12 @@ namespace mongo { static FieldState extractID( BSONObj doc, const BSONField<BSONObj>& field, BSONObj* out, - string* errMsg = NULL ); + std::string* errMsg = NULL ); static FieldState extractID( BSONElement elem, const BSONField<BSONObj>& field, BSONObj* out, - string* errMsg = NULL ); + std::string* errMsg = NULL ); // TODO: BSONElement extraction of types below @@ -209,13 +209,13 @@ namespace mongo { static FieldState extract(BSONObj doc, const BSONField<T>& field, T* out, - string* errMsg = NULL); + std::string* errMsg = NULL); template<typename T> static FieldState extract(BSONObj doc, const BSONField<T*>& field, T** out, - string* errMsg = NULL); + std::string* errMsg = NULL); /** * Similar to the mandatory 'extract' but on a optional field. '*out' would only be @@ -228,7 +228,7 @@ namespace mongo { static FieldState extract(BSONObj doc, const BSONField<T>& field, T** out, // alloc variation - string* errMsg = NULL); + std::string* errMsg = NULL); /** * Extracts a mandatory repetition of BSONSerializable structures, 'field', from the @@ -242,9 +242,9 @@ namespace mongo { */ template<typename T> static FieldState extract(BSONObj doc, - const BSONField<vector<T*> >& field, - vector<T*>* out, - string* errMsg = NULL); + const BSONField<std::vector<T*> >& field, + std::vector<T*>* out, + std::string* errMsg = NULL); /** * Similar to the mandatory repetition' extract but on an optional field. '*out' would @@ -257,9 +257,9 @@ namespace mongo { */ template<typename T> static FieldState extract(BSONObj doc, - const BSONField<vector<T*> >& field, - vector<T*>** out, - string* errMsg = NULL); + const BSONField<std::vector<T*> >& field, + std::vector<T*>** out, + std::string* errMsg = NULL); // // ==================== Below DEPRECATED; use types instead ==================== @@ -271,36 +271,36 @@ namespace mongo { * * It's possible to nest extraction of vectors and maps to any depth, i.e: * - * vector<map<string,vector<string> > > val; + * std::vector<map<std::string,vector<std::string> > > val; * FieldParser::extract(doc, field, val, &val); */ template<typename T> static FieldState extract( BSONObj doc, - const BSONField<vector<T> >& field, - vector<T>* out, - string* errMsg = NULL ); + const BSONField<std::vector<T> >& field, + std::vector<T>* out, + std::string* errMsg = NULL ); template<typename T> static FieldState extract( BSONElement elem, - const BSONField<vector<T> >& field, - vector<T>* out, - string* errMsg = NULL ); + const BSONField<std::vector<T> >& field, + std::vector<T>* out, + std::string* errMsg = NULL ); template<typename K, typename T> static FieldState extract( BSONObj doc, - const BSONField<map<K, T> >& field, - map<K, T>* out, - string* errMsg = NULL ); + const BSONField<std::map<K, T> >& field, + std::map<K, T>* out, + std::string* errMsg = NULL ); template<typename K, typename T> static FieldState extract( BSONElement elem, - const BSONField<map<K, T> >& field, - map<K, T>* out, - string* errMsg = NULL ); + const BSONField<std::map<K, T> >& field, + std::map<K, T>* out, + std::string* errMsg = NULL ); private: template<typename T> - static void clearOwnedVector(vector<T*>* vec); + static void clearOwnedVector(std::vector<T*>* vec); }; } // namespace mongo diff --git a/src/mongo/db/fts/fts_command.h b/src/mongo/db/fts/fts_command.h index 4dc84bfb6e8..4c0ced7efea 100644 --- a/src/mongo/db/fts/fts_command.h +++ b/src/mongo/db/fts/fts_command.h @@ -56,24 +56,24 @@ namespace mongo { std::vector<Privilege>* out); - bool run(OperationContext* txn, const string& dbname, + bool run(OperationContext* txn, const std::string& dbname, BSONObj& cmdObj, int options, - string& errmsg, + std::string& errmsg, BSONObjBuilder& result, bool fromRepl); protected: - bool _run( const string& dbName, + bool _run( const std::string& dbName, BSONObj& cmdObj, int cmdOptions, - const string& ns, - const string& searchString, - string language, // "" for not-set + const std::string& ns, + const std::string& searchString, + std::string language, // "" for not-set int limit, BSONObj& filter, BSONObj& projection, - string& errmsg, + std::string& errmsg, BSONObjBuilder& result ); }; diff --git a/src/mongo/db/fts/fts_index_format.h b/src/mongo/db/fts/fts_index_format.h index e7d64bc0479..75084e822ad 100644 --- a/src/mongo/db/fts/fts_index_format.h +++ b/src/mongo/db/fts/fts_index_format.h @@ -46,12 +46,12 @@ namespace mongo { /* * Helper method to get return entry from the FTSIndex as a BSONObj * @param weight, the weight of the term in the entry - * @param term, the string term in the entry + * @param term, the std::string term in the entry * @param indexPrefix, the fields that go in the index first * @param textIndexVersion, index version. affects key format. */ static BSONObj getIndexKey( double weight, - const string& term, + const std::string& term, const BSONObj& indexPrefix, TextIndexVersion textIndexVersion ); @@ -60,10 +60,10 @@ namespace mongo { * Helper method to get return entry from the FTSIndex as a BSONObj * @param b, reference to the BSONOBjBuilder * @param weight, the weight of the term in the entry - * @param term, the string term in the entry + * @param term, the std::string term in the entry * @param textIndexVersion, index version. affects key format. */ - static void _appendIndexKey( BSONObjBuilder& b, double weight, const string& term, + static void _appendIndexKey( BSONObjBuilder& b, double weight, const std::string& term, TextIndexVersion textIndexVersion ); }; diff --git a/src/mongo/db/fts/fts_language.h b/src/mongo/db/fts/fts_language.h index 3a7a471bc32..5877c8a2756 100644 --- a/src/mongo/db/fts/fts_language.h +++ b/src/mongo/db/fts/fts_language.h @@ -71,13 +71,13 @@ namespace mongo { FTSLanguage(); /** - * Returns the language as a string in canonical form (lowercased English name). It is + * Returns the language as a std::string in canonical form (lowercased English name). It is * an error to call str() on an uninitialized language. */ const std::string& str() const; /** - * Register string 'languageName' as a new language with text index version + * Register std::string 'languageName' as a new language with text index version * 'textIndexVersion'. Saves the resulting language to out-argument 'languageOut'. * Subsequent calls to FTSLanguage::make() will recognize the newly-registered language * string. @@ -97,7 +97,7 @@ namespace mongo { /** * Return the FTSLanguage associated with the given language string. Returns an error - * Status if an invalid language string is passed. + * Status if an invalid language std::string is passed. * * For textIndexVersion=TEXT_INDEX_VERSION_2, language strings are * case-insensitive, and need to be in one of the two following forms: @@ -114,7 +114,7 @@ namespace mongo { TextIndexVersion textIndexVersion ); private: - // String representation of language in canonical form. + // std::string representation of language in canonical form. std::string _canonicalName; }; diff --git a/src/mongo/db/fts/fts_matcher.h b/src/mongo/db/fts/fts_matcher.h index d32a92d11f9..3e3b971ddc3 100644 --- a/src/mongo/db/fts/fts_matcher.h +++ b/src/mongo/db/fts/fts_matcher.h @@ -52,7 +52,7 @@ namespace mongo { * so all full phrases and no negated */ bool phrasesMatch( const BSONObj& obj ) const; - bool phraseMatch( const string& phrase, const BSONObj& obj ) const; + bool phraseMatch( const std::string& phrase, const BSONObj& obj ) const; bool matchesNonTerm( const BSONObj& obj ) const { return !hasNegativeTerm( obj ) && phrasesMatch( obj ); @@ -62,12 +62,12 @@ namespace mongo { /** * @return true if raw has a negated term */ - bool _hasNegativeTerm_string( const FTSLanguage* language, const string& raw ) const; + bool _hasNegativeTerm_string( const FTSLanguage* language, const std::string& raw ) const; /** * @return true if raw has a phrase */ - bool _phraseMatches( const string& phrase, const string& raw ) const; + bool _phraseMatches( const std::string& phrase, const std::string& raw ) const; FTSQuery _query; FTSSpec _spec; diff --git a/src/mongo/db/fts/fts_query.h b/src/mongo/db/fts/fts_query.h index 953bdf15daf..1d8146c2ddc 100644 --- a/src/mongo/db/fts/fts_query.h +++ b/src/mongo/db/fts/fts_query.h @@ -49,13 +49,13 @@ namespace mongo { class FTSQuery { public: - Status parse(const string& query, const StringData& language); + Status parse(const std::string& query, const StringData& language); - const vector<string>& getTerms() const { return _terms; } - const set<string>& getNegatedTerms() const { return _negatedTerms; } + const std::vector<std::string>& getTerms() const { return _terms; } + const std::set<std::string>& getNegatedTerms() const { return _negatedTerms; } - const vector<string>& getPhr() const { return _phrases; } - const vector<string>& getNegatedPhr() const { return _negatedPhrases; } + const std::vector<std::string>& getPhr() const { return _phrases; } + const std::vector<std::string>& getNegatedPhr() const { return _negatedPhrases; } /** * @return true if any negations or phrase + or - @@ -67,25 +67,25 @@ namespace mongo { _negatedPhrases.size() > 0; } - string getSearch() const { return _search; } + std::string getSearch() const { return _search; } const FTSLanguage& getLanguage() const { return *_language; } - string toString() const; + std::string toString() const; - string debugString() const; + std::string debugString() const; BSONObj toBSON() const; protected: - string _search; + std::string _search; const FTSLanguage* _language; - vector<string> _terms; - set<string> _negatedTerms; - vector<string> _phrases; - vector<string> _negatedPhrases; + std::vector<std::string> _terms; + std::set<std::string> _negatedTerms; + std::vector<std::string> _phrases; + std::vector<std::string> _negatedPhrases; private: - void _addTerm( const StopWords* sw, Stemmer& stemmer, const string& term, bool negated ); + void _addTerm( const StopWords* sw, Stemmer& stemmer, const std::string& term, bool negated ); }; } diff --git a/src/mongo/db/fts/fts_spec.h b/src/mongo/db/fts/fts_spec.h index 8bc47fcbaad..7f6365002fb 100644 --- a/src/mongo/db/fts/fts_spec.h +++ b/src/mongo/db/fts/fts_spec.h @@ -49,8 +49,8 @@ namespace mongo { extern const double MAX_WORD_WEIGHT; extern const double DEFAULT_WEIGHT; - typedef std::map<string,double> Weights; // TODO cool map - typedef unordered_map<string,double> TermFrequencyMap; + typedef std::map<std::string,double> Weights; // TODO cool map + typedef unordered_map<std::string,double> TermFrequencyMap; struct ScoreHelperStruct { ScoreHelperStruct() @@ -60,7 +60,7 @@ namespace mongo { double count; double exp; }; - typedef unordered_map<string,ScoreHelperStruct> ScoreHelperMap; + typedef unordered_map<std::string,ScoreHelperStruct> ScoreHelperMap; class FTSSpec { @@ -82,7 +82,7 @@ namespace mongo { bool wildcard() const { return _wildcard; } const FTSLanguage& defaultLanguage() const { return *_defaultLanguage; } - const string& languageOverrideField() const { return _languageOverrideField; } + const std::string& languageOverrideField() const { return _languageOverrideField; } size_t numExtraBefore() const { return _extraBefore.size(); } const std::string& extraBefore( unsigned i ) const { return _extraBefore[i]; } @@ -161,17 +161,17 @@ namespace mongo { TextIndexVersion _textIndexVersion; const FTSLanguage* _defaultLanguage; - string _languageOverrideField; + std::string _languageOverrideField; bool _wildcard; // mapping : fieldname -> weight Weights _weights; // Prefix compound key - used to partition search index - std::vector<string> _extraBefore; + std::vector<std::string> _extraBefore; // Suffix compound key - used for covering index behavior - std::vector<string> _extraAfter; + std::vector<std::string> _extraAfter; }; } diff --git a/src/mongo/db/geo/core.h b/src/mongo/db/geo/core.h index ca4b7138be7..9ca48d86dd0 100644 --- a/src/mongo/db/geo/core.h +++ b/src/mongo/db/geo/core.h @@ -42,8 +42,8 @@ namespace mongo { inline double computeXScanDistance(double y, double maxDistDegrees) { // TODO: this overestimates for large maxDistDegrees far from the equator - return maxDistDegrees / min(cos(deg2rad(min(+89.0, y + maxDistDegrees))), - cos(deg2rad(max(-89.0, y - maxDistDegrees)))); + return maxDistDegrees / std::min(cos(deg2rad(std::min(+89.0, y + maxDistDegrees))), + cos(deg2rad(std::max(-89.0, y - maxDistDegrees)))); } } diff --git a/src/mongo/db/geo/geoquery.h b/src/mongo/db/geo/geoquery.h index 79a7c321673..13adcdfcba0 100644 --- a/src/mongo/db/geo/geoquery.h +++ b/src/mongo/db/geo/geoquery.h @@ -112,7 +112,7 @@ namespace mongo { maxDistance(std::numeric_limits<double>::max()), isNearSphere(false) { } - NearQuery(const string& f) + NearQuery(const std::string& f) : field(f), minDistance(0), maxDistance(std::numeric_limits<double>::max()), @@ -121,7 +121,7 @@ namespace mongo { Status parseFrom(const BSONObj &obj); // The name of the field that contains the geometry. - string field; + std::string field; // The starting point of the near search. PointWithCRS centroid; @@ -136,8 +136,8 @@ namespace mongo { // It's either $near or $nearSphere. bool isNearSphere; - string toString() const { - stringstream ss; + std::string toString() const { + std::stringstream ss; ss << " field=" << field; ss << " maxdist=" << maxDistance; ss << " isNearSphere=" << isNearSphere; @@ -153,7 +153,7 @@ namespace mongo { class GeoQuery { public: GeoQuery() : field(""), predicate(INVALID) {} - GeoQuery(const string& f) : field(f), predicate(INVALID) {} + GeoQuery(const std::string& f) : field(f), predicate(INVALID) {} enum Predicate { WITHIN, @@ -166,7 +166,7 @@ namespace mongo { bool hasS2Region() const; const S2Region& getRegion() const; - string getField() const { return field; } + std::string getField() const { return field; } Predicate getPred() const { return predicate; } const GeometryContainer& getGeometry() const { return geoContainer; } @@ -177,7 +177,7 @@ namespace mongo { bool parseNewQuery(const BSONObj &obj); // Name of the field in the query. - string field; + std::string field; GeometryContainer geoContainer; Predicate predicate; }; diff --git a/src/mongo/db/geo/hash.h b/src/mongo/db/geo/hash.h index b65dfbb78cb..e1a37f23555 100644 --- a/src/mongo/db/geo/hash.h +++ b/src/mongo/db/geo/hash.h @@ -48,7 +48,7 @@ namespace mongo { GeoHash(); // The strings are binary values of length <= 64, // examples: 1001010100101, 1 - explicit GeoHash(const string& hash); + explicit GeoHash(const std::string& hash); explicit GeoHash(const char *s); // bits is how many bits are used to hash each of x and y. GeoHash(unsigned x, unsigned y, unsigned bits = 32); @@ -70,8 +70,8 @@ namespace mongo { bool hasPrefix(const GeoHash& other) const; - string toString() const; - string toStringHex1() const; + std::string toString() const; + std::string toStringHex1() const; void setBit(unsigned pos, bool value); bool getBit(unsigned pos) const; @@ -117,7 +117,7 @@ namespace mongo { // XXX not sure why this is done exactly. Why does binary // data need to be reversed? byte ordering of some sort? static void _copyAndReverse(char *dst, const char *src); - // Create a hash from the provided string. Used by the string and char* cons. + // Create a hash from the provided string. Used by the std::string and char* cons. void initFromString(const char *s); /* Keep the upper _bits*2 bits of _hash, clear the lower bits. * Maybe there's junk in there? XXX Not sure why this is done. diff --git a/src/mongo/db/geo/s2common.h b/src/mongo/db/geo/s2common.h index 6cf07aa48b3..acee143c1d0 100644 --- a/src/mongo/db/geo/s2common.h +++ b/src/mongo/db/geo/s2common.h @@ -69,13 +69,13 @@ namespace mongo { double radius; - string toString() const { - stringstream ss; - ss << "maxKeysPerInsert: " << maxKeysPerInsert << endl; - ss << "maxCellsInCovering: " << maxCellsInCovering << endl; - ss << "finestIndexedLevel: " << finestIndexedLevel << endl; - ss << "coarsestIndexedLevel: " << coarsestIndexedLevel << endl; - ss << "indexVersion: " << indexVersion << endl; + std::string toString() const { + std::stringstream ss; + ss << "maxKeysPerInsert: " << maxKeysPerInsert << std::endl; + ss << "maxCellsInCovering: " << maxCellsInCovering << std::endl; + ss << "finestIndexedLevel: " << finestIndexedLevel << std::endl; + ss << "coarsestIndexedLevel: " << coarsestIndexedLevel << std::endl; + ss << "indexVersion: " << indexVersion << std::endl; return ss.str(); } @@ -91,7 +91,7 @@ namespace mongo { public: // Given a coverer, region, and field name, generate a BSONObj that we can pass to a // FieldRangeSet so that we only examine the keys that the provided region may intersect. - static BSONObj coverAsBSON(const vector<S2CellId> &cover, const string& field, + static BSONObj coverAsBSON(const std::vector<S2CellId> &cover, const std::string& field, const int coarsestIndexedLevel); static void setCoverLimitsBasedOnArea(double area, S2RegionCoverer *coverer, int coarsestIndexedLevel); static bool distanceBetween(const S2Point& us, const BSONObj& them, double *out); diff --git a/src/mongo/db/geo/shapes.h b/src/mongo/db/geo/shapes.h index 2f18f6731c2..6bd7ba3bd1d 100644 --- a/src/mongo/db/geo/shapes.h +++ b/src/mongo/db/geo/shapes.h @@ -54,7 +54,7 @@ namespace mongo { Point(double x, double y); explicit Point(const BSONElement& e); explicit Point(const BSONObj& o); - string toString() const; + std::string toString() const; double x; double y; @@ -75,7 +75,7 @@ namespace mongo { Box(Point min, Point max); BSONArray toBSON() const; - string toString() const; + std::string toString() const; bool between(double min, double max, double val, double fudge = 0) const; bool onBoundary(double bound, double val, double fudge = 0) const; @@ -98,7 +98,7 @@ namespace mongo { class Polygon { public: Polygon(); - Polygon(vector<Point> points); + Polygon(std::vector<Point> points); void add(Point p); int size() const; @@ -123,7 +123,7 @@ namespace mongo { Point _centroid; Box _bounds; bool _boundsCalculated; - vector<Point> _points; + std::vector<Point> _points; }; // Clearly this isn't right but currently it's sufficient. @@ -166,8 +166,8 @@ namespace mongo { }; struct MultiPointWithCRS { - vector<S2Point> points; - vector<S2Cell> cells; + std::vector<S2Point> points; + std::vector<S2Cell> cells; CRS crs; }; @@ -182,7 +182,7 @@ namespace mongo { }; struct GeometryCollection { - vector<PointWithCRS> points; + std::vector<PointWithCRS> points; // The amount of indirection here is painful but we can't operator= scoped_ptr or // OwnedPointerVector. diff --git a/src/mongo/db/index/2d_access_method.h b/src/mongo/db/index/2d_access_method.h index e8584bf0ae4..e7796ea0b4d 100644 --- a/src/mongo/db/index/2d_access_method.h +++ b/src/mongo/db/index/2d_access_method.h @@ -96,7 +96,7 @@ namespace mongo { TwoDIndexingParams& getParams() { return _params; } // This really gets the 'locs' from the provided obj. - void getKeys(const BSONObj& obj, vector<BSONObj>& locs) const; + void getKeys(const BSONObj& obj, std::vector<BSONObj>& locs) const; virtual void getKeys(const BSONObj& obj, BSONObjSet* keys); diff --git a/src/mongo/db/index/2d_common.h b/src/mongo/db/index/2d_common.h index 1027a73c507..dd2dc6faff3 100644 --- a/src/mongo/db/index/2d_common.h +++ b/src/mongo/db/index/2d_common.h @@ -36,8 +36,8 @@ namespace mongo { struct TwoDIndexingParams { - string geo; - vector<pair<string, int> > other; + std::string geo; + std::vector<std::pair<std::string, int> > other; shared_ptr<GeoHashConverter> geoHashConverter; }; diff --git a/src/mongo/db/index/btree_based_access_method.h b/src/mongo/db/index/btree_based_access_method.h index cee96988710..decfbb0bc9a 100644 --- a/src/mongo/db/index/btree_based_access_method.h +++ b/src/mongo/db/index/btree_based_access_method.h @@ -139,7 +139,7 @@ namespace mongo { BSONObjSet oldKeys, newKeys; // These point into the sets oldKeys and newKeys. - vector<BSONObj*> removed, added; + std::vector<BSONObj*> removed, added; DiskLoc loc; bool dupsAllowed; diff --git a/src/mongo/db/index/btree_index_cursor.h b/src/mongo/db/index/btree_index_cursor.h index 721276338c9..e33eb68f432 100644 --- a/src/mongo/db/index/btree_index_cursor.h +++ b/src/mongo/db/index/btree_index_cursor.h @@ -55,8 +55,8 @@ namespace mongo { virtual Status seek(const BSONObj& position); // Btree-specific seeking functions. - Status seek(const vector<const BSONElement*>& position, - const vector<bool>& inclusive); + Status seek(const std::vector<const BSONElement*>& position, + const std::vector<bool>& inclusive); /** * Seek to the key 'position'. If 'afterKey' is true, seeks to the first @@ -69,8 +69,8 @@ namespace mongo { Status skip(const BSONObj& keyBegin, int keyBeginLen, bool afterKey, - const vector<const BSONElement*>& keyEnd, - const vector<bool>& keyEndInclusive); + const std::vector<const BSONElement*>& keyEnd, + const std::vector<bool>& keyEndInclusive); virtual BSONObj getKey() const; virtual DiskLoc getValue() const; @@ -87,7 +87,7 @@ namespace mongo { virtual Status restorePosition(); - virtual string toString(); + virtual std::string toString(); private: // We keep the constructor private and only allow the AM to create us. diff --git a/src/mongo/db/index/btree_key_generator.h b/src/mongo/db/index/btree_key_generator.h index f3d3dde39ff..df866e9870c 100644 --- a/src/mongo/db/index/btree_key_generator.h +++ b/src/mongo/db/index/btree_key_generator.h @@ -40,14 +40,14 @@ namespace mongo { */ class BtreeKeyGenerator { public: - BtreeKeyGenerator(vector<const char*> fieldNames, vector<BSONElement> fixed, bool isSparse); + BtreeKeyGenerator(std::vector<const char*> fieldNames, std::vector<BSONElement> fixed, bool isSparse); virtual ~BtreeKeyGenerator() { } Status getKeys(const BSONObj &obj, BSONObjSet *keys) const; protected: // These are used by the getKeysImpl(s) below. - vector<const char*> _fieldNames; + std::vector<const char*> _fieldNames; bool _isSparse; BSONObj _nullKey; // a full key with all fields null BSONObj _nullObj; // only used for _nullElt @@ -55,25 +55,25 @@ namespace mongo { BSONSizeTracker _sizeTracker; private: // We have V0 and V1. Sigh. - virtual Status getKeysImpl(vector<const char*> fieldNames, vector<BSONElement> fixed, + virtual Status getKeysImpl(std::vector<const char*> fieldNames, std::vector<BSONElement> fixed, const BSONObj &obj, BSONObjSet *keys) const = 0; - vector<BSONElement> _fixed; + std::vector<BSONElement> _fixed; }; class BtreeKeyGeneratorV0 : public BtreeKeyGenerator { public: - BtreeKeyGeneratorV0(vector<const char*> fieldNames, vector<BSONElement> fixed, + BtreeKeyGeneratorV0(std::vector<const char*> fieldNames, std::vector<BSONElement> fixed, bool isSparse); virtual ~BtreeKeyGeneratorV0() { } private: - virtual Status getKeysImpl(vector<const char*> fieldNames, vector<BSONElement> fixed, + virtual Status getKeysImpl(std::vector<const char*> fieldNames, std::vector<BSONElement> fixed, const BSONObj &obj, BSONObjSet *keys) const; }; class BtreeKeyGeneratorV1 : public BtreeKeyGenerator { public: - BtreeKeyGeneratorV1(vector<const char*> fieldNames, vector<BSONElement> fixed, + BtreeKeyGeneratorV1(std::vector<const char*> fieldNames, std::vector<BSONElement> fixed, bool isSparse); virtual ~BtreeKeyGeneratorV1() { } @@ -122,7 +122,7 @@ namespace mongo { * Returns the set of index keys generated from 'obj' according to the key pattern * in 'fieldNames' through the out-parameter 'keys'. */ - virtual Status getKeysImpl(vector<const char*> fieldNames, vector<BSONElement> fixed, + virtual Status getKeysImpl(std::vector<const char*> fieldNames, std::vector<BSONElement> fixed, const BSONObj &obj, BSONObjSet *keys) const; /** @@ -131,7 +131,7 @@ namespace mongo { */ Status getKeysForElement(const BSONElement& el, KeygenContext context, - vector<BSONElement>* out) const; + std::vector<BSONElement>* out) const; /** * getKeysForElement(...) delegates to this function if 'el' is an indexed array. Special @@ -139,7 +139,7 @@ namespace mongo { */ Status getKeysForArrayElement(const BSONElement& el, KeygenContext context, - vector<BSONElement>* out) const; + std::vector<BSONElement>* out) const; /** * A helper for getKeysForArrayElement(...) which handles key patterns that have a @@ -152,7 +152,7 @@ namespace mongo { Status handlePositionalKeypattern(const BSONElement& el, KeygenContext context, bool* isPositional, - vector<BSONElement>* out) const; + std::vector<BSONElement>* out) const; /** * getKeysForElement(...) delegates to this function if 'el' is neither an indexed @@ -160,7 +160,7 @@ namespace mongo { */ Status getKeysForSimpleElement(const BSONElement& el, KeygenContext context, - vector<BSONElement>* out) const; + std::vector<BSONElement>* out) const; /** * Outputs the final btree keys in 'keys', constructing them using the extracted @@ -216,7 +216,7 @@ namespace mongo { // [ [ "a", "b", "c" ], // [ "foo" ], // [ "bar", "0", "a" ] ] - typedef vector< vector<string> > KeyPattern; + typedef std::vector< std::vector<string> > KeyPattern; KeyPattern _keyPattern; // The BSONObj {"": undefined}. diff --git a/src/mongo/db/index/expression_index.h b/src/mongo/db/index/expression_index.h index 3806b1e1c4b..4797ea1ea36 100644 --- a/src/mongo/db/index/expression_index.h +++ b/src/mongo/db/index/expression_index.h @@ -71,14 +71,14 @@ namespace mongo { 2 + S2::kAvgEdge.GetClosestLevel(edgeLen))); coverer.set_max_level(4 + coverer.min_level()); - vector<S2CellId> cover; + std::vector<S2CellId> cover; coverer.GetCovering(region, &cover); // Look at the cells we cover and all cells that are within our covering and finer. // Anything with our cover as a strict prefix is contained within the cover and should // be intersection tested. bool considerCoarser = false; - set<string> intervalSet; + std::set<std::string> intervalSet; for (size_t i = 0; i < cover.size(); ++i) { intervalSet.insert(cover[i].toString()); // If any of our covers could be covered by something in the index, we have @@ -88,7 +88,7 @@ namespace mongo { } } - set<string> exactSet; + std::set<std::string> exactSet; if (considerCoarser) { // Look at the cells that cover us. We want to look at every cell that contains the // covering we would index on if we were to insert the query geometry. We generate @@ -113,18 +113,18 @@ namespace mongo { // We turned the cell IDs into strings which define point intervals or prefixes of // strings we want to look for. - set<string>::iterator exactIt = exactSet.begin(); - set<string>::iterator intervalIt = intervalSet.begin(); + std::set<std::string>::iterator exactIt = exactSet.begin(); + std::set<std::string>::iterator intervalIt = intervalSet.begin(); while (exactSet.end() != exactIt && intervalSet.end() != intervalIt) { - const string& exact = *exactIt; - const string& ival = *intervalIt; + const std::string& exact = *exactIt; + const std::string& ival = *intervalIt; if (exact < ival) { // add exact oilOut->intervals.push_back(IndexBoundsBuilder::makePointInterval(exact)); exactIt++; } else { - string end = ival; + std::string end = ival; end[end.size() - 1]++; oilOut->intervals.push_back( IndexBoundsBuilder::makeRangeInterval(ival, end, true, false)); @@ -142,8 +142,8 @@ namespace mongo { else if (intervalSet.end() != intervalIt) { verify(exactSet.end() == exactIt); do { - const string& ival = *intervalIt; - string end = ival; + const std::string& ival = *intervalIt; + std::string end = ival; end[end.size() - 1]++; oilOut->intervals.push_back( IndexBoundsBuilder::makeRangeInterval(ival, end, true, false)); @@ -154,7 +154,7 @@ namespace mongo { // Make sure that our intervals don't overlap each other and are ordered correctly. // This perhaps should only be done in debug mode. if (!oilOut->isValidFor(1)) { - cout << "check your assumptions! OIL = " << oilOut->toString() << endl; + cout << "check your assumptions! OIL = " << oilOut->toString() << std::endl; verify(0); } } diff --git a/src/mongo/db/index/expression_params.h b/src/mongo/db/index/expression_params.h index 90d294c5800..83e23f2778a 100644 --- a/src/mongo/db/index/expression_params.h +++ b/src/mongo/db/index/expression_params.h @@ -50,7 +50,7 @@ namespace mongo { if (e.isNumber()) { order = static_cast<int>(e.Number()); } - out->other.push_back(make_pair(e.fieldName(), order)); + out->other.push_back(std::make_pair(e.fieldName(), order)); } } @@ -72,7 +72,7 @@ namespace mongo { static void parseHashParams(const BSONObj& infoObj, HashSeed* seedOut, int* versionOut, - string* fieldOut) { + std::string* fieldOut) { // Default _seed to DEFAULT_HASH_SEED if "seed" is not included in the index spec // or if the value of "seed" is not a number @@ -101,8 +101,8 @@ namespace mongo { } static void parseHaystackParams(const BSONObj& infoObj, - string* geoFieldOut, - vector<string>* otherFieldsOut, + std::string* geoFieldOut, + std::vector<std::string>* otherFieldsOut, double* bucketSizeOut) { BSONElement e = infoObj["bucketSize"]; @@ -148,7 +148,7 @@ namespace mongo { "coarsestIndexedLevel", S2::kAvgEdge.GetClosestLevel(100 * 1000.0 / out->radius)); - static const string kIndexVersionFieldName("2dsphereIndexVersion"); + static const std::string kIndexVersionFieldName("2dsphereIndexVersion"); // Determine which version of this index we're using. If none was set in the descriptor, // assume S2_INDEX_VERSION_1 (alas, the first version predates the existence of the version @@ -171,14 +171,14 @@ namespace mongo { private: static double configValueWithDefaultDouble(const BSONObj& infoObj, - const string& name, + const std::string& name, double def) { BSONElement e = infoObj[name]; if (e.isNumber()) { return e.numberDouble(); } return def; } - static int configValueWithDefaultInt(const BSONObj& infoObj, const string& name, int def) { + static int configValueWithDefaultInt(const BSONObj& infoObj, const std::string& name, int def) { BSONElement e = infoObj[name]; if (e.isNumber()) { return e.numberInt(); } return def; diff --git a/src/mongo/db/index/hash_access_method.h b/src/mongo/db/index/hash_access_method.h index d0f46620334..e6e701158ce 100644 --- a/src/mongo/db/index/hash_access_method.h +++ b/src/mongo/db/index/hash_access_method.h @@ -57,7 +57,7 @@ namespace mongo { virtual void getKeys(const BSONObj& obj, BSONObjSet* keys); // Only one of our fields is hashed. This is the field name for it. - string _hashedField; + std::string _hashedField; // _seed defaults to zero. HashSeed _seed; diff --git a/src/mongo/db/index/haystack_access_method.h b/src/mongo/db/index/haystack_access_method.h index 29b6485f7d2..82d8eccf6ef 100644 --- a/src/mongo/db/index/haystack_access_method.h +++ b/src/mongo/db/index/haystack_access_method.h @@ -66,8 +66,8 @@ namespace mongo { private: virtual void getKeys(const BSONObj& obj, BSONObjSet* keys); - string _geoField; - vector<string> _otherFields; + std::string _geoField; + std::vector<std::string> _otherFields; double _bucketSize; }; diff --git a/src/mongo/db/index/haystack_access_method_internal.h b/src/mongo/db/index/haystack_access_method_internal.h index c0ee96d2488..b1e8c11ec42 100644 --- a/src/mongo/db/index/haystack_access_method_internal.h +++ b/src/mongo/db/index/haystack_access_method_internal.h @@ -49,7 +49,7 @@ namespace mongo { GeoHaystackSearchHopper(const BSONObj& nearObj, double maxDistance, unsigned limit, - const string& geoField, + const std::string& geoField, const Collection* collection) : _collection(collection), _near(nearObj), @@ -83,8 +83,8 @@ namespace mongo { Point _near; double _maxDistance; unsigned _limit; - const string _geoField; - vector<DiskLoc> _locs; + const std::string _geoField; + std::vector<DiskLoc> _locs; }; } // namespace mongo diff --git a/src/mongo/db/index/index_cursor.h b/src/mongo/db/index/index_cursor.h index 6d50f243f7b..0100eb98184 100644 --- a/src/mongo/db/index/index_cursor.h +++ b/src/mongo/db/index/index_cursor.h @@ -120,8 +120,8 @@ namespace mongo { */ virtual Status restorePosition() = 0; - // Return a string describing the cursor. - virtual string toString() = 0; + // Return a std::string describing the cursor. + virtual std::string toString() = 0; /** * Add debugging info to the provided builder. diff --git a/src/mongo/db/index/index_descriptor.h b/src/mongo/db/index/index_descriptor.h index b3eb54aa6b1..ce1bb344644 100644 --- a/src/mongo/db/index/index_descriptor.h +++ b/src/mongo/db/index/index_descriptor.h @@ -141,13 +141,13 @@ namespace mongo { // Allow access to arbitrary fields in the per-index info object. Some indices stash // index-specific data there. - BSONElement getInfoElement(const string& name) const { return _infoObj[name]; } + BSONElement getInfoElement(const std::string& name) const { return _infoObj[name]; } // // "Internals" of accessing the index, used by IndexAccessMethod(s). // - // Return a (rather compact) string representation. + // Return a (rather compact) std::string representation. std::string toString() const { _checkOk(); return _infoObj.toString(); } // Return the info object. @@ -171,7 +171,7 @@ namespace mongo { return i.next().eoo(); } - static string makeIndexNamespace( const StringData& ns, + static std::string makeIndexNamespace( const StringData& ns, const StringData& name ) { return ns.toString() + ".$" + name.toString(); } diff --git a/src/mongo/db/index_names.h b/src/mongo/db/index_names.h index fd7af42675b..658ddd8459b 100644 --- a/src/mongo/db/index_names.h +++ b/src/mongo/db/index_names.h @@ -57,40 +57,40 @@ namespace mongo { }; /** - * We use the string representation of index names all over the place, so we declare them all + * We use the std::string representation of index names all over the place, so we declare them all * once here. */ class IndexNames { public: - static const string GEO_2D; - static const string GEO_HAYSTACK; - static const string GEO_2DSPHERE; - static const string TEXT; - static const string HASHED; - static const string BTREE; + static const std::string GEO_2D; + static const std::string GEO_HAYSTACK; + static const std::string GEO_2DSPHERE; + static const std::string TEXT; + static const std::string HASHED; + static const std::string BTREE; /** * True if is a regular (non-plugin) index or uses a plugin that existed before 2.4. * These plugins are grandfathered in and allowed to exist in DBs with * PDFILE_MINOR_VERSION_22_AND_OLDER */ - static bool existedBefore24(const string& name); + static bool existedBefore24(const std::string& name); /** - * Return the first string value in the provided object. For an index key pattern, + * Return the first std::string value in the provided object. For an index key pattern, * a field with a non-string value indicates a "special" (not straight Btree) index. */ - static string findPluginName(const BSONObj& keyPattern); + static std::string findPluginName(const BSONObj& keyPattern); /** * Is the provided access method name one we recognize? */ - static bool isKnownName(const string& name); + static bool isKnownName(const std::string& name); /** * Convert an index name to an IndexType. */ - static IndexType nameToType(const string& accessMethod); + static IndexType nameToType(const std::string& accessMethod); }; } // namespace mongo diff --git a/src/mongo/db/instance.h b/src/mongo/db/instance.h index e8ceb09d863..4433dcf517d 100644 --- a/src/mongo/db/instance.h +++ b/src/mongo/db/instance.h @@ -40,13 +40,13 @@ namespace mongo { - extern string dbExecCommand; + extern std::string dbExecCommand; /** a high level recording of operations to the database - sometimes used for diagnostics and debugging. */ class DiagLog { - ofstream *f; // note this is never freed + std::ofstream *f; // note this is never freed /* 0 = off; 1 = writes, 2 = reads, 3 = both 7 = log a few reads, and all writes. */ @@ -73,7 +73,7 @@ namespace mongo { DbResponse& dbresponse, const HostAndPort &client ); - void getDatabaseNames(vector<std::string> &names, + void getDatabaseNames(std::vector<std::string> &names, const std::string& usePath = storageGlobalParams.dbpath); /* returns true if there is no data on this server. useful when starting replication. @@ -91,7 +91,7 @@ namespace mongo { using DBClientBase::query; - virtual auto_ptr<DBClientCursor> query(const string &ns, Query query, int nToReturn = 0, int nToSkip = 0, + virtual std::auto_ptr<DBClientCursor> query(const std::string &ns, Query query, int nToReturn = 0, int nToSkip = 0, const BSONObj *fieldsToReturn = 0, int queryOptions = 0, int batchSize = 0); virtual bool isFailed() const { @@ -102,14 +102,14 @@ namespace mongo { return true; } - virtual string toString() const { + virtual std::string toString() const { return "DBDirectClient"; } - virtual string getServerAddress() const { + virtual std::string getServerAddress() const { return "localhost"; // TODO: should this have the port? } - virtual bool call( Message &toSend, Message &response, bool assertOk=true , string * actualServer = 0 ); - virtual void say( Message &toSend, bool isRetry = false , string * actualServer = 0 ); + virtual bool call( Message &toSend, Message &response, bool assertOk=true , std::string * actualServer = 0 ); + virtual void say( Message &toSend, bool isRetry = false , std::string * actualServer = 0 ); virtual void sayPiggyBack( Message &toSend ) { // don't need to piggy back when connected locally return say( toSend ); @@ -121,7 +121,7 @@ namespace mongo { return call( toSend , response ); } - virtual unsigned long long count(const string &ns, const BSONObj& query = BSONObj(), int options=0, int limit=0, int skip=0 ); + virtual unsigned long long count(const std::string &ns, const BSONObj& query = BSONObj(), int options=0, int limit=0, int skip=0 ); virtual ConnectionString::ConnectionType type() const { return ConnectionString::MASTER; } diff --git a/src/mongo/db/interrupt_status.h b/src/mongo/db/interrupt_status.h index 8aa418ced16..42087ac4c01 100644 --- a/src/mongo/db/interrupt_status.h +++ b/src/mongo/db/interrupt_status.h @@ -53,7 +53,7 @@ namespace mongo { /** Check for interrupt. - @returns a pointer to a string with additional information; will be + @returns a pointer to a std::string with additional information; will be "" if there hasn't been an interrupt. These strings are static and don't need to be freed. */ diff --git a/src/mongo/db/json.h b/src/mongo/db/json.h index 04c881fa77d..4df19f756d5 100644 --- a/src/mongo/db/json.h +++ b/src/mongo/db/json.h @@ -42,7 +42,7 @@ namespace mongo { * extensions extensions described here * <http://dochub.mongodb.org/core/mongodbextendedjson>, this function * accepts unquoted field names and allows single quotes to optionally be - * used when specifying field names and string values instead of double + * used when specifying field names and std::string values instead of double * quotes. JSON unicode escape sequences (of the form \uXXXX) are * converted to utf8. * @@ -130,13 +130,13 @@ namespace mongo { * context. */ /* * OIDOBJECT : - * { FIELD("$oid") : <24 character hex string> } + * { FIELD("$oid") : <24 character hex std::string> } */ Status objectIdObject(const StringData& fieldName, BSONObjBuilder&); /* * BINARYOBJECT : - * { FIELD("$binary") : <base64 representation of a binary string>, + * { FIELD("$binary") : <base64 representation of a binary std::string>, * FIELD("$type") : <hexadecimal representation of a single byte * indicating the data type> } */ @@ -169,9 +169,9 @@ namespace mongo { /* * REFOBJECT : * { FIELD("$ref") : <string representing collection name>, - * FIELD("$id") : <24 character hex string> } - * | { FIELD("$ref") : STRING , FIELD("$id") : OBJECTID } - * | { FIELD("$ref") : STRING , FIELD("$id") : OIDOBJECT } + * FIELD("$id") : <24 character hex std::string> } + * | { FIELD("$ref") : std::string , FIELD("$id") : OBJECTID } + * | { FIELD("$ref") : std::string , FIELD("$id") : OIDOBJECT } */ Status dbRefObject(const StringData& fieldName, BSONObjBuilder&); @@ -222,7 +222,7 @@ namespace mongo { /* * OBJECTID : - * ObjectId( <24 character hex string> ) + * ObjectId( <24 character hex std::string> ) */ Status objectId(const StringData& fieldName, BSONObjBuilder&); @@ -240,7 +240,7 @@ namespace mongo { /* * DBREF : - * Dbref( <namespace string> , <24 character hex string> ) + * Dbref( <namespace std::string> , <24 character hex std::string> ) */ Status dbRef(const StringData& fieldName, BSONObjBuilder&); @@ -304,7 +304,7 @@ namespace mongo { Status field(std::string* result); /* - * STRING : + * std::string : * " " * | ' ' * | " CHARS " @@ -317,7 +317,7 @@ namespace mongo { * CHAR * | CHAR CHARS * - * Note: " or ' may be allowed depending on whether the string is + * Note: " or ' may be allowed depending on whether the std::string is * double or single quoted * * CHAR : @@ -350,7 +350,7 @@ namespace mongo { /** * Converts the two byte Unicode code point to its UTF8 character - * encoding representation. This function returns a string because + * encoding representation. This function returns a std::string because * UTF8 encodings for code points from 0x0000 to 0xFFFF can range * from one to three characters. */ @@ -393,12 +393,12 @@ namespace mongo { bool match(char matchChar, const char* matchSet) const; /** - * @return true if every character in the string is a hex digit + * @return true if every character in the std::string is a hex digit */ bool isHexString(const StringData&) const; /** - * @return true if every character in the string is a valid base64 + * @return true if every character in the std::string is a valid base64 * character */ bool isBase64String(const StringData&) const; @@ -417,7 +417,7 @@ namespace mongo { * _input - cursor we advance in our input buffer * _input_end - sentinel for the end of our input buffer * - * _buf is the null terminated buffer containing the JSON string we + * _buf is the null terminated buffer containing the JSON std::string we * are parsing. _input_end points to the null byte at the end of * the buffer. strtoll, strtol, and strtod will access the null * byte at the end of the buffer because they are assuming a c-style diff --git a/src/mongo/db/keypattern.h b/src/mongo/db/keypattern.h index 3e0eebfb613..40454e3b672 100644 --- a/src/mongo/db/keypattern.h +++ b/src/mongo/db/keypattern.h @@ -45,7 +45,7 @@ namespace mongo { * and direction +1, one valid BoundList is: (1, 2); (4, 6). The same BoundList * would be valid for index {i:-1} with direction -1. */ - typedef vector<pair<BSONObj,BSONObj> > BoundList; + typedef std::vector<std::pair<BSONObj,BSONObj> > BoundList; /** A KeyPattern is an expression describing a transformation of a document into a * document key. Document keys are used to store documents in indices and to target @@ -132,7 +132,7 @@ namespace mongo { */ bool isCoveredBy( const KeyPattern& other ) const; - string toString() const{ return toBSON().toString(); } + std::string toString() const{ return toBSON().toString(); } /* Given a document, extracts the index key corresponding to this KeyPattern * Warning: assumes that there is a *single* key to be extracted! diff --git a/src/mongo/db/lasterror.h b/src/mongo/db/lasterror.h index 810b8e1bb87..45788c08ab2 100644 --- a/src/mongo/db/lasterror.h +++ b/src/mongo/db/lasterror.h @@ -139,7 +139,7 @@ namespace mongo { LastError * getSafe() { LastError * le = get(false); if ( ! le ) { - error() << " no LastError!" << endl; + error() << " no LastError!" << std::endl; verify( le ); } return le; diff --git a/src/mongo/db/lockstate.h b/src/mongo/db/lockstate.h index 042134229a2..96ec94e8f3b 100644 --- a/src/mongo/db/lockstate.h +++ b/src/mongo/db/lockstate.h @@ -80,7 +80,7 @@ namespace mongo { int nestableCount() const { return _nestableCount; } int otherCount() const { return _otherCount; } - const string& otherName() const { return _otherName; } + const std::string& otherName() const { return _otherName; } WrapperForRWLock* otherLock() const { return _otherLock; } void enterScopedLock( Lock::ScopedLock* lock ); @@ -108,7 +108,7 @@ namespace mongo { int _nestableCount; // recursive lock count on local or admin db XXX - change name int _otherCount; // >0 means write lock, <0 read lock - XXX change name - string _otherName; // which database are we locking and working with (besides local/admin) + std::string _otherName; // which database are we locking and working with (besides local/admin) WrapperForRWLock* _otherLock; // so we don't have to check the map too often (the map has a mutex) // for temprelease @@ -129,7 +129,7 @@ namespace mongo { bool sharedLatching; LockStat stats; public: - string name() const { return rw.name; } + std::string name() const { return rw.name; } LockStat& getStats() { return stats; } WrapperForRWLock(const StringData& name) diff --git a/src/mongo/db/matcher/expression.h b/src/mongo/db/matcher/expression.h index 8f37a6a7c62..1970b4bfd6f 100644 --- a/src/mongo/db/matcher/expression.h +++ b/src/mongo/db/matcher/expression.h @@ -190,7 +190,7 @@ namespace mongo { // // Debug information // - virtual string toString() const; + virtual std::string toString() const; virtual void debugString( StringBuilder& debug, int level = 0 ) const = 0; protected: diff --git a/src/mongo/db/matcher/expression_leaf.h b/src/mongo/db/matcher/expression_leaf.h index b7d88d06d14..8a843dd7703 100644 --- a/src/mongo/db/matcher/expression_leaf.h +++ b/src/mongo/db/matcher/expression_leaf.h @@ -208,8 +208,8 @@ namespace mongo { virtual bool equivalent( const MatchExpression* other ) const; - const string& getString() const { return _regex; } - const string& getFlags() const { return _flags; } + const std::string& getString() const { return _regex; } + const std::string& getFlags() const { return _flags; } private: std::string _regex; diff --git a/src/mongo/db/matcher/expression_text.h b/src/mongo/db/matcher/expression_text.h index 5842cdc3293..4fc603d9c61 100644 --- a/src/mongo/db/matcher/expression_text.h +++ b/src/mongo/db/matcher/expression_text.h @@ -51,8 +51,8 @@ namespace mongo { virtual LeafMatchExpression* shallowClone() const; - const string& getQuery() const { return _query; } - const string& getLanguage() const { return _language; } + const std::string& getQuery() const { return _query; } + const std::string& getLanguage() const { return _language; } private: std::string _query; std::string _language; diff --git a/src/mongo/db/matcher/path.h b/src/mongo/db/matcher/path.h index 5e0d17a8cf7..8fdf8ed2a11 100644 --- a/src/mongo/db/matcher/path.h +++ b/src/mongo/db/matcher/path.h @@ -143,7 +143,7 @@ namespace mongo { bool isArrayOffsetMatch( const StringData& fieldName ) const; bool nextEntireRest() const { return nextPieceOfPath.size() == restOfPath.size(); } - string restOfPath; + std::string restOfPath; bool hasMore; StringData nextPieceOfPath; bool nextPieceOfPathIsNumber; diff --git a/src/mongo/db/matcher/path_internal.h b/src/mongo/db/matcher/path_internal.h index bf0163f8d31..1e06d618b27 100644 --- a/src/mongo/db/matcher/path_internal.h +++ b/src/mongo/db/matcher/path_internal.h @@ -40,7 +40,7 @@ namespace mongo { bool isAllDigits( const StringData& str ); // XXX document me - // Replaces getFieldDottedOrArray without recursion nor string manipulation + // Replaces getFieldDottedOrArray without recursion nor std::string manipulation BSONElement getFieldDottedOrArray( const BSONObj& doc, const FieldRef& path, size_t* idxPath ); diff --git a/src/mongo/db/namespace_string.h b/src/mongo/db/namespace_string.h index fe864955992..0639c686dc5 100644 --- a/src/mongo/db/namespace_string.h +++ b/src/mongo/db/namespace_string.h @@ -207,7 +207,7 @@ namespace mongo { /** * NamespaceDBHash and NamespaceDBEquals allow you to do something like - * unordered_map<string,int,NamespaceDBHash,NamespaceDBEquals> + * unordered_map<std::string,int,NamespaceDBHash,NamespaceDBEquals> * and use the full namespace for the string * but comparisons are done only on the db piece */ diff --git a/src/mongo/db/ops/count.h b/src/mongo/db/ops/count.h index 5cfe801f979..94384529d6c 100644 --- a/src/mongo/db/ops/count.h +++ b/src/mongo/db/ops/count.h @@ -40,6 +40,6 @@ namespace mongo { * @return -1 on ns does not exist error and other errors, 0 on other errors, otherwise the * match count. */ - long long runCount(const std::string& ns, const BSONObj& cmd, string& err, int& errCode ); + long long runCount(const std::string& ns, const BSONObj& cmd, std::string& err, int& errCode ); } // namespace mongo diff --git a/src/mongo/db/ops/update_driver.h b/src/mongo/db/ops/update_driver.h index 28ca13d80d2..29a702a1917 100644 --- a/src/mongo/db/ops/update_driver.h +++ b/src/mongo/db/ops/update_driver.h @@ -147,7 +147,7 @@ namespace mongo { bool _replacementMode; // Collection of update mod instances. Owned here. - vector<ModifierInterface*> _mods; + std::vector<ModifierInterface*> _mods; // What are the list of fields in the collection over which the update is going to be // applied that participate in indices? diff --git a/src/mongo/db/pipeline/accumulator.h b/src/mongo/db/pipeline/accumulator.h index 61b2dade4e7..d0b48b498b6 100644 --- a/src/mongo/db/pipeline/accumulator.h +++ b/src/mongo/db/pipeline/accumulator.h @@ -168,7 +168,7 @@ namespace mongo { private: AccumulatorPush(); - vector<Value> vpValue; + std::vector<Value> vpValue; }; diff --git a/src/mongo/db/pipeline/document.h b/src/mongo/db/pipeline/document.h index 7f2fde8a26f..1ee358b434c 100644 --- a/src/mongo/db/pipeline/document.h +++ b/src/mongo/db/pipeline/document.h @@ -55,7 +55,7 @@ namespace mongo { /** A Document is similar to a BSONObj but with a different in-memory representation. * - * A Document can be treated as a const map<string, const Value> that is + * A Document can be treated as a const std::map<std::string, const Value> that is * very cheap to copy and is Assignable. Therefore, it is acceptable to * pass and return by Value. Note that the data in a Document is * immutable, but you can replace a Document instance with assignment. @@ -88,7 +88,7 @@ namespace mongo { * TODO a version that doesn't use FieldPath */ const Value getNestedField(const FieldPath& fieldNames, - vector<Position>* positions=NULL) const; + std::vector<Position>* positions=NULL) const; /// Number of fields in this document. O(n) size_t size() const { return storage().size(); } @@ -100,7 +100,7 @@ namespace mongo { FieldIterator fieldIterator() const; /// Convenience type for dealing with fields. Used by FieldIterator. - typedef pair<StringData, Value> FieldPair; + typedef std::pair<StringData, Value> FieldPair; /** Get the approximate storage size of the document and sub-values in bytes. * Note: Some memory may be shared with other Documents or between fields within @@ -123,10 +123,10 @@ namespace mongo { */ static int compare(const Document& lhs, const Document& rhs); - string toString() const; + std::string toString() const; friend - ostream& operator << (ostream& out, const Document& doc) { return out << doc.toString(); } + std::ostream& operator << (std::ostream& out, const Document& doc) { return out << doc.toString(); } /** Calculate a hash value. * @@ -356,8 +356,8 @@ namespace mongo { } /// Takes positions vector from Document::getNestedField. All fields in path must exist. - MutableValue getNestedField(const vector<Position>& positions); - void setNestedField(const vector<Position>& positions, const Value& val) { + MutableValue getNestedField(const std::vector<Position>& positions); + void setNestedField(const std::vector<Position>& positions, const Value& val) { getNestedField(positions) = val; } @@ -437,7 +437,7 @@ namespace mongo { // recursive helpers for same-named public methods MutableValue getNestedFieldHelper(const FieldPath& dottedField, size_t level); - MutableValue getNestedFieldHelper(const vector<Position>& positions, size_t level); + MutableValue getNestedFieldHelper(const std::vector<Position>& positions, size_t level); // this should only be called by storage methods and peek/freeze const DocumentStorage* storagePtr() const { @@ -541,7 +541,7 @@ namespace mongo { Value done() { return Value::consume(_array); } private: - vector<Value> _array; + std::vector<Value> _array; }; } diff --git a/src/mongo/db/pipeline/document_internal.h b/src/mongo/db/pipeline/document_internal.h index 4ef2a0f0710..2716c2a4a94 100644 --- a/src/mongo/db/pipeline/document_internal.h +++ b/src/mongo/db/pipeline/document_internal.h @@ -40,7 +40,7 @@ namespace mongo { */ class Position { public: - // This represents "not found" similar to string::npos + // This represents "not found" similar to std::string::npos Position() :index(static_cast<unsigned>(-1)) {} bool found() const { return index != Position().index; } diff --git a/src/mongo/db/pipeline/document_source.h b/src/mongo/db/pipeline/document_source.h index 1b2b3cc4bea..641a3b9643b 100644 --- a/src/mongo/db/pipeline/document_source.h +++ b/src/mongo/db/pipeline/document_source.h @@ -78,7 +78,7 @@ namespace mongo { /** Get the source's name. - @returns the string name of the source as a constant string; + @returns the std::string name of the source as a constant string; this is static, and there's no need to worry about adopting it */ virtual const char *getSourceName() const; @@ -144,13 +144,13 @@ namespace mongo { } /** - * In the default case, serializes the DocumentSource and adds it to the vector<Value>. + * In the default case, serializes the DocumentSource and adds it to the std::vector<Value>. * * A subclass may choose to overwrite this, rather than serialize, * if it should output multiple stages (eg, $sort sometimes also outputs a $limit). */ - virtual void serializeToArray(vector<Value>& array, bool explain = false) const; + virtual void serializeToArray(std::vector<Value>& array, bool explain = false) const; /// Returns true if doesn't require an input source (most DocumentSources do). virtual bool isValidInitialSource() const { return false; } @@ -287,13 +287,13 @@ namespace mongo { virtual bool isValidInitialSource() const { return true; } /* convenient shorthand for a commonly used type */ - typedef vector<Strategy::CommandResult> ShardOutput; + typedef std::vector<Strategy::CommandResult> ShardOutput; /** Returns the result arrays from shards using the 2.4 protocol. * Call this instead of getNext() if you want access to the raw streams. * This method should only be called at most once. */ - vector<BSONArray> getArrays(); + std::vector<BSONArray> getArrays(); /** Create a DocumentSource that wraps the output of many shards @@ -353,7 +353,7 @@ namespace mongo { * in order to fetch data from the database. */ static intrusive_ptr<DocumentSourceCursor> create( - const string& ns, + const std::string& ns, const boost::shared_ptr<Runner>& runner, const intrusive_ptr<ExpressionContext> &pExpCtx); @@ -397,7 +397,7 @@ namespace mongo { private: DocumentSourceCursor( - const string& ns, + const std::string& ns, const boost::shared_ptr<Runner>& runner, const intrusive_ptr<ExpressionContext> &pExpCtx); @@ -413,7 +413,7 @@ namespace mongo { intrusive_ptr<DocumentSourceLimit> _limit; long long _docsAddedToBatches; // for _limit enforcement - const string _ns; + const std::string _ns; boost::shared_ptr<Runner> _runner; // PipelineRunner holds a weak_ptr to this. }; @@ -513,7 +513,7 @@ namespace mongo { Value expandId(const Value& val); - typedef vector<intrusive_ptr<Accumulator> > Accumulators; + typedef std::vector<intrusive_ptr<Accumulator> > Accumulators; typedef boost::unordered_map<Value, Accumulators, Value::Hash> GroupsMap; GroupsMap groups; @@ -529,9 +529,9 @@ namespace mongo { These three vectors parallel each other. */ - vector<string> vFieldName; - vector<intrusive_ptr<Accumulator> (*)()> vpAccumulatorFactory; - vector<intrusive_ptr<Expression> > vpExpression; + std::vector<std::string> vFieldName; + std::vector<intrusive_ptr<Accumulator> (*)()> vpAccumulatorFactory; + std::vector<intrusive_ptr<Expression> > vpExpression; Document makeDocument(const Value& id, const Accumulators& accums, bool mergeableOutput); @@ -549,7 +549,7 @@ namespace mongo { // only used when _spilled scoped_ptr<Sorter<Value, Value>::Iterator> _sorterIterator; - pair<Value, Value> _firstPartOfNextGroup; + std::pair<Value, Value> _firstPartOfNextGroup; Value _currentId; Accumulators _currentAccumulators; }; @@ -605,7 +605,7 @@ namespace mongo { class DocumentSourceMergeCursors : public DocumentSource { public: - typedef vector<pair<ConnectionString, CursorId> > CursorIds; + typedef std::vector<std::pair<ConnectionString, CursorId> > CursorIds; // virtuals from DocumentSource boost::optional<Document> getNext(); @@ -629,7 +629,7 @@ namespace mongo { * Call this instead of getNext() if you want access to the raw streams. * This method should only be called at most once. */ - vector<DBClientCursor*> getCursors(); + std::vector<DBClientCursor*> getCursors(); /** * Returns the next object from the cursor, throwing an appropriate exception if the cursor @@ -646,7 +646,7 @@ namespace mongo { }; // using list to enable removing arbitrary elements - typedef list<boost::shared_ptr<CursorAndConnection> > Cursors; + typedef std::list<boost::shared_ptr<CursorAndConnection> > Cursors; DocumentSourceMergeCursors( const CursorIds& cursorIds, @@ -705,7 +705,7 @@ namespace mongo { // Sets _tempsNs and prepares it to receive data. void prepTempCollection(); - void spill(DBClientBase* conn, const vector<BSONObj>& toInsert); + void spill(DBClientBase* conn, const std::vector<BSONObj>& toInsert); bool _done; @@ -787,7 +787,7 @@ namespace mongo { // virtuals from DocumentSource virtual boost::optional<Document> getNext(); virtual const char *getSourceName() const; - virtual void serializeToArray(vector<Value>& array, bool explain = false) const; + virtual void serializeToArray(std::vector<Value>& array, bool explain = false) const; virtual bool coalesce(const intrusive_ptr<DocumentSource> &pNextSource); virtual void dispose(); @@ -806,7 +806,7 @@ namespace mongo { @param ascending if true, use the key for an ascending sort, otherwise, use it for descending */ - void addKey(const string &fieldPath, bool ascending); + void addKey(const std::string &fieldPath, bool ascending); /// Write out a Document whose contents are the sort key. Document serializeSortKey(bool explain) const; @@ -862,13 +862,13 @@ namespace mongo { // not. class IteratorFromCursor; class IteratorFromBsonArray; - void populateFromCursors(const vector<DBClientCursor*>& cursors); - void populateFromBsonArrays(const vector<BSONArray>& arrays); + void populateFromCursors(const std::vector<DBClientCursor*>& cursors); + void populateFromBsonArrays(const std::vector<BSONArray>& arrays); /* these two parallel each other */ - typedef vector<intrusive_ptr<Expression> > SortKey; + typedef std::vector<intrusive_ptr<Expression> > SortKey; SortKey vSortKey; - vector<char> vAscending; // used like vector<bool> but without specialization + std::vector<char> vAscending; // used like std::vector<bool> but without specialization /// Extracts the fields in vSortKey from the Document; Value extractKey(const Document& d) const; diff --git a/src/mongo/db/pipeline/expression.h b/src/mongo/db/pipeline/expression.h index 31a0171ecc2..cc94babf443 100644 --- a/src/mongo/db/pipeline/expression.h +++ b/src/mongo/db/pipeline/expression.h @@ -170,14 +170,14 @@ namespace mongo { * Expressions are trees, so this is often recursive. * * @param deps Fully qualified paths to depended-on fields are added to this set. - * Empty string means need full document. + * Empty std::string means need full document. * @param path path to self if all ancestors are ExpressionObjects. * Top-level ExpressionObject gets pointer to empty vector. * If any other Expression is an ancestor, or in other cases * where {a:1} inclusion objects aren't allowed, they get * NULL. */ - virtual void addDependencies(DepsTracker* deps, vector<string>* path=NULL) const = 0; + virtual void addDependencies(DepsTracker* deps, std::vector<std::string>* path=NULL) const = 0; /** simple expressions are just inclusion exclusion as supported by ExpressionObject */ virtual bool isSimple() { return false; } @@ -265,14 +265,14 @@ namespace mongo { const VariablesParseState& vps); /* - Produce a field path string with the field prefix removed. + Produce a field path std::string with the field prefix removed. Throws an error if the field prefix is not present. @param prefixedField the prefixed field @returns the field path with the prefix removed */ - static string removeFieldPrefix(const string &prefixedField); + static std::string removeFieldPrefix(const std::string &prefixedField); /** Evaluate the subclass Expression using the given Variables as context and return result. * @@ -282,7 +282,7 @@ namespace mongo { virtual Value evaluateInternal(Variables* vars) const = 0; protected: - typedef vector<intrusive_ptr<Expression> > ExpressionVector; + typedef std::vector<intrusive_ptr<Expression> > ExpressionVector; }; @@ -293,7 +293,7 @@ namespace mongo { // virtuals from Expression virtual intrusive_ptr<Expression> optimize(); virtual Value serialize(bool explain) const; - virtual void addDependencies(DepsTracker* deps, vector<string>* path=NULL) const; + virtual void addDependencies(DepsTracker* deps, std::vector<std::string>* path=NULL) const; /* Add an operand to the n-ary expression. @@ -308,7 +308,7 @@ namespace mongo { /* Get the name of the operator. - @returns the name of the operator; this string belongs to the class + @returns the name of the operator; this std::string belongs to the class implementation, and should not be deleted and should not */ @@ -399,7 +399,7 @@ namespace mongo { public: // virtuals from ExpressionNary virtual intrusive_ptr<Expression> optimize(); - virtual void addDependencies(DepsTracker* deps, vector<string>* path=NULL) const; + virtual void addDependencies(DepsTracker* deps, std::vector<std::string>* path=NULL) const; virtual Value evaluateInternal(Variables* vars) const; virtual Value serialize(bool explain) const; @@ -471,7 +471,7 @@ namespace mongo { public: // virtuals from Expression virtual intrusive_ptr<Expression> optimize(); - virtual void addDependencies(DepsTracker* deps, vector<string>* path=NULL) const; + virtual void addDependencies(DepsTracker* deps, std::vector<std::string>* path=NULL) const; virtual Value evaluateInternal(Variables* vars) const; virtual const char *getOpName() const; virtual Value serialize(bool explain) const; @@ -531,7 +531,7 @@ namespace mongo { public: // virtuals from Expression virtual intrusive_ptr<Expression> optimize(); - virtual void addDependencies(DepsTracker* deps, vector<string>* path=NULL) const; + virtual void addDependencies(DepsTracker* deps, std::vector<std::string>* path=NULL) const; virtual Value evaluateInternal(Variables* vars) const; virtual Value serialize(bool explain) const; @@ -548,17 +548,17 @@ namespace mongo { indicator @returns the newly created field path expression */ - static intrusive_ptr<ExpressionFieldPath> create(const string& fieldPath); + static intrusive_ptr<ExpressionFieldPath> create(const std::string& fieldPath); - /// Like create(), but works with the raw string from the user with the "$" prefixes. + /// Like create(), but works with the raw std::string from the user with the "$" prefixes. static intrusive_ptr<ExpressionFieldPath> parse( - const string& raw, + const std::string& raw, const VariablesParseState& vps); const FieldPath& getFieldPath() const { return _fieldPath; } private: - ExpressionFieldPath(const string& fieldPath, Variables::Id variable); + ExpressionFieldPath(const std::string& fieldPath, Variables::Id variable); /* Internal implementation of evaluateInternal(), used recursively. @@ -605,7 +605,7 @@ namespace mongo { virtual intrusive_ptr<Expression> optimize(); virtual Value serialize(bool explain) const; virtual Value evaluateInternal(Variables* vars) const; - virtual void addDependencies(DepsTracker* deps, vector<string>* path=NULL) const; + virtual void addDependencies(DepsTracker* deps, std::vector<std::string>* path=NULL) const; static intrusive_ptr<Expression> parse( BSONElement expr, @@ -613,16 +613,16 @@ namespace mongo { struct NameAndExpression { NameAndExpression() {} - NameAndExpression(string name, intrusive_ptr<Expression> expression) + NameAndExpression(std::string name, intrusive_ptr<Expression> expression) : name(name) , expression(expression) {} - string name; + std::string name; intrusive_ptr<Expression> expression; }; - typedef map<Variables::Id, NameAndExpression> VariableMap; + typedef std::map<Variables::Id, NameAndExpression> VariableMap; private: ExpressionLet(const VariableMap& vars, @@ -638,19 +638,19 @@ namespace mongo { virtual intrusive_ptr<Expression> optimize(); virtual Value serialize(bool explain) const; virtual Value evaluateInternal(Variables* vars) const; - virtual void addDependencies(DepsTracker* deps, vector<string>* path=NULL) const; + virtual void addDependencies(DepsTracker* deps, std::vector<std::string>* path=NULL) const; static intrusive_ptr<Expression> parse( BSONElement expr, const VariablesParseState& vps); private: - ExpressionMap(const string& varName, // name of variable to set + ExpressionMap(const std::string& varName, // name of variable to set Variables::Id varId, // id of variable to set intrusive_ptr<Expression> input, // yields array to iterate intrusive_ptr<Expression> each); // yields results to be added to output array - string _varName; + std::string _varName; Variables::Id _varId; intrusive_ptr<Expression> _input; intrusive_ptr<Expression> _each; @@ -661,7 +661,7 @@ namespace mongo { // virtuals from Expression virtual Value serialize(bool explain) const; virtual Value evaluateInternal(Variables* vars) const; - virtual void addDependencies(DepsTracker* deps, vector<string>* path=NULL) const; + virtual void addDependencies(DepsTracker* deps, std::vector<std::string>* path=NULL) const; static intrusive_ptr<Expression> parse( BSONElement expr, @@ -722,7 +722,7 @@ namespace mongo { // virtuals from Expression virtual intrusive_ptr<Expression> optimize(); virtual bool isSimple(); - virtual void addDependencies(DepsTracker* deps, vector<string>* path=NULL) const; + virtual void addDependencies(DepsTracker* deps, std::vector<std::string>* path=NULL) const; /** Only evaluates non inclusion expressions. For inclusions, use addToDocument(). */ virtual Value evaluateInternal(Variables* vars) const; virtual Value serialize(bool explain) const; @@ -771,7 +771,7 @@ namespace mongo { @param fieldPath the name of the field to be included */ - void includePath(const string &fieldPath); + void includePath(const std::string &fieldPath); /* Get a count of the added fields. @@ -806,7 +806,7 @@ namespace mongo { @param include if true, the path is included; if false, the path is excluded */ - virtual void path(const string &path, bool include) = 0; + virtual void path(const std::string &path, bool include) = 0; }; void excludeId(bool b) { _excludeId = b; } @@ -816,11 +816,11 @@ namespace mongo { // Mapping from fieldname to the Expression that generates its value. // NULL expression means inclusion from source document. - typedef map<string, intrusive_ptr<Expression> > FieldMap; + typedef std::map<std::string, intrusive_ptr<Expression> > FieldMap; FieldMap _expressions; // this is used to maintain order for generated fields not in the source document - vector<string> _order; + std::vector<std::string> _order; bool _excludeId; bool _atRoot; diff --git a/src/mongo/db/pipeline/field_path.h b/src/mongo/db/pipeline/field_path.h index d8a8984b9f0..93ee10f6afa 100644 --- a/src/mongo/db/pipeline/field_path.h +++ b/src/mongo/db/pipeline/field_path.h @@ -38,12 +38,12 @@ namespace mongo { /** * Constructor. * - * @param fieldPath the dotted field path string or non empty pre-split vector. + * @param fieldPath the dotted field path std::string or non empty pre-split vector. * The constructed object will have getPathLength() > 0. * Uassert if any component field names do not pass validation. */ - FieldPath(const string& fieldPath); - FieldPath(const vector<string>& fieldPath); + FieldPath(const std::string& fieldPath); + FieldPath(const std::vector<std::string>& fieldPath); /** Get the number of path elements in the field path. @@ -58,7 +58,7 @@ namespace mongo { @param i the zero based index of the path element. @returns the path element */ - const string& getFieldName(size_t i) const; + const std::string& getFieldName(size_t i) const; /** Get the full path. @@ -66,7 +66,7 @@ namespace mongo { @param fieldPrefix whether or not to include the field prefix @returns the complete field path */ - string getPath(bool fieldPrefix) const; + std::string getPath(bool fieldPrefix) const; /** Write the full path. @@ -74,7 +74,7 @@ namespace mongo { @param outStream where to write the path to @param fieldPrefix whether or not to include the field prefix */ - void writePath(ostream &outStream, bool fieldPrefix) const; + void writePath(std::ostream &outStream, bool fieldPrefix) const; /** Get the prefix string. @@ -93,15 +93,15 @@ namespace mongo { private: /** Uassert if a field name does not pass validation. */ - static void uassertValidFieldName(const string& fieldName); + static void uassertValidFieldName(const std::string& fieldName); /** * Push a new field name to the back of the vector of names comprising the field path. * Uassert if 'fieldName' does not pass validation. */ - void pushFieldName(const string& fieldName); + void pushFieldName(const std::string& fieldName); - vector<string> vFieldName; + std::vector<std::string> vFieldName; }; } @@ -114,7 +114,7 @@ namespace mongo { return vFieldName.size(); } - inline const string& FieldPath::getFieldName(size_t i) const { + inline const std::string& FieldPath::getFieldName(size_t i) const { dassert(i < getPathLength()); return vFieldName[i]; } diff --git a/src/mongo/db/pipeline/pipeline.h b/src/mongo/db/pipeline/pipeline.h index 4d11f8eed29..297d73874f9 100644 --- a/src/mongo/db/pipeline/pipeline.h +++ b/src/mongo/db/pipeline/pipeline.h @@ -57,15 +57,15 @@ namespace mongo { * @returns the pipeline, if created, otherwise a NULL reference */ static intrusive_ptr<Pipeline> parseCommand( - string& errmsg, + std::string& errmsg, const BSONObj& cmdObj, const intrusive_ptr<ExpressionContext>& pCtx); /// Helper to implement Command::addRequiredPrivileges static void addRequiredPrivileges(Command* commandTemplate, - const string& dbname, + const std::string& dbname, BSONObj cmdObj, - vector<Privilege>* out); + std::vector<Privilege>* out); intrusive_ptr<ExpressionContext> getContext() const { return pCtx; } @@ -122,10 +122,10 @@ namespace mongo { bool canRunInMongos() const; /** - * Write the pipeline's operators to a vector<Value>, with the + * Write the pipeline's operators to a std::vector<Value>, with the * explain flag true (for DocumentSource::serializeToArray()). */ - vector<Value> writeExplainOps() const; + std::vector<Value> writeExplainOps() const; /** * Returns the dependencies needed by this pipeline. diff --git a/src/mongo/db/pipeline/value.h b/src/mongo/db/pipeline/value.h index 2a70a94733d..d4dd9b5899e 100644 --- a/src/mongo/db/pipeline/value.h +++ b/src/mongo/db/pipeline/value.h @@ -45,7 +45,7 @@ namespace mongo { * change. However if you have a non-const Value you replace it with * operator=. These rules are the same as BSONObj, and similar to * shared_ptr<const Object> with stronger guarantees of constness. This is - * also the same as Java's String type. + * also the same as Java's std::string type. * * Thread-safety: A single Value instance can be safely shared between * threads as long as there are no writers while other threads are @@ -73,12 +73,12 @@ namespace mongo { explicit Value(const OpTime& value) : _storage(Timestamp, value.asDate()) {} explicit Value(const OID& value) : _storage(jstOID, value) {} explicit Value(const StringData& value) : _storage(String, value) {} - explicit Value(const string& value) : _storage(String, StringData(value)) {} + explicit Value(const std::string& value) : _storage(String, StringData(value)) {} explicit Value(const char* value) : _storage(String, StringData(value)) {} explicit Value(const Document& doc) : _storage(Object, doc) {} explicit Value(const BSONObj& obj); explicit Value(const BSONArray& arr); - explicit Value(const vector<Value>& vec) : _storage(Array, new RCVector(vec)) {} + explicit Value(const std::vector<Value>& vec) : _storage(Array, new RCVector(vec)) {} explicit Value(const BSONBinData& bd) : _storage(BinData, bd) {} explicit Value(const BSONRegEx& re) : _storage(RegEx, re) {} explicit Value(const BSONCodeWScope& cws) : _storage(CodeWScope, cws) {} @@ -109,7 +109,7 @@ namespace mongo { * consumed is replaced with an empty vector. * In C++11 this would be spelled Value(std::move(consumed)). */ - static Value consume(vector<Value>& consumed) { + static Value consume(std::vector<Value>& consumed) { RCVector* vec = new RCVector(); std::swap(vec->vec, consumed); return Value(ValueStorage(Array, vec)); @@ -143,7 +143,7 @@ namespace mongo { * See coerceTo methods below for a more type-flexible alternative. */ double getDouble() const; - string getString() const; + std::string getString() const; Document getDocument() const; OID getOid() const; bool getBool() const; @@ -151,11 +151,11 @@ namespace mongo { OpTime getTimestamp() const; const char* getRegex() const; const char* getRegexFlags() const; - string getSymbol() const; - string getCode() const; + std::string getSymbol() const; + std::string getCode() const; int getInt() const; long long getLong() const; - const vector<Value>& getArray() const { return _storage.getArray(); } + const std::vector<Value>& getArray() const { return _storage.getArray(); } size_t getArrayLength() const; /// Access an element of a subarray. Returns Value() if missing or getType() != Array @@ -183,7 +183,7 @@ namespace mongo { * These currently assert if called on an unconvertible type. * TODO: decided how to handle unsupported types. */ - string coerceToString() const; + std::string coerceToString() const; int coerceToInt() const; long long coerceToLong() const; double coerceToDouble() const; @@ -218,8 +218,8 @@ namespace mongo { } /// This is for debugging, logging, etc. See getString() for how to extract a string. - string toString() const; - friend ostream& operator << (ostream& out, const Value& v); + std::string toString() const; + friend std::ostream& operator << (std::ostream& out, const Value& v); void swap(Value& rhs) { _storage.swap(rhs._storage); @@ -243,7 +243,7 @@ namespace mongo { void hash_combine(size_t& seed) const; /// struct Hash is defined to enable the use of Values as keys in unordered_map. - struct Hash : unary_function<const Value&, size_t> { + struct Hash : std::unary_function<const Value&, size_t> { size_t operator()(const Value& rV) const; }; @@ -304,7 +304,7 @@ namespace mongo { return _storage.getString(); } - inline string Value::getString() const { + inline std::string Value::getString() const { verify(getType() == String); return _storage.getString().toString(); } @@ -341,11 +341,11 @@ namespace mongo { return flags; } - inline string Value::getSymbol() const { + inline std::string Value::getSymbol() const { verify(getType() == Symbol); return _storage.getString().toString(); } - inline string Value::getCode() const { + inline std::string Value::getCode() const { verify(getType() == Code); return _storage.getString().toString(); } diff --git a/src/mongo/db/pipeline/value_internal.h b/src/mongo/db/pipeline/value_internal.h index 7565e318bd5..d124892282a 100644 --- a/src/mongo/db/pipeline/value_internal.h +++ b/src/mongo/db/pipeline/value_internal.h @@ -47,21 +47,21 @@ namespace mongo { class RCVector : public RefCountable { public: RCVector() {} - RCVector(const vector<Value>& v) :vec(v) {} - vector<Value> vec; + RCVector(const std::vector<Value>& v) :vec(v) {} + std::vector<Value> vec; }; class RCCodeWScope : public RefCountable { public: - RCCodeWScope(const string& str, BSONObj obj) :code(str), scope(obj.getOwned()) {} - const string code; + RCCodeWScope(const std::string& str, BSONObj obj) :code(str), scope(obj.getOwned()) {} + const std::string code; const BSONObj scope; // Not worth converting to Document for now }; class RCDBRef : public RefCountable { public: - RCDBRef(const string& str, const OID& o) :ns(str), oid(o) {} - const string ns; + RCDBRef(const std::string& str, const OID& o) :ns(str), oid(o) {} + const std::string ns; const OID oid; }; @@ -168,7 +168,7 @@ namespace mongo { } } - const vector<Value>& getArray() const { + const std::vector<Value>& getArray() const { dassert(typeid(*genericRCPtr) == typeid(const RCVector)); const RCVector* arrayPtr = static_cast<const RCVector*>(genericRCPtr); return arrayPtr->vec; diff --git a/src/mongo/db/projection.h b/src/mongo/db/projection.h index d71f106ac14..b36ff7b88aa 100644 --- a/src/mongo/db/projection.h +++ b/src/mongo/db/projection.h @@ -52,18 +52,18 @@ namespace mongo { BSONObj hydrate( const BSONObj& key ) const; void addNo() { _add( false , "" ); } - void addYes( const string& name ) { _add( true , name ); } + void addYes( const std::string& name ) { _add( true , name ); } private: - void _add( bool b , const string& name ) { + void _add( bool b , const std::string& name ) { _include.push_back( b ); _names.push_back( name ); _stringSize += name.size(); } - vector<bool> _include; // one entry per field in key. true iff should be in output - vector<string> _names; // name of field since key doesn't have names + std::vector<bool> _include; // one entry per field in key. true iff should be in output + std::vector<std::string> _names; // name of field since key doesn't have names int _stringSize; }; @@ -129,7 +129,7 @@ namespace mongo { * Validate the given query satisfies this projection's positional operator. * NOTE: this function is only used to validate projections with a positional operator. * @param query User-supplied query specifier - * @return Field name if found, empty string otherwise. + * @return Field name if found, empty std::string otherwise. */ void validateQuery( const BSONObj query ) const; @@ -142,14 +142,14 @@ namespace mongo { void append( BSONObjBuilder& b , const BSONElement& e, const MatchDetails* details = NULL, const ArrayOpType arrayOpType = ARRAY_OP_NORMAL ) const; - void add( const string& field, bool include ); - void add( const string& field, int skip, int limit ); + void add( const std::string& field, bool include ); + void add( const std::string& field, int skip, int limit ); void appendArray( BSONObjBuilder& b , const BSONObj& a , bool nested=false) const; bool _include; // true if default at this level is to include bool _special; // true if this level can't be skipped or included without recursing - //TODO: benchmark vector<pair> vs map + //TODO: benchmark std::vector<pair> vs map typedef StringMap<boost::shared_ptr<Projection> > FieldMap; FieldMap _fields; BSONObj _source; diff --git a/src/mongo/db/query/canonical_query.h b/src/mongo/db/query/canonical_query.h index 8c3db4ed204..d4c7626e816 100644 --- a/src/mongo/db/query/canonical_query.h +++ b/src/mongo/db/query/canonical_query.h @@ -67,13 +67,13 @@ namespace mongo { const MatchExpressionParser::WhereCallback& whereCallback = MatchExpressionParser::WhereCallback()); - static Status canonicalize(const string& ns, + static Status canonicalize(const std::string& ns, const BSONObj& query, CanonicalQuery** out, const MatchExpressionParser::WhereCallback& whereCallback = MatchExpressionParser::WhereCallback()); - static Status canonicalize(const string& ns, + static Status canonicalize(const std::string& ns, const BSONObj& query, long long skip, long long limit, @@ -81,7 +81,7 @@ namespace mongo { const MatchExpressionParser::WhereCallback& whereCallback = MatchExpressionParser::WhereCallback()); - static Status canonicalize(const string& ns, + static Status canonicalize(const std::string& ns, const BSONObj& query, const BSONObj& sort, const BSONObj& proj, @@ -89,7 +89,7 @@ namespace mongo { const MatchExpressionParser::WhereCallback& whereCallback = MatchExpressionParser::WhereCallback()); - static Status canonicalize(const string& ns, + static Status canonicalize(const std::string& ns, const BSONObj& query, const BSONObj& sort, const BSONObj& proj, @@ -99,7 +99,7 @@ namespace mongo { const MatchExpressionParser::WhereCallback& whereCallback = MatchExpressionParser::WhereCallback()); - static Status canonicalize(const string& ns, + static Status canonicalize(const std::string& ns, const BSONObj& query, const BSONObj& sort, const BSONObj& proj, @@ -110,7 +110,7 @@ namespace mongo { const MatchExpressionParser::WhereCallback& whereCallback = MatchExpressionParser::WhereCallback()); - static Status canonicalize(const string& ns, + static Status canonicalize(const std::string& ns, const BSONObj& query, const BSONObj& sort, const BSONObj& proj, @@ -132,7 +132,7 @@ namespace mongo { static bool isSimpleIdQuery(const BSONObj& query); // What namespace is this query over? - const string& ns() const { return _pq->ns(); } + const std::string& ns() const { return _pq->ns(); } // // Accessors for the query diff --git a/src/mongo/db/query/explain_plan.h b/src/mongo/db/query/explain_plan.h index 7ffbd489914..1a25dbb9322 100644 --- a/src/mongo/db/query/explain_plan.h +++ b/src/mongo/db/query/explain_plan.h @@ -68,7 +68,7 @@ namespace mongo { TypeExplain** explain); /** - * Returns a short plan summary string describing the leaves of the query solution. + * Returns a short plan summary std::string describing the leaves of the query solution. * * Used for logging. */ diff --git a/src/mongo/db/query/index_bounds.h b/src/mongo/db/query/index_bounds.h index 8bf955aadaf..b5236d2d4e4 100644 --- a/src/mongo/db/query/index_bounds.h +++ b/src/mongo/db/query/index_bounds.h @@ -41,13 +41,13 @@ namespace mongo { */ struct OrderedIntervalList { OrderedIntervalList() { } - OrderedIntervalList(const string& n) : name(n) { } + OrderedIntervalList(const std::string& n) : name(n) { } // Must be ordered according to the index order. - vector<Interval> intervals; + std::vector<Interval> intervals; // TODO: We could drop this. Only used in IndexBounds::isValidFor. - string name; + std::string name; bool isValidFor(int expectedOrientation) const; std::string toString() const; @@ -74,7 +74,7 @@ namespace mongo { IndexBounds() : isSimpleRange(false), endKeyInclusive(false) { } // For each indexed field, the values that the field is allowed to take on. - vector<OrderedIntervalList> fields; + std::vector<OrderedIntervalList> fields; // Debugging check. // We must have as many fields the key pattern does. @@ -121,7 +121,7 @@ namespace mongo { * * Returns true if there is a valid start key. Returns false otherwise. */ - bool getStartKey(vector<const BSONElement*>* valueOut, vector<bool>* inclusiveOut); + bool getStartKey(std::vector<const BSONElement*>* valueOut, std::vector<bool>* inclusiveOut); /** * The states of a key from an index scan. See checkKey below. @@ -179,7 +179,7 @@ namespace mongo { * If the i-th element is true, seek to the i-th element of out. */ KeyState checkKey(const BSONObj& key, int* keyEltsToUse, bool* movePastKeyElts, - vector<const BSONElement*>* out, vector<bool>* incOut); + std::vector<const BSONElement*>* out, std::vector<bool>* incOut); /** * Relative position of a key to an interval. @@ -217,7 +217,7 @@ namespace mongo { * 'where' is the leftmost field that isn't in the interval we think it is. * 'what' is the orientation of the field with respect to that interval. */ - bool findLeftmostProblem(const vector<BSONElement>& keyValues, size_t* where, + bool findLeftmostProblem(const std::vector<BSONElement>& keyValues, size_t* where, Location* what); /** @@ -226,16 +226,16 @@ namespace mongo { * * keyValues are the elements of the index key in order. */ - bool spaceLeftToAdvance(size_t fieldsToCheck, const vector<BSONElement>& keyValues); + bool spaceLeftToAdvance(size_t fieldsToCheck, const std::vector<BSONElement>& keyValues); // The actual bounds. Must outlive this object. Not owned by us. const IndexBounds* _bounds; // For each field, which interval are we currently in? - vector<size_t> _curInterval; + std::vector<size_t> _curInterval; // Direction of scan * direction of indexing. - vector<int> _expectedDirection; + std::vector<int> _expectedDirection; }; } // namespace mongo diff --git a/src/mongo/db/query/index_bounds_builder.h b/src/mongo/db/query/index_bounds_builder.h index dceed96bc61..2e760ed663c 100644 --- a/src/mongo/db/query/index_bounds_builder.h +++ b/src/mongo/db/query/index_bounds_builder.h @@ -104,8 +104,8 @@ namespace mongo { bool startInclusive, bool endInclusive); - static Interval makeRangeInterval(const string& start, - const string& end, + static Interval makeRangeInterval(const std::string& start, + const std::string& end, bool startInclusive, bool endInclusive); @@ -114,7 +114,7 @@ namespace mongo { * The object must have exactly one field which is the value of the point interval. */ static Interval makePointInterval(const BSONObj& obj); - static Interval makePointInterval(const string& str); + static Interval makePointInterval(const std::string& str); static Interval makePointInterval(double d); /** @@ -131,13 +131,13 @@ namespace mongo { /** * Copied almost verbatim from db/queryutil.cpp. * - * returns a string that when used as a matcher, would match a super set of regex() + * returns a std::string that when used as a matcher, would match a super set of regex() * * returns "" for complex regular expressions * * used to optimize queries in some simple regex cases that start with '^' */ - static string simpleRegex(const char* regex, + static std::string simpleRegex(const char* regex, const char* flags, BoundsTightness* tightnessOut); diff --git a/src/mongo/db/query/index_entry.h b/src/mongo/db/query/index_entry.h index 9e81e78ee85..f69ca28fc5f 100644 --- a/src/mongo/db/query/index_entry.h +++ b/src/mongo/db/query/index_entry.h @@ -43,10 +43,10 @@ namespace mongo { * Use this constructor if you're making an IndexEntry from the catalog. */ IndexEntry(const BSONObj& kp, - const string& accessMethod, + const std::string& accessMethod, bool mk, bool sp, - const string& n, + const std::string& n, const BSONObj& io) : keyPattern(kp), multikey(mk), @@ -63,7 +63,7 @@ namespace mongo { IndexEntry(const BSONObj& kp, bool mk, bool sp, - const string& n, + const std::string& n, const BSONObj& io) : keyPattern(kp), multikey(mk), @@ -93,7 +93,7 @@ namespace mongo { bool sparse; - string name; + std::string name; // Geo indices have extra parameters. We need those available to plan correctly. BSONObj infoObj; diff --git a/src/mongo/db/query/index_tag.h b/src/mongo/db/query/index_tag.h index 060bf7212cc..9fb115c818d 100644 --- a/src/mongo/db/query/index_tag.h +++ b/src/mongo/db/query/index_tag.h @@ -73,7 +73,7 @@ namespace mongo { // root. We do this once and store it. // TODO: Do a FieldRef / StringData pass. // TODO: We might want this inside of the MatchExpression. - string path; + std::string path; // Points to the innermost containing $elemMatch. If this tag is // attached to an expression not contained in an $elemMatch, then diff --git a/src/mongo/db/query/interval.h b/src/mongo/db/query/interval.h index 1d3e156af4a..e4f82da8088 100644 --- a/src/mongo/db/query/interval.h +++ b/src/mongo/db/query/interval.h @@ -52,7 +52,7 @@ namespace mongo { /** Creates an empty interval */ Interval(); - string toString() const { + std::string toString() const { mongoutils::str::stream ss; if (startInclusive) { ss << "["; @@ -165,7 +165,7 @@ namespace mongo { /** * toString for IntervalComparison */ - static string cmpstr(IntervalComparison c); + static std::string cmpstr(IntervalComparison c); // // Mutation of intervals diff --git a/src/mongo/db/query/lite_parsed_query.h b/src/mongo/db/query/lite_parsed_query.h index e99a073e950..a03ef36f54f 100644 --- a/src/mongo/db/query/lite_parsed_query.h +++ b/src/mongo/db/query/lite_parsed_query.h @@ -52,7 +52,7 @@ namespace mongo { * Fills out a LiteParsedQuery. Used for debugging and testing, when we don't have a * QueryMessage. */ - static Status make(const string& ns, + static Status make(const std::string& ns, int ntoskip, int ntoreturn, int queryoptions, @@ -115,17 +115,17 @@ namespace mongo { static BSONObj normalizeSortOrder(const BSONObj& sortObj); // Names of the maxTimeMS command and query option. - static const string cmdOptionMaxTimeMS; - static const string queryOptionMaxTimeMS; + static const std::string cmdOptionMaxTimeMS; + static const std::string queryOptionMaxTimeMS; // Names of the $meta projection values. - static const string metaTextScore; - static const string metaGeoNearDistance; - static const string metaGeoNearPoint; - static const string metaDiskLoc; - static const string metaIndexKey; + static const std::string metaTextScore; + static const std::string metaGeoNearDistance; + static const std::string metaGeoNearPoint; + static const std::string metaDiskLoc; + static const std::string metaIndexKey; - const string& ns() const { return _ns; } + const std::string& ns() const { return _ns; } bool isLocalDB() const { return _ns.compare(0, 6, "local.") == 0; } const BSONObj& getFilter() const { return _filter; } @@ -153,14 +153,14 @@ namespace mongo { private: LiteParsedQuery(); - Status init(const string& ns, int ntoskip, int ntoreturn, int queryOptions, + Status init(const std::string& ns, int ntoskip, int ntoreturn, int queryOptions, const BSONObj& queryObj, const BSONObj& proj, bool fromQueryMessage); Status initFullQuery(const BSONObj& top); static StatusWith<int> parseMaxTimeMS(const BSONElement& maxTimeMSElt); - string _ns; + std::string _ns; int _ntoskip; int _ntoreturn; BSONObj _filter; diff --git a/src/mongo/db/query/parsed_projection.h b/src/mongo/db/query/parsed_projection.h index 0bcd51756a7..64c6b9d70ba 100644 --- a/src/mongo/db/query/parsed_projection.h +++ b/src/mongo/db/query/parsed_projection.h @@ -64,7 +64,7 @@ namespace mongo { * If requiresDocument() == false, what fields are required to compute * the projection? */ - const vector<string>& getRequiredFields() const { + const std::vector<std::string>& getRequiredFields() const { return _requiredFields; } @@ -114,7 +114,7 @@ namespace mongo { const std::string& matchfield); // TODO: stringdata? - vector<string> _requiredFields; + std::vector<std::string> _requiredFields; bool _requiresDocument; diff --git a/src/mongo/db/query/plan_cache.h b/src/mongo/db/query/plan_cache.h index 402633c8c5b..84dbab1fa34 100644 --- a/src/mongo/db/query/plan_cache.h +++ b/src/mongo/db/query/plan_cache.h @@ -85,7 +85,7 @@ namespace mongo { PlanCacheIndexTree() : entry(NULL), index_pos(0) { } ~PlanCacheIndexTree() { - for (vector<PlanCacheIndexTree*>::const_iterator it = children.begin(); + for (std::vector<PlanCacheIndexTree*>::const_iterator it = children.begin(); it != children.end(); ++it) { delete *it; } diff --git a/src/mongo/db/query/plan_enumerator.h b/src/mongo/db/query/plan_enumerator.h index 8cccbab61c8..5f27a6ebbf1 100644 --- a/src/mongo/db/query/plan_enumerator.h +++ b/src/mongo/db/query/plan_enumerator.h @@ -53,7 +53,7 @@ namespace mongo { MatchExpression* root; // Not owned here. - const vector<IndexEntry>* indices; + const std::vector<IndexEntry>* indices; // How many plans are we willing to ouput from an OR? We currently consider // all possibly OR plans, which means the product of the number of possibilities @@ -176,7 +176,7 @@ namespace mongo { struct PredicateAssignment { PredicateAssignment() : indexToAssign(0) { } - vector<IndexID> first; + std::vector<IndexID> first; // Not owned here. MatchExpression* expr; @@ -193,7 +193,7 @@ namespace mongo { // subsequent state it just asks all its children to move their states forward. // Must use all of subnodes. - vector<MemoID> subnodes; + std::vector<MemoID> subnodes; // The number of OR states that we've enumerated so far. size_t counter; @@ -202,20 +202,20 @@ namespace mongo { // This is used by AndAssignment and is not an actual assignment. struct OneIndexAssignment { // 'preds[i]' is uses index 'index' at position 'positions[i]' - vector<MatchExpression*> preds; - vector<IndexPosition> positions; + std::vector<MatchExpression*> preds; + std::vector<IndexPosition> positions; IndexID index; }; struct AndEnumerableState { - vector<OneIndexAssignment> assignments; - vector<MemoID> subnodesToIndex; + std::vector<OneIndexAssignment> assignments; + std::vector<MemoID> subnodesToIndex; }; struct AndAssignment { AndAssignment() : counter(0) { } - vector<AndEnumerableState> choices; + std::vector<AndEnumerableState> choices; // We're on the counter-th member of state. size_t counter; @@ -223,7 +223,7 @@ namespace mongo { struct ArrayAssignment { ArrayAssignment() : counter(0) { } - vector<MemoID> subnodes; + std::vector<MemoID> subnodes; size_t counter; }; @@ -235,7 +235,7 @@ namespace mongo { scoped_ptr<OrAssignment> orAssignment; scoped_ptr<AndAssignment> andAssignment; scoped_ptr<ArrayAssignment> arrayAssignment; - string toString() const; + std::string toString() const; }; /** @@ -268,9 +268,9 @@ namespace mongo { */ bool partitionPreds(MatchExpression* node, PrepMemoContext context, - vector<MatchExpression*>* indexOut, - vector<MemoID>* subnodesOut, - vector<MemoID>* mandatorySubnodes); + std::vector<MatchExpression*>* indexOut, + std::vector<MemoID>* subnodesOut, + std::vector<MemoID>* mandatorySubnodes); /** * Finds a set of predicates that can be safely compounded with the set @@ -334,9 +334,9 @@ namespace mongo { * and then not assign the $near because the $within is already assigned (and * has the same path). */ - void getMultikeyCompoundablePreds(const vector<MatchExpression*>& assigned, - const vector<MatchExpression*>& couldCompound, - vector<MatchExpression*>* out); + void getMultikeyCompoundablePreds(const std::vector<MatchExpression*>& assigned, + const std::vector<MatchExpression*>& couldCompound, + std::vector<MatchExpression*>* out); /** * 'andAssignment' contains assignments that we've already committed to outputting, @@ -357,12 +357,12 @@ namespace mongo { * and notice that we have already assigned this same set of predicates to * the single index {a: 1, b: 1} via compounding. */ - bool alreadyCompounded(const set<MatchExpression*>& ixisectAssigned, + bool alreadyCompounded(const std::set<MatchExpression*>& ixisectAssigned, const AndAssignment* andAssignment); /** * Output index intersection assignments inside of an AND node. */ - typedef unordered_map<IndexID, vector<MatchExpression*> > IndexToPredMap; + typedef unordered_map<IndexID, std::vector<MatchExpression*> > IndexToPredMap; /** * Generate index intersection assignments given the predicate/index structure in idxToFirst @@ -371,7 +371,7 @@ namespace mongo { */ void enumerateAndIntersect(const IndexToPredMap& idxToFirst, const IndexToPredMap& idxToNotFirst, - const vector<MemoID>& subnodes, + const std::vector<MemoID>& subnodes, AndAssignment* andAssignment); /** @@ -381,7 +381,7 @@ namespace mongo { */ void enumerateOneIndex(const IndexToPredMap& idxToFirst, const IndexToPredMap& idxToNotFirst, - const vector<MemoID>& subnodes, + const std::vector<MemoID>& subnodes, AndAssignment* andAssignment); /** @@ -399,7 +399,7 @@ namespace mongo { * Try to assign predicates in 'tryCompound' to 'thisIndex' as compound assignments. * Output the assignments in 'assign'. */ - void compound(const vector<MatchExpression*>& tryCompound, + void compound(const std::vector<MatchExpression*>& tryCompound, const IndexEntry& thisIndex, OneIndexAssignment* assign); @@ -429,7 +429,7 @@ namespace mongo { MatchExpression* _root; // Indices we're allowed to enumerate with. Not owned here. - const vector<IndexEntry>* _indices; + const std::vector<IndexEntry>* _indices; // Do we output >1 index per AND (index intersection)? bool _ixisect; diff --git a/src/mongo/db/query/plan_ranker.h b/src/mongo/db/query/plan_ranker.h index 41049febbfc..8ffdece195b 100644 --- a/src/mongo/db/query/plan_ranker.h +++ b/src/mongo/db/query/plan_ranker.h @@ -53,7 +53,7 @@ namespace mongo { * Caller owns pointers in 'why'. * 'candidateOrder' holds indices into candidates ordered by score (winner in first element). */ - static size_t pickBestPlan(const vector<CandidatePlan>& candidates, + static size_t pickBestPlan(const std::vector<CandidatePlan>& candidates, PlanRankingDecision* why); /** diff --git a/src/mongo/db/query/planner_access.h b/src/mongo/db/query/planner_access.h index 71dd60d9f39..43300261fd4 100644 --- a/src/mongo/db/query/planner_access.h +++ b/src/mongo/db/query/planner_access.h @@ -140,7 +140,7 @@ namespace mongo { static QuerySolutionNode* buildIndexedDataAccess(const CanonicalQuery& query, MatchExpression* root, bool inArrayOperator, - const vector<IndexEntry>& indices); + const std::vector<IndexEntry>& indices); /** * Takes ownership of 'root'. @@ -148,7 +148,7 @@ namespace mongo { static QuerySolutionNode* buildIndexedAnd(const CanonicalQuery& query, MatchExpression* root, bool inArrayOperator, - const vector<IndexEntry>& indices); + const std::vector<IndexEntry>& indices); /** * Takes ownership of 'root'. @@ -156,7 +156,7 @@ namespace mongo { static QuerySolutionNode* buildIndexedOr(const CanonicalQuery& query, MatchExpression* root, bool inArrayOperator, - const vector<IndexEntry>& indices); + const std::vector<IndexEntry>& indices); /** * Traverses the tree rooted at the $elemMatch expression 'node', @@ -170,8 +170,8 @@ namespace mongo { * tagged to use an index. */ static void findElemMatchChildren(const MatchExpression* node, - vector<MatchExpression*>* out, - vector<MatchExpression*>* subnodesOut); + std::vector<MatchExpression*>* out, + std::vector<MatchExpression*>* subnodesOut); /** * Helper used by buildIndexedAnd and buildIndexedOr. @@ -189,8 +189,8 @@ namespace mongo { static bool processIndexScans(const CanonicalQuery& query, MatchExpression* root, bool inArrayOperator, - const vector<IndexEntry>& indices, - vector<QuerySolutionNode*>* out); + const std::vector<IndexEntry>& indices, + std::vector<QuerySolutionNode*>* out); // // Helpers for creating an index scan. diff --git a/src/mongo/db/query/planner_ixselect.h b/src/mongo/db/query/planner_ixselect.h index a68837af352..ca385bd35fa 100644 --- a/src/mongo/db/query/planner_ixselect.h +++ b/src/mongo/db/query/planner_ixselect.h @@ -46,15 +46,15 @@ namespace mongo { * The 'prefix' argument is a path prefix to be prepended to any fields mentioned in * predicates encountered. Some array operators specify a path prefix. */ - static void getFields(MatchExpression* node, string prefix, unordered_set<string>* out); + static void getFields(MatchExpression* node, std::string prefix, unordered_set<std::string>* out); /** * Find all indices prefixed by fields we have predicates over. Only these indices are * useful in answering the query. */ - static void findRelevantIndices(const unordered_set<string>& fields, - const vector<IndexEntry>& indices, - vector<IndexEntry>* out); + static void findRelevantIndices(const unordered_set<std::string>& fields, + const std::vector<IndexEntry>& indices, + std::vector<IndexEntry>* out); /** * Return true if the index key pattern field 'elt' (which belongs to 'index') can be used @@ -84,8 +84,8 @@ namespace mongo { * original predicate by having an AND as a parent. */ static void rateIndices(MatchExpression* node, - string prefix, - const vector<IndexEntry>& indices); + std::string prefix, + const std::vector<IndexEntry>& indices); /** * Amend the RelevantTag lists for all predicates in the subtree rooted at 'node' to remove @@ -94,7 +94,7 @@ namespace mongo { * See the body of this function and the specific stripInvalidAssignments functions for details. */ static void stripInvalidAssignments(MatchExpression* node, - const vector<IndexEntry>& indices); + const std::vector<IndexEntry>& indices); private: /** @@ -129,7 +129,7 @@ namespace mongo { * those annotations get removed here. */ static void stripInvalidAssignmentsToTextIndexes(MatchExpression* node, - const vector<IndexEntry>& indices); + const std::vector<IndexEntry>& indices); /** * For V1 2dsphere indices we ignore the sparse option. As such we can use an index @@ -149,7 +149,7 @@ namespace mongo { * predicate on every geo field in the index. */ static void stripInvalidAssignmentsTo2dsphereIndices(MatchExpression* node, - const vector<IndexEntry>& indices); + const std::vector<IndexEntry>& indices); }; } // namespace mongo diff --git a/src/mongo/db/query/query_planner.h b/src/mongo/db/query/query_planner.h index e314e1f132c..151c7278728 100644 --- a/src/mongo/db/query/query_planner.h +++ b/src/mongo/db/query/query_planner.h @@ -102,7 +102,7 @@ namespace mongo { * On failure, 'out' is set to NULL. */ static Status cacheDataFromTaggedTree(const MatchExpression* const taggedTree, - const vector<IndexEntry>& relevantIndices, + const std::vector<IndexEntry>& relevantIndices, PlanCacheIndexTree** out); /** @@ -124,7 +124,7 @@ namespace mongo { */ static Status tagAccordingToCache(MatchExpression* filter, const PlanCacheIndexTree* const indexTree, - const map<BSONObj, size_t>& indexMap); + const std::map<BSONObj, size_t>& indexMap); }; } // namespace mongo diff --git a/src/mongo/db/query/query_planner_common.h b/src/mongo/db/query/query_planner_common.h index e1c858ab98c..2caa2545be3 100644 --- a/src/mongo/db/query/query_planner_common.h +++ b/src/mongo/db/query/query_planner_common.h @@ -95,7 +95,7 @@ namespace mongo { } else { for (size_t i = 0; i < isn->bounds.fields.size(); ++i) { - vector<Interval>& iv = isn->bounds.fields[i].intervals; + std::vector<Interval>& iv = isn->bounds.fields[i].intervals; // Step 1: reverse the list. std::reverse(iv.begin(), iv.end()); // Step 2: reverse each interval. @@ -106,7 +106,7 @@ namespace mongo { } if (!isn->bounds.isValidFor(isn->indexKeyPattern, isn->direction)) { - QLOG() << "Invalid bounds: " << isn->bounds.toString() << endl; + QLOG() << "Invalid bounds: " << isn->bounds.toString() << std::endl; verify(0); } diff --git a/src/mongo/db/query/query_planner_params.h b/src/mongo/db/query/query_planner_params.h index 6d51291f1fb..38429bd014d 100644 --- a/src/mongo/db/query/query_planner_params.h +++ b/src/mongo/db/query/query_planner_params.h @@ -88,7 +88,7 @@ namespace mongo { size_t options; // What indices are available for planning? - vector<IndexEntry> indices; + std::vector<IndexEntry> indices; // What's our shard key? If INCLUDE_SHARD_FILTER is set we will create a shard filtering // stage. If we know the shard key, we can perform covering analysis instead of always diff --git a/src/mongo/db/query/query_planner_test_lib.h b/src/mongo/db/query/query_planner_test_lib.h index 9c7d7eb9caf..8e4b9abdeab 100644 --- a/src/mongo/db/query/query_planner_test_lib.h +++ b/src/mongo/db/query/query_planner_test_lib.h @@ -53,7 +53,7 @@ namespace mongo { */ static bool solutionMatches(const BSONObj& testSoln, const QuerySolutionNode* trueSoln); - static bool solutionMatches(const string& testSoln, const QuerySolutionNode* trueSoln) { + static bool solutionMatches(const std::string& testSoln, const QuerySolutionNode* trueSoln) { return solutionMatches(fromjson(testSoln), trueSoln); } }; diff --git a/src/mongo/db/query/query_solution.h b/src/mongo/db/query/query_solution.h index 45908539398..6000c823528 100644 --- a/src/mongo/db/query/query_solution.h +++ b/src/mongo/db/query/query_solution.h @@ -53,9 +53,9 @@ namespace mongo { } /** - * Return a string representation of this node and any children. + * Return a std::string representation of this node and any children. */ - string toString() const; + std::string toString() const; /** * What stage should this be transcribed to? See stage_types.h. @@ -103,7 +103,7 @@ namespace mongo { * * TODO: 'field' is probably more appropriate as a FieldRef or string. */ - virtual bool hasField(const string& field) const = 0; + virtual bool hasField(const std::string& field) const = 0; /** * Returns true if the tree rooted at this node provides data that is sorted by the @@ -143,7 +143,7 @@ namespace mongo { } // These are owned here. - vector<QuerySolutionNode*> children; + std::vector<QuerySolutionNode*> children; // If a stage has a non-NULL filter all values outputted from that stage must pass that // filter. @@ -199,9 +199,9 @@ namespace mongo { boost::scoped_ptr<SolutionCacheData> cacheData; /** - * Output a human-readable string representing the plan. + * Output a human-readable std::string representing the plan. */ - string toString() { + std::string toString() { if (NULL == root) { return "empty query solution"; } @@ -224,7 +224,7 @@ namespace mongo { // text's return is LOC_AND_UNOWNED_OBJ so it's fetched and has all fields. bool fetched() const { return true; } - bool hasField(const string& field) const { return true; } + bool hasField(const std::string& field) const { return true; } bool sortedByDiskLoc() const { return false; } const BSONObjSet& getSort() const { return _sort; } @@ -251,7 +251,7 @@ namespace mongo { virtual void appendToString(mongoutils::str::stream* ss, int indent) const; bool fetched() const { return true; } - bool hasField(const string& field) const { return true; } + bool hasField(const std::string& field) const { return true; } bool sortedByDiskLoc() const { return false; } const BSONObjSet& getSort() const { return _sort; } @@ -260,7 +260,7 @@ namespace mongo { BSONObjSet _sort; // Name of the namespace. - string name; + std::string name; // Should we make a tailable cursor? bool tailable; @@ -280,7 +280,7 @@ namespace mongo { virtual void appendToString(mongoutils::str::stream* ss, int indent) const; bool fetched() const; - bool hasField(const string& field) const; + bool hasField(const std::string& field) const; bool sortedByDiskLoc() const { return false; } const BSONObjSet& getSort() const { return children.back()->getSort(); } @@ -298,7 +298,7 @@ namespace mongo { virtual void appendToString(mongoutils::str::stream* ss, int indent) const; bool fetched() const; - bool hasField(const string& field) const; + bool hasField(const std::string& field) const; bool sortedByDiskLoc() const { return true; } const BSONObjSet& getSort() const { return _sort; } @@ -316,7 +316,7 @@ namespace mongo { virtual void appendToString(mongoutils::str::stream* ss, int indent) const; bool fetched() const; - bool hasField(const string& field) const; + bool hasField(const std::string& field) const; bool sortedByDiskLoc() const { // Even if our children are sorted by their diskloc or other fields, we don't maintain // any order on the output. @@ -340,7 +340,7 @@ namespace mongo { virtual void appendToString(mongoutils::str::stream* ss, int indent) const; bool fetched() const; - bool hasField(const string& field) const; + bool hasField(const std::string& field) const; bool sortedByDiskLoc() const { return false; } const BSONObjSet& getSort() const { return _sorts; } @@ -370,7 +370,7 @@ namespace mongo { virtual void appendToString(mongoutils::str::stream* ss, int indent) const; bool fetched() const { return true; } - bool hasField(const string& field) const { return true; } + bool hasField(const std::string& field) const { return true; } bool sortedByDiskLoc() const { return children[0]->sortedByDiskLoc(); } const BSONObjSet& getSort() const { return children[0]->getSort(); } @@ -390,7 +390,7 @@ namespace mongo { virtual void appendToString(mongoutils::str::stream* ss, int indent) const; bool fetched() const { return false; } - bool hasField(const string& field) const; + bool hasField(const std::string& field) const; bool sortedByDiskLoc() const; const BSONObjSet& getSort() const { return _sorts; } @@ -448,7 +448,7 @@ namespace mongo { */ bool fetched() const { return true; } - bool hasField(const string& field) const { + bool hasField(const std::string& field) const { // TODO: Returning false isn't always the right answer -- we may either be including // certain fields, or we may be dropping fields (in which case hasField returns true). // @@ -502,7 +502,7 @@ namespace mongo { virtual void appendToString(mongoutils::str::stream* ss, int indent) const; bool fetched() const { return children[0]->fetched(); } - bool hasField(const string& field) const { return children[0]->hasField(field); } + bool hasField(const std::string& field) const { return children[0]->hasField(field); } bool sortedByDiskLoc() const { return false; } const BSONObjSet& getSort() const { return _sorts; } @@ -536,7 +536,7 @@ namespace mongo { virtual void appendToString(mongoutils::str::stream* ss, int indent) const; bool fetched() const { return children[0]->fetched(); } - bool hasField(const string& field) const { return children[0]->hasField(field); } + bool hasField(const std::string& field) const { return children[0]->hasField(field); } bool sortedByDiskLoc() const { return children[0]->sortedByDiskLoc(); } const BSONObjSet& getSort() const { return children[0]->getSort(); } @@ -553,7 +553,7 @@ namespace mongo { virtual void appendToString(mongoutils::str::stream* ss, int indent) const; bool fetched() const { return children[0]->fetched(); } - bool hasField(const string& field) const { return children[0]->hasField(field); } + bool hasField(const std::string& field) const { return children[0]->hasField(field); } bool sortedByDiskLoc() const { return children[0]->sortedByDiskLoc(); } const BSONObjSet& getSort() const { return children[0]->getSort(); } @@ -576,7 +576,7 @@ namespace mongo { virtual void appendToString(mongoutils::str::stream* ss, int indent) const; bool fetched() const { return false; } - bool hasField(const string& field) const; + bool hasField(const std::string& field) const; bool sortedByDiskLoc() const { return false; } const BSONObjSet& getSort() const { return _sorts; } BSONObjSet _sorts; @@ -596,7 +596,7 @@ namespace mongo { virtual void appendToString(mongoutils::str::stream* ss, int indent) const; bool fetched() const { return true; } - bool hasField(const string& field) const { return true; } + bool hasField(const std::string& field) const { return true; } bool sortedByDiskLoc() const { return false; } const BSONObjSet& getSort() const { return _sorts; } @@ -620,7 +620,7 @@ namespace mongo { virtual void appendToString(mongoutils::str::stream* ss, int indent) const; bool fetched() const { return true; } - bool hasField(const string& field) const { return true; } + bool hasField(const std::string& field) const { return true; } bool sortedByDiskLoc() const { return false; } const BSONObjSet& getSort() const { return _sorts; } @@ -654,7 +654,7 @@ namespace mongo { virtual void appendToString(mongoutils::str::stream* ss, int indent) const; bool fetched() const { return children[0]->fetched(); } - bool hasField(const string& field) const { return children[0]->hasField(field); } + bool hasField(const std::string& field) const { return children[0]->hasField(field); } bool sortedByDiskLoc() const { return children[0]->sortedByDiskLoc(); } const BSONObjSet& getSort() const { return children[0]->getSort(); } @@ -677,7 +677,7 @@ namespace mongo { bool fetched() const { return children[0]->fetched(); } // Any flagged results are OWNED_OBJ and as such they'll have any field we need. - bool hasField(const string& field) const { return children[0]->hasField(field); } + bool hasField(const std::string& field) const { return children[0]->hasField(field); } bool sortedByDiskLoc() const { return false; } const BSONObjSet& getSort() const { return sorts; } @@ -702,7 +702,7 @@ namespace mongo { // This stage is created "on top" of normal planning and as such the properties // below don't really matter. bool fetched() const { return false; } - bool hasField(const string& field) const { return !indexKeyPattern[field].eoo(); } + bool hasField(const std::string& field) const { return !indexKeyPattern[field].eoo(); } bool sortedByDiskLoc() const { return false; } const BSONObjSet& getSort() const { return sorts; } @@ -729,7 +729,7 @@ namespace mongo { virtual void appendToString(mongoutils::str::stream* ss, int indent) const; bool fetched() const { return true; } - bool hasField(const string& field) const { return true; } + bool hasField(const std::string& field) const { return true; } bool sortedByDiskLoc() const { return false; } const BSONObjSet& getSort() const { return sorts; } diff --git a/src/mongo/db/query/runner.h b/src/mongo/db/query/runner.h index 474b93c1fd3..ebcc12f82a4 100644 --- a/src/mongo/db/query/runner.h +++ b/src/mongo/db/query/runner.h @@ -64,7 +64,7 @@ namespace mongo { RUNNER_ERROR, }; - static string statestr(RunnerState s) { + static std::string statestr(RunnerState s) { if (RUNNER_ADVANCED == s) { return "RUNNER_ADVANCED"; } @@ -154,7 +154,7 @@ namespace mongo { /** * Return the NS that the query is running over. */ - virtual const string& ns() = 0; + virtual const std::string& ns() = 0; /** * Return the Collection that the query is running over. diff --git a/src/mongo/db/query/type_explain.h b/src/mongo/db/query/type_explain.h index 1048e591c85..a151c78715d 100644 --- a/src/mongo/db/query/type_explain.h +++ b/src/mongo/db/query/type_explain.h @@ -42,7 +42,7 @@ namespace mongo { * query. The exception is the multi plan runner, in which * case plan selection depends on actually running the query. * - * Currently, just a summary string describing the plan + * Currently, just a summary std::string describing the plan * used to run the query. */ struct PlanInfo { diff --git a/src/mongo/db/range_deleter.h b/src/mongo/db/range_deleter.h index 9c47659bf0d..9a3b8c6b1fa 100644 --- a/src/mongo/db/range_deleter.h +++ b/src/mongo/db/range_deleter.h @@ -304,7 +304,7 @@ namespace mongo { * Must be a synchronous call. CursorIds should be populated after call. * Must not throw exception. */ - virtual void getCursorIds(const StringData& ns, set<CursorId>* openCursors) = 0; + virtual void getCursorIds(const StringData& ns, std::set<CursorId>* openCursors) = 0; }; } // namespace mongo diff --git a/src/mongo/db/range_deleter_mock_env.h b/src/mongo/db/range_deleter_mock_env.h index 2bffc7a418b..ce9457889d6 100644 --- a/src/mongo/db/range_deleter_mock_env.h +++ b/src/mongo/db/range_deleter_mock_env.h @@ -45,7 +45,7 @@ namespace mongo { }; /** - * Comparator function object compatible with std::set. + * Comparator function object compatible with set. */ struct DeletedRangeCmp { bool operator()(const DeletedRange& lhs, const DeletedRange& rhs) const; @@ -132,14 +132,14 @@ namespace mongo { const BSONObj& max, const BSONObj& shardKeyPattern, bool secondaryThrottle, - string* errMsg); + std::string* errMsg); /** * Basic implementation of gathering open cursors that matches the signature for * RangeDeleterEnv::getCursorIds. The cursors returned can be modified with * the setCursorId and clearCursorMap methods. */ - void getCursorIds(const StringData& ns, set<CursorId>* in); + void getCursorIds(const StringData& ns, std::set<CursorId>* in); private: // mutex acquisition ordering: diff --git a/src/mongo/db/repl/connections.h b/src/mongo/db/repl/connections.h index 9be9c36e04e..a32c77ed924 100644 --- a/src/mongo/db/repl/connections.h +++ b/src/mongo/db/repl/connections.h @@ -81,18 +81,18 @@ namespace mongo { So here what we do is wrapper known safe methods and not allow cursor-style queries at all. This makes ScopedConn limited in functionality but very safe. More non-cursor wrappers can be added here if needed. */ - bool runCommand(const string &dbname, const BSONObj& cmd, BSONObj &info, int options=0) { + bool runCommand(const std::string &dbname, const BSONObj& cmd, BSONObj &info, int options=0) { return conn()->runCommand(dbname, cmd, info, options); } - unsigned long long count(const string &ns) { + unsigned long long count(const std::string &ns) { return conn()->count(ns); } - BSONObj findOne(const string &ns, const Query& q, const BSONObj *fieldsToReturn = 0, int queryOptions = 0) { + BSONObj findOne(const std::string &ns, const Query& q, const BSONObj *fieldsToReturn = 0, int queryOptions = 0) { return conn()->findOne(ns, q, fieldsToReturn, queryOptions); } private: - auto_ptr<scoped_lock> connLock; + std::auto_ptr<scoped_lock> connLock; static mongo::mutex mapMutex; struct ConnectionInfo { mongo::mutex lock; @@ -123,14 +123,14 @@ namespace mongo { private: int _timeout; } *connInfo; - typedef map<string,ScopedConn::ConnectionInfo*> M; + typedef std::map<std::string,ScopedConn::ConnectionInfo*> M; static M& _map; scoped_ptr<DBClientConnection>& conn() { return connInfo->cc; } - const string _hostport; + const std::string _hostport; // we should already be locked... bool connect() { - string err; + std::string err; if (!connInfo->cc->connect(_hostport, err)) { log() << "couldn't connect to " << _hostport << ": " << err << rsLog; return false; diff --git a/src/mongo/db/repl/master_slave.h b/src/mongo/db/repl/master_slave.h index dbcd0953fb5..740a767cc4e 100644 --- a/src/mongo/db/repl/master_slave.h +++ b/src/mongo/db/repl/master_slave.h @@ -51,7 +51,7 @@ namespace mongo { extern volatile int relinquishSyncingSome; extern volatile int syncing; - // Global variable that contains a string telling why master/slave halted + // Global variable that contains a std::string telling why master/slave halted extern const char *replAllDead; /* A replication exception */ @@ -92,18 +92,18 @@ namespace mongo { back to read more transactions. (Imagine a scenario of slave startup where we try to clone 100 databases in one pass.) */ - set<string> addDbNextPass; + std::set<std::string> addDbNextPass; - set<string> incompleteCloneDbs; + std::set<std::string> incompleteCloneDbs; BSONObj _me; ReplSource(); - void resyncDrop( OperationContext* txn, const string& db ); + void resyncDrop( OperationContext* txn, const std::string& db ); // call without the db mutex void syncToTailOfRemoteLog(); - string ns() const { return string( "local.oplog.$" ) + sourceName(); } + std::string ns() const { return std::string( "local.oplog.$" ) + sourceName(); } unsigned _sleepAdviceTime; /** @@ -124,17 +124,17 @@ namespace mongo { OplogReader oplogReader; void applyOperation(OperationContext* txn, Database* db, const BSONObj& op); - string hostName; // ip addr or hostname plus optionally, ":<port>" - string _sourceName; // a logical source name. - string sourceName() const { return _sourceName.empty() ? "main" : _sourceName; } - string only; // only a certain db. note that in the sources collection, this may not be changed once you start replicating. + std::string hostName; // ip addr or hostname plus optionally, ":<port>" + std::string _sourceName; // a logical source name. + std::string sourceName() const { return _sourceName.empty() ? "main" : _sourceName; } + std::string only; // only a certain db. note that in the sources collection, this may not be changed once you start replicating. /* the last time point we have already synced up to (in the remote/master's oplog). */ OpTime syncedTo; int nClonedThisPass; - typedef vector< shared_ptr< ReplSource > > SourceVector; + typedef std::vector< shared_ptr< ReplSource > > SourceVector; static void loadAll(SourceVector&); explicit ReplSource(BSONObj); @@ -150,7 +150,7 @@ namespace mongo { bool operator==(const ReplSource&r) const { return hostName == r.hostName && sourceName() == r.sourceName(); } - string toString() const { return sourceName() + "@" + hostName; } + std::string toString() const { return sourceName() + "@" + hostName; } bool haveMoreDbsToSync() const { return !addDbNextPass.empty(); } int sleepAdvice() const { @@ -172,14 +172,14 @@ namespace mongo { class DatabaseIgnorer { public: /** Indicate that operations for 'db' should be ignored until after 'futureOplogTime' */ - void doIgnoreUntilAfter( const string &db, const OpTime &futureOplogTime ); + void doIgnoreUntilAfter( const std::string &db, const OpTime &futureOplogTime ); /** * Query ignore state of 'db'; if 'currentOplogTime' is after the ignore * limit, the ignore state will be cleared. */ - bool ignoreAt( const string &db, const OpTime ¤tOplogTime ); + bool ignoreAt( const std::string &db, const OpTime ¤tOplogTime ); private: - map< string, OpTime > _ignores; + std::map< std::string, OpTime > _ignores; }; } diff --git a/src/mongo/db/repl/member_state.h b/src/mongo/db/repl/member_state.h index 587f729568d..d9c1801dd59 100644 --- a/src/mongo/db/repl/member_state.h +++ b/src/mongo/db/repl/member_state.h @@ -69,7 +69,7 @@ namespace mongo { bool readable() const { return s == RS_PRIMARY || s == RS_SECONDARY; } bool shunned() const { return s == RS_SHUNNED; } - string toString() const; + std::string toString() const; bool operator==(const MemberState& r) const { return s == r.s; } bool operator!=(const MemberState& r) const { return s != r.s; } diff --git a/src/mongo/db/repl/multicmd.h b/src/mongo/db/repl/multicmd.h index 0f8b8df9bc5..02f53e2796e 100644 --- a/src/mongo/db/repl/multicmd.h +++ b/src/mongo/db/repl/multicmd.h @@ -36,9 +36,9 @@ namespace mongo { struct Target { - Target(string hostport) : toHost(hostport), ok(false) { } + Target(std::string hostport) : toHost(hostport), ok(false) { } //Target() : ok(false) { } - const string toHost; + const std::string toHost; bool ok; BSONObj result; }; @@ -49,7 +49,7 @@ namespace mongo { in: Target::toHost out: Target::result and Target::ok */ - void multiCommand(BSONObj cmd, list<Target>& L); + void multiCommand(BSONObj cmd, std::list<Target>& L); class _MultiCommandJob : public BackgroundJob { public: @@ -58,7 +58,7 @@ namespace mongo { _MultiCommandJob(BSONObj& _cmd, Target& _d) : cmd(_cmd), d(_d) { } private: - string name() const { return "MultiCommandJob"; } + std::string name() const { return "MultiCommandJob"; } void run() { try { ScopedConn c(d.toHost); @@ -72,17 +72,17 @@ namespace mongo { } }; - inline void multiCommand(BSONObj cmd, list<Target>& L) { - list< shared_ptr<BackgroundJob> > jobs; + inline void multiCommand(BSONObj cmd, std::list<Target>& L) { + std::list< shared_ptr<BackgroundJob> > jobs; - for( list<Target>::iterator i = L.begin(); i != L.end(); i++ ) { + for( std::list<Target>::iterator i = L.begin(); i != L.end(); i++ ) { Target& d = *i; _MultiCommandJob *j = new _MultiCommandJob(cmd, d); jobs.push_back( shared_ptr<BackgroundJob>(j) ); j->go(); } - for( list< shared_ptr<BackgroundJob> >::iterator i = jobs.begin(); i != jobs.end(); i++ ) { + for( std::list< shared_ptr<BackgroundJob> >::iterator i = jobs.begin(); i != jobs.end(); i++ ) { (*i)->wait(); } } diff --git a/src/mongo/db/repl/oplogreader.h b/src/mongo/db/repl/oplogreader.h index 40979dc2538..9121c466f66 100644 --- a/src/mongo/db/repl/oplogreader.h +++ b/src/mongo/db/repl/oplogreader.h @@ -76,11 +76,11 @@ namespace mongo { bool connect(const std::string& hostname, const BSONObj& me); - bool connect(const mongo::OID& rid, const int from, const string& to); + bool connect(const mongo::OID& rid, const int from, const std::string& to); void tailCheck() { if( cursor.get() && cursor->isDead() ) { - log() << "repl: old cursor isDead, will initiate a new one" << endl; + log() << "repl: old cursor isDead, will initiate a new one" << std::endl; resetCursor(); } } @@ -149,7 +149,7 @@ namespace mongo { int getTailingQueryOptions() const { return _tailingQueryOptions; } void setTailingQueryOptions( int tailingQueryOptions ) { _tailingQueryOptions = tailingQueryOptions; } - void peek(vector<BSONObj>& v, int n) { + void peek(std::vector<BSONObj>& v, int n) { if( cursor.get() ) cursor->peek(v,n); } @@ -159,7 +159,7 @@ namespace mongo { private: /** @return true iff connection was successful */ - bool commonConnect(const string& hostName); + bool commonConnect(const std::string& hostName); bool passthroughHandshake(const mongo::OID& rid, const int f); }; diff --git a/src/mongo/db/repl/rs.h b/src/mongo/db/repl/rs.h index 549a0cb948d..7be93804842 100644 --- a/src/mongo/db/repl/rs.h +++ b/src/mongo/db/repl/rs.h @@ -73,6 +73,7 @@ namespace mongo { // Main entry point for replica sets void startReplSets(ReplSetCmdline *replSetCmdline); + /** * does local authentication * directly authorizes against AuthenticationInfo diff --git a/src/mongo/db/repl/rs_config.h b/src/mongo/db/repl/rs_config.h index 27b38774185..f25984a9ddf 100644 --- a/src/mongo/db/repl/rs_config.h +++ b/src/mongo/db/repl/rs_config.h @@ -38,7 +38,7 @@ namespace mongo { class Member; - const string rsConfigNs = "local.system.replset"; + const std::string rsConfigNs = "local.system.replset"; class ReplSetConfig { enum { EMPTYCONFIG = -2 }; @@ -82,14 +82,14 @@ namespace mongo { int slaveDelay; /* seconds. int rather than unsigned for convenient to/front bson conversion. */ bool hidden; /* if set, don't advertise to drives in isMaster. for non-primaries (priority 0) */ bool buildIndexes; /* if false, do not create any non-_id indexes */ - map<string,string> tags; /* tagging for data center, rack, etc. */ + std::map<std::string,std::string> tags; /* tagging for data center, rack, etc. */ private: - set<TagSubgroup*> _groups; // the subgroups this member belongs to + std::set<TagSubgroup*> _groups; // the subgroups this member belongs to public: - const set<TagSubgroup*>& groups() const { + const std::set<TagSubgroup*>& groups() const { return _groups; } - set<TagSubgroup*>& groupsw() { + std::set<TagSubgroup*>& groupsw() { return _groups; } void check() const; /* check validity, assert if not. */ @@ -98,7 +98,7 @@ namespace mongo { void updateGroups(const OpTime& last) { RACECHECK scoped_lock lk(ReplSetConfig::groupMx); - for (set<TagSubgroup*>::const_iterator it = groups().begin(); it != groups().end(); it++) { + for (std::set<TagSubgroup*>::const_iterator it = groups().begin(); it != groups().end(); it++) { (*it)->updateLast(last); } } @@ -115,8 +115,8 @@ namespace mongo { // if they are the same size and not equal, at least one // element in A must be different in B - for (map<string,string>::const_iterator lit = tags.begin(); lit != tags.end(); lit++) { - map<string,string>::const_iterator rit = r.tags.find((*lit).first); + for (std::map<std::string,std::string>::const_iterator lit = tags.begin(); lit != tags.end(); lit++) { + std::map<std::string,std::string>::const_iterator rit = r.tags.find((*lit).first); if (rit == r.tags.end() || (*lit).second != (*rit).second) { return false; @@ -129,8 +129,8 @@ namespace mongo { bool operator!=(const MemberCfg& r) const { return !(*this == r); } }; - vector<MemberCfg> members; - string _id; + std::vector<MemberCfg> members; + std::string _id; int version; struct HealthOptions { @@ -156,26 +156,26 @@ namespace mongo { }; HealthOptions ho; - string md5; + std::string md5; BSONObj getLastErrorDefaults; - map<string,TagRule*> rules; + std::map<std::string,TagRule*> rules; - list<HostAndPort> otherMemberHostnames() const; // except self + std::list<HostAndPort> otherMemberHostnames() const; // except self /** @return true if could connect, and there is no cfg object there at all */ bool empty() const { return version == EMPTYCONFIG; } - string toString() const { return asBson().toString(); } + std::string toString() const { return asBson().toString(); } /** validate the settings. does not call check() on each member, you have to do that separately. */ void checkRsConfig() const; /** check if modification makes sense */ - static bool legalChange(const ReplSetConfig& old, const ReplSetConfig& n, string& errmsg); + static bool legalChange(const ReplSetConfig& old, const ReplSetConfig& n, std::string& errmsg); //static void receivedNewConfig(BSONObj); void saveConfigLocally(BSONObj comment); // to local db - string saveConfigEverywhere(); // returns textual info on what happened + std::string saveConfigEverywhere(); // returns textual info on what happened /** * Update members' groups when the config changes but members stay the same. @@ -248,14 +248,14 @@ namespace mongo { struct TagSubgroup : boost::noncopyable { ~TagSubgroup(); // never called; not defined TagSubgroup(const std::string& nm) : name(nm) { } - const string name; + const std::string name; OpTime last; - vector<TagClause*> clauses; + std::vector<TagClause*> clauses; // this probably won't actually point to valid members after the // subgroup is created, as initFromConfig() makes a copy of the // config - set<MemberCfg*> m; + std::set<MemberCfg*> m; void updateLast(const OpTime& op); @@ -279,9 +279,9 @@ namespace mongo { */ struct TagClause { OpTime last; - map<string,TagSubgroup*> subgroups; + std::map<std::string,TagSubgroup*> subgroups; TagRule *rule; - string name; + std::string name; /** * If we have get a clause like {machines : 3} and this server is * tagged with "machines", then it's really {machines : 2}, as we @@ -292,7 +292,7 @@ namespace mongo { int actualTarget; void updateLast(const OpTime& op); - string toString() const; + std::string toString() const; }; /** @@ -316,15 +316,15 @@ namespace mongo { * "ny" -> {A, B},{C} * "sf" -> {D},{E} */ - void _populateTagMap(map<string,TagClause> &tagMap); + void _populateTagMap(std::map<std::string,TagClause> &tagMap); public: struct TagRule { - vector<TagClause*> clauses; + std::vector<TagClause*> clauses; OpTime last; void updateLast(const OpTime& op); - string toString() const; + std::string toString() const; }; }; diff --git a/src/mongo/db/repl/rs_sync.h b/src/mongo/db/repl/rs_sync.h index 5765172b070..f5df70b1b85 100644 --- a/src/mongo/db/repl/rs_sync.h +++ b/src/mongo/db/repl/rs_sync.h @@ -46,7 +46,7 @@ namespace replset { // TODO: move hbmsg into an error-keeping class (SERVER-4444) - void sethbmsg(const string& s, const int logLevel=0); + void sethbmsg(const std::string& s, const int logLevel=0); } // namespace replset } // namespace mongo diff --git a/src/mongo/db/repl/server.h b/src/mongo/db/repl/server.h index d84dcd56ad4..9216c0bc87d 100644 --- a/src/mongo/db/repl/server.h +++ b/src/mongo/db/repl/server.h @@ -62,12 +62,12 @@ namespace mongo { private: virtual bool initClient() { return true; } - virtual string name() const { return _name; } + virtual std::string name() const { return _name; } void doWork(); std::deque<lam> d; mongo::mutex m; boost::condition c; - string _name; + std::string _name; bool rq; }; diff --git a/src/mongo/db/repl/sync.h b/src/mongo/db/repl/sync.h index 9edca0b585b..18ecaa63e54 100644 --- a/src/mongo/db/repl/sync.h +++ b/src/mongo/db/repl/sync.h @@ -38,9 +38,9 @@ namespace mongo { class Sync { protected: - string hn; + std::string hn; public: - Sync(const string& hostname) : hn(hostname) {} + Sync(const std::string& hostname) : hn(hostname) {} virtual ~Sync() {} virtual BSONObj getMissingDoc(Database* db, const BSONObj& o); @@ -48,7 +48,7 @@ namespace mongo { * If applyOperation_inlock should be called again after an update fails. */ virtual bool shouldRetry(const BSONObj& o); - void setHostname(const string& hostname); + void setHostname(const std::string& hostname); }; } diff --git a/src/mongo/db/repl/sync_source_feedback.h b/src/mongo/db/repl/sync_source_feedback.h index dd2bfbcf9b3..ba1fe483e45 100644 --- a/src/mongo/db/repl/sync_source_feedback.h +++ b/src/mongo/db/repl/sync_source_feedback.h @@ -107,8 +107,8 @@ namespace mongo { // protects cond and maps and the indicator bools boost::mutex _mtx; // contains the most recent optime of each member syncing to us - map<mongo::OID, OpTime> _slaveMap; - typedef map<mongo::OID, Member*> OIDMemberMap; + std::map<mongo::OID, OpTime> _slaveMap; + typedef std::map<mongo::OID, Member*> OIDMemberMap; // contains a pointer to each member, which we can look up by oid OIDMemberMap _members; // used to alert our thread of changes which need to be passed up the chain diff --git a/src/mongo/db/repl/write_concern.h b/src/mongo/db/repl/write_concern.h index 5dd332cf2f5..9c9aab87dc9 100644 --- a/src/mongo/db/repl/write_concern.h +++ b/src/mongo/db/repl/write_concern.h @@ -47,7 +47,7 @@ namespace mongo { /** @return true if op has made it to w servers */ bool opReplicatedEnough( OpTime op , int w ); - bool opReplicatedEnough( OpTime op , const string& w ); + bool opReplicatedEnough( OpTime op , const std::string& w ); bool opReplicatedEnough( OpTime op , BSONElement w ); bool waitForReplication( OpTime op , int w , int maxSecondsToWait ); diff --git a/src/mongo/db/server_parameters.h b/src/mongo/db/server_parameters.h index 1d7e0610021..c4feb946ad5 100644 --- a/src/mongo/db/server_parameters.h +++ b/src/mongo/db/server_parameters.h @@ -66,14 +66,14 @@ namespace mongo { bool allowedToChangeAtRuntime() const { return _allowedToChangeAtRuntime; } - virtual void append( BSONObjBuilder& b, const string& name ) = 0; + virtual void append( BSONObjBuilder& b, const std::string& name ) = 0; virtual Status set( const BSONElement& newValueElement ) = 0; - virtual Status setFromString( const string& str ) = 0; + virtual Status setFromString( const std::string& str ) = 0; private: - string _name; + std::string _name; bool _allowedToChangeAtStartup; bool _allowedToChangeAtRuntime; }; @@ -114,7 +114,7 @@ namespace mongo { _value( value ) {} virtual ~ExportedServerParameter() {} - virtual void append( BSONObjBuilder& b, const string& name ) { + virtual void append( BSONObjBuilder& b, const std::string& name ) { b.append( name, *_value ); } @@ -123,7 +123,7 @@ namespace mongo { virtual const T& get() const { return *_value; } - virtual Status setFromString( const string& str ); + virtual Status setFromString( const std::string& str ); protected: diff --git a/src/mongo/db/sorter/sorter.h b/src/mongo/db/sorter/sorter.h index 3789bccff63..c5955e67911 100644 --- a/src/mongo/db/sorter/sorter.h +++ b/src/mongo/db/sorter/sorter.h @@ -62,7 +62,7 @@ * // Return *this if your type doesn't have an unowned state * Type getOwned() const; * - * Comparators are functors that that compare pair<Key, Value> and return an + * Comparators are functors that that compare std::pair<Key, Value> and return an * int less than, equal to, or greater than 0 depending on how the two pairs * compare with the same semantics as memcmp. * Example for Key=BSONObj, Value=int: diff --git a/src/mongo/db/startup_warnings.cpp b/src/mongo/db/startup_warnings.cpp index ac708bb2127..930e08dec10 100644 --- a/src/mongo/db/startup_warnings.cpp +++ b/src/mongo/db/startup_warnings.cpp @@ -26,6 +26,8 @@ * then also delete it in the license file. */ +#include "mongo/platform/basic.h" + #include "mongo/db/startup_warnings.h" #include <boost/filesystem/operations.hpp> diff --git a/src/mongo/db/stats/service_stats.h b/src/mongo/db/stats/service_stats.h index da8b121aa55..168a7f104ac 100644 --- a/src/mongo/db/stats/service_stats.h +++ b/src/mongo/db/stats/service_stats.h @@ -59,10 +59,10 @@ namespace mongo { void logResponse( uint64_t duration, uint64_t bytes ); /** - * Render the histogram as string that can be used inside an + * Render the histogram as std::string that can be used inside an * HTML doc. */ - string toHTML() const; + std::string toHTML() const; private: SpinLock _spinLock; // protects state below diff --git a/src/mongo/db/stats/snapshots.h b/src/mongo/db/stats/snapshots.h index 9ea639a6fc8..29c8fc5bdfe 100644 --- a/src/mongo/db/stats/snapshots.h +++ b/src/mongo/db/stats/snapshots.h @@ -101,10 +101,10 @@ namespace mongo { int numDeltas() const { return _stored-1; } const SnapshotData& getPrev( int numBack = 0 ); - auto_ptr<SnapshotDelta> computeDelta( int numBack = 0 ); + std::auto_ptr<SnapshotDelta> computeDelta( int numBack = 0 ); - void outputLockInfoHTML( stringstream& ss ); + void outputLockInfoHTML( std::stringstream& ss ); private: mongo::mutex _lock; int _n; @@ -115,7 +115,7 @@ namespace mongo { class SnapshotThread : public BackgroundJob { public: - virtual string name() const { return "snapshot"; } + virtual std::string name() const { return "snapshot"; } void run(); }; diff --git a/src/mongo/db/stats/top.h b/src/mongo/db/stats/top.h index 9ab16ade79e..a90b1503e81 100644 --- a/src/mongo/db/stats/top.h +++ b/src/mongo/db/stats/top.h @@ -96,7 +96,7 @@ namespace mongo { mutable SimpleMutex _lock; CollectionData _global; UsageMap _usage; - string _lastDropped; + std::string _lastDropped; }; } // namespace mongo diff --git a/src/mongo/db/storage/durable_mapped_file.h b/src/mongo/db/storage/durable_mapped_file.h index 7511692b598..628327252f5 100644 --- a/src/mongo/db/storage/durable_mapped_file.h +++ b/src/mongo/db/storage/durable_mapped_file.h @@ -55,7 +55,7 @@ namespace mongo { /** @return file length */ unsigned long long length() const { return MemoryMappedFile::length(); } - string filename() const { return MemoryMappedFile::filename(); } + std::string filename() const { return MemoryMappedFile::filename(); } void flush(bool sync) { MemoryMappedFile::flush(sync); } @@ -139,13 +139,13 @@ namespace mongo { mutex& _mutex() { return _m; } DurableMappedFile* find_inlock(void *p, /*out*/ size_t& ofs); - map<void*,DurableMappedFile*>::iterator finditer_inlock(void *p) { return _views.upper_bound(p); } + std::map<void*,DurableMappedFile*>::iterator finditer_inlock(void *p) { return _views.upper_bound(p); } unsigned numberOfViews_inlock() const { return _views.size(); } private: mutex _m; - map<void*, DurableMappedFile*> _views; + std::map<void*, DurableMappedFile*> _views; }; // allows a pointer into any private view of a DurableMappedFile to be resolved to the DurableMappedFile object diff --git a/src/mongo/db/storage/extent.h b/src/mongo/db/storage/extent.h index 175180f2171..8a27e271c04 100644 --- a/src/mongo/db/storage/extent.h +++ b/src/mongo/db/storage/extent.h @@ -66,7 +66,7 @@ namespace mongo { // ----- - bool validates(const DiskLoc diskLoc, std::vector<string>* errors = NULL) const; + bool validates(const DiskLoc diskLoc, std::vector<std::string>* errors = NULL) const; BSONObj dump() const; diff --git a/src/mongo/db/storage/mmap_v1/dur.h b/src/mongo/db/storage/mmap_v1/dur.h index f1c760549b5..b777b048a88 100644 --- a/src/mongo/db/storage/mmap_v1/dur.h +++ b/src/mongo/db/storage/mmap_v1/dur.h @@ -56,7 +56,7 @@ namespace mongo { class DurableInterface : boost::noncopyable { public: - virtual ~DurableInterface() { log() << "ERROR warning ~DurableInterface not intended to be called" << endl; } + virtual ~DurableInterface() { log() << "ERROR warning ~DurableInterface not intended to be called" << std::endl; } /** Declare that a file has been created Normally writes are applied only after journaling, for safety. But here the file @@ -97,7 +97,7 @@ namespace mongo { range length. @return new buffer pointer. this is modified when testIntent is true. */ - virtual void* writingRangesAtOffsets(void *buf, const vector< pair< long long, unsigned > > &ranges ) = 0; + virtual void* writingRangesAtOffsets(void *buf, const std::vector< std::pair< long long, unsigned > > &ranges ) = 0; /** Wait for acknowledgement of the next group commit. @return true if --dur is on. There will be delay. @@ -194,7 +194,7 @@ namespace mongo { class NonDurableImpl : public DurableInterface { void* writingPtr(void *x, unsigned len); void* writingAtOffset(void *buf, unsigned ofs, unsigned len) { return buf; } - void* writingRangesAtOffsets(void *buf, const vector< pair< long long, unsigned > > &ranges) { return buf; } + void* writingRangesAtOffsets(void *buf, const std::vector< std::pair< long long, unsigned > > &ranges) { return buf; } void declareWriteIntent(void *, unsigned); void createdFile(const std::string& filename, unsigned long long len) { } bool awaitCommit() { return false; } @@ -209,7 +209,7 @@ namespace mongo { bool _aCommitIsNeeded(); void* writingPtr(void *x, unsigned len); void* writingAtOffset(void *buf, unsigned ofs, unsigned len); - void* writingRangesAtOffsets(void *buf, const vector< pair< long long, unsigned > > &ranges); + void* writingRangesAtOffsets(void *buf, const std::vector< std::pair< long long, unsigned > > &ranges); void declareWriteIntent(void *, unsigned); void createdFile(const std::string& filename, unsigned long long len); bool awaitCommit(); diff --git a/src/mongo/db/storage/mmap_v1/dur_commitjob.h b/src/mongo/db/storage/mmap_v1/dur_commitjob.h index 4a1d5b66b69..5f32ee46e35 100644 --- a/src/mongo/db/storage/mmap_v1/dur_commitjob.h +++ b/src/mongo/db/storage/mmap_v1/dur_commitjob.h @@ -57,7 +57,7 @@ namespace mongo { bool contains(const WriteIntent& rhs) const { return (start() <= rhs.start() && end() >= rhs.end()); } // merge into me: void absorb(const WriteIntent& other); - friend ostream& operator << (ostream& out, const WriteIntent& wi) { + friend std::ostream& operator << (std::ostream& out, const WriteIntent& wi) { return (out << "p: " << wi.p << " end: " << wi.end() << " len: " << wi.len); } private: @@ -79,7 +79,7 @@ namespace mongo { */ bool checkAndSet(void* p, int len) { unsigned x = mongoutils::hashPointer(p); - pair<void*, int>& nd = nodes[x % N]; + std::pair<void*, int>& nd = nodes[x % N]; if( nd.first == p ) { if( nd.second < len ) { nd.second = len; @@ -93,15 +93,15 @@ namespace mongo { } private: enum { N = Prime }; // this should be small the idea is that it fits in the cpu cache easily - pair<void*,int> nodes[N]; + std::pair<void*,int> nodes[N]; }; /** our record of pending/uncommitted write intents */ class IntentsAndDurOps : boost::noncopyable { public: - vector<WriteIntent> _intents; + std::vector<WriteIntent> _intents; Already<127> _alreadyNoted; - vector< shared_ptr<DurOp> > _durOps; // all the ops other than basic writes + std::vector< shared_ptr<DurOp> > _durOps; // all the ops other than basic writes /** reset the IntentsAndDurOps structure (empties all the above) */ void clear(); @@ -111,7 +111,7 @@ namespace mongo { wassert( _intents.size() < 2000000 ); } #if defined(DEBUG_WRITE_INTENT) - map<void*,int> _debug; + std::map<void*,int> _debug; #endif }; @@ -152,7 +152,7 @@ namespace mongo { /** note an operation other than a "basic write". threadsafe (locks in the impl) */ void noteOp(shared_ptr<DurOp> p); - vector< shared_ptr<DurOp> >& ops() { + std::vector< shared_ptr<DurOp> >& ops() { dassert( Lock::isLocked() ); // a rather weak check, we require more than that groupCommitMutex.dassertLocked(); // this is what really makes the below safe return _intentsAndDurOps._durOps; @@ -184,7 +184,7 @@ namespace mongo { /** used in prepbasicwrites. sorted so that overlapping and duplicate items * can be merged. we sort here so the caller receives something they must * keep const from their pov. */ - const vector<WriteIntent>& getIntentsSorted() { + const std::vector<WriteIntent>& getIntentsSorted() { groupCommitMutex.dassertLocked(); sort(_intentsAndDurOps._intents.begin(), _intentsAndDurOps._intents.end()); return _intentsAndDurOps._intents; diff --git a/src/mongo/db/storage/mmap_v1/dur_journalformat.h b/src/mongo/db/storage/mmap_v1/dur_journalformat.h index 9e35e10cfe2..5bf73bacfb8 100644 --- a/src/mongo/db/storage/mmap_v1/dur_journalformat.h +++ b/src/mongo/db/storage/mmap_v1/dur_journalformat.h @@ -42,7 +42,7 @@ namespace mongo { */ struct JHeader { JHeader() { } - JHeader(string fname); + JHeader(std::string fname); char magic[2]; // "j\n". j means journal, then a linefeed, fwiw if you were to run "less" on the file or something... @@ -133,9 +133,9 @@ namespace mongo { bool isLocalDbContext() const { return _fileNo & LocalDbBit; } void clearLocalDbContextBit() { _fileNo = getFileNo(); } - static string suffix(int fileno) { + static std::string suffix(int fileno) { if( fileno == DotNsSuffix ) return "ns"; - stringstream ss; + std::stringstream ss; ss << fileno; return ss.str(); } diff --git a/src/mongo/db/storage/mmap_v1/dur_journalimpl.h b/src/mongo/db/storage/mmap_v1/dur_journalimpl.h index 6be3515dda5..04aca13e69d 100644 --- a/src/mongo/db/storage/mmap_v1/dur_journalimpl.h +++ b/src/mongo/db/storage/mmap_v1/dur_journalimpl.h @@ -39,7 +39,7 @@ namespace mongo { /** the writeahead journal for durability */ class Journal { public: - string dir; // set by journalMakeDir() during initialization + std::string dir; // set by journalMakeDir() during initialization Journal(); @@ -92,13 +92,13 @@ namespace mongo { unsigned long long _curFileId; // current file id see JHeader::fileId struct JFile { - string filename; + std::string filename; unsigned long long lastEventTimeMs; }; // files which have been closed but not unlinked (rotated out) yet // ordered oldest to newest - list<JFile> _oldJournalFiles; // use _curLogFileMutex + std::list<JFile> _oldJournalFiles; // use _curLogFileMutex // lsn related static void preFlush(); diff --git a/src/mongo/db/storage/mmap_v1/dur_recover.h b/src/mongo/db/storage/mmap_v1/dur_recover.h index c7eac7e0546..fc81ba23fd1 100644 --- a/src/mongo/db/storage/mmap_v1/dur_recover.h +++ b/src/mongo/db/storage/mmap_v1/dur_recover.h @@ -52,13 +52,13 @@ namespace mongo { DurableMappedFile* newEntry(const ParsedJournalEntry&, RecoveryJob&); private: DurableMappedFile *mmf; - string dbName; + std::string dbName; int fileNo; } last; public: RecoveryJob() : _lastDataSyncedFromLastRun(0), _mx("recovery"), _recovering(false) { _lastSeqMentionedInConsoleLog = 1; } - void go(vector<boost::filesystem::path>& files); + void go(std::vector<boost::filesystem::path>& files); ~RecoveryJob(); /** @param data data between header and footer. compressed if recovering. */ @@ -70,13 +70,13 @@ namespace mongo { private: void write(Last& last, const ParsedJournalEntry& entry); // actually writes to the file void applyEntry(Last& last, const ParsedJournalEntry& entry, bool apply, bool dump); - void applyEntries(const vector<ParsedJournalEntry> &entries); + void applyEntries(const std::vector<ParsedJournalEntry> &entries); bool processFileBuffer(const void *, unsigned len); bool processFile(boost::filesystem::path journalfile); void _close(); // doesn't lock DurableMappedFile* getDurableMappedFile(const ParsedJournalEntry& entry); - list<boost::shared_ptr<DurableMappedFile> > _mmfs; + std::list<boost::shared_ptr<DurableMappedFile> > _mmfs; unsigned long long _lastDataSyncedFromLastRun; unsigned long long _lastSeqMentionedInConsoleLog; diff --git a/src/mongo/db/storage/mmap_v1/dur_stats.h b/src/mongo/db/storage/mmap_v1/dur_stats.h index e2c0b29353e..d97c48d5a39 100644 --- a/src/mongo/db/storage/mmap_v1/dur_stats.h +++ b/src/mongo/db/storage/mmap_v1/dur_stats.h @@ -41,8 +41,8 @@ namespace mongo { unsigned _intervalMicros; struct S { BSONObj _asObj(); - string _asCSV(); - string _CSVHeader(); + std::string _asCSV(); + std::string _CSVHeader(); void reset(); unsigned _commits; diff --git a/src/mongo/db/storage/mmap_v1/durop.h b/src/mongo/db/storage/mmap_v1/durop.h index 562ddb0a490..43af9efe6de 100644 --- a/src/mongo/db/storage/mmap_v1/durop.h +++ b/src/mongo/db/storage/mmap_v1/durop.h @@ -72,7 +72,7 @@ namespace mongo { */ virtual void replay() = 0; - virtual string toString() = 0; + virtual std::string toString() = 0; /** if the op requires all file to be closed before doing its work, returns true. */ virtual bool needFilesClosed() { return false; } @@ -92,7 +92,7 @@ namespace mongo { /** param f filename to create with path */ FileCreatedOp(const std::string& f, unsigned long long l); virtual void replay(); - virtual string toString(); + virtual std::string toString(); virtual bool needFilesClosed(); protected: virtual void _serialize(AlignedBuilder& ab); @@ -108,12 +108,12 @@ namespace mongo { DropDbOp(const std::string& db) : DurOp(JEntry::OpCode_DropDb), _db(db) { } virtual void replay(); - virtual string toString() { return string("DropDbOp ") + _db; } + virtual std::string toString() { return std::string("DropDbOp ") + _db; } virtual bool needFilesClosed() { return true; } protected: virtual void _serialize(AlignedBuilder& ab); private: - string _db; + std::string _db; }; } diff --git a/src/mongo/db/structure/btree/btree_logic.h b/src/mongo/db/structure/btree/btree_logic.h index 872384e6f88..e0c9942c12e 100644 --- a/src/mongo/db/structure/btree/btree_logic.h +++ b/src/mongo/db/structure/btree/btree_logic.h @@ -425,7 +425,7 @@ namespace mongo { const DiskLoc leftChild, const DiskLoc rightChild); - string dupKeyError(const KeyDataType& key) const; + std::string dupKeyError(const KeyDataType& key) const; void setInternalKey(OperationContext* txn, BucketType* bucket, @@ -510,8 +510,8 @@ namespace mongo { const BSONObj& rBegin, int rBeginLen, bool rSup, - const vector<const BSONElement*>& rEnd, - const vector<bool>& rEndInclusive, + const std::vector<const BSONElement*>& rEnd, + const std::vector<bool>& rEndInclusive, const Ordering& o, int direction) const; diff --git a/src/mongo/db/structure/btree/btree_ondisk.h b/src/mongo/db/structure/btree/btree_ondisk.h index c32cda92375..1c8e5ad3efe 100644 --- a/src/mongo/db/structure/btree/btree_ondisk.h +++ b/src/mongo/db/structure/btree/btree_ondisk.h @@ -267,7 +267,7 @@ namespace mongo { invariant( la <= 0xffffff ); // must fit in 3 bytes if( la < 0 ) { if ( la != -1 ) { - log() << "btree diskloc isn't negative 1: " << la << endl; + log() << "btree diskloc isn't negative 1: " << la << std::endl; invariant ( la == -1 ); } la = 0; @@ -287,7 +287,7 @@ namespace mongo { return DiskLoc(a >> 8, ofs); } - string toString() const { return DiskLoc(*this).toString(); } + std::string toString() const { return DiskLoc(*this).toString(); } }; struct BtreeBucketV1 { diff --git a/src/mongo/db/structure/btree/key.h b/src/mongo/db/structure/btree/key.h index 214bfacf1e4..83203b0fee2 100644 --- a/src/mongo/db/structure/btree/key.h +++ b/src/mongo/db/structure/btree/key.h @@ -47,7 +47,7 @@ namespace mongo { explicit KeyBson(const BSONObj& obj) : _o(obj) { } int woCompare(const KeyBson& r, const Ordering &o) const; BSONObj toBson() const { return _o; } - string toString() const { return _o.toString(); } + std::string toString() const { return _o.toString(); } int dataSize() const { return _o.objsize(); } const char * data() const { return _o.objdata(); } BSONElement _firstElement() const { return _o.firstElement(); } @@ -86,7 +86,7 @@ namespace mongo { int woCompare(const KeyV1& r, const Ordering &o) const; bool woEqual(const KeyV1& r) const; BSONObj toBson() const; - string toString() const { return toBson().toString(); } + std::string toString() const { return toBson().toString(); } /** get the key data we want to store in the btree bucket */ const char * data() const { return (const char *) _keyData; } diff --git a/src/mongo/db/structure/catalog/hashtab.h b/src/mongo/db/structure/catalog/hashtab.h index ac15b506ebf..e73962ee31d 100644 --- a/src/mongo/db/structure/catalog/hashtab.h +++ b/src/mongo/db/structure/catalog/hashtab.h @@ -87,7 +87,7 @@ namespace mongo { if ( nodes(i).hash == h && nodes(i).k == k ) { if ( chain >= 200 ) - out() << "warning: hashtable " << name << " long chain " << endl; + out() << "warning: hashtable " << name << " long chain " << std::endl; found = true; return i; } @@ -95,13 +95,13 @@ namespace mongo { i = (i+1) % n; if ( i == start ) { // shouldn't get here / defensive for infinite loops - out() << "error: hashtable " << name << " is full n:" << n << endl; + out() << "error: hashtable " << name << " is full n:" << n << std::endl; return -1; } if( chain >= maxChain ) { if ( firstNonUsed >= 0 ) return firstNonUsed; - out() << "error: hashtable " << name << " max chain reached:" << maxChain << endl; + out() << "error: hashtable " << name << " max chain reached:" << maxChain << std::endl; return -1; } } @@ -111,7 +111,7 @@ namespace mongo { /* buf must be all zeroes on initialization. */ HashTable(void* buf, int buflen, const char *_name) : name(_name) { int m = sizeof(Node); - // out() << "hashtab init, buflen:" << buflen << " m:" << m << endl; + // out() << "hashtab init, buflen:" << buflen << " m:" << m << std::endl; n = buflen / m; if ( (n & 1) == 0 ) n--; @@ -120,7 +120,7 @@ namespace mongo { //nodes = (Node *) buf; if ( sizeof(Node) != 628 ) { - out() << "HashTable() " << _name << " sizeof(node):" << sizeof(Node) << " n:" << n << " sizeof(Key): " << sizeof(Key) << " sizeof(Type):" << sizeof(Type) << endl; + out() << "HashTable() " << _name << " sizeof(node):" << sizeof(Node) << " n:" << n << " sizeof(Key): " << sizeof(Key) << " sizeof(Type):" << sizeof(Type) << std::endl; verify( sizeof(Node) == 628 ); } diff --git a/src/mongo/db/structure/catalog/namespace-inl.h b/src/mongo/db/structure/catalog/namespace-inl.h index 2de1e2edbd0..5cd45963f1f 100644 --- a/src/mongo/db/structure/catalog/namespace-inl.h +++ b/src/mongo/db/structure/catalog/namespace-inl.h @@ -43,15 +43,15 @@ namespace mongo { // memset( buf, 0, sizeof(buf) ); uassert( 10080 , "ns name too long, max size is 127 bytes", ns.size() <= MaxNsLen); - uassert( 17380 , "ns name can't contain embedded '\0' byte", ns.find('\0') == string::npos); + uassert( 17380 , "ns name can't contain embedded '\0' byte", ns.find('\0') == std::string::npos); ns.copyTo( buf, true ); return *this; } - inline string Namespace::extraName(int i) const { + inline std::string Namespace::extraName(int i) const { char ex[] = "$extra"; ex[5] += i; - string s = string(buf) + ex; + std::string s = std::string(buf) + ex; massert( 10348 , "$extra: ns name too long", s.size() <= MaxNsLen); return s; } diff --git a/src/mongo/db/structure/catalog/namespace.h b/src/mongo/db/structure/catalog/namespace.h index bd5e36bffc6..02c8721b0cf 100644 --- a/src/mongo/db/structure/catalog/namespace.h +++ b/src/mongo/db/structure/catalog/namespace.h @@ -75,11 +75,11 @@ namespace mongo { // This includes rum for the NUL byte so it can be used when sizing buffers. MaxNsLenWithNUL = 128, - // MaxNsLenWithNUL excluding the NUL byte. Use this when comparing string lengths. + // MaxNsLenWithNUL excluding the NUL byte. Use this when comparing std::string lengths. MaxNsLen = MaxNsLenWithNUL - 1, // Maximum allowed length of fully qualified namespace name of any real collection. - // Does not include NUL so it can be directly compared to string lengths. + // Does not include NUL so it can be directly compared to std::string lengths. MaxNsColletionLen = MaxNsLen - 7/*strlen(".$extra")*/, }; private: diff --git a/src/mongo/db/structure/catalog/namespace_details.h b/src/mongo/db/structure/catalog/namespace_details.h index 1deda0ff3f3..468e5e967b1 100644 --- a/src/mongo/db/structure/catalog/namespace_details.h +++ b/src/mongo/db/structure/catalog/namespace_details.h @@ -264,7 +264,7 @@ namespace mongo { */ void paddingFits( OperationContext* txn ) { MONGO_SOMETIMES(sometimes, 4) { // do this on a sampled basis to journal less - double x = max(1.0, _paddingFactor - 0.001 ); + double x = std::max(1.0, _paddingFactor - 0.001 ); setPaddingFactor( txn, x ); } } @@ -277,8 +277,8 @@ namespace mongo { can pushes this down considerably. further tweaking will be a good idea but this should be an adequate starting point. */ - double N = min(_nIndexes,7) + 3; - double x = min(2.0,_paddingFactor + (0.001 * N)); + double N = std::min(_nIndexes,7) + 3; + double x = std::min(2.0,_paddingFactor + (0.001 * N)); setPaddingFactor( txn, x ); } } diff --git a/src/mongo/db/structure/catalog/namespace_index.h b/src/mongo/db/structure/catalog/namespace_index.h index 85d05fc861d..f5871ba8e0c 100644 --- a/src/mongo/db/structure/catalog/namespace_index.h +++ b/src/mongo/db/structure/catalog/namespace_index.h @@ -84,7 +84,7 @@ namespace mongo { void maybeMkdir() const; DurableMappedFile _f; - auto_ptr<HashTable<Namespace,NamespaceDetails> > _ht; + std::auto_ptr<HashTable<Namespace,NamespaceDetails> > _ht; std::string _dir; std::string _database; }; diff --git a/src/mongo/db/write_concern.h b/src/mongo/db/write_concern.h index bfa31571a45..6e4a1c30087 100644 --- a/src/mongo/db/write_concern.h +++ b/src/mongo/db/write_concern.h @@ -59,9 +59,9 @@ namespace mongo { bool wTimedOut; int wTime; - vector<BSONObj> writtenTo; + std::vector<BSONObj> writtenTo; - string err; // this is the old err field, should deprecate + std::string err; // this is the old err field, should deprecate }; /** diff --git a/src/mongo/dbtests/config_server_fixture.h b/src/mongo/dbtests/config_server_fixture.h index 9aa33e612eb..55c2d7f559f 100644 --- a/src/mongo/dbtests/config_server_fixture.h +++ b/src/mongo/dbtests/config_server_fixture.h @@ -73,7 +73,7 @@ namespace mongo { class CustomConnectHook: public ConnectionString::ConnectionHook { public: virtual DBClientBase* connect(const ConnectionString& connStr, - string& errmsg, + std::string& errmsg, double socketTimeout) { // Note - must be new, since it gets owned elsewhere @@ -98,10 +98,10 @@ namespace mongo { } /** - * Returns a connection string to the virtual config server. + * Returns a connection std::string to the virtual config server. */ ConnectionString configSvr() const { - return ConnectionString(string("$dummy:10000")); + return ConnectionString(std::string("$dummy:10000")); } /** diff --git a/src/mongo/dbtests/mock/mock_dbclient_connection.h b/src/mongo/dbtests/mock/mock_dbclient_connection.h index a4f902e4e7d..8fa1a890c90 100644 --- a/src/mongo/dbtests/mock/mock_dbclient_connection.h +++ b/src/mongo/dbtests/mock/mock_dbclient_connection.h @@ -78,13 +78,13 @@ namespace mongo { uint64_t getSockCreationMicroSec() const; - virtual void insert(const string& ns, BSONObj obj, int flags = 0); + virtual void insert(const std::string& ns, BSONObj obj, int flags = 0); - virtual void insert(const string& ns, const vector<BSONObj>& objList, int flags = 0); + virtual void insert(const std::string& ns, const std::vector<BSONObj>& objList, int flags = 0); - virtual void remove(const string& ns, Query query, bool justOne = false); + virtual void remove(const std::string& ns, Query query, bool justOne = false); - virtual void remove(const string& ns, Query query, int flags = 0); + virtual void remove(const std::string& ns, Query query, int flags = 0); // // Getters diff --git a/src/mongo/dbtests/mock/mock_remote_db_server.h b/src/mongo/dbtests/mock/mock_remote_db_server.h index 92b6975e68f..61074e4c857 100644 --- a/src/mongo/dbtests/mock/mock_remote_db_server.h +++ b/src/mongo/dbtests/mock/mock_remote_db_server.h @@ -40,7 +40,7 @@ namespace mongo { const std::string IdentityNS("local.me"); - const BSONField<string> HostField("host"); + const BSONField<std::string> HostField("host"); /** * A very simple mock that acts like a database server. Every object keeps track of its own @@ -136,7 +136,7 @@ namespace mongo { * @param obj the document to insert. * @param flags ignored. */ - void insert(const string& ns, BSONObj obj, int flags = 0); + void insert(const std::string& ns, BSONObj obj, int flags = 0); /** * Removes documents from this server. @@ -145,7 +145,7 @@ namespace mongo { * @param query ignored. * @param flags ignored. */ - void remove(const string& ns, Query query, int flags = 0); + void remove(const std::string& ns, Query query, int flags = 0); // // DBClientBase methods @@ -172,7 +172,7 @@ namespace mongo { double getSoTimeout() const; /** - * @return the exact string address passed to hostAndPort parameter of the + * @return the exact std::string address passed to hostAndPort parameter of the * constructor. In other words, doesn't automatically append a * 'default' port if none is specified. */ @@ -212,7 +212,7 @@ namespace mongo { void checkIfUp(InstanceID id) const; typedef unordered_map<std::string, boost::shared_ptr<CircularBSONIterator> > CmdToReplyObj; - typedef unordered_map<std::string, vector<BSONObj> > MockDataMgr; + typedef unordered_map<std::string, std::vector<BSONObj> > MockDataMgr; bool _isRunning; diff --git a/src/mongo/logger/labeled_level.h b/src/mongo/logger/labeled_level.h index 1ef1793584e..9a1f6d2459c 100644 --- a/src/mongo/logger/labeled_level.h +++ b/src/mongo/logger/labeled_level.h @@ -35,7 +35,7 @@ namespace mongo { namespace logger { /** - * Deprecated utility for associating a string and log level together. + * Deprecated utility for associating a std::string and log level together. */ class LabeledLevel { public: diff --git a/src/mongo/logger/log_severity.h b/src/mongo/logger/log_severity.h index f4062a27db5..388f7038d26 100644 --- a/src/mongo/logger/log_severity.h +++ b/src/mongo/logger/log_severity.h @@ -75,7 +75,7 @@ namespace logger { inline LogSeverity lessSevere() const; /** - * Returns a string naming this severity level. + * Returns a std::string naming this severity level. * * See toStringData(), below. */ diff --git a/src/mongo/logger/ramlog.h b/src/mongo/logger/ramlog.h index 56d1c233276..39aecf6b54c 100644 --- a/src/mongo/logger/ramlog.h +++ b/src/mongo/logger/ramlog.h @@ -105,11 +105,11 @@ namespace mongo { private: static int repeats(const std::vector<const char *>& v, int i); - static string clean(const std::vector<const char *>& v, int i, string line=""); - static string color(const std::string& line); + static std::string clean(const std::vector<const char *>& v, int i, std::string line=""); + static std::string color(const std::string& line); /* turn http:... into an anchor */ - static string linkify(const char *s); + static std::string linkify(const char *s); explicit RamLog( const std::string& name ); ~RamLog(); // want this private as we want to leak so we can use them till the very end @@ -125,7 +125,7 @@ namespace mongo { char lines[N][C]; unsigned h; // current position unsigned n; // number of lines stores 0 o N - string _name; + std::string _name; long long _totalLinesWritten; time_t _lastWrite; diff --git a/src/mongo/platform/process_id.h b/src/mongo/platform/process_id.h index 186a0016f85..31a85680260 100644 --- a/src/mongo/platform/process_id.h +++ b/src/mongo/platform/process_id.h @@ -94,7 +94,7 @@ namespace mongo { uint32_t asUInt32() const { return static_cast<uint32_t>(_npid); } /** - * Provides a string representation of the pid. + * Provides a std::string representation of the pid. */ std::string toString() const; diff --git a/src/mongo/s/balance.h b/src/mongo/s/balance.h index 998d4ec6263..4e97c38b4f4 100644 --- a/src/mongo/s/balance.h +++ b/src/mongo/s/balance.h @@ -56,14 +56,14 @@ namespace mongo { virtual void run(); - virtual string name() const { return "Balancer"; } + virtual std::string name() const { return "Balancer"; } private: typedef MigrateInfo CandidateChunk; typedef shared_ptr<CandidateChunk> CandidateChunkPtr; // hostname:port of my mongos - string _myid; + std::string _myid; // time the Balancer started running time_t _started; @@ -90,7 +90,7 @@ namespace mongo { * @param conn is the connection with the config server(s) * @param candidateChunks (IN/OUT) filled with candidate chunks, one per collection, that could possibly be moved */ - void _doBalanceRound( DBClientBase& conn, vector<CandidateChunkPtr>* candidateChunks ); + void _doBalanceRound( DBClientBase& conn, std::vector<CandidateChunkPtr>* candidateChunks ); /** * Issues chunk migration request, one at a time. @@ -100,7 +100,7 @@ namespace mongo { * @param waitForDelete wait for deletes to complete after each chunk move * @return number of chunks effectively moved */ - int _moveChunks(const vector<CandidateChunkPtr>* candidateChunks, + int _moveChunks(const std::vector<CandidateChunkPtr>* candidateChunks, bool secondaryThrottle, bool waitForDelete); diff --git a/src/mongo/s/balancer_policy.h b/src/mongo/s/balancer_policy.h index 0cb2e735854..1bd674aeeb6 100644 --- a/src/mongo/s/balancer_policy.h +++ b/src/mongo/s/balancer_policy.h @@ -49,19 +49,19 @@ namespace mongo { max(chunk[ChunkType::max()].Obj().getOwned()) { } - string toString() const; + std::string toString() const; }; struct TagRange { BSONObj min; BSONObj max; - string tag; + std::string tag; TagRange(){} - TagRange( const BSONObj& a_min, const BSONObj& a_max, const string& a_tag ) + TagRange( const BSONObj& a_min, const BSONObj& a_max, const std::string& a_tag ) : min( a_min.getOwned() ), max( a_max.getOwned() ), tag( a_tag ){} - string toString() const; + std::string toString() const; }; class ShardInfo { @@ -69,13 +69,13 @@ namespace mongo { ShardInfo(); ShardInfo( long long maxSize, long long currSize, bool draining, bool opsQueued, - const set<string>& tags = set<string>(), - const string& _mongoVersion = string("") ); + const std::set<std::string>& tags = std::set<std::string>(), + const std::string& _mongoVersion = std::string("") ); - void addTag( const string& tag ); + void addTag( const std::string& tag ); /** @return true if we have the tag OR if the tag is "" */ - bool hasTag( const string& tag ) const; + bool hasTag( const std::string& tag ) const; /** * @return true if a shard cannot receive any new chunks because it reaches 'shardLimits'. @@ -99,33 +99,33 @@ namespace mongo { long long getCurrSize() const { return _currSize; } - string getMongoVersion() const { return _mongoVersion; } + std::string getMongoVersion() const { return _mongoVersion; } - string toString() const; + std::string toString() const; private: long long _maxSize; long long _currSize; bool _draining; bool _hasOpsQueued; - set<string> _tags; - string _mongoVersion; + std::set<std::string> _tags; + std::string _mongoVersion; }; struct MigrateInfo { - const string ns; - const string to; - const string from; + const std::string ns; + const std::string to; + const std::string from; const ChunkInfo chunk; - MigrateInfo( const string& a_ns , const string& a_to , const string& a_from , const BSONObj& a_chunk ) + MigrateInfo( const std::string& a_ns , const std::string& a_to , const std::string& a_from , const BSONObj& a_chunk ) : ns( a_ns ) , to( a_to ) , from( a_from ), chunk( a_chunk ) {} }; - typedef map< string,ShardInfo > ShardInfoMap; - typedef map< string,vector<BSONObj> > ShardToChunksMap; + typedef std::map< std::string,ShardInfo > ShardInfoMap; + typedef std::map< std::string,std::vector<BSONObj> > ShardToChunksMap; class DistributionStatus : boost::noncopyable { public: @@ -145,13 +145,13 @@ namespace mongo { * @param forTag "" if you don't care, or a tag * @return shard best suited to receive a chunk */ - string getBestReceieverShard( const string& forTag ) const; + std::string getBestReceieverShard( const std::string& forTag ) const; /** * @return the shard with the most chunks * based on # of chunks with the given tag */ - string getMostOverloadedShard( const string& forTag ) const; + std::string getMostOverloadedShard( const std::string& forTag ) const; // ---- basic accessors, counters, etc... @@ -160,25 +160,25 @@ namespace mongo { unsigned totalChunks() const; /** @return number of chunks in this shard */ - unsigned numberOfChunksInShard( const string& shard ) const; + unsigned numberOfChunksInShard( const std::string& shard ) const; /** @return number of chunks in this shard with the given tag */ - unsigned numberOfChunksInShardWithTag( const string& shard, const string& tag ) const; + unsigned numberOfChunksInShardWithTag( const std::string& shard, const std::string& tag ) const; /** @return chunks for the shard */ - const vector<BSONObj>& getChunks( const string& shard ) const; + const std::vector<BSONObj>& getChunks( const std::string& shard ) const; /** @return all tags we know about, not include "" */ - const set<string>& tags() const { return _allTags; } + const std::set<std::string>& tags() const { return _allTags; } /** @return the right tag for chunk, possibly "" */ - string getTagForChunk( const BSONObj& chunk ) const; + std::string getTagForChunk( const BSONObj& chunk ) const; /** @return all shards we know about */ - const set<string>& shards() const { return _shards; } + const std::set<std::string>& shards() const { return _shards; } /** @return the ShardInfo for the shard */ - const ShardInfo& shardInfo( const string& shard ) const; + const ShardInfo& shardInfo( const std::string& shard ) const; /** writes all state to log() */ void dump() const; @@ -186,9 +186,9 @@ namespace mongo { private: const ShardInfoMap& _shardInfo; const ShardToChunksMap& _shardChunks; - map<BSONObj,TagRange> _tagRanges; - set<string> _allTags; - set<string> _shards; + std::map<BSONObj,TagRange> _tagRanges; + std::set<std::string> _allTags; + std::set<std::string> _shards; }; class BalancerPolicy { @@ -205,7 +205,7 @@ namespace mongo { * @returns NULL or MigrateInfo of the best move to make towards balacing the collection. * caller owns the MigrateInfo instance */ - static MigrateInfo* balance( const string& ns, + static MigrateInfo* balance( const std::string& ns, const DistributionStatus& distribution, int balancedLastTime ); diff --git a/src/mongo/s/bson_serializable.h b/src/mongo/s/bson_serializable.h index e96df009f3b..e3344884d45 100644 --- a/src/mongo/s/bson_serializable.h +++ b/src/mongo/s/bson_serializable.h @@ -61,7 +61,7 @@ namespace mongo { /** Clears the internal state. */ virtual void clear() = 0; - /** Returns a string representation of the current internal state. */ + /** Returns a std::string representation of the current internal state. */ virtual std::string toString() const = 0; }; diff --git a/src/mongo/s/chunk.h b/src/mongo/s/chunk.h index a9b1422ada6..d6600b3b5e9 100644 --- a/src/mongo/s/chunk.h +++ b/src/mongo/s/chunk.h @@ -50,8 +50,8 @@ namespace mongo { typedef shared_ptr<const Chunk> ChunkPtr; // key is max for each Chunk or ChunkRange - typedef map<BSONObj,ChunkPtr,BSONObjCmp> ChunkMap; - typedef map<BSONObj,shared_ptr<ChunkRange>,BSONObjCmp> ChunkRangeMap; + typedef std::map<BSONObj,ChunkPtr,BSONObjCmp> ChunkMap; + typedef std::map<BSONObj,shared_ptr<ChunkRange>,BSONObjCmp> ChunkRangeMap; typedef shared_ptr<const ChunkManager> ChunkManagerPtr; @@ -95,8 +95,8 @@ namespace mongo { // to a subset of fields). bool containsPoint( const BSONObj& point ) const; - string genID() const; - static string genID( const string& ns , const BSONObj& min ); + std::string genID() const; + static std::string genID( const std::string& ns , const BSONObj& min ); // // chunk version support @@ -146,7 +146,7 @@ namespace mongo { * * @throws UserException */ - Status multiSplit( const vector<BSONObj>& splitPoints ) const; + Status multiSplit( const std::vector<BSONObj>& splitPoints ) const; /** * Asks the mongod holding this chunk to find a key that approximately divides this chunk in two @@ -161,7 +161,7 @@ namespace mongo { * @param maxPoints limits the number of split points that are needed, zero is max (optional) * @param maxObjs limits the number of objects in each chunk, zero is as max (optional) */ - void pickSplitVector( vector<BSONObj>& splitPoints , int chunkSize , int maxPoints = 0, int maxObjs = 0) const; + void pickSplitVector( std::vector<BSONObj>& splitPoints , int chunkSize , int maxPoints = 0, int maxObjs = 0) const; // // migration support @@ -223,15 +223,15 @@ namespace mongo { // accessors and helpers // - string toString() const; + std::string toString() const; - friend ostream& operator << (ostream& out, const Chunk& c) { return (out << c.toString()); } + friend std::ostream& operator << (std::ostream& out, const Chunk& c) { return (out << c.toString()); } // chunk equality is determined by comparing the min and max bounds of the chunk bool operator==(const Chunk& s) const; bool operator!=(const Chunk& s) const { return ! ( *this == s ); } - string getns() const; + std::string getns() const; Shard getShard() const { return _shard; } const ChunkManager* getManager() const { return _manager; } @@ -320,7 +320,7 @@ namespace mongo { verify(min.getMax() == max.getMin()); } - friend ostream& operator<<(ostream& out, const ChunkRange& cr) { + friend std::ostream& operator<<(std::ostream& out, const ChunkRange& cr) { return (out << "ChunkRange(min=" << cr._min << ", max=" << cr._max << ", shard=" << cr._shard <<")"); } @@ -361,18 +361,18 @@ namespace mongo { */ class ChunkManager { public: - typedef map<Shard,ChunkVersion> ShardVersionMap; + typedef std::map<Shard,ChunkVersion> ShardVersionMap; // Loads a new chunk manager from a collection document ChunkManager( const BSONObj& collDoc ); // Creates an empty chunk manager for the namespace - ChunkManager( const string& ns, const ShardKeyPattern& pattern, bool unique ); + ChunkManager( const std::string& ns, const ShardKeyPattern& pattern, bool unique ); // Updates a chunk manager based on an older manager ChunkManager( ChunkManagerPtr oldManager ); - string getns() const { return _ns; } + std::string getns() const { return _ns; } const ShardKeyPattern& getShardKey() const { return _key; } @@ -391,21 +391,21 @@ namespace mongo { // // Creates new chunks based on info in chunk manager - void createFirstChunks( const string& config, + void createFirstChunks( const std::string& config, const Shard& primary, - const vector<BSONObj>* initPoints, - const vector<Shard>* initShards ); + const std::vector<BSONObj>* initPoints, + const std::vector<Shard>* initShards ); // Loads existing ranges based on info in chunk manager - void loadExistingRanges( const string& config ); + void loadExistingRanges( const std::string& config ); // Helpers for load void calcInitSplitsAndShards( const Shard& primary, - const vector<BSONObj>* initPoints, - const vector<Shard>* initShards, - vector<BSONObj>* splitPoints, - vector<Shard>* shards ) const; + const std::vector<BSONObj>* initPoints, + const std::vector<Shard>* initShards, + std::vector<BSONObj>* splitPoints, + std::vector<Shard>* shards ) const; // // Methods to use once loaded / created @@ -434,10 +434,10 @@ namespace mongo { ChunkPtr findChunkOnServer( const Shard& shard ) const; - void getShardsForQuery( set<Shard>& shards , const BSONObj& query ) const; - void getAllShards( set<Shard>& all ) const; + void getShardsForQuery( std::set<Shard>& shards , const BSONObj& query ) const; + void getAllShards( std::set<Shard>& all ) const; /** @param shards set to the shards covered by the interval [min, max], see SERVER-4791 */ - void getShardsForRange( set<Shard>& shards, const BSONObj& min, const BSONObj& max ) const; + void getShardsForRange( std::set<Shard>& shards, const BSONObj& min, const BSONObj& max ) const; // Transforms query into bounds for each field in the shard key // for example : @@ -468,7 +468,7 @@ namespace mongo { bool compatibleWith( const Chunk& other ) const; bool compatibleWith( ChunkPtr other ) const { if( ! other ) return false; return compatibleWith( *other ); } - string toString() const; + std::string toString() const; ChunkVersion getVersion( const StringData& shardName ) const; ChunkVersion getVersion( const Shard& shard ) const; @@ -488,28 +488,28 @@ namespace mongo { ChunkManagerPtr reload(bool force=true) const; // doesn't modify self! void markMinorForReload( ChunkVersion majorVersion ) const; - void getMarkedMinorVersions( set<ChunkVersion>& minorVersions ) const; + void getMarkedMinorVersions( std::set<ChunkVersion>& minorVersions ) const; private: // helpers for loading // returns true if load was consistent - bool _load( const string& config, ChunkMap& chunks, set<Shard>& shards, + bool _load( const std::string& config, ChunkMap& chunks, std::set<Shard>& shards, ShardVersionMap& shardVersions, ChunkManagerPtr oldManager); static bool _isValid(const ChunkMap& chunks); // end helpers // All members should be const for thread-safety - const string _ns; + const std::string _ns; const ShardKeyPattern _key; const bool _unique; const ChunkMap _chunkMap; const ChunkRangeManager _chunkRanges; - const set<Shard> _shards; + const std::set<Shard> _shards; const ShardVersionMap _shardVersions; // max version per shard @@ -537,8 +537,8 @@ namespace mongo { _staleMinorSetMutex( "SplitHeuristics::staleMinorSet" ), _staleMinorCount( 0 ) {} - void markMinorForReload( const string& ns, ChunkVersion majorVersion ); - void getMarkedMinorVersions( set<ChunkVersion>& minorVersions ); + void markMinorForReload( const std::string& ns, ChunkVersion majorVersion ); + void getMarkedMinorVersions( std::set<ChunkVersion>& minorVersions ); TicketHolder _splitTickets; @@ -546,7 +546,7 @@ namespace mongo { // mutex protects below int _staleMinorCount; - set<ChunkVersion> _staleMinorSet; + std::set<ChunkVersion> _staleMinorSet; // Test whether we should split once data * splitTestFactor > chunkSize (approximately) static const int splitTestFactor = 5; @@ -610,10 +610,10 @@ namespace mongo { Chunk _c; }; */ - inline string Chunk::genID() const { return genID(_manager->getns(), _min); } + inline std::string Chunk::genID() const { return genID(_manager->getns(), _min); } bool setShardVersion( DBClientBase & conn, - const string& ns, + const std::string& ns, ChunkVersion version, ChunkManagerPtr manager, bool authoritative, diff --git a/src/mongo/s/chunk_diff.h b/src/mongo/s/chunk_diff.h index 1ce4cc41c21..70588694617 100644 --- a/src/mongo/s/chunk_diff.h +++ b/src/mongo/s/chunk_diff.h @@ -75,10 +75,10 @@ namespace mongo { * * TODO: Make a standard VersionedRange to encapsulate this info in both mongod and mongos? */ - void attach( const string& ns, + void attach( const std::string& ns, RangeMap& currMap, ChunkVersion& maxVersion, - map<ShardType, ChunkVersion>& maxShardVersions ) + std::map<ShardType, ChunkVersion>& maxShardVersions ) { _ns = ns; _currMap = &currMap; @@ -123,8 +123,8 @@ namespace mongo { virtual BSONObj minFrom( const ValType& max ) const { verify( false ); return BSONObj(); } virtual std::pair<BSONObj,ValType> rangeFor( const BSONObj& chunkDoc, const BSONObj& min, const BSONObj& max ) const = 0; - virtual ShardType shardFor( const string& name ) const = 0; - virtual string nameFrom( const ShardType& shard ) const = 0; + virtual ShardType shardFor( const std::string& name ) const = 0; + virtual std::string nameFrom( const ShardType& shard ) const = 0; /// /// End adapter functions @@ -146,8 +146,8 @@ namespace mongo { // specified. // Returns the number of diffs processed, or -1 if the diffs were inconsistent // Throws a DBException on connection errors - int calculateConfigDiff( string config, - const set<ChunkVersion>& extraMinorVersions = set<ChunkVersion>() ); + int calculateConfigDiff( std::string config, + const std::set<ChunkVersion>& extraMinorVersions = std::set<ChunkVersion>() ); // Applies changes to the config data from a cursor passed in // Returns the number of diffs processed, or -1 if the diffs were inconsistent @@ -156,14 +156,14 @@ namespace mongo { // Returns the query needed to find new changes to a collection from the config server // Needed only if a custom connection is required to the config server - Query configDiffQuery( const set<ChunkVersion>& extraMinorVersions = set<ChunkVersion>() ) const; + Query configDiffQuery( const std::set<ChunkVersion>& extraMinorVersions = std::set<ChunkVersion>() ) const; private: - string _ns; + std::string _ns; RangeMap* _currMap; ChunkVersion* _maxVersion; - map<ShardType, ChunkVersion>* _maxShardVersions; + std::map<ShardType, ChunkVersion>* _maxShardVersions; // Store for later use int _validDiffs; diff --git a/src/mongo/s/chunk_version.h b/src/mongo/s/chunk_version.h index b8955906780..e5b27ec53fb 100644 --- a/src/mongo/s/chunk_version.h +++ b/src/mongo/s/chunk_version.h @@ -138,8 +138,8 @@ namespace mongo { return _epoch.isSet(); } - string toString() const { - stringstream ss; + std::string toString() const { + std::stringstream ss; // Similar to month/day/year. For the most part when debugging, we care about major // so it's first ss << _major << "|" << _minor << "||" << _epoch; @@ -237,19 +237,19 @@ namespace mongo { // { version : <TS> } and { version : [<TS>,<OID>] } format // - static bool canParseBSON( const BSONElement& el, const string& prefix="" ){ + static bool canParseBSON( const BSONElement& el, const std::string& prefix="" ){ bool canParse; fromBSON( el, prefix, &canParse ); return canParse; } - static ChunkVersion fromBSON( const BSONElement& el, const string& prefix="" ){ + static ChunkVersion fromBSON( const BSONElement& el, const std::string& prefix="" ){ bool canParse; return fromBSON( el, prefix, &canParse ); } static ChunkVersion fromBSON( const BSONElement& el, - const string& prefix, + const std::string& prefix, bool* canParse ) { *canParse = true; @@ -281,33 +281,33 @@ namespace mongo { // { version : <TS>, versionEpoch : <OID> } object format // - static bool canParseBSON( const BSONObj& obj, const string& prefix="" ){ + static bool canParseBSON( const BSONObj& obj, const std::string& prefix="" ){ bool canParse; fromBSON( obj, prefix, &canParse ); return canParse; } - static ChunkVersion fromBSON( const BSONObj& obj, const string& prefix="" ){ + static ChunkVersion fromBSON( const BSONObj& obj, const std::string& prefix="" ){ bool canParse; return fromBSON( obj, prefix, &canParse ); } static ChunkVersion fromBSON( const BSONObj& obj, - const string& prefixIn, + const std::string& prefixIn, bool* canParse ) { *canParse = true; - string prefix = prefixIn; + std::string prefix = prefixIn; // "version" doesn't have a "cluster constanst" because that field is never // written to the config. if( prefixIn == "" && ! obj[ "version" ].eoo() ){ - prefix = (string)"version"; + prefix = (std::string)"version"; } // TODO: use ChunkType::DEPRECATED_lastmod() // NOTE: type_chunk.h includes this file else if( prefixIn == "" && ! obj["lastmod"].eoo() ){ - prefix = (string)"lastmod"; + prefix = (std::string)"lastmod"; } ChunkVersion version = fromBSON( obj[ prefix ], prefixIn, canParse ); @@ -413,10 +413,10 @@ namespace mongo { // versions that know nothing about epochs. // - BSONObj toBSONWithPrefix( const string& prefixIn ) const { + BSONObj toBSONWithPrefix( const std::string& prefixIn ) const { BSONObjBuilder b; - string prefix = prefixIn; + std::string prefix = prefixIn; if( prefix == "" ) prefix = "version"; b.appendTimestamp( prefix, _combined ); @@ -424,11 +424,11 @@ namespace mongo { return b.obj(); } - void addToBSON( BSONObjBuilder& b, const string& prefix="" ) const { + void addToBSON( BSONObjBuilder& b, const std::string& prefix="" ) const { b.appendElements( toBSONWithPrefix( prefix ) ); } - void addEpochToBSON( BSONObjBuilder& b, const string& prefix="" ) const { + void addEpochToBSON( BSONObjBuilder& b, const std::string& prefix="" ) const { b.append( prefix + "Epoch", _epoch ); } @@ -482,7 +482,7 @@ namespace mongo { }; - inline ostream& operator<<( ostream &s , const ChunkVersion& v) { + inline std::ostream& operator<<( std::ostream &s , const ChunkVersion& v) { s << v.toString(); return s; } diff --git a/src/mongo/s/client_info.h b/src/mongo/s/client_info.h index 12ff9dec848..a6fddbc8903 100644 --- a/src/mongo/s/client_info.h +++ b/src/mongo/s/client_info.h @@ -76,7 +76,7 @@ namespace mongo { * notes that this client use this shard * keeps track of all shards accessed this request */ - void addShardHost( const string& shardHost ); + void addShardHost( const std::string& shardHost ); /** * Notes that this client wrote to these particular hosts with write commands. @@ -87,7 +87,7 @@ namespace mongo { /** * gets shards used on the previous request */ - set<string>* getPrevShardHosts() const { return &_prev->shardHostsWritten; } + std::set<std::string>* getPrevShardHosts() const { return &_prev->shardHostsWritten; } /** * Gets the shards, hosts, and opTimes the client last wrote to with write commands. @@ -99,7 +99,7 @@ namespace mongo { /** * gets all shards we've accessed since the last time we called clearSinceLastGetError */ - const set<string>& sinceLastGetError() const { return _sinceLastGetError; } + const std::set<std::string>& sinceLastGetError() const { return _sinceLastGetError; } /** * clears list of shards we've talked to @@ -140,7 +140,7 @@ namespace mongo { hostOpTimes.clear(); } - std::set<string> shardHostsWritten; + std::set<std::string> shardHostsWritten; HostOpTimeMap hostOpTimes; }; @@ -154,7 +154,7 @@ namespace mongo { RequestInfo* _prev; // "" - std::set<string> _sinceLastGetError; // all shards accessed since last getLastError + std::set<std::string> _sinceLastGetError; // all shards accessed since last getLastError int _lastAccess; bool _autoSplitOk; @@ -167,7 +167,7 @@ namespace mongo { * This data will be used by subsequent GLE calls, to ensure we look for the correct * write on the correct PRIMARY. * result: the result from calling runCommand - * conn: the string name of the hostAndPort where the command ran. This can be a replica set + * conn: the std::string name of the hostAndPort where the command ran. This can be a replica set * seed list. */ void saveGLEStats(const BSONObj& result, const std::string& conn); diff --git a/src/mongo/s/cluster_client_internal.h b/src/mongo/s/cluster_client_internal.h index e5bb6c1731a..5bf4658cd19 100644 --- a/src/mongo/s/cluster_client_internal.h +++ b/src/mongo/s/cluster_client_internal.h @@ -55,7 +55,7 @@ namespace mongo { * compatible, and an error Status if anything else goes wrong. */ Status checkClusterMongoVersions(const ConnectionString& configLoc, - const string& minMongoVersion); + const std::string& minMongoVersion); /** * Returns all collections in the cluster, found at this moment. @@ -63,7 +63,7 @@ namespace mongo { * Returns OK if loaded successfully, error Status if not. */ Status findAllCollections(const ConnectionString& configLoc, - OwnedPointerMap<string, CollectionType>* collections); + OwnedPointerMap<std::string, CollectionType>* collections); /** * Returns all collections in the cluster, but does not throw an error if epochs are not @@ -72,7 +72,7 @@ namespace mongo { * Returns OK if loaded successfully, error Status if not. */ Status findAllCollectionsV3(const ConnectionString& configLoc, - OwnedPointerMap<string, CollectionType>* collections); + OwnedPointerMap<std::string, CollectionType>* collections); /** * Returns all chunks for a collection in the cluster. @@ -80,7 +80,7 @@ namespace mongo { * Returns OK if loaded successfully, error Status if not. */ Status findAllChunks(const ConnectionString& configLoc, - const string& ns, + const std::string& ns, OwnedPointerVector<ChunkType>* chunks); /** @@ -89,9 +89,9 @@ namespace mongo { * Returns OK if loaded successfully, error Status if not. */ Status logConfigChange(const ConnectionString& configLoc, - const string& clientHost, - const string& ns, - const string& description, + const std::string& clientHost, + const std::string& ns, + const std::string& description, const BSONObj& details); // @@ -103,6 +103,6 @@ namespace mongo { void _checkGLE(ScopedDbConnection& conn); // Helper function which throws for invalid cursor initialization - DBClientCursor* _safeCursor(auto_ptr<DBClientCursor> cursor); + DBClientCursor* _safeCursor(std::auto_ptr<DBClientCursor> cursor); } diff --git a/src/mongo/s/collection_metadata.h b/src/mongo/s/collection_metadata.h index 9916e41c185..a4a0094a577 100644 --- a/src/mongo/s/collection_metadata.h +++ b/src/mongo/s/collection_metadata.h @@ -75,7 +75,7 @@ namespace mongo { * If a new metadata can't be created, returns NULL and fills in 'errMsg', if it was * provided. */ - CollectionMetadata* cloneMinusPending( const ChunkType& pending, string* errMsg ) const; + CollectionMetadata* cloneMinusPending( const ChunkType& pending, std::string* errMsg ) const; /** * Returns a new metadata's instance based on 'this's state by adding a 'pending' chunk. @@ -86,7 +86,7 @@ namespace mongo { * If a new metadata can't be created, returns NULL and fills in 'errMsg', if it was * provided. */ - CollectionMetadata* clonePlusPending( const ChunkType& pending, string* errMsg ) const; + CollectionMetadata* clonePlusPending( const ChunkType& pending, std::string* errMsg ) const; /** * Returns a new metadata's instance based on 'this's state by removing 'chunk'. @@ -98,7 +98,7 @@ namespace mongo { */ CollectionMetadata* cloneMigrate( const ChunkType& chunk, const ChunkVersion& newShardVersion, - string* errMsg ) const; + std::string* errMsg ) const; /** * Returns a new metadata's instance by splitting an existing 'chunk' at the points @@ -112,9 +112,9 @@ namespace mongo { * Note: 'splitKeys' must be sorted in ascending order. */ CollectionMetadata* cloneSplit( const ChunkType& chunk, - const vector<BSONObj>& splitKeys, + const std::vector<BSONObj>& splitKeys, const ChunkVersion& newShardVersion, - string* errMsg ) const; + std::string* errMsg ) const; /** * Returns a new metadata instance by merging a key range which starts and ends at existing @@ -127,7 +127,7 @@ namespace mongo { CollectionMetadata* cloneMerge( const BSONObj& minKey, const BSONObj& maxKey, const ChunkVersion& newShardVersion, - string* errMsg ) const; + std::string* errMsg ) const; // // verification logic @@ -234,9 +234,9 @@ namespace mongo { void toBSONPending( BSONArrayBuilder& bb ) const; /** - * String output of the metadata information. + * std::string output of the metadata information. */ - string toString() const; + std::string toString() const; /** * Use the MetadataLoader to fill the empty metadata from the config server, or use @@ -258,7 +258,7 @@ namespace mongo { */ CollectionMetadata* clonePlusChunk( const ChunkType& chunk, const ChunkVersion& newShardVersion, - string* errMsg ) const; + std::string* errMsg ) const; private: // Effectively, the MetadataLoader is this class's builder. So we open an exception diff --git a/src/mongo/s/config.h b/src/mongo/s/config.h index 1f62dcb3ba1..06412248118 100644 --- a/src/mongo/s/config.h +++ b/src/mongo/s/config.h @@ -83,7 +83,7 @@ namespace mongo { bool isDirty() const { return _dirty; } bool wasDropped() const { return _dropped; } - void save( const string& ns ); + void save( const std::string& ns ); bool unique() const { return _unqiue; } BSONObj key() const { return _key; } @@ -97,11 +97,11 @@ namespace mongo { bool _dropped; }; - typedef map<string,CollectionInfo> Collections; + typedef std::map<std::string,CollectionInfo> Collections; public: - DBConfig( string name ) + DBConfig( std::string name ) : _name( name ) , _primary("config","") , _shardingEnabled(false), @@ -111,7 +111,7 @@ namespace mongo { } virtual ~DBConfig() {} - string getName() const { return _name; }; + std::string getName() const { return _name; }; /** * @return if anything in this db is partitioned or not @@ -130,38 +130,38 @@ namespace mongo { * WARNING: It's not safe to place initial chunks onto non-primary shards using this method. * The initShards parameter allows legacy behavior expected by map-reduce. */ - ChunkManagerPtr shardCollection( const string& ns , + ChunkManagerPtr shardCollection( const std::string& ns , ShardKeyPattern fieldsAndOrder , bool unique , - vector<BSONObj>* initPoints = 0, - vector<Shard>* initShards = 0 ); + std::vector<BSONObj>* initPoints = 0, + std::vector<Shard>* initShards = 0 ); /** @return true if there was sharding info to remove */ - bool removeSharding( const string& ns ); + bool removeSharding( const std::string& ns ); /** * @return whether or not the 'ns' collection is partitioned */ - bool isSharded( const string& ns ); + bool isSharded( const std::string& ns ); // Atomically returns *either* the chunk manager *or* the primary shard for the collection, // neither if the collection doesn't exist. - void getChunkManagerOrPrimary( const string& ns, ChunkManagerPtr& manager, ShardPtr& primary ); + void getChunkManagerOrPrimary( const std::string& ns, ChunkManagerPtr& manager, ShardPtr& primary ); - ChunkManagerPtr getChunkManager( const string& ns , bool reload = false, bool forceReload = false ); - ChunkManagerPtr getChunkManagerIfExists( const string& ns , bool reload = false, bool forceReload = false ); + ChunkManagerPtr getChunkManager( const std::string& ns , bool reload = false, bool forceReload = false ); + ChunkManagerPtr getChunkManagerIfExists( const std::string& ns , bool reload = false, bool forceReload = false ); - const Shard& getShard( const string& ns ); + const Shard& getShard( const std::string& ns ); /** * @return the correct for shard for the ns * if the namespace is sharded, will return NULL */ - ShardPtr getShardIfExists( const string& ns ); + ShardPtr getShardIfExists( const std::string& ns ); const Shard& getPrimary() const { - uassert( 8041 , (string)"no primary shard configured for db: " + _name , _primary.ok() ); + uassert( 8041 , (std::string)"no primary shard configured for db: " + _name , _primary.ok() ); return _primary; } @@ -170,7 +170,7 @@ namespace mongo { bool load(); bool reload(); - bool dropDatabase( string& errmsg ); + bool dropDatabase( std::string& errmsg ); // model stuff @@ -179,29 +179,29 @@ namespace mongo { void unserialize(const BSONObj& from); - void getAllShards(set<Shard>& shards) const; + void getAllShards(std::set<Shard>& shards) const; - void getAllShardedCollections(set<string>& namespaces) const; + void getAllShardedCollections(std::set<std::string>& namespaces) const; protected: /** lockless */ - bool _isSharded( const string& ns ); + bool _isSharded( const std::string& ns ); - bool _dropShardedCollections( int& num, set<Shard>& allServers , string& errmsg ); + bool _dropShardedCollections( int& num, std::set<Shard>& allServers , std::string& errmsg ); bool _load(); bool _reload(); void _save( bool db = true, bool coll = true ); - string _name; // e.g. "alleyinsider" + std::string _name; // e.g. "alleyinsider" Shard _primary; // e.g. localhost , mongo.foo.com:9999 bool _shardingEnabled; - //map<string,CollectionInfo> _sharded; // { "alleyinsider.blog.posts" : { ts : 1 } , ... ] - all ns that are sharded - //map<string,ChunkManagerPtr> _shards; // this will only have entries for things that have been looked at + //map<std::string,CollectionInfo> _sharded; // { "alleyinsider.blog.posts" : { ts : 1 } , ... ] - all ns that are sharded + //map<std::string,ChunkManagerPtr> _shards; // this will only have entries for things that have been looked at Collections _collections; @@ -217,7 +217,7 @@ namespace mongo { bool ok( bool checkConsistency = false ); - virtual string modelServer() { + virtual std::string modelServer() { uassert( 10190 , "ConfigServer not setup" , _primary.ok() ); return _primary.getConnString(); } @@ -225,7 +225,7 @@ namespace mongo { /** call at startup, this will initiate connection to the grid db */ - bool init( vector<string> configHosts ); + bool init( std::vector<std::string> configHosts ); bool init( const std::string& s ); @@ -234,10 +234,10 @@ namespace mongo { * hostname:port entries are unique. Otherwise return false * and fill errmsg with message containing the offending server. */ - bool checkHostsAreUnique( const vector<string>& configHosts, string* errmsg ); + bool checkHostsAreUnique( const std::vector<std::string>& configHosts, std::string* errmsg ); bool allUp(); - bool allUp( string& errmsg ); + bool allUp( std::string& errmsg ); int dbConfigVersion(); int dbConfigVersion( DBClientBase& conn ); @@ -253,13 +253,13 @@ namespace mongo { * * This call is guaranteed never to throw. */ - void logChange( const string& what , const string& ns , const BSONObj& detail = BSONObj() ); + void logChange( const std::string& what , const std::string& ns , const BSONObj& detail = BSONObj() ); ConnectionString getConnectionString() const { return ConnectionString( _primary.getConnString() , ConnectionString::SYNC ); } - void replicaSetChange(const string& setName, const string& newConnectionString); + void replicaSetChange(const std::string& setName, const std::string& newConnectionString); static int VERSION; @@ -268,11 +268,11 @@ namespace mongo { * check to see if all config servers have the same state * will try tries time to make sure not catching in a bad state */ - bool checkConfigServersConsistent( string& errmsg , int tries = 4 ) const; + bool checkConfigServersConsistent( std::string& errmsg , int tries = 4 ) const; private: - string getHost( const std::string& name , bool withPort ); - vector<string> _config; + std::string getHost( const std::string& name , bool withPort ); + std::vector<std::string> _config; }; } // namespace mongo diff --git a/src/mongo/s/config_upgrade.h b/src/mongo/s/config_upgrade.h index c32f3b3945d..c5767e00c0c 100644 --- a/src/mongo/s/config_upgrade.h +++ b/src/mongo/s/config_upgrade.h @@ -126,11 +126,11 @@ namespace mongo { bool doUpgradeV0ToV5(const ConnectionString& configLoc, const VersionType& lastVersionInfo, - string* errMsg); + std::string* errMsg); bool doUpgradeV4ToV5(const ConnectionString& configLoc, const VersionType& lastVersionInfo, - string* errMsg); + std::string* errMsg); // // Utilities for upgrading a config database to a new config version and checking the status of @@ -156,7 +156,7 @@ namespace mongo { * * @return a VersionStatus enum indicating compatibility */ - VersionStatus isConfigVersionCompatible(const VersionType& versionInfo, string* whyNot); + VersionStatus isConfigVersionCompatible(const VersionType& versionInfo, std::string* whyNot); /** * Returns the config version of the cluster pointed at by the connection string. @@ -176,6 +176,6 @@ namespace mongo { bool upgrade, VersionType* initialVersionInfo, VersionType* finalVersionInfo, - string* errMsg); + std::string* errMsg); } // end namespace diff --git a/src/mongo/s/config_upgrade_helpers.h b/src/mongo/s/config_upgrade_helpers.h index 02100d4ea23..93276651f6f 100644 --- a/src/mongo/s/config_upgrade_helpers.h +++ b/src/mongo/s/config_upgrade_helpers.h @@ -74,12 +74,12 @@ namespace mongo { /** * Creates a suffix for an upgrade's working collection */ - string genWorkingSuffix(const OID& lastUpgradeId); + std::string genWorkingSuffix(const OID& lastUpgradeId); /** * Creates a suffix for an upgrade's backup collection */ - string genBackupSuffix(const OID& lastUpgradeId); + std::string genBackupSuffix(const OID& lastUpgradeId); /** * Checks whether an unsuccessful upgrade was performed last time and also checks whether diff --git a/src/mongo/s/cursors.h b/src/mongo/s/cursors.h index 73503bced7b..292434a0dbc 100644 --- a/src/mongo/s/cursors.h +++ b/src/mongo/s/cursors.h @@ -106,9 +106,9 @@ namespace mongo { static long long TIMEOUT; - typedef map<long long,ShardedClientCursorPtr> MapSharded; - typedef map<long long,int> MapShardedInt; - typedef map<long long,string> MapNormal; + typedef std::map<long long,ShardedClientCursorPtr> MapSharded; + typedef std::map<long long,int> MapShardedInt; + typedef std::map<long long,std::string> MapNormal; CursorCache(); ~CursorCache(); @@ -123,7 +123,7 @@ namespace mongo { void removeRef( long long id ); /** @return the server for id or "" */ - string getRef( long long id ) const ; + std::string getRef( long long id ) const ; /** @return the ns for id or "" */ std::string getRefNS(long long id) const ; diff --git a/src/mongo/s/d_logic.h b/src/mongo/s/d_logic.h index ca4a77636bc..668969517da 100644 --- a/src/mongo/s/d_logic.h +++ b/src/mongo/s/d_logic.h @@ -52,32 +52,32 @@ namespace mongo { ShardingState(); bool enabled() const { return _enabled; } - const string& getConfigServer() const { return _configServer; } - void enable( const string& server ); + const std::string& getConfigServer() const { return _configServer; } + void enable( const std::string& server ); // Initialize sharding state and begin authenticating outgoing connections and handling // shard versions. If this is not run before sharded operations occur auth will not work // and versions will not be tracked. - static void initialize(const string& server); + static void initialize(const std::string& server); - void gotShardName( const string& name ); - bool setShardName( const string& name ); // Same as above, does not throw - string getShardName() { scoped_lock lk(_mutex); return _shardName; } + void gotShardName( const std::string& name ); + bool setShardName( const std::string& name ); // Same as above, does not throw + std::string getShardName() { scoped_lock lk(_mutex); return _shardName; } // Helpers for SetShardVersion which report the host name sent to this shard when the shard // name does not match. Do not use in other places. // TODO: Remove once SSV is deprecated - void gotShardNameAndHost( const string& name, const string& host ); - bool setShardNameAndHost( const string& name, const string& host ); + void gotShardNameAndHost( const std::string& name, const std::string& host ); + bool setShardNameAndHost( const std::string& name, const std::string& host ); /** Reverts back to a state where this mongod is not sharded. */ void resetShardingState(); // versioning support - bool hasVersion( const string& ns ); - bool hasVersion( const string& ns , ChunkVersion& version ); - const ChunkVersion getVersion( const string& ns ) const; + bool hasVersion( const std::string& ns ); + bool hasVersion( const std::string& ns , ChunkVersion& version ); + const ChunkVersion getVersion( const std::string& ns ) const; /** * If the metadata for 'ns' at this shard is at or above the requested version, @@ -97,7 +97,7 @@ namespace mongo { * and deadlocks may occur with shard-as-a-config. Therefore, nothing here guarantees * that 'latestShardVersion' is indeed the current one on return. */ - Status refreshMetadataIfNeeded( const string& ns, + Status refreshMetadataIfNeeded( const std::string& ns, const ChunkVersion& reqShardVersion, ChunkVersion* latestShardVersion ); @@ -123,14 +123,14 @@ namespace mongo { * @return !OK if something else went wrong during reload * @return latestShardVersion the version that is now stored for this collection */ - Status refreshMetadataNow( const string& ns, ChunkVersion* latestShardVersion ); + Status refreshMetadataNow( const std::string& ns, ChunkVersion* latestShardVersion ); void appendInfo( BSONObjBuilder& b ); // querying support - bool needCollectionMetadata( const string& ns ) const; - CollectionMetadataPtr getCollectionMetadata( const string& ns ); + bool needCollectionMetadata( const std::string& ns ) const; + CollectionMetadataPtr getCollectionMetadata( const std::string& ns ); // chunk migrate and split support @@ -151,7 +151,7 @@ namespace mongo { * @param min max the chunk to eliminate from the current metadata * @param version at which the new metadata should be at */ - void donateChunk( const string& ns , const BSONObj& min , const BSONObj& max , ChunkVersion version ); + void donateChunk( const std::string& ns , const BSONObj& min , const BSONObj& max , ChunkVersion version ); /** * Creates and installs new chunk metadata for a given collection by reclaiming a previously @@ -167,7 +167,7 @@ namespace mongo { * @param ns the collection * @param prevMetadata the previous metadata before we donated a chunk */ - void undoDonateChunk( const string& ns, CollectionMetadataPtr prevMetadata ); + void undoDonateChunk( const std::string& ns, CollectionMetadataPtr prevMetadata ); /** * Remembers a chunk range between 'min' and 'max' as a range which will have data migrated @@ -178,11 +178,11 @@ namespace mongo { * * @return false with errMsg if the range is owned by this shard */ - bool notePending( const string& ns, + bool notePending( const std::string& ns, const BSONObj& min, const BSONObj& max, const OID& epoch, - string* errMsg ); + std::string* errMsg ); /** * Stops tracking a chunk range between 'min' and 'max' that previously was having data @@ -196,11 +196,11 @@ namespace mongo { * @return false with errMsg if the range is owned by the shard or the epoch of the metadata * has changed */ - bool forgetPending( const string& ns, + bool forgetPending( const std::string& ns, const BSONObj& min, const BSONObj& max, const OID& epoch, - string* errMsg ); + std::string* errMsg ); /** * Creates and installs a new chunk metadata for a given collection by splitting one of its @@ -215,7 +215,7 @@ namespace mongo { * @param splitKeys point in which to split * @param version at which the new metadata should be at */ - void splitChunk( const string& ns , const BSONObj& min , const BSONObj& max , const vector<BSONObj>& splitKeys , + void splitChunk( const std::string& ns , const BSONObj& min , const BSONObj& max , const std::vector<BSONObj>& splitKeys , ChunkVersion version ); /** @@ -231,7 +231,7 @@ namespace mongo { * @param minKey maxKey the range which should be merged * @param newShardVersion the shard version the newly merged chunk should have */ - void mergeChunks( const string& ns, + void mergeChunks( const std::string& ns, const BSONObj& minKey, const BSONObj& maxKey, ChunkVersion mergedVersion ); @@ -247,7 +247,7 @@ namespace mongo { * TESTING ONLY * Uninstalls the metadata for a given collection. */ - void resetMetadata( const string& ns ); + void resetMetadata( const std::string& ns ); private: @@ -255,16 +255,16 @@ namespace mongo { * Refreshes collection metadata by asking the config server for the latest information. * May or may not be based on a requested version. */ - Status doRefreshMetadata( const string& ns, + Status doRefreshMetadata( const std::string& ns, const ChunkVersion& reqShardVersion, bool useRequestedVersion, ChunkVersion* latestShardVersion ); bool _enabled; - string _configServer; + std::string _configServer; - string _shardName; + std::string _shardName; // protects state below mutable mongo::mutex _mutex; @@ -273,7 +273,7 @@ namespace mongo { mutable TicketHolder _configServerTickets; // Map from a namespace into the metadata we need for each collection on this shard - typedef map<string,CollectionMetadataPtr> CollectionMetadataMap; + typedef std::map<std::string,CollectionMetadataPtr> CollectionMetadataMap; CollectionMetadataMap _collMetadata; }; @@ -291,8 +291,8 @@ namespace mongo { bool hasID() const { return _id.isSet(); } void setID( const OID& id ); - const ChunkVersion getVersion( const string& ns ) const; - void setVersion( const string& ns , const ChunkVersion& version ); + const ChunkVersion getVersion( const std::string& ns ) const; + void setVersion( const std::string& ns , const ChunkVersion& version ); static ShardedConnectionInfo* get( bool create ); static void reset(); @@ -310,7 +310,7 @@ namespace mongo { OID _id; bool _forceVersionOk; // if this is true, then chunk version #s aren't check, and all ops are allowed - typedef map<string,ChunkVersion> NSVersionMap; + typedef std::map<std::string,ChunkVersion> NSVersionMap; NSVersionMap _versions; static boost::thread_specific_ptr<ShardedConnectionInfo> _tl; @@ -334,20 +334,20 @@ namespace mongo { // --- core --- // ----------------- - unsigned long long extractVersion( BSONElement e , string& errmsg ); + unsigned long long extractVersion( BSONElement e , std::string& errmsg ); /** * @return true if we have any shard info for the ns */ - bool haveLocalShardingInfo( const string& ns ); + bool haveLocalShardingInfo( const std::string& ns ); /** * @return true if the current threads shard version is ok, or not in sharded version * Also returns an error message and the Config/ChunkVersions causing conflicts */ - bool shardVersionOk( const string& ns, - string& errmsg, + bool shardVersionOk( const std::string& ns, + std::string& errmsg, ChunkVersion& received, ChunkVersion& wanted ); diff --git a/src/mongo/s/d_writeback.h b/src/mongo/s/d_writeback.h index 86f5fefb6a2..6090d8ce3a4 100644 --- a/src/mongo/s/d_writeback.h +++ b/src/mongo/s/d_writeback.h @@ -58,7 +58,7 @@ namespace mongo { // a map from mongos's serverIDs to queues of "rejected" operations // an operation is rejected if it targets data that does not live on this shard anymore - typedef map<string,shared_ptr<QueueInfo> > WriteBackQueuesMap; + typedef std::map<std::string,shared_ptr<QueueInfo> > WriteBackQueuesMap; public: @@ -74,7 +74,7 @@ namespace mongo { * * @return the writebackId generated */ - OID queueWriteBack( const string& remote , BSONObjBuilder& opBuilder ); + OID queueWriteBack( const std::string& remote , BSONObjBuilder& opBuilder ); /* * @param remote server ID @@ -82,7 +82,7 @@ namespace mongo { * * Gets access to server 'remote's queue, which is synchronized. */ - shared_ptr<QueueInfo> getWritebackQueue( const string& remote ); + shared_ptr<QueueInfo> getWritebackQueue( const std::string& remote ); /* * @return true if there is no operation queued for write back @@ -108,7 +108,7 @@ namespace mongo { class Cleaner : public PeriodicTask { public: - virtual string taskName() const { return "WriteBackManager::cleaner"; } + virtual std::string taskName() const { return "WriteBackManager::cleaner"; } virtual void taskDoWork(); }; diff --git a/src/mongo/s/dbclient_multi_command.h b/src/mongo/s/dbclient_multi_command.h index 56d8f8adabf..abcc3eeebb4 100644 --- a/src/mongo/s/dbclient_multi_command.h +++ b/src/mongo/s/dbclient_multi_command.h @@ -71,7 +71,7 @@ namespace mongo { // What to send const ConnectionString endpoint; - const string dbName; + const std::string dbName; const BSONObj cmdObj; // Where to send it diff --git a/src/mongo/s/dbclient_shard_resolver.h b/src/mongo/s/dbclient_shard_resolver.h index c46fe90d509..960d038c9c7 100644 --- a/src/mongo/s/dbclient_shard_resolver.h +++ b/src/mongo/s/dbclient_shard_resolver.h @@ -60,7 +60,7 @@ namespace mongo { Status chooseWriteHost( const std::string& shardName, ConnectionString* shardHost ) const; /** - * Resolves a replica set connection string to a master, if possible. + * Resolves a replica set connection std::string to a master, if possible. * Returns HostNotFound if the master is not reachable * Returns ReplicaSetNotFound if the replica set is not being tracked */ diff --git a/src/mongo/s/distlock.h b/src/mongo/s/distlock.h index 84f46776f11..fc7fb27c16b 100644 --- a/src/mongo/s/distlock.h +++ b/src/mongo/s/distlock.h @@ -54,9 +54,9 @@ namespace mongo { */ class MONGO_CLIENT_API LockException : public DBException { public: - LockException( const char * msg , int code ) : DBException( msg, code ) {} - LockException( const string& msg, int code ) : DBException( msg, code ) {} - virtual ~LockException() throw() { } + LockException( const char * msg , int code ) : DBException( msg, code ) {} + LockException( const std::string& msg, int code ) : DBException( msg, code ) {} + virtual ~LockException() throw() { } }; /** @@ -65,7 +65,7 @@ namespace mongo { class MONGO_CLIENT_API TimeNotFoundException : public LockException { public: TimeNotFoundException( const char * msg , int code ) : LockException( msg, code ) {} - TimeNotFoundException( const string& msg, int code ) : LockException( msg, code ) {} + TimeNotFoundException( const std::string& msg, int code ) : LockException( msg, code ) {} virtual ~TimeNotFoundException() throw() { } }; @@ -104,7 +104,7 @@ namespace mongo { struct PingData { - PingData( const string& _id , Date_t _lastPing , Date_t _remote , OID _ts ) + PingData( const std::string& _id , Date_t _lastPing , Date_t _remote , OID _ts ) : id(_id), lastPing(_lastPing), remote(_remote), ts(_ts){ } @@ -112,23 +112,23 @@ namespace mongo { : id(""), lastPing(0), remote(0), ts(){ } - string id; + std::string id; Date_t lastPing; Date_t remote; OID ts; }; - class LastPings { - public: - LastPings() : _mutex( "DistributedLock::LastPings" ) {} - ~LastPings(){} + class LastPings { + public: + LastPings() : _mutex( "DistributedLock::LastPings" ) {} + ~LastPings(){} - PingData getLastPing( const ConnectionString& conn, const string& lockName ); - void setLastPing( const ConnectionString& conn, const string& lockName, const PingData& pd ); + PingData getLastPing( const ConnectionString& conn, const std::string& lockName ); + void setLastPing( const ConnectionString& conn, const std::string& lockName, const PingData& pd ); - mongo::mutex _mutex; - map< std::pair<string, string>, PingData > _lastPings; - }; + mongo::mutex _mutex; + std::map< std::pair<std::string, std::string>, PingData > _lastPings; + }; static LastPings lastPings; @@ -143,7 +143,7 @@ namespace mongo { * @param legacy use legacy logic * */ - DistributedLock( const ConnectionString& conn , const string& name , unsigned long long lockTimeout = 0, bool asProcess = false ); + DistributedLock( const ConnectionString& conn , const std::string& name , unsigned long long lockTimeout = 0, bool asProcess = false ); ~DistributedLock(){}; /** @@ -156,7 +156,7 @@ namespace mongo { * details if not * @return true if it managed to grab the lock */ - bool lock_try( const string& why , bool reenter = false, BSONObj * other = 0, double timeout = 0.0 ); + bool lock_try( const std::string& why , bool reenter = false, BSONObj * other = 0, double timeout = 0.0 ); /** * Returns true if we currently believe we hold this lock and it was possible to @@ -164,7 +164,7 @@ namespace mongo { * lock is not held or if we failed to contact the config servers within the timeout, * returns false. */ - bool isLockHeld( double timeout, string* errMsg ); + bool isLockHeld( double timeout, std::string* errMsg ); /** * Releases a previously taken lock. @@ -175,7 +175,7 @@ namespace mongo { bool isRemoteTimeSkewed(); - const string& getProcessId(); + const std::string& getProcessId(); const ConnectionString& getRemoteConnection(); @@ -198,16 +198,16 @@ namespace mongo { /** * Namespace for lock pings */ - static const string lockPingNS; + static const std::string lockPingNS; /** * Namespace for locks */ - static const string locksNS; + static const std::string locksNS; const ConnectionString _conn; - const string _name; - const string _processId; + const std::string _name; + const std::string _processId; // Timeout for lock, usually LOCK_TIMEOUT const unsigned long long _lockTimeout; @@ -223,7 +223,7 @@ namespace mongo { // May or may not exist, depending on startup mongo::mutex _mutex; - string _threadId; + std::string _threadId; }; @@ -284,7 +284,7 @@ namespace mongo { * Returns false if the lock is known _not_ to be held, otherwise asks the underlying * lock to issue a 'isLockHeld' call and returns whatever that calls does. */ - bool isLockHeld( double timeout, string* errMsg) { + bool isLockHeld( double timeout, std::string* errMsg) { if ( !_lock ) { *errMsg = "Lock is not currently set up"; return false; @@ -306,7 +306,7 @@ namespace mongo { DistributedLock * _lock; bool _got; BSONObj _other; - string _why; + std::string _why; }; /** @@ -317,7 +317,7 @@ namespace mongo { class MONGO_CLIENT_API ScopedDistributedLock { public: - ScopedDistributedLock(const ConnectionString& conn, const string& name); + ScopedDistributedLock(const ConnectionString& conn, const std::string& name); virtual ~ScopedDistributedLock(); @@ -329,7 +329,7 @@ namespace mongo { * * @return if the lock was successfully acquired */ - virtual bool tryAcquire(string* errMsg); + virtual bool tryAcquire(std::string* errMsg); /** * Tries to unlock the lock if acquired. Cannot report an error or block indefinitely @@ -348,7 +348,7 @@ namespace mongo { * waitForMillis = -1 indicates we should retry indefinitely. * @return true if the lock was acquired */ - bool acquire(long long waitForMillis, string* errMsg); + bool acquire(long long waitForMillis, std::string* errMsg); bool isAcquired() const { return _acquired; @@ -366,17 +366,17 @@ namespace mongo { return _lockTryIntervalMillis; } - void setLockMessage(const string& why) { + void setLockMessage(const std::string& why) { _why = why; } - string getLockMessage() const { + std::string getLockMessage() const { return _why; } private: DistributedLock _lock; - string _why; + std::string _why; long long _lockTryIntervalMillis; bool _acquired; diff --git a/src/mongo/s/grid.h b/src/mongo/s/grid.h index c5035c03dad..e68918abce8 100644 --- a/src/mongo/s/grid.h +++ b/src/mongo/s/grid.h @@ -51,7 +51,7 @@ namespace mongo { * gets the config the db. * will return an empty DBConfig if not in db already */ - DBConfigPtr getDBConfig( const StringData& ns , bool create=true , const string& shardNameHint="" ); + DBConfigPtr getDBConfig( const StringData& ns , bool create=true , const std::string& shardNameHint="" ); /** * removes db entry. @@ -91,25 +91,25 @@ namespace mongo { * addShard will create a new shard in the grid. It expects a mongod process to be running * on the provided address. Adding a shard that is a replica set is supported. * - * @param name is an optional string with the name of the shard. if omitted, grid will + * @param name is an optional std::string with the name of the shard. if omitted, grid will * generate one and update the parameter. - * @param servers is the connection string of the shard being added + * @param servers is the connection std::string of the shard being added * @param maxSize is the optional space quota in bytes. Zeros means there's no limitation to * space usage * @param errMsg is the error description in case the operation failed. * @return true if shard was successfully added. */ - bool addShard( string* name , const ConnectionString& servers , long long maxSize , string& errMsg ); + bool addShard( std::string* name , const ConnectionString& servers , long long maxSize , std::string& errMsg ); /** * @return true if the config database knows about a host 'name' */ - bool knowAboutShard( const string& name ) const; + bool knowAboutShard( const std::string& name ) const; /** * @return true if the chunk balancing functionality is enabled */ - bool shouldBalance( const string& ns = "", BSONObj* balancerDocOut = 0 ) const; + bool shouldBalance( const std::string& ns = "", BSONObj* balancerDocOut = 0 ) const; /** * @@ -135,7 +135,7 @@ namespace mongo { private: mongo::mutex _lock; // protects _databases; TODO: change to r/w lock ?? - map<string, DBConfigPtr > _databases; // maps ns to DBConfig's + std::map<std::string, DBConfigPtr > _databases; // maps ns to DBConfig's bool _allowLocalShard; // can 'localhost' be used in shard addresses? /** @@ -143,12 +143,12 @@ namespace mongo { * @return true if it managed to generate a shard name. May return false if (currently) * 10000 shard */ - bool _getNewShardName( string* name ) const; + bool _getNewShardName( std::string* name ) const; /** * @return whether a give dbname is used for shard "local" databases (e.g., admin or local) */ - static bool _isSpecialLocalDB( const string& dbName ); + static bool _isSpecialLocalDB( const std::string& dbName ); /** * @param balancerDoc bson that may contain a marker to stop the balancer diff --git a/src/mongo/s/metadata_loader.h b/src/mongo/s/metadata_loader.h index a1af44ebca9..744a0d0c25a 100644 --- a/src/mongo/s/metadata_loader.h +++ b/src/mongo/s/metadata_loader.h @@ -67,8 +67,8 @@ namespace mongo { public: /** - * Takes a connection string to the config servers to be used for loading data. Note - * that we make no restrictions about which connection string that is, including + * Takes a connection std::string to the config servers to be used for loading data. Note + * that we make no restrictions about which connection std::string that is, including * CUSTOM, which we rely on in testing. */ explicit MetadataLoader( const ConnectionString& configLoc ); @@ -94,8 +94,8 @@ namespace mongo { * @return HostUnreachable if there was an error contacting the config servers * @return RemoteChangeDetected if the data loaded was modified by another operation */ - Status makeCollectionMetadata( const string& ns, - const string& shard, + Status makeCollectionMetadata( const std::string& ns, + const std::string& shard, const CollectionMetadata* oldMetadata, CollectionMetadata* metadata ) const; @@ -137,8 +137,8 @@ namespace mongo { * @return RemoteChangeDetected if the collection doc loaded is unexpectedly different * */ - Status initCollection( const string& ns, - const string& shard, + Status initCollection( const std::string& ns, + const std::string& shard, CollectionMetadata* metadata ) const; /** @@ -154,8 +154,8 @@ namespace mongo { * @return NamespaceNotFound if there are no chunks loaded and an epoch change is detected * TODO: @return FailedToParse */ - Status initChunks( const string& ns, - const string& shard, + Status initChunks( const std::string& ns, + const std::string& shard, const CollectionMetadata* oldMetadata, CollectionMetadata* metadata ) const; }; diff --git a/src/mongo/s/mock_ns_targeter.h b/src/mongo/s/mock_ns_targeter.h index f4e6140220e..ee8ace36436 100644 --- a/src/mongo/s/mock_ns_targeter.h +++ b/src/mongo/s/mock_ns_targeter.h @@ -160,7 +160,7 @@ namespace mongo { KeyRange parseRange( const BSONObj& query ) const { - string fieldName = query.firstElement().fieldName(); + std::string fieldName = query.firstElement().fieldName(); if ( query.firstElement().isNumber() ) { diff --git a/src/mongo/s/mock_shard_resolver.h b/src/mongo/s/mock_shard_resolver.h index e47036cef33..a37c6cfe905 100644 --- a/src/mongo/s/mock_shard_resolver.h +++ b/src/mongo/s/mock_shard_resolver.h @@ -45,7 +45,7 @@ namespace mongo { Status chooseWriteHost( const std::string& shardName, ConnectionString* shardHost ) const { std::string errMsg; - *shardHost = ConnectionString::parse( string( "$" ) + shardName + ":12345", errMsg ); + *shardHost = ConnectionString::parse( std::string( "$" ) + shardName + ":12345", errMsg ); ASSERT_EQUALS( errMsg, "" ); return Status::OK(); } diff --git a/src/mongo/s/ns_targeter.h b/src/mongo/s/ns_targeter.h index 1d5cc78f323..9212b191370 100644 --- a/src/mongo/s/ns_targeter.h +++ b/src/mongo/s/ns_targeter.h @@ -161,7 +161,7 @@ namespace mongo { shardName( other.shardName ), shardVersion( other.shardVersion ) { } - ShardEndpoint( const string& shardName, + ShardEndpoint( const std::string& shardName, const ChunkVersion& shardVersion ) : shardName( shardName ), shardVersion( shardVersion ) { } diff --git a/src/mongo/s/range_arithmetic.h b/src/mongo/s/range_arithmetic.h index a1f0f440554..d13683be70b 100644 --- a/src/mongo/s/range_arithmetic.h +++ b/src/mongo/s/range_arithmetic.h @@ -111,12 +111,12 @@ namespace mongo { * NOTE: For overlap testing to work correctly, there may be no overlaps present in the map * itself. */ - typedef map<BSONObj, BSONObj, BSONObjCmp> RangeMap; + typedef std::map<BSONObj, BSONObj, BSONObjCmp> RangeMap; /** * A RangeVector is a list of [lower,upper) ranges. */ - typedef vector<pair<BSONObj,BSONObj> > RangeVector; + typedef std::vector<std::pair<BSONObj,BSONObj> > RangeVector; /** * Returns the overlap of a range [inclusiveLower, exclusiveUpper) with the provided range map @@ -144,13 +144,13 @@ namespace mongo { const BSONObj& exclusiveUpper ); /** - * String representation of [inclusiveLower, exclusiveUpper) + * std::string representation of [inclusiveLower, exclusiveUpper) */ std::string rangeToString( const BSONObj& inclusiveLower, const BSONObj& exclusiveUpper ); /** - * String representation of overlapping ranges as a list "[range1),[range2),..." + * std::string representation of overlapping ranges as a list "[range1),[range2),..." */ std::string overlapToString( RangeVector overlap ); diff --git a/src/mongo/s/request.h b/src/mongo/s/request.h index a8230f36b4c..3e494952005 100644 --- a/src/mongo/s/request.h +++ b/src/mongo/s/request.h @@ -70,7 +70,7 @@ namespace mongo { // ---- low level access ---- - void reply( Message & response , const string& fromServer ); + void reply( Message & response , const std::string& fromServer ); Message& m() { return _m; } DbMessage& d() { return _d; } diff --git a/src/mongo/s/shard.h b/src/mongo/s/shard.h index 34f8db89f3e..1079de7122e 100644 --- a/src/mongo/s/shard.h +++ b/src/mongo/s/shard.h @@ -49,12 +49,12 @@ namespace mongo { : _name("") , _addr("") , _maxSize(0) , _isDraining( false ) { } - Shard( const string& name , const string& addr, long long maxSize = 0 , bool isDraining = false ) + Shard( const std::string& name , const std::string& addr, long long maxSize = 0 , bool isDraining = false ) : _name(name) , _addr( addr ) , _maxSize( maxSize ) , _isDraining( isDraining ) { _setAddr( addr ); } - Shard( const string& ident ) { + Shard( const std::string& ident ) { reset( ident ); } @@ -69,29 +69,29 @@ namespace mongo { _maxSize( other->_maxSize ) , _isDraining( other->_isDraining ) { } - static Shard make( const string& ident ) { + static Shard make( const std::string& ident ) { Shard s; s.reset( ident ); return s; } - static Shard findIfExists( const string& shardName ); + static Shard findIfExists( const std::string& shardName ); /** * @param ident either name or address */ - void reset( const string& ident ); + void reset( const std::string& ident ); void setAddress( const ConnectionString& cs ); ConnectionString getAddress() const { return _cs; } - string getName() const { + std::string getName() const { verify( _name.size() ); return _name; } - string getConnString() const { + std::string getConnString() const { verify( _addr.size() ); return _addr; } @@ -104,11 +104,11 @@ namespace mongo { return _isDraining; } - string toString() const { + std::string toString() const { return _name + ":" + _addr; } - friend ostream& operator << (ostream& out, const Shard& s) { + friend std::ostream& operator << (std::ostream& out, const Shard& s) { return (out << s.toString()); } @@ -122,11 +122,11 @@ namespace mongo { return ! ( *this == s ); } - bool operator==( const string& s ) const { + bool operator==( const std::string& s ) const { return _name == s || _addr == s; } - bool operator!=( const string& s ) const { + bool operator!=( const std::string& s ) const { return _name != s && _addr != s; } @@ -137,10 +137,10 @@ namespace mongo { bool ok() const { return _addr.size() > 0; } // Set internal to true to run the command with internal authentication privileges. - BSONObj runCommand( const string& db , const string& simple ) const { + BSONObj runCommand( const std::string& db , const std::string& simple ) const { return runCommand( db , BSON( simple << 1 ) ); } - BSONObj runCommand( const string& db , const BSONObj& cmd ) const ; + BSONObj runCommand( const std::string& db , const BSONObj& cmd ) const ; ShardStatus getStatus() const ; @@ -149,14 +149,14 @@ namespace mongo { * retursn true if node is the shard * of if the replica set contains node */ - bool containsNode( const string& node ) const; + bool containsNode( const std::string& node ) const; - const set<string>& tags() const { return _tags; } - void addTag( const string& tag ) { _tags.insert( tag ); } + const std::set<std::string>& tags() const { return _tags; } + void addTag( const std::string& tag ) { _tags.insert( tag ); } - static void getAllShards( vector<Shard>& all ); - static void printShardInfo( ostream& out ); - static Shard lookupRSName( const string& name); + static void getAllShards( std::vector<Shard>& all ); + static void printShardInfo( std::ostream& out ); + static Shard lookupRSName( const std::string& name); /** * @parm current - shard where the chunk/database currently lives in @@ -166,22 +166,22 @@ namespace mongo { static void reloadShardInfo(); - static void removeShard( const string& name ); + static void removeShard( const std::string& name ); - static bool isAShardNode( const string& ident ); + static bool isAShardNode( const std::string& ident ); static Shard EMPTY; private: - void _setAddr( const string& addr ); + void _setAddr( const std::string& addr ); - string _name; - string _addr; + std::string _name; + std::string _addr; ConnectionString _cs; long long _maxSize; // in MBytes, 0 is unlimited bool _isDraining; // shard is currently being removed - set<string> _tags; + std::set<std::string> _tags; }; typedef shared_ptr<Shard> ShardPtr; @@ -190,13 +190,13 @@ namespace mongo { ShardStatus( const Shard& shard , const BSONObj& obj ); - friend ostream& operator << (ostream& out, const ShardStatus& s) { + friend std::ostream& operator << (std::ostream& out, const ShardStatus& s) { out << s.toString(); return out; } - string toString() const { - stringstream ss; + std::string toString() const { + std::stringstream ss; ss << "shard: " << _shard << " mapped: " << _mapped << " writeLock: " << _writeLock @@ -220,7 +220,7 @@ namespace mongo { return _hasOpsQueued; } - string mongoVersion() const { + std::string mongoVersion() const { return _mongoVersion; } @@ -229,7 +229,7 @@ namespace mongo { long long _mapped; bool _hasOpsQueued; // true if 'writebacks' are pending double _writeLock; - string _mongoVersion; + std::string _mongoVersion; }; class ChunkManager; @@ -237,9 +237,9 @@ namespace mongo { class ShardConnection : public AScopedConnection { public: - ShardConnection( const Shard * s , const string& ns, ChunkManagerPtr manager = ChunkManagerPtr() ); - ShardConnection( const Shard& s , const string& ns, ChunkManagerPtr manager = ChunkManagerPtr() ); - ShardConnection( const string& addr , const string& ns, ChunkManagerPtr manager = ChunkManagerPtr() ); + ShardConnection( const Shard * s , const std::string& ns, ChunkManagerPtr manager = ChunkManagerPtr() ); + ShardConnection( const Shard& s , const std::string& ns, ChunkManagerPtr manager = ChunkManagerPtr() ); + ShardConnection( const std::string& addr , const std::string& ns, ChunkManagerPtr manager = ChunkManagerPtr() ); ~ShardConnection(); @@ -273,11 +273,11 @@ namespace mongo { return _conn; } - string getHost() const { + std::string getHost() const { return _addr; } - string getNS() const { + std::string getNS() const { return _ns; } @@ -302,10 +302,10 @@ namespace mongo { /** this just passes through excpet it checks for stale configs */ - bool runCommand( const string& db , const BSONObj& cmd , BSONObj& res ); + bool runCommand( const std::string& db , const BSONObj& cmd , BSONObj& res ); /** checks all of my thread local connections for the version of this ns */ - static void checkMyConnectionVersions( const string & ns ); + static void checkMyConnectionVersions( const std::string & ns ); /** * Returns all the current sharded connections to the pool. @@ -322,7 +322,7 @@ namespace mongo { /** * Forgets a namespace to prevent future versioning. */ - static void forgetNS( const string& ns ); + static void forgetNS( const std::string& ns ); private: void _init(); @@ -330,8 +330,8 @@ namespace mongo { bool _finishedInit; - string _addr; - string _ns; + std::string _addr; + std::string _ns; ChunkManagerPtr _manager; DBClientBase* _conn; diff --git a/src/mongo/s/shardkey.h b/src/mongo/s/shardkey.h index 8dec3e65b27..6c5064eb06d 100644 --- a/src/mongo/s/shardkey.h +++ b/src/mongo/s/shardkey.h @@ -90,7 +90,7 @@ namespace mongo { BSONObj key() const { return pattern.toBSON(); } - string toString() const; + std::string toString() const; BSONObj extractKey(const BSONObj& from) const; @@ -145,7 +145,7 @@ namespace mongo { BSONObj gMax; /* question: better to have patternfields precomputed or not? depends on if we use copy constructor often. */ - set<string> patternfields; + std::set<std::string> patternfields; }; inline BSONObj ShardKeyPattern::extractKey(const BSONObj& from) const { diff --git a/src/mongo/s/stale_exception.h b/src/mongo/s/stale_exception.h index 79eaa4e51ce..e91a243df60 100644 --- a/src/mongo/s/stale_exception.h +++ b/src/mongo/s/stale_exception.h @@ -42,8 +42,8 @@ namespace mongo { */ class StaleConfigException : public AssertionException { public: - StaleConfigException( const string& ns, - const string& raw, + StaleConfigException( const std::string& ns, + const std::string& raw, int code, ChunkVersion received, ChunkVersion wanted, @@ -61,13 +61,13 @@ namespace mongo { } /** Preferred if we're rebuilding this from a thrown exception */ - StaleConfigException( const string& raw, + StaleConfigException( const std::string& raw, int code, const BSONObj& error, bool justConnection = false ) : AssertionException( stream() << raw << " ( ns : " << ( error["ns"].type() == String ? - error["ns"].String() : string("<unknown>") ) + error["ns"].String() : std::string("<unknown>") ) << ", received : " << ChunkVersion::fromBSON( error, "vReceived" ).toString() << ", wanted : " @@ -93,13 +93,13 @@ namespace mongo { virtual ~StaleConfigException() throw() {} - virtual void appendPrefix( stringstream& ss ) const { + virtual void appendPrefix( std::stringstream& ss ) const { ss << "stale sharding config exception: "; } bool justConnection() const { return _justConnection; } - string getns() const { return _ns; } + std::string getns() const { return _ns; } /** * true if this exception would require a full reload of config data to resolve @@ -109,12 +109,12 @@ namespace mongo { _received.isSet() != _wanted.isSet(); } - static bool parse( const string& big , string& ns , string& raw ) { - string::size_type start = big.find( '[' ); - if ( start == string::npos ) + static bool parse( const std::string& big , std::string& ns , std::string& raw ) { + std::string::size_type start = big.find( '[' ); + if ( start == std::string::npos ) return false; - string::size_type end = big.find( ']' ,start ); - if ( end == string::npos ) + std::string::size_type end = big.find( ']' ,start ); + if ( end == std::string::npos ) return false; ns = big.substr( start + 1 , ( end - start ) - 1 ); @@ -144,22 +144,22 @@ namespace mongo { private: bool _justConnection; - string _ns; + std::string _ns; ChunkVersion _received; ChunkVersion _wanted; }; class SendStaleConfigException : public StaleConfigException { public: - SendStaleConfigException( const string& ns, - const string& raw, + SendStaleConfigException( const std::string& ns, + const std::string& raw, ChunkVersion received, ChunkVersion wanted, bool justConnection = false ) : StaleConfigException( ns, raw, SendStaleConfigCode, received, wanted, justConnection ){ } - SendStaleConfigException( const string& raw, + SendStaleConfigException( const std::string& raw, const BSONObj& error, bool justConnection = false ) : StaleConfigException( raw, SendStaleConfigCode, error, justConnection ) { @@ -168,15 +168,15 @@ namespace mongo { class RecvStaleConfigException : public StaleConfigException { public: - RecvStaleConfigException( const string& ns, - const string& raw, + RecvStaleConfigException( const std::string& ns, + const std::string& raw, ChunkVersion received, ChunkVersion wanted, bool justConnection = false ) : StaleConfigException( ns, raw, RecvStaleConfigCode, received, wanted, justConnection ){ } - RecvStaleConfigException( const string& raw, + RecvStaleConfigException( const std::string& raw, const BSONObj& error, bool justConnection = false ) : StaleConfigException( raw, RecvStaleConfigCode, error, justConnection ) { diff --git a/src/mongo/s/strategy.h b/src/mongo/s/strategy.h index 885adbd8e14..d812751d75c 100644 --- a/src/mongo/s/strategy.h +++ b/src/mongo/s/strategy.h @@ -62,12 +62,12 @@ namespace mongo { * * This version should be used by internal commands when possible. */ - void commandOp( const string& db, + void commandOp( const std::string& db, const BSONObj& command, int options, - const string& versionedNS, + const std::string& versionedNS, const BSONObj& targetingQuery, - vector<CommandResult>* results ); + std::vector<CommandResult>* results ); /** * Executes a command represented in the Request on the sharded cluster. diff --git a/src/mongo/s/type_changelog.h b/src/mongo/s/type_changelog.h index 064eff73ced..44a30fdba7e 100644 --- a/src/mongo/s/type_changelog.h +++ b/src/mongo/s/type_changelog.h @@ -50,7 +50,7 @@ namespace mongo { * * // Process the response. * ChangelogType exampleType; - * string errMsg; + * std::string errMsg; * if (!exampleType.parseBSON(exampleDoc, &errMsg) || !exampleType.isValid(&errMsg)) { * // Can't use 'exampleType'. Take action. * } @@ -112,7 +112,7 @@ namespace mongo { void cloneTo(ChangelogType* other) const; /** - * Returns a string representation of the current internal state. + * Returns a std::string representation of the current internal state. */ std::string toString() const; diff --git a/src/mongo/s/type_chunk.h b/src/mongo/s/type_chunk.h index 6a26db8d418..8bbd5ad3a9a 100644 --- a/src/mongo/s/type_chunk.h +++ b/src/mongo/s/type_chunk.h @@ -51,7 +51,7 @@ namespace mongo { * * // Process the response. * ChunkType exampleType; - * string errMsg; + * std::string errMsg; * if (!exampleType.parseBSON(exampleDoc, &errMsg) || !exampleType.isValid(&errMsg)) { * // Can't use 'exampleType'. Take action. * } @@ -115,7 +115,7 @@ namespace mongo { void cloneTo(ChunkType* other) const; /** - * Returns a string representation of the current internal state. + * Returns a std::string representation of the current internal state. */ std::string toString() const; diff --git a/src/mongo/s/type_collection.h b/src/mongo/s/type_collection.h index aa04b550cb6..8f1be36109a 100644 --- a/src/mongo/s/type_collection.h +++ b/src/mongo/s/type_collection.h @@ -50,7 +50,7 @@ namespace mongo { * * // Process the response. * CollectionType exampleType; - * string errMsg; + * std::string errMsg; * if (!exampleType.parseBSON(exampleDoc, &errMsg) || !exampleType.isValid(&errMsg)) { * // Can't use 'exampleType'. Take action. * } @@ -115,7 +115,7 @@ namespace mongo { void cloneTo(CollectionType* other) const; /** - * Returns a string representation of the current internal state. + * Returns a std::string representation of the current internal state. */ std::string toString() const; diff --git a/src/mongo/s/type_config_version.h b/src/mongo/s/type_config_version.h index 5d4d9387d03..fe855826100 100644 --- a/src/mongo/s/type_config_version.h +++ b/src/mongo/s/type_config_version.h @@ -50,7 +50,7 @@ namespace mongo { * * // Process the response. * VersionType exampleType; - * string errMsg; + * std::string errMsg; * if (!exampleType.parseBSON(exampleDoc, &errMsg) || !exampleType.isValid(&errMsg)) { * // Can't use 'exampleType'. Take action. * } @@ -112,7 +112,7 @@ namespace mongo { void cloneTo(VersionType* other) const; /** - * Returns a string representation of the current internal state. + * Returns a std::string representation of the current internal state. */ std::string toString() const; diff --git a/src/mongo/s/type_database.h b/src/mongo/s/type_database.h index cdfb5274fd3..28b68005b32 100644 --- a/src/mongo/s/type_database.h +++ b/src/mongo/s/type_database.h @@ -50,7 +50,7 @@ namespace mongo { * * // Process the response. * DatabaseType exampleType; - * string errMsg; + * std::string errMsg; * if (!exampleType.parseBSON(exampleDoc, &errMsg) || !exampleType.isValid(&errMsg)) { * // Can't use 'exampleType'. Take action. * } @@ -111,7 +111,7 @@ namespace mongo { void cloneTo(DatabaseType* other) const; /** - * Returns a string representation of the current internal state. + * Returns a std::string representation of the current internal state. */ std::string toString() const; diff --git a/src/mongo/s/type_lockpings.h b/src/mongo/s/type_lockpings.h index fe841792649..64dcafa283a 100644 --- a/src/mongo/s/type_lockpings.h +++ b/src/mongo/s/type_lockpings.h @@ -50,7 +50,7 @@ namespace mongo { * * // Process the response. * LockpingsType exampleType; - * string errMsg; + * std::string errMsg; * if (!exampleType.parseBSON(exampleDoc, &errMsg) || !exampleType.isValid(&errMsg)) { * // Can't use 'exampleType'. Take action. * } @@ -107,7 +107,7 @@ namespace mongo { void cloneTo(LockpingsType* other) const; /** - * Returns a string representation of the current internal state. + * Returns a std::string representation of the current internal state. */ std::string toString() const; @@ -150,7 +150,7 @@ namespace mongo { private: // Convention: (M)andatory, (O)ptional, (S)pecial rule. - std::string _process; // (M) string describing the process holding the lock + std::string _process; // (M) std::string describing the process holding the lock bool _isProcessSet; Date_t _ping; // (M) last time the holding process updated this document bool _isPingSet; diff --git a/src/mongo/s/type_locks.h b/src/mongo/s/type_locks.h index 5a96b282f0b..379fb7d5d3d 100644 --- a/src/mongo/s/type_locks.h +++ b/src/mongo/s/type_locks.h @@ -50,7 +50,7 @@ namespace mongo { * * // Process the response. * LocksType exampleType; - * string errMsg; + * std::string errMsg; * if (!exampleType.parseBSON(exampleDoc, &errMsg) || !exampleType.isValid(&errMsg)) { * // Can't use 'exampleType'. Take action. * } @@ -111,7 +111,7 @@ namespace mongo { void cloneTo(LocksType* other) const; /** - * Returns a string representation of the current internal state. + * Returns a std::string representation of the current internal state. */ std::string toString() const; diff --git a/src/mongo/s/type_mongos.h b/src/mongo/s/type_mongos.h index b462390e04e..fa176b5885a 100644 --- a/src/mongo/s/type_mongos.h +++ b/src/mongo/s/type_mongos.h @@ -50,7 +50,7 @@ namespace mongo { * * // Process the response. * MongosType exampleType; - * string errMsg; + * std::string errMsg; * if (!exampleType.parseBSON(exampleDoc, &errMsg) || !exampleType.isValid(&errMsg)) { * // Can't use 'exampleType'. Take action. * } @@ -111,7 +111,7 @@ namespace mongo { void cloneTo(MongosType* other) const; /** - * Returns a string representation of the current internal state. + * Returns a std::string representation of the current internal state. */ std::string toString() const; diff --git a/src/mongo/s/type_settings.h b/src/mongo/s/type_settings.h index 633318d6ce7..5d0798d4c12 100644 --- a/src/mongo/s/type_settings.h +++ b/src/mongo/s/type_settings.h @@ -50,7 +50,7 @@ namespace mongo { * * // Process the response. * SettingsType exampleType; - * string errMsg; + * std::string errMsg; * if (!exampleType.parseBSON(exampleDoc, &errMsg) || !exampleType.isValid(&errMsg)) { * // Can't use 'exampleType'. Take action. * } @@ -111,7 +111,7 @@ namespace mongo { void cloneTo(SettingsType* other) const; /** - * Returns a string representation of the current internal state. + * Returns a std::string representation of the current internal state. */ std::string toString() const; diff --git a/src/mongo/s/type_shard.h b/src/mongo/s/type_shard.h index eb5c0287e87..2c2e20d64fc 100644 --- a/src/mongo/s/type_shard.h +++ b/src/mongo/s/type_shard.h @@ -50,7 +50,7 @@ namespace mongo { * * // Process the response. * ShardType exampleType; - * string errMsg; + * std::string errMsg; * if (!exampleType.parseBSON(exampleDoc, &errMsg) || !exampleType.isValid(&errMsg)) { * // Can't use 'exampleType'. Take action. * } @@ -110,7 +110,7 @@ namespace mongo { void cloneTo(ShardType* other) const; /** - * Returns a string representation of the current internal state. + * Returns a std::string representation of the current internal state. */ std::string toString() const; @@ -218,7 +218,7 @@ namespace mongo { // Convention: (M)andatory, (O)ptional, (S)pecial rule. std::string _name; // (M) shard's id bool _isNameSet; - std::string _host; // (M) connection string for the host(s) + std::string _host; // (M) connection std::string for the host(s) bool _isHostSet; bool _draining; // (O) is it draining chunks? bool _isDrainingSet; diff --git a/src/mongo/s/type_tags.h b/src/mongo/s/type_tags.h index 6561e5ebe9b..95218e606c4 100644 --- a/src/mongo/s/type_tags.h +++ b/src/mongo/s/type_tags.h @@ -50,7 +50,7 @@ namespace mongo { * * // Process the response. * TagsType exampleType; - * string errMsg; + * std::string errMsg; * if (!exampleType.parseBSON(exampleDoc, &errMsg) || !exampleType.isValid(&errMsg)) { * // Can't use 'exampleType'. Take action. * } @@ -109,7 +109,7 @@ namespace mongo { void cloneTo(TagsType* other) const; /** - * Returns a string representation of the current internal state. + * Returns a std::string representation of the current internal state. */ std::string toString() const; diff --git a/src/mongo/s/version_manager.h b/src/mongo/s/version_manager.h index 9b326f724af..f59e0e5a094 100644 --- a/src/mongo/s/version_manager.h +++ b/src/mongo/s/version_manager.h @@ -41,8 +41,8 @@ namespace mongo { bool isVersionableCB( DBClientBase* ); bool initShardVersionCB( DBClientBase*, BSONObj& ); - bool forceRemoteCheckShardVersionCB( const string& ); - bool checkShardVersionCB( DBClientBase*, const string&, bool, int ); + bool forceRemoteCheckShardVersionCB( const std::string& ); + bool checkShardVersionCB( DBClientBase*, const std::string&, bool, int ); bool checkShardVersionCB( ShardConnection*, bool, int ); void resetShardVersionCB( DBClientBase* ); diff --git a/src/mongo/s/write_ops/batch_downconvert.h b/src/mongo/s/write_ops/batch_downconvert.h index 521a48143eb..391c328a7f9 100644 --- a/src/mongo/s/write_ops/batch_downconvert.h +++ b/src/mongo/s/write_ops/batch_downconvert.h @@ -101,8 +101,8 @@ namespace mongo { // Helper that acts as an auto-ptr for write and wc errors struct GLEErrors { - auto_ptr<WriteErrorDetail> writeError; - auto_ptr<WCErrorDetail> wcError; + std::auto_ptr<WriteErrorDetail> writeError; + std::auto_ptr<WCErrorDetail> wcError; }; /** @@ -140,9 +140,9 @@ namespace mongo { // Used for reporting legacy write concern responses struct LegacyWCResponse { - string shardHost; + std::string shardHost; BSONObj gleResponse; - string errToReport; + std::string errToReport; }; /** @@ -156,5 +156,5 @@ namespace mongo { const StringData& dbName, const BSONObj& options, const HostOpTimeMap& hostOpTimes, - vector<LegacyWCResponse>* wcResponses ); + std::vector<LegacyWCResponse>* wcResponses ); } diff --git a/src/mongo/s/write_ops/batch_write_exec.h b/src/mongo/s/write_ops/batch_write_exec.h index cb0f63fdb4f..e8d2c249fb8 100644 --- a/src/mongo/s/write_ops/batch_write_exec.h +++ b/src/mongo/s/write_ops/batch_write_exec.h @@ -93,7 +93,7 @@ namespace mongo { MultiCommandDispatch* _dispatcher; // Stats - auto_ptr<BatchWriteExecStats> _stats; + std::auto_ptr<BatchWriteExecStats> _stats; }; struct HostOpTime { diff --git a/src/mongo/s/write_ops/batch_write_op.h b/src/mongo/s/write_ops/batch_write_op.h index 0237bb6185d..a2e601b97d1 100644 --- a/src/mongo/s/write_ops/batch_write_op.h +++ b/src/mongo/s/write_ops/batch_write_op.h @@ -107,7 +107,7 @@ namespace mongo { */ Status targetBatch( const NSTargeter& targeter, bool recordTargetErrors, - vector<TargetedWriteBatch*>* targetedBatches ); + std::vector<TargetedWriteBatch*>* targetedBatches ); /** * Fills a BatchCommandRequest from a TargetedWriteBatch for this BatchWriteOp. diff --git a/src/mongo/s/write_ops/batched_command_response.h b/src/mongo/s/write_ops/batched_command_response.h index fa96d742e02..5b66be7dc25 100644 --- a/src/mongo/s/write_ops/batched_command_response.h +++ b/src/mongo/s/write_ops/batched_command_response.h @@ -55,7 +55,7 @@ namespace mongo { static const BSONField<int> ok; static const BSONField<int> errCode; - static const BSONField<string> errMessage; + static const BSONField<std::string> errMessage; static const BSONField<long long> n; static const BSONField<long long> nModified; static const BSONField<std::vector<BatchedUpsertDetail*> > upsertDetails; @@ -157,7 +157,7 @@ namespace mongo { bool _isErrCodeSet; // (O) whether all items in the batch applied correctly - string _errMessage; + std::string _errMessage; bool _isErrMessageSet; // (M) number of documents affected diff --git a/src/mongo/s/write_ops/write_op.h b/src/mongo/s/write_ops/write_op.h index 07957f1e314..9fd05ffc44a 100644 --- a/src/mongo/s/write_ops/write_op.h +++ b/src/mongo/s/write_ops/write_op.h @@ -217,7 +217,7 @@ namespace mongo { }; // First value is write item index in the batch, second value is child write op index - typedef pair<int, int> WriteOpRef; + typedef std::pair<int, int> WriteOpRef; /** * A write with A) a request targeted at a particular shard endpoint, and B) a response targeted diff --git a/src/mongo/s/writeback_listener.h b/src/mongo/s/writeback_listener.h index fc4c81dee86..0d45ca7fb17 100644 --- a/src/mongo/s/writeback_listener.h +++ b/src/mongo/s/writeback_listener.h @@ -52,21 +52,21 @@ namespace mongo { public: static void init( DBClientBase& conn ); - static void init( const string& host ); + static void init( const std::string& host ); protected: - WriteBackListener( const string& addr ); + WriteBackListener( const std::string& addr ); - string name() const { return _name; } + std::string name() const { return _name; } void run(); private: - string _addr; - string _name; + std::string _addr; + std::string _name; static mongo::mutex _cacheLock; // protects _cache - static unordered_map<string,WriteBackListener*> _cache; // server to listener - static unordered_set<string> _seenSets; // cache of set urls we've seen - note this is ever expanding for order, case, changes + static unordered_map<std::string,WriteBackListener*> _cache; // server to listener + static unordered_set<std::string> _seenSets; // cache of set urls we've seen - note this is ever expanding for order, case, changes }; diff --git a/src/mongo/scripting/bench.h b/src/mongo/scripting/bench.h index 957d3cfee8f..fb78380dcd6 100644 --- a/src/mongo/scripting/bench.h +++ b/src/mongo/scripting/bench.h @@ -64,7 +64,7 @@ namespace mongo { DBClientBase *createConnection() const; /** - * Connection string describing the host to which to connect. + * Connection std::string describing the host to which to connect. */ std::string host; @@ -418,12 +418,12 @@ namespace mongo { private: // TODO: Same as for createWithConfig. static boost::mutex _staticMutex; - static map< OID, BenchRunner* > _activeRuns; + static std::map< OID, BenchRunner* > _activeRuns; OID _oid; BenchRunState _brState; boost::scoped_ptr<BenchRunConfig> _config; - vector<BenchRunWorker *> _workers; + std::vector<BenchRunWorker *> _workers; BSONObj before; BSONObj after; diff --git a/src/mongo/scripting/bson_template_evaluator.h b/src/mongo/scripting/bson_template_evaluator.h index f597686cf38..e310712f220 100644 --- a/src/mongo/scripting/bson_template_evaluator.h +++ b/src/mongo/scripting/bson_template_evaluator.h @@ -181,7 +181,7 @@ namespace mongo { const BSONObj& in, BSONObjBuilder& out); /* * Operator method to support #RAND_STRING : { key : { #RAND_STRING: [12] } } - * The array argument to RAND_STRING is the length of the string that is desired. + * The array argument to RAND_STRING is the length of the std::string that is desired. * This will evaluate to something like { key : "randomstring" } */ static Status evalRandString(BsonTemplateEvaluator* btl, const char* fieldName, @@ -189,7 +189,7 @@ namespace mongo { /* * Operator method to support #CONCAT : { key : { #CONCAT: ["hello", " ", "world", 2012] } } * The array argument to CONCAT are the strings to be concatenated. If the argument is not - * a string it will be stringified and concatendated. + * a std::string it will be stringified and concatendated. * This will evaluate to { key : "hello world2012" } */ static Status evalConcat(BsonTemplateEvaluator* btl, const char* fieldName, diff --git a/src/mongo/scripting/engine.h b/src/mongo/scripting/engine.h index 8fd409ae9ed..05061e82a19 100644 --- a/src/mongo/scripting/engine.h +++ b/src/mongo/scripting/engine.h @@ -34,7 +34,7 @@ namespace mongo { typedef unsigned long long ScriptingFunction; typedef BSONObj (*NativeFunction)(const BSONObj& args, void* data); - typedef map<string, ScriptingFunction> FunctionCacheMap; + typedef std::map<std::string, ScriptingFunction> FunctionCacheMap; class DBClientWithCommands; class DBClientBase; @@ -58,9 +58,9 @@ namespace mongo { virtual void localConnect(const char* dbName) = 0; virtual void externalSetup() = 0; - virtual void setLocalDB(const string& localDBName) { _localDBName = localDBName; } + virtual void setLocalDB(const std::string& localDBName) { _localDBName = localDBName; } virtual BSONObj getObject(const char* field) = 0; - virtual string getString(const char* field) = 0; + virtual std::string getString(const char* field) = 0; virtual bool getBoolean(const char* field) = 0; virtual double getNumber(const char* field) = 0; virtual int getNumberInt(const char* field) { return (int)getNumber(field); } @@ -81,7 +81,7 @@ namespace mongo { virtual void rename(const char* from, const char* to) = 0; - virtual string getError() = 0; + virtual std::string getError() = 0; virtual bool hasOutOfMemoryException() = 0; @@ -109,22 +109,22 @@ namespace mongo { readOnlyArgs, readOnlyRecv); if (res == 0) return; - uasserted(9004, string("invoke failed: ") + getError()); + uasserted(9004, std::string("invoke failed: ") + getError()); } void invokeSafe(const char* code, const BSONObj* args, const BSONObj* recv, int timeoutMs = 0) { if (invoke(code, args, recv, timeoutMs) == 0) return; - uasserted(9005, string("invoke failed: ") + getError()); + uasserted(9005, std::string("invoke failed: ") + getError()); } virtual void injectNative(const char* field, NativeFunction func, void* data = 0) = 0; - virtual bool exec(const StringData& code, const string& name, bool printResult, + virtual bool exec(const StringData& code, const std::string& name, bool printResult, bool reportError, bool assertOnError, int timeoutMs = 0) = 0; - virtual void execSetup(const StringData& code, const string& name = "setup") { + virtual void execSetup(const StringData& code, const std::string& name = "setup") { exec(code, name, false, true, true, 0); } @@ -132,7 +132,7 @@ namespace mongo { execSetup(file.source, file.name); } - virtual bool execFile(const string& filename, bool printResult, bool reportError, + virtual bool execFile(const std::string& filename, bool printResult, bool reportError, int timeoutMs = 0); void execCoreFiles(); @@ -145,7 +145,7 @@ namespace mongo { */ static void storedFuncMod(); - static void validateObjectIdString(const string& str); + static void validateObjectIdString(const std::string& str); /** increments the number of times a scope was used */ void incTimesUsed() { ++_numTimesUsed; } @@ -176,9 +176,9 @@ namespace mongo { virtual ScriptingFunction _createFunction(const char* code, ScriptingFunction functionNumber = 0) = 0; - string _localDBName; + std::string _localDBName; long long _loadedVersion; - set<string> _storedNames; + std::set<std::string> _storedNames; static long long _lastVersion; FunctionCacheMap _cachedFunctions; int _numTimesUsed; @@ -206,7 +206,7 @@ namespace mongo { * This must include authenticated users. * @return the scope */ - auto_ptr<Scope> getPooledScope(const string& db, const string& scopeType); + std::auto_ptr<Scope> getPooledScope(const std::string& db, const std::string& scopeType); void setScopeInitCallback(void (*func)(Scope&)) { _scopeInitCallback = func; } static void setConnectCallback(void (*func)(DBClientWithCommands&)) { @@ -254,7 +254,7 @@ namespace mongo { }; void installGlobalUtils(Scope& scope); - bool hasJSReturn(const string& s); + bool hasJSReturn(const std::string& s); const char* jsSkipWhiteSpace(const char* raw); extern ScriptEngine* globalScriptEngine; diff --git a/src/mongo/scripting/engine_v8.h b/src/mongo/scripting/engine_v8.h index a365b2e4e45..29e995576a3 100644 --- a/src/mongo/scripting/engine_v8.h +++ b/src/mongo/scripting/engine_v8.h @@ -91,9 +91,9 @@ namespace mongo { ~ObjTracker() { if (!_container.empty()) { LOG(1) << "freeing " << _container.size() << " uncollected " - << typeid(_ObjType).name() << " objects" << endl; + << typeid(_ObjType).name() << " objects" << std::endl; } - typename set<TrackedPtr*>::iterator it = _container.begin(); + typename std::set<TrackedPtr*>::iterator it = _container.begin(); while (it != _container.end()) { delete *it; _container.erase(it++); @@ -128,7 +128,7 @@ namespace mongo { } // container for all TrackedPtrs created by this ObjTracker instance - set<TrackedPtr*> _container; + std::set<TrackedPtr*> _container; }; /** @@ -176,7 +176,7 @@ namespace mongo { virtual void installBSONTypes(); - virtual string getError() { return _error; } + virtual std::string getError() { return _error; } virtual bool hasOutOfMemoryException(); @@ -194,7 +194,7 @@ namespace mongo { virtual double getNumber(const char* field); virtual int getNumberInt(const char* field); virtual long long getNumberLongLong(const char* field); - virtual string getString(const char* field); + virtual std::string getString(const char* field); virtual bool getBoolean(const char* field); virtual BSONObj getObject(const char* field); @@ -213,7 +213,7 @@ namespace mongo { int timeoutMs = 0, bool ignoreReturn = false, bool readOnlyArgs = false, bool readOnlyRecv = false); - virtual bool exec(const StringData& code, const string& name, bool printResult, + virtual bool exec(const StringData& code, const std::string& name, bool printResult, bool reportError, bool assertOnError, int timeoutMs); // functions to create v8 object and function templates @@ -287,7 +287,7 @@ namespace mongo { std::string v8ExceptionToSTLString(const v8::TryCatch* try_catch); /** - * Create a V8 string with a local handle + * Create a V8 std::string with a local handle */ static inline v8::Handle<v8::String> v8StringData(StringData str) { return v8::String::New(str.rawData(), str.size()); @@ -342,10 +342,10 @@ namespace mongo { template <size_t N> v8::Handle<v8::String> strLitToV8(const char (&str)[N]) { - // Note that _strLitMap is keyed on string pointer not string - // value. This is OK because each string literal has a constant + // Note that _strLitMap is keyed on std::string pointer not string + // value. This is OK because each std::string literal has a constant // pointer for the program's lifetime. This works best if (but does - // not require) the linker interns all string literals giving + // not require) the linker interns all std::string literals giving // identical strings used in different places the same pointer. StrLitMap::iterator it = _strLitMap.find(str); @@ -434,8 +434,8 @@ namespace mongo { v8::Persistent<v8::Context> _context; v8::Persistent<v8::Object> _global; - string _error; - vector<v8::Persistent<v8::Value> > _funcs; + std::string _error; + std::vector<v8::Persistent<v8::Value> > _funcs; enum ConnectState { NOT, LOCAL, EXTERNAL }; ConnectState _connectState; @@ -535,7 +535,7 @@ namespace mongo { */ DeadlineMonitor<V8Scope>* getDeadlineMonitor() { return &_deadlineMonitor; } - typedef map<unsigned, V8Scope*> OpIdToScopeMap; + typedef std::map<unsigned, V8Scope*> OpIdToScopeMap; mongo::mutex _globalInterruptLock; // protects map of all operation ids -> scope OpIdToScopeMap _opToScopeMap; // map of mongo op ids to scopes (protected by // _globalInterruptLock). @@ -561,7 +561,7 @@ namespace mongo { BSONObj _obj; bool _modified; bool _readOnly; - set<string> _removed; + std::set<std::string> _removed; }; /** @@ -600,7 +600,7 @@ namespace mongo { if (haveError) { if (reportError) - log() << _error << endl; + log() << _error << std::endl; if (assertOnError) uasserted(16722, _error); return true; diff --git a/src/mongo/scripting/v8_utils.h b/src/mongo/scripting/v8_utils.h index 418476cacd5..89ec2095387 100644 --- a/src/mongo/scripting/v8_utils.h +++ b/src/mongo/scripting/v8_utils.h @@ -50,7 +50,7 @@ namespace mongo { std::ostream& operator<<(std::ostream& s, const v8::Handle<v8::Value>& o); std::ostream& operator<<(std::ostream& s, const v8::Handle<v8::TryCatch>* try_catch); - /** Simple v8 object to string conversion helper */ + /** Simple v8 object to std::string conversion helper */ std::string toSTLString(const v8::Handle<v8::Value>& o); /** Like toSTLString but doesn't allocate a new std::string @@ -92,7 +92,7 @@ namespace mongo { v8::String::Utf8Value _str; }; - /** Get the properties of an object (and it's prototype) as a comma-delimited string */ + /** Get the properties of an object (and it's prototype) as a comma-delimited std::string */ std::string v8ObjectToString(const v8::Handle<v8::Object>& o); class V8Scope; diff --git a/src/mongo/server.h b/src/mongo/server.h index 3d861e8f012..157c23d7f7c 100644 --- a/src/mongo/server.h +++ b/src/mongo/server.h @@ -47,7 +47,6 @@ #include "mongo/bson/inline_decls.h" -//using namespace std; //using namespace bson; /* Note: do not clutter code with these -- ONLY use in hot spots / significant loops. */ diff --git a/src/mongo/shell/linenoise_utf8.h b/src/mongo/shell/linenoise_utf8.h index 703de88894e..c9387ccc643 100644 --- a/src/mongo/shell/linenoise_utf8.h +++ b/src/mongo/shell/linenoise_utf8.h @@ -44,8 +44,8 @@ enum BadUTF8 { }; /** - * Convert a null terminated UTF-8 string from UTF-8 and store it in a UChar32 destination buffer - * Always null terminates the destination string if at least one character position is available + * Convert a null terminated UTF-8 std::string from UTF-8 and store it in a UChar32 destination buffer + * Always null terminates the destination std::string if at least one character position is available * Errors in the UTF-8 encoding will be handled in two ways: the erroneous characters will be * converted to the Unicode error character U+FFFD and flag bits will be set in the conversionErrorCode * int. @@ -64,8 +64,8 @@ void copyString8to32( int & conversionErrorCode ); /** - * Copy a null terminated UChar32 string to a UChar32 destination buffer - * Always null terminates the destination string if at least one character position is available + * Copy a null terminated UChar32 std::string to a UChar32 destination buffer + * Always null terminates the destination std::string if at least one character position is available * * @param dest32 Destination UChar32 buffer * @param source32 Source UChar32 string @@ -74,9 +74,9 @@ void copyString8to32( void copyString32( UChar32* dest32, const UChar32* source32, size_t destLengthInCharacters ); /** - * Convert a specified number of UChar32 characters from a possibly null terminated UChar32 string to UTF-8 + * Convert a specified number of UChar32 characters from a possibly null terminated UChar32 std::string to UTF-8 * and store it in a UChar8 destination buffer - * Always null terminates the destination string if at least one character position is available + * Always null terminates the destination std::string if at least one character position is available * * @param dest8 Destination UChar8 buffer * @param source32 Source UChar32 string @@ -87,8 +87,8 @@ void copyString32( UChar32* dest32, const UChar32* source32, size_t destLengthIn size_t copyString32to8counted( UChar8* dest8, const UChar32* source32, size_t outputBufferSizeInBytes, size_t charCount ); /** - * Convert a null terminated UChar32 string to UTF-8 and store it in a UChar8 destination buffer - * Always null terminates the destination string if at least one character position is available + * Convert a null terminated UChar32 std::string to UTF-8 and store it in a UChar8 destination buffer + * Always null terminates the destination std::string if at least one character position is available * * @param dest8 Destination UChar8 buffer * @param source32 Source UChar32 string @@ -101,15 +101,15 @@ size_t copyString32to8( UChar8* dest8, const UChar32* source32, size_t outputBuf * Count characters (i.e. Unicode code points, array elements) in a null terminated UChar32 string * * @param str32 Source UChar32 string - * @return String length in characters + * @return std::string length in characters */ size_t strlen32( const UChar32* str32 ); /** * Compare two UChar32 null-terminated strings with length parameter * - * @param first32 First string to compare - * @param second32 Second string to compare + * @param first32 First std::string to compare + * @param second32 Second std::string to compare * @param length Maximum number of characters to compare * @return Negative if first < second, positive if first > second, zero if equal */ diff --git a/src/mongo/shell/shell_utils.h b/src/mongo/shell/shell_utils.h index 6132a372a6f..5e6f7a45c17 100644 --- a/src/mongo/shell/shell_utils.h +++ b/src/mongo/shell/shell_utils.h @@ -57,11 +57,11 @@ namespace mongo { /** Prompt for confirmation from cin. */ class Prompter { public: - Prompter( const string &prompt ); + Prompter( const std::string &prompt ); /** @return prompted confirmation or cached confirmation. */ bool confirm(); private: - const string _prompt; + const std::string _prompt; bool _confirmed; }; @@ -72,7 +72,7 @@ namespace mongo { void registerConnection( DBClientWithCommands &client ); void killOperationsOnAllConnections( bool withPrompt ) const; private: - map<string,set<string> > _connectionUris; + std::map<std::string,std::set<std::string> > _connectionUris; mutable mongo::mutex _mutex; }; diff --git a/src/mongo/shell/shell_utils_launcher.h b/src/mongo/shell/shell_utils_launcher.h index 68046fd1867..6cb5f5687b3 100644 --- a/src/mongo/shell/shell_utils_launcher.h +++ b/src/mongo/shell/shell_utils_launcher.h @@ -92,7 +92,7 @@ namespace mongo { /** Register an unregistered pid. */ void registerPid( ProcessId pid, int output ); void deletePid( ProcessId pid ); - void getRegisteredPids( vector<ProcessId> &pids ); + void getRegisteredPids( std::vector<ProcessId> &pids ); private: std::map<int,std::pair<ProcessId,int> > _ports; @@ -118,7 +118,7 @@ namespace mongo { int port() const { return _port; } private: - boost::filesystem::path findProgram( const string &prog ); + boost::filesystem::path findProgram( const std::string &prog ); void launchProcess( int child_stdout ); std::vector<std::string> _argv; diff --git a/src/mongo/tools/mongobridge_options.h b/src/mongo/tools/mongobridge_options.h index 181bd273db4..fb71ad5354f 100644 --- a/src/mongo/tools/mongobridge_options.h +++ b/src/mongo/tools/mongobridge_options.h @@ -47,7 +47,7 @@ namespace mongo { int port; int delay; int connectTimeoutSec; - string destUri; + std::string destUri; MongoBridgeGlobalParams() : port(0), delay(0), connectTimeoutSec(15) {} }; diff --git a/src/mongo/tools/stat_util.h b/src/mongo/tools/stat_util.h index c0ba9bade37..e2ad42f1c36 100644 --- a/src/mongo/tools/stat_util.h +++ b/src/mongo/tools/stat_util.h @@ -37,14 +37,14 @@ namespace mongo { struct NamespaceInfo { - string ns; + std::string ns; // these need to be in millis long long read; long long write; - string toString() const { - stringstream ss; + std::string toString() const { + std::stringstream ss; ss << ns << " r: " << read << " w: " << write; return ss.str(); } @@ -52,7 +52,7 @@ namespace mongo { }; struct NamespaceDiff { - string ns; + std::string ns; long long read; long long write; @@ -70,7 +70,7 @@ namespace mongo { } }; - typedef map<string,NamespaceInfo> NamespaceStats; + typedef std::map<std::string,NamespaceInfo> NamespaceStats; /** * static methods useful for computing status from serverStatus type things @@ -96,20 +96,20 @@ namespace mongo { void setAll( bool all ) { _all = all; } static NamespaceStats parseServerStatusLocks( const BSONObj& serverStatus ); - static vector<NamespaceDiff> computeDiff( const NamespaceStats& prev , const NamespaceStats& current ); + static std::vector<NamespaceDiff> computeDiff( const NamespaceStats& prev , const NamespaceStats& current ); private: double percent( const char * outof , const char * val , const BSONObj& a , const BSONObj& b ); - double diff( const string& name , const BSONObj& a , const BSONObj& b ); + double diff( const std::string& name , const BSONObj& a , const BSONObj& b ); - void _appendMem( BSONObjBuilder& result , const string& name , unsigned width , double sz ); + void _appendMem( BSONObjBuilder& result , const std::string& name , unsigned width , double sz ); - void _appendNet( BSONObjBuilder& result , const string& name , double diff ); + void _appendNet( BSONObjBuilder& result , const std::string& name , double diff ); template<typename T> - void _append( BSONObjBuilder& result , const string& name , unsigned width , const T& t ) { + void _append( BSONObjBuilder& result , const std::string& name , unsigned width , const T& t ) { if ( name.size() > width ) width = name.size(); result.append( name , BSON( "width" << (int)width << "data" << t ) ); diff --git a/src/mongo/tools/tool.h b/src/mongo/tools/tool.h index 6e62f151dce..c63188e40d5 100644 --- a/src/mongo/tools/tool.h +++ b/src/mongo/tools/tool.h @@ -51,26 +51,26 @@ namespace mongo { Tool(); virtual ~Tool(); - static auto_ptr<Tool> (*createInstance)(); + static std::auto_ptr<Tool> (*createInstance)(); int main( int argc , char ** argv, char ** envp ); - string getNS() { + std::string getNS() { if (toolGlobalParams.coll.size() == 0) { - cerr << "no collection specified!" << endl; + cerr << "no collection specified!" << std::endl; throw -1; } return toolGlobalParams.db + "." + toolGlobalParams.coll; } - string getAuthenticationDatabase(); + std::string getAuthenticationDatabase(); bool isMaster(); bool isMongos(); virtual int run() = 0; - virtual void printHelp(ostream &out) = 0; + virtual void printHelp(std::ostream &out) = 0; protected: @@ -88,7 +88,7 @@ namespace mongo { }; class BSONTool : public Tool { - auto_ptr<Matcher> _matcher; + std::auto_ptr<Matcher> _matcher; public: BSONTool(); @@ -105,5 +105,5 @@ namespace mongo { } #define REGISTER_MONGO_TOOL(TYPENAME) \ - auto_ptr<Tool> createInstanceOfThisTool() {return auto_ptr<Tool>(new TYPENAME());} \ - auto_ptr<Tool> (*Tool::createInstance)() = createInstanceOfThisTool; + std::auto_ptr<Tool> createInstanceOfThisTool() {return std::auto_ptr<Tool>(new TYPENAME());} \ + std::auto_ptr<Tool> (*Tool::createInstance)() = createInstanceOfThisTool; diff --git a/src/mongo/tools/tool_options.h b/src/mongo/tools/tool_options.h index 6644a0de58c..f93cb03f7e7 100644 --- a/src/mongo/tools/tool_options.h +++ b/src/mongo/tools/tool_options.h @@ -98,7 +98,7 @@ namespace mongo { // Legacy interface for getting options in tools // TODO: Remove this when we use the new interface everywhere - std::string getParam(std::string name, string def=""); + std::string getParam(std::string name, std::string def=""); int getParam(std::string name, int def); bool hasParam(std::string name); diff --git a/src/mongo/unittest/unittest.h b/src/mongo/unittest/unittest.h index 72d94e2f266..69849fca5f9 100644 --- a/src/mongo/unittest/unittest.h +++ b/src/mongo/unittest/unittest.h @@ -265,7 +265,7 @@ namespace mongo { */ class Suite : private boost::noncopyable { public: - Suite( const string& name ); + Suite( const std::string& name ); virtual ~Suite(); template<class T> @@ -293,7 +293,7 @@ namespace mongo { * The implementation of this function must be safe to call during the global static * initialization block before main() executes. */ - static Suite *getSuite(const string& name); + static Suite *getSuite(const std::string& name); protected: virtual void setupTests(); @@ -367,7 +367,7 @@ namespace mongo { public: /** - * file string must stay in scope and remain unchanged for the lifetime + * file std::string must stay in scope and remain unchanged for the lifetime * of the TestAssertion object. */ TestAssertion( const char* file, unsigned line ); diff --git a/src/mongo/util/array.h b/src/mongo/util/array.h index 2676317e595..9c2536eb887 100644 --- a/src/mongo/util/array.h +++ b/src/mongo/util/array.h @@ -105,8 +105,8 @@ namespace mongo { return _it->_data[_pos]; } - string toString() const { - stringstream ss; + std::string toString() const { + std::stringstream ss; ss << _pos; return ss.str(); } diff --git a/src/mongo/util/assert_util.h b/src/mongo/util/assert_util.h index c154482dc36..6ce577562fa 100644 --- a/src/mongo/util/assert_util.h +++ b/src/mongo/util/assert_util.h @@ -279,7 +279,7 @@ namespace mongo { try { \ expression; \ } catch ( const std::exception &e ) { \ - stringstream ss; \ + std::stringstream ss; \ ss << "caught exception: " << e.what() << ' ' << __FILE__ << ' ' << __LINE__; \ msgasserted( 13294 , ss.str() ); \ } catch ( ... ) { \ @@ -290,7 +290,7 @@ namespace mongo { try { \ expression; \ } catch ( const std::exception &e ) { \ - stringstream ss; \ + std::stringstream ss; \ ss << msg << " caught exception exception: " << e.what(); \ msgasserted( 14043 , ss.str() ); \ } catch ( ... ) { \ diff --git a/src/mongo/util/background.h b/src/mongo/util/background.h index 23ec9fbd0f5..fa6a55f5a6a 100644 --- a/src/mongo/util/background.h +++ b/src/mongo/util/background.h @@ -138,7 +138,7 @@ namespace mongo { * class MyTask : public PeriodicTask { * public: * virtual std::string name() const { return "MyTask; " } - * virtual void doWork() { log() << "hi" << endl; } + * virtual void doWork() { log() << "hi" << std::endl; } * } myTask; */ class PeriodicTask { diff --git a/src/mongo/util/base64.h b/src/mongo/util/base64.h index 7412cfadb28..3d56a7f4fc1 100644 --- a/src/mongo/util/base64.h +++ b/src/mongo/util/base64.h @@ -67,12 +67,12 @@ namespace mongo { extern Alphabet alphabet; - void encode( stringstream& ss , const char * data , int size ); - string encode( const char * data , int size ); - string encode( const string& s ); + void encode( std::stringstream& ss , const char * data , int size ); + std::string encode( const char * data , int size ); + std::string encode( const std::string& s ); - void decode( stringstream& ss , const string& s ); - string decode( const string& s ); + void decode( std::stringstream& ss , const std::string& s ); + std::string decode( const std::string& s ); extern const char* chars; diff --git a/src/mongo/util/bson_util.h b/src/mongo/util/bson_util.h index 6b0f927e2f9..b4b4bae30b2 100644 --- a/src/mongo/util/bson_util.h +++ b/src/mongo/util/bson_util.h @@ -34,13 +34,13 @@ namespace mongo { template <typename T> -void bsonArrToNumVector(BSONElement el, vector<T>& results){ +void bsonArrToNumVector(BSONElement el, std::vector<T>& results){ if(el.type() == Array){ vector<BSONElement> elements = el.Array(); - for(vector<BSONElement>::iterator i = elements.begin(); i != elements.end(); ++i){ + for(std::vector<BSONElement>::iterator i = elements.begin(); i != elements.end(); ++i){ results.push_back( (T) (*i).Number() ); } } diff --git a/src/mongo/util/bufreader.h b/src/mongo/util/bufreader.h index 0451dbd29c5..2afb66c3c7a 100644 --- a/src/mongo/util/bufreader.h +++ b/src/mongo/util/bufreader.h @@ -118,7 +118,7 @@ namespace mongo { return StringData(start, len); } - void readStr(string& s) { + void readStr(std::string& s) { s = readCStr().toString(); } diff --git a/src/mongo/util/concurrency/mapsf.h b/src/mongo/util/concurrency/mapsf.h index 6152e841cc7..b57caf6bbbb 100644 --- a/src/mongo/util/concurrency/mapsf.h +++ b/src/mongo/util/concurrency/mapsf.h @@ -37,17 +37,17 @@ namespace mongo { if not a hot code path no problem. Examples: - mapsf< map<int,int>, int, int > mp; + mapsf< std::map<int,int>, int, int > mp; int x = mp.get(); - map< map<int,int>, int, int > two; + std::map< std::map<int,int>, int, int > two; mp.swap(two); { - mapsf< map<int,int>, int, int >::ref r(mp); + mapsf< std::map<int,int>, int, int >::ref r(mp); r[9] = 1; - map<int,int>::iterator i = r.r.begin(); + std::map<int,int>::iterator i = r.r.begin(); } */ template< class M > diff --git a/src/mongo/util/concurrency/mutex.h b/src/mongo/util/concurrency/mutex.h index 289051c5f48..acdcf71a85b 100644 --- a/src/mongo/util/concurrency/mutex.h +++ b/src/mongo/util/concurrency/mutex.h @@ -46,7 +46,7 @@ #include "mongo/util/concurrency/mutexdebugger.h" #endif -// Macro to get line as a string constant +// Macro to get line as a std::string constant #define MONGO_STRINGIFY(X) #X // Double-expansion trick to get preproc to actually substitute __LINE__ #define _MONGO_LINE_STRING(LINE) MONGO_STRINGIFY( LINE ) diff --git a/src/mongo/util/concurrency/race.h b/src/mongo/util/concurrency/race.h index 14de06538ed..2e372d2b854 100644 --- a/src/mongo/util/concurrency/race.h +++ b/src/mongo/util/concurrency/race.h @@ -48,11 +48,11 @@ namespace mongo { class Block { volatile int n; unsigned ncalls; - const string file; + const std::string file; const unsigned line; void fail() { log() << "\n\n\nrace: synchronization (race condition) failure\ncurrent locks this thread (" << getThreadName() << "):" << std::endl - << mutexDebugger.currentlyLocked() << std::endl; + << mutexDebugger.currentlyLocked(); printStackTrace(); ::abort(); } diff --git a/src/mongo/util/concurrency/simplerwlock.h b/src/mongo/util/concurrency/simplerwlock.h index 5e094bafeb1..289c422606d 100644 --- a/src/mongo/util/concurrency/simplerwlock.h +++ b/src/mongo/util/concurrency/simplerwlock.h @@ -48,7 +48,7 @@ namespace mongo { unsigned tid; #endif public: - const string name; + const std::string name; SimpleRWLock(const StringData& name = "" ); void lock(); void unlock(); diff --git a/src/mongo/util/concurrency/task.h b/src/mongo/util/concurrency/task.h index 0679ca89fe7..9eec42f85bc 100644 --- a/src/mongo/util/concurrency/task.h +++ b/src/mongo/util/concurrency/task.h @@ -43,7 +43,7 @@ namespace mongo { protected: virtual void setUp(); // Override to perform any do-once work for the task. virtual void doWork() = 0; // implement the task here. - virtual string name() const = 0; // name the thread + virtual std::string name() const = 0; // name the thread public: Task(); @@ -76,7 +76,7 @@ namespace mongo { }; shared_ptr<Sample> q( new Sample() ); fork(q); - cout << q->result << endl; // could print 1234 or 0. + cout << q->result << std::endl; // could print 1234 or 0. } */ diff --git a/src/mongo/util/concurrency/value.h b/src/mongo/util/concurrency/value.h index 0e451f05a36..5dc15684c8a 100644 --- a/src/mongo/util/concurrency/value.h +++ b/src/mongo/util/concurrency/value.h @@ -42,16 +42,16 @@ namespace mongo { */ class DiagStr { mutable SpinLock m; - string _s; + std::string _s; public: DiagStr(const DiagStr& r) : _s(r.get()) { } - DiagStr(const string& r) : _s(r) { } + DiagStr(const std::string& r) : _s(r) { } DiagStr() { } bool empty() const { scoped_spinlock lk(m); return _s.empty(); } - string get() const { + std::string get() const { scoped_spinlock lk(m); return _s; } @@ -59,18 +59,18 @@ namespace mongo { scoped_spinlock lk(m); _s = s; } - void set(const string& s) { + void set(const std::string& s) { scoped_spinlock lk(m); _s = s; } - operator string() const { return get(); } - void operator=(const string& s) { set(s); } + operator std::string() const { return get(); } + void operator=(const std::string& s) { set(s); } void operator=(const DiagStr& rhs) { set( rhs.get() ); } // == is not defined. use get() == ... instead. done this way so one thinks about if composing multiple operations - bool operator==(const string& s) const; + bool operator==(const std::string& s) const; }; } diff --git a/src/mongo/util/embedded_builder.h b/src/mongo/util/embedded_builder.h index 32632d13764..7cb9671b1dd 100644 --- a/src/mongo/util/embedded_builder.h +++ b/src/mongo/util/embedded_builder.h @@ -35,11 +35,11 @@ namespace mongo { class EmbeddedBuilder { public: EmbeddedBuilder( BSONObjBuilder *b ) { - _builders.push_back( make_pair( "", b ) ); + _builders.push_back( std::make_pair( "", b ) ); } // It is assumed that the calls to prepareContext will be made with the 'name' // parameter in lex ascending order. - void prepareContext( string &name ) { + void prepareContext( std::string &name ) { int i = 1, n = _builders.size(); while( i < n && name.substr( 0, _builders[ i ].first.length() ) == _builders[ i ].first && @@ -51,20 +51,20 @@ namespace mongo { for( int j = n - 1; j >= i; --j ) { popBuilder(); } - for( string next = splitDot( name ); !next.empty(); next = splitDot( name ) ) { + for( std::string next = splitDot( name ); !next.empty(); next = splitDot( name ) ) { addBuilder( next ); } } - void appendAs( const BSONElement &e, string name ) { + void appendAs( const BSONElement &e, std::string name ) { if ( e.type() == Object && e.valuesize() == 5 ) { // empty object -- this way we can add to it later - string dummyName = name + ".foo"; + std::string dummyName = name + ".foo"; prepareContext( dummyName ); return; } prepareContext( name ); back()->appendAs( e, name ); } - BufBuilder &subarrayStartAs( string name ) { + BufBuilder &subarrayStartAs( std::string name ) { prepareContext( name ); return back()->subarrayStart( name ); } @@ -73,19 +73,19 @@ namespace mongo { popBuilder(); } - static string splitDot( string & str ) { + static std::string splitDot( std::string & str ) { size_t pos = str.find( '.' ); - if ( pos == string::npos ) + if ( pos == std::string::npos ) return ""; - string ret = str.substr( 0, pos ); + std::string ret = str.substr( 0, pos ); str = str.substr( pos + 1 ); return ret; } private: - void addBuilder( const string &name ) { + void addBuilder( const std::string &name ) { shared_ptr< BSONObjBuilder > newBuilder( new BSONObjBuilder( back()->subobjStart( name ) ) ); - _builders.push_back( make_pair( name, newBuilder.get() ) ); + _builders.push_back( std::make_pair( name, newBuilder.get() ) ); _builderStorage.push_back( newBuilder ); } void popBuilder() { @@ -96,8 +96,8 @@ namespace mongo { BSONObjBuilder *back() { return _builders.back().second; } - vector< pair< string, BSONObjBuilder * > > _builders; - vector< shared_ptr< BSONObjBuilder > > _builderStorage; + std::vector< std::pair< std::string, BSONObjBuilder * > > _builders; + std::vector< shared_ptr< BSONObjBuilder > > _builderStorage; }; diff --git a/src/mongo/util/file_allocator.h b/src/mongo/util/file_allocator.h index ac69879b04f..99710a06e9b 100644 --- a/src/mongo/util/file_allocator.h +++ b/src/mongo/util/file_allocator.h @@ -55,14 +55,14 @@ namespace mongo { * May be called if file exists. If file exists, or its allocation has * been requested, size is updated to match existing file size. */ - void requestAllocation( const string &name, long &size ); + void requestAllocation( const std::string &name, long &size ); /** * Returns when file has been allocated. If file exists, size is * updated to match existing file size. */ - void allocateAsap( const string &name, unsigned long long &size ); + void allocateAsap( const std::string &name, unsigned long long &size ); void waitUntilFinished() const; @@ -81,22 +81,22 @@ namespace mongo { // caller must hold pendingMutex_ lock. Returns size if allocated or // allocation requested, -1 otherwise. - long prevSize( const string &name ) const; + long prevSize( const std::string &name ) const; // caller must hold pendingMutex_ lock. - bool inProgress( const string &name ) const; + bool inProgress( const std::string &name ) const; /** called from the worked thread */ static void run( FileAllocator * fa ); // generate a unique name for temporary files - string makeTempFileName( boost::filesystem::path root ); + std::string makeTempFileName( boost::filesystem::path root ); mutable mongo::mutex _pendingMutex; mutable boost::condition _pendingUpdated; - std::list< string > _pending; - mutable map< string, long > _pendingSize; + std::list< std::string > _pending; + mutable std::map< std::string, long > _pendingSize; // unique number for temporary files static unsigned long long _uniqueNumber; diff --git a/src/mongo/util/goodies.h b/src/mongo/util/goodies.h index 3b69f5b278a..67b8d14b89f 100644 --- a/src/mongo/util/goodies.h +++ b/src/mongo/util/goodies.h @@ -45,10 +45,10 @@ namespace mongo { /* @return a dump of the buffer as hex byte ascii output */ - string hexdump(const char *data, unsigned len); + std::string hexdump(const char *data, unsigned len); template<class T> - inline string ToString(const T& t) { + inline std::string ToString(const T& t) { std::stringstream s; s << t; return s.str(); @@ -154,8 +154,8 @@ namespace mongo { delete[] _buf; } - string toString() const { - string s = _buf; + std::string toString() const { + std::string s = _buf; return s; } @@ -196,7 +196,7 @@ namespace mongo { template<typename U> ptr(const ptr<U>& p) : _p(p) {} template<typename U> ptr(const boost::shared_ptr<U>& p) : _p(p.get()) {} template<typename U> ptr(const boost::scoped_ptr<U>& p) : _p(p.get()) {} - //template<typename U> ptr(const auto_ptr<U>& p) : _p(p.get()) {} + //template<typename U> ptr(const std::auto_ptr<U>& p) : _p(p.get()) {} // assign to ptr<T> ptr& operator= (T* p) { _p = p; return *this; } // needed for NULL @@ -204,7 +204,7 @@ namespace mongo { template<typename U> ptr& operator= (const ptr<U>& p) { _p = p; return *this; } template<typename U> ptr& operator= (const boost::shared_ptr<U>& p) { _p = p.get(); return *this; } template<typename U> ptr& operator= (const boost::scoped_ptr<U>& p) { _p = p.get(); return *this; } - //template<typename U> ptr& operator= (const auto_ptr<U>& p) { _p = p.get(); return *this; } + //template<typename U> ptr& operator= (const std::auto_ptr<U>& p) { _p = p.get(); return *this; } // use T* operator->() const { return _p; } diff --git a/src/mongo/util/histogram.h b/src/mongo/util/histogram.h index 3e2630c0807..c5c4b8d6a11 100644 --- a/src/mongo/util/histogram.h +++ b/src/mongo/util/histogram.h @@ -88,7 +88,7 @@ namespace mongo { void insert( uint32_t element ); /** - * Render the histogram as string that can be used inside an + * Render the histogram as std::string that can be used inside an * HTML doc. */ std::string toHTML() const; diff --git a/src/mongo/util/log.h b/src/mongo/util/log.h index cae0e8add5d..39ec810ae65 100644 --- a/src/mongo/util/log.h +++ b/src/mongo/util/log.h @@ -122,7 +122,7 @@ namespace logger { /** output the error # and error message with prefix. handy for use as parm in uassert/massert. */ - string errnoWithPrefix( const char * prefix ); + std::string errnoWithPrefix( const char * prefix ); // Guard that alters the indentation level used by log messages on the current thread. // Used only by mongodump (mongo/tools/dump.cpp). Do not introduce new uses. @@ -134,7 +134,7 @@ namespace logger { extern Tee* const warnings; // Things put here go in serverStatus extern Tee* const startupWarningsLog; // Things put here get reported in MMS - string errnoWithDescription(int errorcode = -1); + std::string errnoWithDescription(int errorcode = -1); /** * Write the current context (backtrace), along with the optional "msg". diff --git a/src/mongo/util/logfile.h b/src/mongo/util/logfile.h index 62b3c2e9c4a..21d955252f0 100644 --- a/src/mongo/util/logfile.h +++ b/src/mongo/util/logfile.h @@ -55,7 +55,7 @@ namespace mongo { void readAt(unsigned long long offset, void *_buf, size_t _len); - const string _name; + const std::string _name; void truncate(); // Removes extra data after current position diff --git a/src/mongo/util/md5.h b/src/mongo/util/md5.h index 0fbf70308fe..074f6c704de 100644 --- a/src/mongo/util/md5.h +++ b/src/mongo/util/md5.h @@ -81,7 +81,7 @@ extern "C" /* Initialize the algorithm. */ void md5_init(md5_state_t *pms); - /* Append a string to the message. */ + /* Append a std::string to the message. */ void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes); /* Finish the message and return the digest. */ diff --git a/src/mongo/util/mmap.h b/src/mongo/util/mmap.h index 74df77364fe..f23b503f00e 100644 --- a/src/mongo/util/mmap.h +++ b/src/mongo/util/mmap.h @@ -124,13 +124,13 @@ namespace mongo { virtual bool isDurableMappedFile() { return false; } - string filename() const { return _filename; } + std::string filename() const { return _filename; } void setFilename(const std::string& fn); virtual uint64_t getUniqueId() const = 0; private: - string _filename; + std::string _filename; static int _flushAll( bool sync ); // returns n flushed protected: virtual void close() = 0; diff --git a/src/mongo/util/mongoutils/html.h b/src/mongo/util/mongoutils/html.h index 563440ffd1b..78bcc49ec55 100644 --- a/src/mongo/util/mongoutils/html.h +++ b/src/mongo/util/mongoutils/html.h @@ -43,42 +43,40 @@ namespace mongoutils { namespace html { - using namespace std; + inline std::string _end() { return "</body></html>"; } + inline std::string _table() { return "</table>\n\n"; } + inline std::string _tr() { return "</tr>\n"; } - inline string _end() { return "</body></html>"; } - inline string _table() { return "</table>\n\n"; } - inline string _tr() { return "</tr>\n"; } - - inline string tr() { return "<tr>"; } - inline string tr(const std::string& a, const std::string& b) { - stringstream ss; + inline std::string tr() { return "<tr>"; } + inline std::string tr(const std::string& a, const std::string& b) { + std::stringstream ss; ss << "<tr><td>" << a << "</td><td>" << b << "</td></tr>\n"; return ss.str(); } template <class T> - inline string td(T x) { - stringstream ss; + inline std::string td(T x) { + std::stringstream ss; ss << "<td>" << x << "</td>"; return ss.str(); } - inline string td(const std::string& x) { + inline std::string td(const std::string& x) { return "<td>" + x + "</td>"; } - inline string th(const std::string& x) { + inline std::string th(const std::string& x) { return "<th>" + x + "</th>"; } - inline void tablecell( stringstream& ss , bool b ) { + inline void tablecell( std::stringstream& ss , bool b ) { ss << "<td>" << (b ? "<b>X</b>" : "") << "</td>"; } template< typename T> - inline void tablecell( stringstream& ss , const T& t ) { + inline void tablecell( std::stringstream& ss , const T& t ) { ss << "<td>" << t << "</td>"; } - inline string table(const char *headers[] = 0, bool border = true) { - stringstream ss; + inline std::string table(const char *headers[] = 0, bool border = true) { + std::stringstream ss; ss << "\n<table " << (border?"border=1 ":"") << "cellpadding=2 cellspacing=0>\n"; @@ -93,8 +91,8 @@ namespace mongoutils { return ss.str(); } - inline string start(const std::string& title) { - stringstream ss; + inline std::string start(const std::string& title) { + std::stringstream ss; ss << "<html><head>\n<title>"; ss << title; ss << "</title>\n"; @@ -110,54 +108,54 @@ namespace mongoutils { return ss.str(); } - inline string red(const std::string& contentHtml, bool color=true) { + inline std::string red(const std::string& contentHtml, bool color=true) { if( !color ) return contentHtml; - stringstream ss; + std::stringstream ss; ss << "<span style=\"color:#A00;\">" << contentHtml << "</span>"; return ss.str(); } - inline string grey(const std::string& contentHtml, bool color=true) { + inline std::string grey(const std::string& contentHtml, bool color=true) { if( !color ) return contentHtml; - stringstream ss; + std::stringstream ss; ss << "<span style=\"color:#888;\">" << contentHtml << "</span>"; return ss.str(); } - inline string blue(const std::string& contentHtml, bool color=true) { + inline std::string blue(const std::string& contentHtml, bool color=true) { if( !color ) return contentHtml; - stringstream ss; + std::stringstream ss; ss << "<span style=\"color:#00A;\">" << contentHtml << "</span>"; return ss.str(); } - inline string yellow(const std::string& contentHtml, bool color=true) { + inline std::string yellow(const std::string& contentHtml, bool color=true) { if( !color ) return contentHtml; - stringstream ss; + std::stringstream ss; ss << "<span style=\"color:#A80;\">" << contentHtml << "</span>"; return ss.str(); } - inline string green(const std::string& contentHtml, bool color=true) { + inline std::string green(const std::string& contentHtml, bool color=true) { if( !color ) return contentHtml; - stringstream ss; + std::stringstream ss; ss << "<span style=\"color:#0A0;\">" << contentHtml << "</span>"; return ss.str(); } - inline string p(const std::string& contentHtml) { - stringstream ss; + inline std::string p(const std::string& contentHtml) { + std::stringstream ss; ss << "<p>" << contentHtml << "</p>\n"; return ss.str(); } - inline string h2(const std::string& contentHtml) { - stringstream ss; + inline std::string h2(const std::string& contentHtml) { + std::stringstream ss; ss << "<h2>" << contentHtml << "</h2>\n"; return ss.str(); } /* does NOT escape the strings. */ - inline string a(const std::string& href, + inline std::string a(const std::string& href, const std::string& title="", const std::string& contentHtml = "") { - stringstream ss; + std::stringstream ss; ss << "<a"; if( !href.empty() ) ss << " href=\"" << href << '"'; if( !title.empty() ) ss << " title=\"" << title << '"'; @@ -169,8 +167,8 @@ namespace mongoutils { } /* escape for HTML display */ - inline string escape(const string& data) { - string buffer; + inline std::string escape(const std::string& data) { + std::string buffer; buffer.reserve( data.size() ); for( size_t pos = 0; pos != data.size(); ++pos ) { switch( data[pos] ) { diff --git a/src/mongo/util/mongoutils/str.h b/src/mongo/util/mongoutils/str.h index 816327928e3..1fbb69fe23b 100644 --- a/src/mongo/util/mongoutils/str.h +++ b/src/mongo/util/mongoutils/str.h @@ -55,7 +55,7 @@ namespace mongoutils { since the following doesn't work: - (stringstream() << 1).str(); + (std::stringstream() << 1).str(); */ class stream { public: @@ -98,7 +98,7 @@ namespace mongoutils { inline bool equals( const char * a , const char * b ) { return strcmp( a , b ) == 0; } - /** find char x, and return rest of string thereafter, or "" if not found */ + /** find char x, and return rest of std::string thereafter, or "" if not found */ inline const char * after(const char *s, char x) { const char *p = strchr(s, x); return (p != 0) ? p+1 : ""; @@ -108,7 +108,7 @@ namespace mongoutils { return (p != 0) ? std::string(p+1) : ""; } - /** find string x, and return rest of string thereafter, or "" if not found */ + /** find std::string x, and return rest of std::string thereafter, or "" if not found */ inline const char * after(const char *s, const char *x) { const char *p = strstr(s, x); return (p != 0) ? p+strlen(x) : ""; @@ -129,13 +129,13 @@ namespace mongoutils { return strchr(s.c_str(), x) != 0; } - /** @return everything before the character x, else entire string */ + /** @return everything before the character x, else entire std::string */ inline std::string before(const std::string& s, char x) { const char *p = strchr(s.c_str(), x); return (p != 0) ? s.substr(0, p-s.c_str()) : s; } - /** @return everything before the string x, else entire string */ + /** @return everything before the std::string x, else entire std::string */ inline std::string before(const std::string& s, const std::string& x) { const char *p = strstr(s.c_str(), x.c_str()); return (p != 0) ? s.substr(0, p-s.c_str()) : s; @@ -157,7 +157,7 @@ namespace mongoutils { inline int shareCommonPrefix(const std::string &a, const std::string &b) { return shareCommonPrefix(a.c_str(), b.c_str()); } - /** string to unsigned. zero if not a number. can end with non-num chars */ + /** std::string to unsigned. zero if not a number. can end with non-num chars */ inline unsigned toUnsigned(const std::string& a) { unsigned x = 0; const char *p = a.c_str(); @@ -170,8 +170,8 @@ namespace mongoutils { return x; } - /** split a string on a specific char. We don't split N times, just once - on the first occurrence. If char not present entire string is in L + /** split a std::string on a specific char. We don't split N times, just once + on the first occurrence. If char not present entire std::string is in L and R is empty. @return true if char found */ diff --git a/src/mongo/util/net/hostandport.h b/src/mongo/util/net/hostandport.h index 96c926e8e47..3cc139a9476 100644 --- a/src/mongo/util/net/hostandport.h +++ b/src/mongo/util/net/hostandport.h @@ -43,8 +43,8 @@ namespace mongo { struct HostAndPort { HostAndPort() : _port(-1) { } - /** From a string hostname[:portnumber] - Throws user assertion if bad config string or bad port #. + /** From a std::string hostname[:portnumber] + Throws user assertion if bad config std::string or bad port #. */ HostAndPort(const std::string& s); @@ -78,16 +78,16 @@ namespace mongo { /** * @param includePort host:port if true, host otherwise */ - string toString( bool includePort=true ) const; + std::string toString( bool includePort=true ) const; - operator string() const { return toString(); } + operator std::string() const { return toString(); } void append( StringBuilder& ss ) const; bool empty() const { return _host.empty() && _port < 0; } - const string& host() const { + const std::string& host() const { return _host; } int port() const { @@ -104,21 +104,21 @@ namespace mongo { private: void init(const char *); - string _host; + std::string _host; int _port; // -1 indicates unspecified }; inline HostAndPort HostAndPort::me() { const char* ips = serverGlobalParams.bind_ip.c_str(); while(*ips) { - string ip; + std::string ip; const char * comma = strchr(ips, ','); if (comma) { - ip = string(ips, comma - ips); + ip = std::string(ips, comma - ips); ips = comma + 1; } else { - ip = string(ips); + ip = std::string(ips); ips = ""; } HostAndPort h = HostAndPort(ip, serverGlobalParams.port); @@ -127,13 +127,13 @@ namespace mongo { } } - string h = getHostName(); + std::string h = getHostName(); verify( !h.empty() ); verify( h != "localhost" ); return HostAndPort(h, serverGlobalParams.port); } - inline string HostAndPort::toString( bool includePort ) const { + inline std::string HostAndPort::toString( bool includePort ) const { if ( ! includePort ) return host(); @@ -165,7 +165,7 @@ namespace mongo { inline bool HostAndPort::isLocalHost() const { - string _host = host(); + std::string _host = host(); return ( _host == "localhost" || mongoutils::str::startsWith(_host.c_str(), "127.") || _host == "::1" @@ -180,7 +180,7 @@ namespace mongo { if( colon ) { int port = atoi(colon+1); massert(13095, "HostAndPort: bad port #", port > 0); - _host = string(p,colon-p); + _host = std::string(p,colon-p); _port = port; } else { diff --git a/src/mongo/util/net/httpclient.h b/src/mongo/util/net/httpclient.h index b9e37bec462..ade84d03307 100644 --- a/src/mongo/util/net/httpclient.h +++ b/src/mongo/util/net/httpclient.h @@ -37,13 +37,13 @@ namespace mongo { class MONGO_CLIENT_API HttpClient : boost::noncopyable { public: - typedef map<string,string> Headers; + typedef std::map<std::string,std::string> Headers; class MONGO_CLIENT_API Result { public: Result() {} - const string& getEntireResponse() const { + const std::string& getEntireResponse() const { return _entireResponse; } @@ -51,19 +51,19 @@ namespace mongo { return _headers; } - const string& getBody() const { + const std::string& getBody() const { return _body; } private: - void _init( int code , string entire ); + void _init( int code , std::string entire ); int _code; - string _entireResponse; + std::string _entireResponse; Headers _headers; - string _body; + std::string _body; friend class HttpClient; }; @@ -79,6 +79,6 @@ namespace mongo { int post( const std::string& url , const std::string& body , Result * result = 0 ); private: - int _go( const char * command , string url , const char * body , Result * result ); + int _go( const char * command , std::string url , const char * body , Result * result ); }; } diff --git a/src/mongo/util/net/message.h b/src/mongo/util/net/message.h index ad3a0e85cc8..8366bfab5ff 100644 --- a/src/mongo/util/net/message.h +++ b/src/mongo/util/net/message.h @@ -52,7 +52,7 @@ namespace mongo { enum Operations { opReply = 1, /* reply. responseTo is set. */ - dbMsg = 1000, /* generic msg command followed by a string */ + dbMsg = 1000, /* generic msg command followed by a std::string */ dbUpdate = 2001, /* update object */ dbInsert = 2002, //dbGetByOID = 2003, @@ -306,7 +306,7 @@ namespace mongo { void send( MessagingPort &p, const char *context ); - string toString() const; + std::string toString() const; private: void _setData( MsgData *d, bool freeIt ) { diff --git a/src/mongo/util/net/message_server.h b/src/mongo/util/net/message_server.h index bfcf30c7d9f..1f698fede7e 100644 --- a/src/mongo/util/net/message_server.h +++ b/src/mongo/util/net/message_server.h @@ -65,7 +65,7 @@ namespace mongo { public: struct Options { int port; // port to bind to - string ipList; // addresses to bind to + std::string ipList; // addresses to bind to Options() : port(0), ipList("") {} }; diff --git a/src/mongo/util/net/miniwebserver.h b/src/mongo/util/net/miniwebserver.h index f960a76eb28..645db42746f 100644 --- a/src/mongo/util/net/miniwebserver.h +++ b/src/mongo/util/net/miniwebserver.h @@ -40,30 +40,30 @@ namespace mongo { class MiniWebServer : public Listener { public: - MiniWebServer(const string& name, const string &ip, int _port); + MiniWebServer(const std::string& name, const std::string &ip, int _port); virtual ~MiniWebServer() {} virtual void doRequest( const char *rq, // the full request - string url, + std::string url, // set these and return them: - string& responseMsg, + std::string& responseMsg, int& responseCode, - vector<string>& headers, // if completely empty, content-type: text/html will be added + std::vector<std::string>& headers, // if completely empty, content-type: text/html will be added const SockAddr &from ) = 0; // --- static helpers ---- - static void parseParams( BSONObj & params , string query ); + static void parseParams( BSONObj & params , std::string query ); - static string parseURL( const char * buf ); - static string parseMethod( const char * headers ); - static string getHeader( const char * headers , const std::string& name ); + static std::string parseURL( const char * buf ); + static std::string parseMethod( const char * headers ); + static std::string getHeader( const char * headers , const std::string& name ); static const char *body( const char *buf ); - static string urlDecode(const char* s); - static string urlDecode(const std::string& s) {return urlDecode(s.c_str());} + static std::string urlDecode(const char* s); + static std::string urlDecode(const std::string& s) {return urlDecode(s.c_str());} private: void accepted(boost::shared_ptr<Socket> psocket, long long connectionId ); diff --git a/src/mongo/util/net/ssl_manager.h b/src/mongo/util/net/ssl_manager.h index ef3c0352098..8e8419e1894 100644 --- a/src/mongo/util/net/ssl_manager.h +++ b/src/mongo/util/net/ssl_manager.h @@ -40,7 +40,7 @@ namespace mongo { /* - * @return the SSL version string prefixed with prefix and suffixed with suffix + * @return the SSL version std::string prefixed with prefix and suffixed with suffix */ const std::string getSSLVersion(const std::string &prefix, const std::string &suffix); } diff --git a/src/mongo/util/options_parser/constraints.h b/src/mongo/util/options_parser/constraints.h index 14bdc3387e0..4f9b0244b61 100644 --- a/src/mongo/util/options_parser/constraints.h +++ b/src/mongo/util/options_parser/constraints.h @@ -126,8 +126,8 @@ namespace optionenvironment { Key _otherKey; }; - /** Implementation of a Constraint that enforces a specific format on a string value. Fails if - * the value of the key is not a string or does not match the given regex. + /** Implementation of a Constraint that enforces a specific format on a std::string value. Fails if + * the value of the key is not a std::string or does not match the given regex. */ class StringFormatKeyConstraint : public KeyConstraint { public: diff --git a/src/mongo/util/options_parser/option_description.h b/src/mongo/util/options_parser/option_description.h index 45a135d8b4a..8d9d3794eb8 100644 --- a/src/mongo/util/options_parser/option_description.h +++ b/src/mongo/util/options_parser/option_description.h @@ -179,7 +179,7 @@ namespace optionenvironment { OptionDescription& validRange(long min, long max); /** - * Specifies that this option is incompatible with another option. The string provided must + * Specifies that this option is incompatible with another option. The std::string provided must * be the dottedName, which is the name used to access the option in the result Environment. * * TODO: Find a way to check that that option actually exists in our section somewhere. @@ -196,7 +196,7 @@ namespace optionenvironment { /** * Specifies that this option is required to match the given format, specified as a regular * expression. The displayFormat argument is what gets printed to the user in the case - * where this constraint is not satisfied. This is only allowed on String options. + * where this constraint is not satisfied. This is only allowed on std::string options. */ OptionDescription& format(const std::string& regexFormat, const std::string& displayFormat); diff --git a/src/mongo/util/options_parser/option_section.h b/src/mongo/util/options_parser/option_section.h index 84169bca119..63d75c852c8 100644 --- a/src/mongo/util/options_parser/option_section.h +++ b/src/mongo/util/options_parser/option_section.h @@ -71,7 +71,7 @@ namespace optionenvironment { * // Run the parser * Status ret = parser.run(options, argc, argv, envp, &environment); * if (!ret.isOK()) { - * cerr << options.helpString() << endl; + * cerr << options.helpString() << std::endl; * exit(EXIT_FAILURE); * } */ @@ -85,7 +85,7 @@ namespace optionenvironment { /** * Add a sub section to this section. Used mainly to keep track of section headers for when - * we need generate the help string for the command line + * we need generate the help std::string for the command line */ Status addSection(const OptionSection& subSection); diff --git a/src/mongo/util/options_parser/options_parser.h b/src/mongo/util/options_parser/options_parser.h index 7ab2e2f7ea2..8e277f25352 100644 --- a/src/mongo/util/options_parser/options_parser.h +++ b/src/mongo/util/options_parser/options_parser.h @@ -59,7 +59,7 @@ namespace optionenvironment { * // Run the parser * Status ret = parser.run(options, argv, env, &environment); * if (!ret.isOK()) { - * cerr << options.helpString() << endl; + * cerr << options.helpString() << std::endl; * exit(EXIT_FAILURE); * } * @@ -67,11 +67,11 @@ namespace optionenvironment { * ret = environment.get(moe::Key("help"), &displayHelp); * if (!ret.isOK()) { * // Help is a switch, so it should always be set - * cout << "Should not get here" << endl; + * cout << "Should not get here" << std::endl; * exit(EXIT_FAILURE); * } * if (displayHelp) { - * cout << options.helpString() << endl; + * cout << options.helpString() << std::endl; * exit(EXIT_SUCCESS); * } * @@ -107,7 +107,7 @@ namespace optionenvironment { Status parseCommandLine(const OptionSection&, const std::vector<std::string>& argv, Environment*); - /** Handles parsing of an INI config string and adds the results to the given Environment */ + /** Handles parsing of an INI config std::string and adds the results to the given Environment */ Status parseINIConfigFile(const OptionSection&, const std::string& config, Environment*); /** Gets defaults from the OptionSection and adds them to the given Environment */ diff --git a/src/mongo/util/options_parser/value.h b/src/mongo/util/options_parser/value.h index c2d4a8854c9..9c9bb1468d7 100644 --- a/src/mongo/util/options_parser/value.h +++ b/src/mongo/util/options_parser/value.h @@ -88,7 +88,7 @@ namespace optionenvironment { Status get(double* val) const; Status get(int* val) const; Status get(long* val) const; - Status get(string* val) const; + Status get(std::string* val) const; Status get(unsigned long long* val) const; Status get(unsigned* val) const; @@ -112,7 +112,7 @@ namespace optionenvironment { bool equal(const Value&) const; /** - * Return the string representation of this Value. This function is used only for + * Return the std::string representation of this Value. This function is used only for * debugging purposes and does not output data in an easily parseable format. */ std::string toString() const; diff --git a/src/mongo/util/paths.h b/src/mongo/util/paths.h index cb8b425253f..f06c24bf500 100644 --- a/src/mongo/util/paths.h +++ b/src/mongo/util/paths.h @@ -48,7 +48,7 @@ namespace mongo { checking. if you want to say 'my param MUST be a relative path", use this. */ struct RelativePath { - string _p; + std::string _p; bool empty() const { return _p.empty(); } @@ -61,8 +61,8 @@ namespace mongo { /** from a full path */ static RelativePath fromFullPath(boost::filesystem::path f) { boost::filesystem::path dbp(storageGlobalParams.dbpath); // normalizes / and backslash - string fullpath = f.string(); - string relative = str::after(fullpath, dbp.string()); + std::string fullpath = f.string(); + std::string relative = str::after(fullpath, dbp.string()); if( relative.empty() ) { log() << "warning file is not under db path? " << fullpath << ' ' << dbp.string(); RelativePath rp; @@ -77,13 +77,13 @@ namespace mongo { return rp; } - string toString() const { return _p; } + std::string toString() const { return _p; } bool operator!=(const RelativePath& r) const { return _p != r._p; } bool operator==(const RelativePath& r) const { return _p == r._p; } bool operator<(const RelativePath& r) const { return _p < r._p; } - string asFullPath() const { + std::string asFullPath() const { boost::filesystem::path x(storageGlobalParams.dbpath); x /= _p; return x.string(); @@ -91,7 +91,7 @@ namespace mongo { }; - inline dev_t getPartition(const string& path){ + inline dev_t getPartition(const std::string& path){ struct stat stats; if (stat(path.c_str(), &stats) != 0){ @@ -101,7 +101,7 @@ namespace mongo { return stats.st_dev; } - inline bool onSamePartition(const string& path1, const string& path2){ + inline bool onSamePartition(const std::string& path1, const std::string& path2){ dev_t dev1 = getPartition(path1); dev_t dev2 = getPartition(path2); diff --git a/src/mongo/util/processinfo.h b/src/mongo/util/processinfo.h index 40ca98e8967..d41b085a6eb 100644 --- a/src/mongo/util/processinfo.h +++ b/src/mongo/util/processinfo.h @@ -55,17 +55,17 @@ namespace mongo { /** * Get the type of os (e.g. Windows, Linux, Mac OS) */ - const string& getOsType() const { return sysInfo().osType; } + const std::string& getOsType() const { return sysInfo().osType; } /** * Get the os Name (e.g. Ubuntu, Gentoo, Windows Server 2008) */ - const string& getOsName() const { return sysInfo().osName; } + const std::string& getOsName() const { return sysInfo().osName; } /** * Get the os version (e.g. 10.04, 11.3.0, 6.1 (build 7600)) */ - const string& getOsVersion() const { return sysInfo().osVersion; } + const std::string& getOsVersion() const { return sysInfo().osVersion; } /** * Get the cpu address size (e.g. 32, 36, 64) @@ -90,7 +90,7 @@ namespace mongo { /** * Get the CPU architecture (e.g. x86, x86_64) */ - const string& getArch() const { return sysInfo().cpuArch; } + const std::string& getArch() const { return sysInfo().cpuArch; } /** * Determine if NUMA is enabled (interleaved) for this process @@ -138,7 +138,7 @@ namespace mongo { * * NOTE: requires blockCheckSupported() == true */ - static bool pagesInMemory(const void* start, size_t numPages, vector<char>* out); + static bool pagesInMemory(const void* start, size_t numPages, std::vector<char>* out); private: /** @@ -146,14 +146,14 @@ namespace mongo { */ class SystemInfo { public: - string osType; - string osName; - string osVersion; + std::string osType; + std::string osName; + std::string osVersion; unsigned addrSize; unsigned long long memSize; unsigned numCores; unsigned long long pageSize; - string cpuArch; + std::string cpuArch; bool hasNuma; BSONObj _extraStats; diff --git a/src/mongo/util/string_map.h b/src/mongo/util/string_map.h index df9c3fb13e9..60293ff915c 100644 --- a/src/mongo/util/string_map.h +++ b/src/mongo/util/string_map.h @@ -49,7 +49,7 @@ namespace mongo { }; struct StringMapDefaultConvertorOther { - string operator()( const StringData& s ) const { + std::string operator()( const StringData& s ) const { return s.toString(); } }; diff --git a/src/mongo/util/stringutils.h b/src/mongo/util/stringutils.h index de58ef55d56..5f321c4d942 100644 --- a/src/mongo/util/stringutils.h +++ b/src/mongo/util/stringutils.h @@ -77,7 +77,7 @@ namespace mongo { bool _lexOnly; }; - // TODO: Sane-ify core string functionality + // TODO: Sane-ify core std::string functionality // For now, this needs to be near the LexNumCmp or else int versionCmp(const StringData rhs, const StringData lhs); diff --git a/src/mongo/util/text.h b/src/mongo/util/text.h index ca8ab42d449..ebcaa332975 100644 --- a/src/mongo/util/text.h +++ b/src/mongo/util/text.h @@ -39,7 +39,7 @@ namespace mongo { class StringSplitter { public: - /** @param big the string to be split + /** @param big the std::string to be split @param splitter the delimiter */ StringSplitter( const char * big , const char * splitter ) @@ -49,7 +49,7 @@ namespace mongo { /** @return true if more to be taken via next() */ bool more() const { return _big[0] != 0; } - /** get next split string fragment */ + /** get next split std::string fragment */ std::string next(); void split( std::vector<std::string>& l ); @@ -66,7 +66,7 @@ namespace mongo { }; /* This doesn't defend against ALL bad UTF8, but it will guarantee that the - * string can be converted to sequence of codepoints. However, it doesn't + * std::string can be converted to sequence of codepoints. However, it doesn't * guarantee that the codepoints are valid. */ bool isValidUTF8(const char *s); diff --git a/src/mongo/util/time_support.h b/src/mongo/util/time_support.h index 93ac132626d..284aa7a811e 100644 --- a/src/mongo/util/time_support.h +++ b/src/mongo/util/time_support.h @@ -95,7 +95,7 @@ namespace mongo { std::string dateToCtimeString(Date_t date); /** - * Parses a Date_t from an ISO 8601 string representation. + * Parses a Date_t from an ISO 8601 std::string representation. * * Sample formats: "2013-07-23T18:42:14.072-05:00" * "2013-07-23T18:42:14.072Z" diff --git a/src/mongo/util/trace.h b/src/mongo/util/trace.h index 2c8e7f1d327..2f5f20b20b5 100755 --- a/src/mongo/util/trace.h +++ b/src/mongo/util/trace.h @@ -46,10 +46,10 @@ namespace mongo { @param name comma separated trace names */ - static void setTraces(const string &names); + static void setTraces(const std::string &names); #endif - static void setTrace(const string &name, unsigned level); + static void setTrace(const std::string &name, unsigned level); /** Test to see if the given trace is on or off. @@ -57,18 +57,18 @@ namespace mongo { @param name the name of the trace to check @returns true if the trace is on, false otherwise */ - static unsigned getTrace(const string &name); + static unsigned getTrace(const std::string &name); private: Trace(); ~Trace(); struct Hash : - unary_function<string, size_t> { - size_t operator()(const string &rS) const; + std::unary_function<std::string, size_t> { + size_t operator()(const std::string &rS) const; }; - typedef boost::unordered_map<string, unsigned, Trace::Hash> MapType; + typedef boost::unordered_map<std::string, unsigned, Trace::Hash> MapType; class NameMap { public: NameMap(); @@ -87,7 +87,7 @@ namespace mongo { namespace mongo { - inline size_t Trace::Hash::operator()(const string &rS) const { + inline size_t Trace::Hash::operator()(const std::string &rS) const { size_t seed = 0xf0afbeef; boost::hash_combine(seed, rS); return seed; diff --git a/src/mongo/util/version.h b/src/mongo/util/version.h index 24a465285e5..1de46d666e6 100644 --- a/src/mongo/util/version.h +++ b/src/mongo/util/version.h @@ -41,7 +41,7 @@ namespace mongo { extern const BSONArray versionArray; std::string mongodVersion(); - // Convert a version string into a numeric array + // Convert a version std::string into a numeric array BSONArray toVersionArray(const char* version); // Checks whether another version is the same major version as us diff --git a/src/mongo/util/winutil.h b/src/mongo/util/winutil.h index b4f38ecc9ab..d24adfa3650 100644 --- a/src/mongo/util/winutil.h +++ b/src/mongo/util/winutil.h @@ -38,12 +38,12 @@ namespace mongo { - inline string GetWinErrMsg(DWORD err) { + inline std::string GetWinErrMsg(DWORD err) { LPTSTR errMsg; ::FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, (LPTSTR)&errMsg, 0, NULL ); std::string errMsgStr = toUtf8String( errMsg ); ::LocalFree( errMsg ); - // FormatMessage() appends a newline to the end of error messages, we trim it because endl flushes the buffer. + // FormatMessage() appends a newline to the end of error messages, we trim it because std::endl flushes the buffer. errMsgStr = errMsgStr.erase( errMsgStr.length() - 2 ); std::ostringstream output; output << errMsgStr << " (" << err << ")"; |