summaryrefslogtreecommitdiff
path: root/src/mongo/bson
diff options
context:
space:
mode:
authorEric Milkie <milkie@10gen.com>2012-03-06 10:50:18 -0500
committerEric Milkie <milkie@10gen.com>2012-03-06 10:50:18 -0500
commitfd713371498dec2b2cb319c3a50c7a0c49a062ec (patch)
treeea618422fec1a0b4b2ed075831deb4ecf89b3803 /src/mongo/bson
parentbe3473afebbac25047383db98c68660b729d6deb (diff)
downloadmongo-fd713371498dec2b2cb319c3a50c7a0c49a062ec.tar.gz
SERVER-1268: don't put "using namespace" statements in headers
Diffstat (limited to 'src/mongo/bson')
-rw-r--r--src/mongo/bson/bson-inl.h50
-rw-r--r--src/mongo/bson/bson.h8
-rw-r--r--src/mongo/bson/bson_db.h8
-rw-r--r--src/mongo/bson/bsonelement.h22
-rw-r--r--src/mongo/bson/bsonmisc.h14
-rw-r--r--src/mongo/bson/bsonobj.h40
-rw-r--r--src/mongo/bson/bsonobjbuilder.h54
-rw-r--r--src/mongo/bson/bsonobjiterator.h4
-rw-r--r--src/mongo/bson/bsontypes.h2
-rw-r--r--src/mongo/bson/oid.h12
-rw-r--r--src/mongo/bson/ordering.h2
-rw-r--r--src/mongo/bson/stringdata.h6
-rw-r--r--src/mongo/bson/util/misc.h12
13 files changed, 114 insertions, 120 deletions
diff --git a/src/mongo/bson/bson-inl.h b/src/mongo/bson/bson-inl.h
index 9e8b3654802..3b3ab029046 100644
--- a/src/mongo/bson/bson-inl.h
+++ b/src/mongo/bson/bson-inl.h
@@ -121,7 +121,7 @@ dodouble:
// we use memcmp as we allow zeros in UTF8 strings
int lsz = l.valuestrsize();
int rsz = r.valuestrsize();
- int common = min(lsz, rsz);
+ int common = std::min(lsz, rsz);
int res = memcmp(l.valuestr(), r.valuestr(), common);
if( res )
return res;
@@ -193,7 +193,7 @@ dodouble:
inline BSONObj BSONElement::embeddedObjectUserCheck() const {
if ( MONGO_likely(isABSONObj()) )
return BSONObj(value());
- stringstream ss;
+ std::stringstream ss;
ss << "invalid parameter: expected an object (" << fieldName() << ")";
uasserted( 10065 , ss.str() );
return BSONObj(); // never reachable
@@ -318,7 +318,7 @@ dodouble:
/* add all the fields from the object specified to this object if they don't exist */
inline BSONObjBuilder& BSONObjBuilder::appendElementsUnique(BSONObj x) {
- set<string> have;
+ std::set<std::string> have;
{
BSONObjIterator i = iterator();
while ( i.more() )
@@ -399,7 +399,7 @@ dodouble:
}
// {a: {b:1}} -> {a.b:1}
- void nested2dotted(BSONObjBuilder& b, const BSONObj& obj, const string& base="");
+ void nested2dotted(BSONObjBuilder& b, const BSONObj& obj, const std::string& base="");
inline BSONObj nested2dotted(const BSONObj& obj) {
BSONObjBuilder b;
nested2dotted(b, obj);
@@ -433,7 +433,7 @@ dodouble:
* also, dotted2nested ignores order
*/
- typedef map<string, BSONElement> BSONMap;
+ typedef std::map<std::string, BSONElement> BSONMap;
inline BSONMap bson2map(const BSONObj& obj) {
BSONMap m;
BSONObjIterator it(obj);
@@ -450,7 +450,7 @@ dodouble:
}
};
- typedef set<BSONElement, BSONElementFieldNameCmp> BSONSortedElements;
+ typedef std::set<BSONElement, BSONElementFieldNameCmp> BSONSortedElements;
inline BSONSortedElements bson2set( const BSONObj& obj ) {
BSONSortedElements s;
BSONObjIterator it(obj);
@@ -459,7 +459,7 @@ dodouble:
return s;
}
- inline string BSONObj::toString( bool isArray, bool full ) const {
+ inline std::string BSONObj::toString( bool isArray, bool full ) const {
if ( isEmpty() ) return "{}";
StringBuilder s;
toString(s, isArray, full);
@@ -609,7 +609,7 @@ dodouble:
default: {
StringBuilder ss;
ss << "BSONElement: bad type " << (int) type();
- string msg = ss.str();
+ std::string msg = ss.str();
massert( 13655 , msg.c_str(),false);
}
}
@@ -675,7 +675,7 @@ dodouble:
{
StringBuilder ss;
ss << "BSONElement: bad type " << (int) type();
- string msg = ss.str();
+ std::string msg = ss.str();
massert(10320 , msg.c_str(),false);
}
}
@@ -684,7 +684,7 @@ dodouble:
return totalSize;
}
- inline string BSONElement::toString( bool includeFieldName, bool full ) const {
+ inline std::string BSONElement::toString( bool includeFieldName, bool full ) const {
StringBuilder s;
toString(s, includeFieldName, full);
return s.str();
@@ -796,7 +796,7 @@ dodouble:
if ( e.eoo() ) {
const char *p = strchr(name, '.');
if ( p ) {
- string left(name, p-name);
+ std::string left(name, p-name);
BSONObj sub = getObjectField(left.c_str());
return sub.isEmpty() ? BSONElement() : sub.getFieldDotted(p+1);
}
@@ -834,25 +834,25 @@ dodouble:
inline BSONObj BSONElement::Obj() const { return embeddedObjectUserCheck(); }
- inline BSONElement BSONElement::operator[] (const string& field) const {
+ inline BSONElement BSONElement::operator[] (const std::string& field) const {
BSONObj o = Obj();
return o[field];
}
- inline void BSONObj::elems(vector<BSONElement> &v) const {
+ inline void BSONObj::elems(std::vector<BSONElement> &v) const {
BSONObjIterator i(*this);
while( i.more() )
v.push_back(i.next());
}
- inline void BSONObj::elems(list<BSONElement> &v) const {
+ inline void BSONObj::elems(std::list<BSONElement> &v) const {
BSONObjIterator i(*this);
while( i.more() )
v.push_back(i.next());
}
template <class T>
- void BSONObj::Vals(vector<T>& v) const {
+ void BSONObj::Vals(std::vector<T>& v) const {
BSONObjIterator i(*this);
while( i.more() ) {
T t;
@@ -861,7 +861,7 @@ dodouble:
}
}
template <class T>
- void BSONObj::Vals(list<T>& v) const {
+ void BSONObj::Vals(std::list<T>& v) const {
BSONObjIterator i(*this);
while( i.more() ) {
T t;
@@ -871,7 +871,7 @@ dodouble:
}
template <class T>
- void BSONObj::vals(vector<T>& v) const {
+ void BSONObj::vals(std::vector<T>& v) const {
BSONObjIterator i(*this);
while( i.more() ) {
try {
@@ -883,7 +883,7 @@ dodouble:
}
}
template <class T>
- void BSONObj::vals(list<T>& v) const {
+ void BSONObj::vals(std::list<T>& v) const {
BSONObjIterator i(*this);
while( i.more() ) {
try {
@@ -895,11 +895,11 @@ dodouble:
}
}
- inline ostream& operator<<( ostream &s, const BSONObj &o ) {
+ inline std::ostream& operator<<( std::ostream &s, const BSONObj &o ) {
return s << o.toString();
}
- inline ostream& operator<<( ostream &s, const BSONElement &e ) {
+ inline std::ostream& operator<<( std::ostream &s, const BSONElement &e ) {
return s << e.toString();
}
@@ -923,9 +923,9 @@ dodouble:
}
// used by jsonString()
- inline string escape( string s , bool escape_slash=false) {
+ inline std::string escape( std::string s , bool escape_slash=false) {
StringBuilder ret;
- for ( string::iterator i = s.begin(); i != s.end(); ++i ) {
+ for ( std::string::iterator i = s.begin(); i != s.end(); ++i ) {
switch ( *i ) {
case '"':
ret << "\\\"";
@@ -965,14 +965,14 @@ dodouble:
return ret.str();
}
- inline string BSONObj::hexDump() const {
- stringstream ss;
+ inline std::string BSONObj::hexDump() const {
+ std::stringstream ss;
const char *d = objdata();
int size = objsize();
for( int i = 0; i < size; ++i ) {
ss.width( 2 );
ss.fill( '0' );
- ss << hex << (unsigned)(unsigned char)( d[ i ] ) << dec;
+ ss << std::hex << (unsigned)(unsigned char)( d[ i ] ) << std::dec;
if ( ( d[ i ] >= '0' && d[ i ] <= '9' ) || ( d[ i ] >= 'A' && d[ i ] <= 'z' ) )
ss << '\'' << d[ i ] << '\'';
if ( i != size - 1 )
diff --git a/src/mongo/bson/bson.h b/src/mongo/bson/bson.h
index b4a359d1f86..2305b3975d7 100644
--- a/src/mongo/bson/bson.h
+++ b/src/mongo/bson/bson.h
@@ -53,9 +53,9 @@ namespace bson {
class assertion : public std::exception {
public:
- assertion( unsigned u , const string& s )
+ assertion( unsigned u , const std::string& s )
: id( u ) , msg( s ) {
- stringstream ss;
+ std::stringstream ss;
ss << "BsonAssertion id: " << u << " " << s;
full = ss.str();
}
@@ -65,8 +65,8 @@ namespace bson {
virtual const char* what() const throw() { return full.c_str(); }
unsigned id;
- string msg;
- string full;
+ std::string msg;
+ std::string full;
};
}
diff --git a/src/mongo/bson/bson_db.h b/src/mongo/bson/bson_db.h
index 3f597bde3e1..15ceaef66cd 100644
--- a/src/mongo/bson/bson_db.h
+++ b/src/mongo/bson/bson_db.h
@@ -47,15 +47,15 @@ namespace mongo {
return OpTime();
}
- inline string BSONElement::_asCode() const {
+ inline std::string BSONElement::_asCode() const {
switch( type() ) {
case mongo::String:
case Code:
- return string(valuestr(), valuestrsize()-1);
+ return std::string(valuestr(), valuestrsize()-1);
case CodeWScope:
- return string(codeWScopeCode(), *(int*)(valuestr())-1);
+ return std::string(codeWScopeCode(), *(int*)(valuestr())-1);
default:
- log() << "can't convert type: " << (int)(type()) << " to code" << endl;
+ log() << "can't convert type: " << (int)(type()) << " to code" << std::endl;
}
uassert( 10062 , "not code" , 0 );
return "";
diff --git a/src/mongo/bson/bsonelement.h b/src/mongo/bson/bsonelement.h
index 29e8b43fcc7..a9b722b44b4 100644
--- a/src/mongo/bson/bsonelement.h
+++ b/src/mongo/bson/bsonelement.h
@@ -60,16 +60,16 @@ namespace mongo {
/** These functions, which start with a capital letter, throw a UserException if the
element is not of the required type. Example:
- string foo = obj["foo"].String(); // exception if not a string type or DNE
+ std::string foo = obj["foo"].String(); // std::exception if not a std::string type or DNE
*/
- string String() const { return chk(mongo::String).valuestr(); }
+ std::string String() const { return chk(mongo::String).valuestr(); }
Date_t Date() const { return chk(mongo::Date).date(); }
double Number() const { return chk(isNumber()).number(); }
double Double() const { return chk(NumberDouble)._numberDouble(); }
long long Long() const { return chk(NumberLong)._numberLong(); }
int Int() const { return chk(NumberInt)._numberInt(); }
bool Bool() const { return chk(mongo::Bool).boolean(); }
- vector<BSONElement> Array() const; // see implementation for detailed comments
+ std::vector<BSONElement> Array() const; // see implementation for detailed comments
mongo::OID OID() const { return chk(jstOID).__oid(); }
void Null() const { chk(isNull()); } // throw UserException if not null
void OK() const { chk(ok()); } // throw UserException if element DNE
@@ -92,17 +92,17 @@ namespace mongo {
void Val(mongo::OID& v) const { v = OID(); }
void Val(int& v) const { v = Int(); }
void Val(double& v) const { v = Double(); }
- void Val(string& v) const { v = String(); }
+ void Val(std::string& v) const { v = String(); }
/** Use ok() to check if a value is assigned:
if( myObj["foo"].ok() ) ...
*/
bool ok() const { return !eoo(); }
- string toString( bool includeFieldName = true, bool full=false) const;
+ std::string toString( bool includeFieldName = true, bool full=false) const;
void toString(StringBuilder& s, bool includeFieldName = true, bool full=false) const;
- string jsonString( JsonStringFormat format, bool includeFieldNames = true, int pretty = 0 ) const;
- operator string() const { return toString(); }
+ std::string jsonString( JsonStringFormat format, bool includeFieldNames = true, int pretty = 0 ) const;
+ operator std::string() const { return toString(); }
/** Returns the type of the element */
BSONType type() const { return (BSONType) *data; }
@@ -110,7 +110,7 @@ namespace mongo {
/** retrieve a field within this element
throws exception if *this is not an embedded object
*/
- BSONElement operator[] (const string& field) const;
+ BSONElement operator[] (const std::string& field) const;
/** returns the tyoe of the element fixed for the main type
the main purpose is numbers. any numeric type will return NumberDouble
@@ -237,8 +237,8 @@ namespace mongo {
return type() == mongo::String ? valuestr() : "";
}
/** Get the string value of the element. If not a string returns "". */
- string str() const {
- return type() == mongo::String ? string(valuestr(), valuestrsize()-1) : string();
+ std::string str() const {
+ return type() == mongo::String ? std::string(valuestr(), valuestrsize()-1) : std::string();
}
/** Get javascript code of a CodeWScope data element. */
@@ -407,7 +407,7 @@ namespace mongo {
}
}
- string _asCode() const;
+ std::string _asCode() const;
OpTime _opTime() const;
private:
diff --git a/src/mongo/bson/bsonmisc.h b/src/mongo/bson/bsonmisc.h
index 8a379396d17..d56d730becc 100644
--- a/src/mongo/bson/bsonmisc.h
+++ b/src/mongo/bson/bsonmisc.h
@@ -38,7 +38,7 @@ namespace mongo {
BSONObj _order;
};
- typedef set<BSONObj,BSONObjCmp> BSONObjSet;
+ typedef std::set<BSONObj,BSONObjCmp> BSONObjSet;
enum FieldCompareResult {
LEFT_SUBFIELD = -2,
@@ -48,7 +48,7 @@ namespace mongo {
RIGHT_SUBFIELD = 2
};
- FieldCompareResult compareDottedFieldNames( const string& l , const string& r );
+ FieldCompareResult compareDottedFieldNames( const std::string& l , const std::string& r );
/** Use BSON macro to build a BSONObj from a stream
@@ -74,25 +74,25 @@ namespace mongo {
/* Utility class to auto assign object IDs.
Example:
- cout << BSON( GENOID << "z" << 3 ); // { _id : ..., z : 3 }
+ std::cout << BSON( GENOID << "z" << 3 ); // { _id : ..., z : 3 }
*/
extern struct GENOIDLabeler { } GENOID;
/* Utility class to add a Date element with the current time
Example:
- cout << BSON( "created" << DATENOW ); // { created : "2009-10-09 11:41:42" }
+ std::cout << BSON( "created" << DATENOW ); // { created : "2009-10-09 11:41:42" }
*/
extern struct DateNowLabeler { } DATENOW;
/* Utility class to assign a NULL value to a given attribute
Example:
- cout << BSON( "a" << BSONNULL ); // { a : null }
+ std::cout << BSON( "a" << BSONNULL ); // { a : null }
*/
extern struct NullLabeler { } BSONNULL;
/* Utility class to add the minKey (minus infinity) to a given attribute
Example:
- cout << BSON( "a" << MINKEY ); // { "a" : { "$minKey" : 1 } }
+ std::cout << BSON( "a" << MINKEY ); // { "a" : { "$minKey" : 1 } }
*/
extern struct MinKeyLabeler { } MINKEY;
extern struct MaxKeyLabeler { } MAXKEY;
@@ -165,7 +165,7 @@ namespace mongo {
bool haveSubobj() const { return _subobj.get() != 0; }
BSONObjBuilder *subobj();
- auto_ptr< BSONObjBuilder > _subobj;
+ std::auto_ptr< BSONObjBuilder > _subobj;
};
/**
diff --git a/src/mongo/bson/bsonobj.h b/src/mongo/bson/bsonobj.h
index cfed22e40b0..d9a776c14b2 100644
--- a/src/mongo/bson/bsonobj.h
+++ b/src/mongo/bson/bsonobj.h
@@ -28,8 +28,8 @@
namespace mongo {
- typedef set< BSONElement, BSONElementCmpWithoutField > BSONElementSet;
- typedef multiset< BSONElement, BSONElementCmpWithoutField > BSONElementMSet;
+ typedef std::set< BSONElement, BSONElementCmpWithoutField > BSONElementSet;
+ typedef std::multiset< BSONElement, BSONElementCmpWithoutField > BSONElementMSet;
/**
C++ representation of a "BSON" object -- that is, an extended JSON-style
@@ -138,16 +138,16 @@ namespace mongo {
/** Readable representation of a BSON object in an extended JSON-style notation.
This is an abbreviated representation which might be used for logging.
*/
- string toString( bool isArray = false, bool full=false ) const;
+ std::string toString( bool isArray = false, bool full=false ) const;
void toString(StringBuilder& s, bool isArray = false, bool full=false ) const;
/** Properly formatted JSON string.
@param pretty if true we try to add some lf's and indentation
*/
- string jsonString( JsonStringFormat format = Strict, int pretty = 0 ) const;
+ std::string jsonString( JsonStringFormat format = Strict, int pretty = 0 ) const;
/** note: addFields always adds _id even if not specified */
- int addFields(BSONObj& from, set<string>& fields); /* returns n added */
+ int addFields(BSONObj& from, std::set<std::string>& fields); /* returns n added */
/** remove specified field and return a new object with the remaining fields.
slowish as builds a full new object
@@ -160,7 +160,7 @@ namespace mongo {
int nFields() const;
/** adds the field names to the fields set. does NOT clear it (appends). */
- int getFieldNames(set<string>& fields) const;
+ int getFieldNames(std::set<std::string>& fields) const;
/** @return the specified element. element.eoo() will be true if not found.
@param name field to find. supports dot (".") notation to reach into embedded objects.
@@ -171,7 +171,7 @@ namespace mongo {
@param name field to find. supports dot (".") notation to reach into embedded objects.
for example "x.y" means "in the nested object in field x, retrieve field y"
*/
- BSONElement getFieldDotted(const string& name) const {
+ BSONElement getFieldDotted(const std::string& name) const {
return getFieldDotted( name.c_str() );
}
@@ -207,14 +207,14 @@ namespace mongo {
return getField(field);
}
- BSONElement operator[] (const string& field) const {
+ BSONElement operator[] (const std::string& field) const {
return getField(field);
}
BSONElement operator[] (int field) const {
StringBuilder ss;
ss << field;
- string s = ss.str();
+ std::string s = ss.str();
return getField(s.c_str());
}
@@ -281,7 +281,7 @@ namespace mongo {
void dump() const;
/** Alternative output format */
- string hexDump() const;
+ std::string hexDump() const;
/**wo='well ordered'. fields must be in same order in each object.
Ordering is with respect to the signs of the elements
@@ -368,7 +368,7 @@ namespace mongo {
bool valid() const;
/** @return an md5 value for this object. */
- string md5() const;
+ std::string md5() const;
bool operator==( const BSONObj& other ) const { return equal( other ); }
bool operator!=(const BSONObj& other) const { return !operator==( other); }
@@ -396,30 +396,30 @@ namespace mongo {
};
/** add all elements of the object to the specified vector */
- void elems(vector<BSONElement> &) const;
+ void elems(std::vector<BSONElement> &) const;
/** add all elements of the object to the specified list */
- void elems(list<BSONElement> &) const;
+ void elems(std::list<BSONElement> &) const;
/** add all values of the object to the specified vector. If type mismatches, exception.
this is most useful when the BSONObj is an array, but can be used with non-arrays too in theory.
example:
bo sub = y["subobj"].Obj();
- vector<int> myints;
+ std::vector<int> myints;
sub.Vals(myints);
*/
template <class T>
- void Vals(vector<T> &) const;
+ void Vals(std::vector<T> &) const;
/** add all values of the object to the specified list. If type mismatches, exception. */
template <class T>
- void Vals(list<T> &) const;
+ void Vals(std::list<T> &) const;
/** add all values of the object to the specified vector. If type mismatches, skip. */
template <class T>
- void vals(vector<T> &) const;
+ void vals(std::vector<T> &) const;
/** add all values of the object to the specified list. If type mismatches, skip. */
template <class T>
- void vals(list<T> &) const;
+ void vals(std::list<T> &) const;
friend class BSONObjIterator;
typedef BSONObjIterator iterator;
@@ -494,8 +494,8 @@ namespace mongo {
}
};
- ostream& operator<<( ostream &s, const BSONObj &o );
- ostream& operator<<( ostream &s, const BSONElement &e );
+ std::ostream& operator<<( std::ostream &s, const BSONObj &o );
+ std::ostream& operator<<( std::ostream &s, const BSONElement &e );
StringBuilder& operator<<( StringBuilder &s, const BSONObj &o );
StringBuilder& operator<<( StringBuilder &s, const BSONElement &e );
diff --git a/src/mongo/bson/bsonobjbuilder.h b/src/mongo/bson/bsonobjbuilder.h
index 04f59d1b3cc..0b18a45abf0 100644
--- a/src/mongo/bson/bsonobjbuilder.h
+++ b/src/mongo/bson/bsonobjbuilder.h
@@ -39,8 +39,6 @@
namespace mongo {
- using namespace std;
-
#if defined(_WIN32)
// warning: 'this' : used in base member initializer list
#pragma warning( disable : 4355 )
@@ -49,26 +47,26 @@ namespace mongo {
template<typename T>
class BSONFieldValue {
public:
- BSONFieldValue( const string& name , const T& t ) {
+ BSONFieldValue( const std::string& name , const T& t ) {
_name = name;
_t = t;
}
const T& value() const { return _t; }
- const string& name() const { return _name; }
+ const std::string& name() const { return _name; }
private:
- string _name;
+ std::string _name;
T _t;
};
template<typename T>
class BSONField {
public:
- BSONField( const string& name , const string& longName="" )
+ BSONField( const std::string& name , const std::string& longName="" )
: _name(name), _longName(longName) {}
- const string& name() const { return _name; }
- operator string() const { return _name; }
+ const std::string& name() const { return _name; }
+ operator std::string() const { return _name; }
BSONFieldValue<T> make( const T& t ) const {
return BSONFieldValue<T>( _name , t );
@@ -84,8 +82,8 @@ namespace mongo {
}
private:
- string _name;
- string _longName;
+ std::string _name;
+ std::string _longName;
};
/** Utility for creating a BSONObj.
@@ -242,7 +240,7 @@ namespace mongo {
long long x = n;
if ( x < 0 )
x = x * -1;
- if ( x < ( (numeric_limits<int>::max)() / 2 ) ) // extra () to avoid max macro on windows
+ if ( x < ( (std::numeric_limits<int>::max)() / 2 ) ) // extra () to avoid max macro on windows
append( fieldName , (int)n );
else
append( fieldName , n );
@@ -295,7 +293,7 @@ namespace mongo {
/** tries to append the data as a number
* @return true if the data was able to be converted to a number
*/
- bool appendAsNumber( const StringData& fieldName , const string& data );
+ bool appendAsNumber( const StringData& fieldName , const std::string& data );
/** Append a BSON Object ID (OID type).
@deprecated Generally, it is preferred to use the append append(name, oid)
@@ -357,7 +355,7 @@ namespace mongo {
if( dt > 0 && dt <= 0xffffffff ) {
static int n;
if( n++ == 0 )
- log() << "DEV WARNING appendDate() called with a tiny (but nonzero) date" << endl;
+ log() << "DEV WARNING appendDate() called with a tiny (but nonzero) date" << std::endl;
}
#endif
_b.appendNum((char) Date);
@@ -403,7 +401,7 @@ namespace mongo {
return append(fieldName, str, (int) strlen(str)+1);
}
/** Append a string element */
- BSONObjBuilder& append(const StringData& fieldName, const string& str) {
+ BSONObjBuilder& append(const StringData& fieldName, const std::string& str) {
return append(fieldName, str.c_str(), (int) str.size()+1);
}
@@ -533,14 +531,14 @@ namespace mongo {
/** Append an array of values. */
template < class T >
- BSONObjBuilder& append( const StringData& fieldName, const vector< T >& vals );
+ BSONObjBuilder& append( const StringData& fieldName, const std::vector< T >& vals );
template < class T >
- BSONObjBuilder& append( const StringData& fieldName, const list< T >& vals );
+ BSONObjBuilder& append( const StringData& fieldName, const std::list< T >& vals );
/** Append a set of values. */
template < class T >
- BSONObjBuilder& append( const StringData& fieldName, const set< T >& vals );
+ BSONObjBuilder& append( const StringData& fieldName, const std::set< T >& vals );
/**
* destructive
@@ -595,7 +593,7 @@ namespace mongo {
void appendKeys( const BSONObj& keyPattern , const BSONObj& values );
- static string numStr( int i ) {
+ static std::string numStr( int i ) {
if (i>=0 && i<100 && numStrsReady)
return numStrs[i];
StringBuilder o;
@@ -614,8 +612,8 @@ namespace mongo {
// prevent implicit string conversions which would allow bad things like BSON( BSON( "foo" << 1 ) << 2 )
struct ForceExplicitString {
- ForceExplicitString( const string &str ) : str_( str ) {}
- string str_;
+ ForceExplicitString( const std::string &str ) : str_( str ) {}
+ std::string str_;
};
/** Stream oriented way to add field names and values. */
@@ -679,7 +677,7 @@ namespace mongo {
BSONSizeTracker * _tracker;
bool _doneCalled;
- static const string numStrs[100]; // cache of 0 to 99 inclusive
+ static const std::string numStrs[100]; // cache of 0 to 99 inclusive
static bool numStrsReady; // for static init safety. see comments in db/jsobj.cpp
};
@@ -775,7 +773,7 @@ namespace mongo {
char *r;
long int n = strtol( name.data(), &r, 10 );
if ( *r )
- uasserted( 13048, (string)"can't append to array using string field name [" + name.data() + "]" );
+ uasserted( 13048, (std::string)"can't append to array using string field name [" + name.data() + "]" );
fill(n);
}
@@ -800,13 +798,13 @@ namespace mongo {
return _b.obj();
}
- string num() { return _b.numStr(_i++); }
+ std::string num() { return _b.numStr(_i++); }
int _i;
BSONObjBuilder _b;
};
template < class T >
- inline BSONObjBuilder& BSONObjBuilder::append( const StringData& fieldName, const vector< T >& vals ) {
+ inline BSONObjBuilder& BSONObjBuilder::append( const StringData& fieldName, const std::vector< T >& vals ) {
BSONObjBuilder arrBuilder;
for ( unsigned int i = 0; i < vals.size(); ++i )
arrBuilder.append( numStr( i ), vals[ i ] );
@@ -825,13 +823,13 @@ namespace mongo {
}
template < class T >
- inline BSONObjBuilder& BSONObjBuilder::append( const StringData& fieldName, const list< T >& vals ) {
- return _appendIt< list< T > >( *this, fieldName, vals );
+ inline BSONObjBuilder& BSONObjBuilder::append( const StringData& fieldName, const std::list< T >& vals ) {
+ return _appendIt< std::list< T > >( *this, fieldName, vals );
}
template < class T >
- inline BSONObjBuilder& BSONObjBuilder::append( const StringData& fieldName, const set< T >& vals ) {
- return _appendIt< set< T > >( *this, fieldName, vals );
+ inline BSONObjBuilder& BSONObjBuilder::append( const StringData& fieldName, const std::set< T >& vals ) {
+ return _appendIt< std::set< T > >( *this, fieldName, vals );
}
diff --git a/src/mongo/bson/bsonobjiterator.h b/src/mongo/bson/bsonobjiterator.h
index 39ae24d9b86..e4dcca886ab 100644
--- a/src/mongo/bson/bsonobjiterator.h
+++ b/src/mongo/bson/bsonobjiterator.h
@@ -113,9 +113,9 @@ namespace mongo {
we match array # positions with their vector position, and ignore
any fields with non-numeric field names.
*/
- inline vector<BSONElement> BSONElement::Array() const {
+ inline std::vector<BSONElement> BSONElement::Array() const {
chk(mongo::Array);
- vector<BSONElement> v;
+ std::vector<BSONElement> v;
BSONObjIterator i(Obj());
while( i.more() ) {
BSONElement e = i.next();
diff --git a/src/mongo/bson/bsontypes.h b/src/mongo/bson/bsontypes.h
index 6d315aa9af1..1a176d18e60 100644
--- a/src/mongo/bson/bsontypes.h
+++ b/src/mongo/bson/bsontypes.h
@@ -23,8 +23,6 @@ namespace bson { }
namespace mongo {
- using namespace std;
-
class BSONArrayBuilder;
class BSONElement;
class BSONObj;
diff --git a/src/mongo/bson/oid.h b/src/mongo/bson/oid.h
index 1bc81019756..7be75e47188 100644
--- a/src/mongo/bson/oid.h
+++ b/src/mongo/bson/oid.h
@@ -41,7 +41,7 @@ namespace mongo {
OID() : a(0), b(0) { }
/** init from a 24 char hex string */
- explicit OID(const string &s) { init(s); }
+ explicit OID(const std::string &s) { init(s); }
/** initialize to 'null' */
void clear() { a = 0; b = 0; }
@@ -55,8 +55,8 @@ namespace mongo {
bool operator<=( const OID& other ) const { return compare( other ) <= 0; }
/** @return the object ID output as 24 hex digits */
- string str() const { return toHexLower(data, 12); }
- string toString() const { return str(); }
+ std::string str() const { return toHexLower(data, 12); }
+ std::string toString() const { return str(); }
static OID gen() { OID o; o.init(); return o; }
@@ -64,7 +64,7 @@ namespace mongo {
void init();
/** init from a 24 char hex string */
- void init( string s );
+ void init( std::string s );
/** Set to the min/max OID that could be generated at given timestamp. */
void init( Date_t date, bool max=false );
@@ -121,7 +121,7 @@ namespace mongo {
};
#pragma pack()
- ostream& operator<<( ostream &s, const OID &o );
+ std::ostream& operator<<( std::ostream &s, const OID &o );
inline StringBuilder& operator<< (StringBuilder& s, const OID& o) { return (s << o.str()); }
/** Formatting mode for generating JSON from BSON.
@@ -138,6 +138,6 @@ namespace mongo {
JS
};
- ostream& operator<<( ostream &s, const OID &o );
+ std::ostream& operator<<( std::ostream &s, const OID &o );
}
diff --git a/src/mongo/bson/ordering.h b/src/mongo/bson/ordering.h
index 53f72f1baa4..25545b66b3f 100644
--- a/src/mongo/bson/ordering.h
+++ b/src/mongo/bson/ordering.h
@@ -46,7 +46,7 @@ namespace mongo {
// for woCompare...
unsigned descending(unsigned mask) const { return bits & mask; }
- /*operator string() const {
+ /*operator std::string() const {
StringBuilder buf;
for ( unsigned i=0; i<nkeys; i++)
buf.append( get(i) > 0 ? "+" : "-" );
diff --git a/src/mongo/bson/stringdata.h b/src/mongo/bson/stringdata.h
index 1fb4e7d25d3..f8a56c1ba2f 100644
--- a/src/mongo/bson/stringdata.h
+++ b/src/mongo/bson/stringdata.h
@@ -42,14 +42,14 @@ namespace mongo {
/** Construct a StringData explicitly, for the case where the length of the string
* is already known. 'c' must be a pointer to a null-terminated string, and strlenOfc
- * must be the length that std::strlen(c) would return, a.k.a the index of the
+ * must be the length that strlen(c) would return, a.k.a the index of the
* terminator in c.
*/
StringData( const char* c, unsigned len )
: _data(c), _size(len) {}
- /** Construct a StringData, for the case of a std::string. */
- StringData( const string& s )
+ /** Construct a StringData, for the case of a string. */
+ StringData( const std::string& s )
: _data(s.c_str()), _size((unsigned) s.size()) {}
// Construct a StringData explicitly, for the case of a literal whose size is
diff --git a/src/mongo/bson/util/misc.h b/src/mongo/bson/util/misc.h
index b1043c59953..a50cddf208a 100644
--- a/src/mongo/bson/util/misc.h
+++ b/src/mongo/bson/util/misc.h
@@ -24,8 +24,6 @@
namespace mongo {
- using namespace std;
-
inline void time_t_to_String(time_t t, char *buf) {
#if defined(_WIN32)
ctime_s(buf, 32, &t);
@@ -35,7 +33,7 @@ namespace mongo {
buf[24] = 0; // don't want the \n
}
- inline string time_t_to_String(time_t t = time(0) ) {
+ inline std::string time_t_to_String(time_t t = time(0) ) {
char buf[64];
#if defined(_WIN32)
ctime_s(buf, sizeof(buf), &t);
@@ -46,7 +44,7 @@ namespace mongo {
return buf;
}
- inline string time_t_to_String_no_year(time_t t) {
+ inline std::string time_t_to_String_no_year(time_t t) {
char buf[64];
#if defined(_WIN32)
ctime_s(buf, sizeof(buf), &t);
@@ -57,7 +55,7 @@ namespace mongo {
return buf;
}
- inline string time_t_to_String_short(time_t t) {
+ inline std::string time_t_to_String_short(time_t t) {
char buf[64];
#if defined(_WIN32)
ctime_s(buf, sizeof(buf), &t);
@@ -85,7 +83,7 @@ namespace mongo {
gmtime_r(&dtime, buf);
#endif
}
- string toString() const {
+ std::string toString() const {
char buf[64];
time_t_to_String(toTimeT(), buf);
return buf;
@@ -93,7 +91,7 @@ namespace mongo {
time_t toTimeT() const {
// cant use uassert from bson/util
assert((long long)millis >= 0); // TODO when millis is signed, delete
- assert(((long long)millis/1000) < (numeric_limits<time_t>::max)());
+ assert(((long long)millis/1000) < (std::numeric_limits<time_t>::max)());
return millis / 1000;
}
};