diff options
author | Eliot Horowitz <eliot@10gen.com> | 2010-02-26 12:07:46 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2010-02-26 12:07:46 -0500 |
commit | c3f07f3be05934d8dae18c83d6c1bad57eaff739 (patch) | |
tree | 2418089fb2d6084a82c4bf7b2f1d08e0d200f39d /util | |
parent | 27e94db45caa61293da51898c3df72e538f18805 (diff) | |
download | mongo-c3f07f3be05934d8dae18c83d6c1bad57eaff739.tar.gz |
some missing operators
Diffstat (limited to 'util')
-rw-r--r-- | util/goodies.h | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/util/goodies.h b/util/goodies.h index 6577b9db7e6..d2678f5fa9c 100644 --- a/util/goodies.h +++ b/util/goodies.h @@ -510,13 +510,19 @@ namespace mongo { memset( _buf , 0 , _size ); } + ThreadSafeString( const ThreadSafeString& other ) + : _size( other._size ) , _buf( new char[_size] ){ + strncpy( _buf , other._buf , _size ); + } + ~ThreadSafeString(){ - delete _buf; + delete[] _buf; _buf = 0; } operator string() const { - return (string)_buf; + string s = _buf; + return s; } ThreadSafeString& operator=( const char * str ){ @@ -527,6 +533,18 @@ namespace mongo { _buf[s] = 0; return *this; } + + bool operator==( const ThreadSafeString& other ) const { + return strcmp( _buf , other._buf ) == 0; + } + + bool operator==( const char * str ) const { + return strcmp( _buf , str ) == 0; + } + + bool operator!=( const char * str ) const { + return strcmp( _buf , str ); + } bool empty() const { return _buf[0] == 0; |