diff options
author | Dwight <dwight@10gen.com> | 2010-09-29 13:51:33 -0400 |
---|---|---|
committer | Dwight <dwight@10gen.com> | 2010-09-29 13:51:33 -0400 |
commit | 809d102b5e295e5e36a8ea1544cc7a8cebae7d80 (patch) | |
tree | 935451d215902f1934bca36d2b296891be211d0c /util | |
parent | 6a931d5e050f4553032e0dbbb77504e119e0c66c (diff) | |
download | mongo-809d102b5e295e5e36a8ea1544cc7a8cebae7d80.tar.gz |
replsetoplog diag html page was broken
Diffstat (limited to 'util')
-rw-r--r-- | util/mongoutils/str.h | 13 | ||||
-rw-r--r-- | util/stringutils.h | 2 |
2 files changed, 15 insertions, 0 deletions
diff --git a/util/mongoutils/str.h b/util/mongoutils/str.h index d2c538492ee..88d2b196f4a 100644 --- a/util/mongoutils/str.h +++ b/util/mongoutils/str.h @@ -115,6 +115,19 @@ namespace mongoutils { inline int shareCommonPrefix(const string &a, const string &b) { return shareCommonPrefix(a.c_str(), b.c_str()); } + /** string to unsigned. zero if not a number. can end with non-num chars */ + inline unsigned toUnsigned(const string& a) { + unsigned x = 0; + const char *p = a.c_str(); + while( 1 ) { + if( !isdigit(*p) ) + break; + x = x * 10 + (*p - '0'); + p++; + } + return x; + } + } } diff --git a/util/stringutils.h b/util/stringutils.h index 6b79c33e96e..856315787a6 100644 --- a/util/stringutils.h +++ b/util/stringutils.h @@ -20,6 +20,8 @@ namespace mongo { + // see also mongoutils/str.h - perhaps move these there? + void splitStringDelim( const string& str , vector<string>* res , char delim ); void joinStringDelim( const vector<string>& strs , string* res , char delim ); |