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/mongo/util | |
parent | c10e8282a7af38f8512e911a14889e14df8a2c6a (diff) | |
download | mongo-f2bfd36a6f3eb7e7e2587268be3cc12636703d42.tar.gz |
SERVER-13256: Remove pch - qualify std in headers
Diffstat (limited to 'src/mongo/util')
42 files changed, 183 insertions, 185 deletions
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 << ")"; |