summaryrefslogtreecommitdiff
path: root/util/hostandport.h
diff options
context:
space:
mode:
authorDwight <dmerriman@gmail.com>2010-04-21 14:41:09 -0400
committerDwight <dmerriman@gmail.com>2010-04-21 14:41:09 -0400
commit7fb0052d9ccf944e59e3eb863bf93972c22a0121 (patch)
treeca0299137e3a7134f21e0244eea9c7dfdaf81053 /util/hostandport.h
parent5660d034776250a15adec0433ee04724a1d15dcc (diff)
downloadmongo-7fb0052d9ccf944e59e3eb863bf93972c22a0121.tar.gz
some rs work and clean up BSONElement
Diffstat (limited to 'util/hostandport.h')
-rw-r--r--util/hostandport.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/util/hostandport.h b/util/hostandport.h
index 0577d455391..21527ee224f 100644
--- a/util/hostandport.h
+++ b/util/hostandport.h
@@ -29,6 +29,20 @@ namespace mongo {
HostAndPort(string h, int p = -1) : _host(h), _port(p) { }
+ static HostAndPort fromString(string s) {
+ const char *p = s.c_str();
+ uassert(13110, "HostAndPort: bad config string", *p);
+ const char *colon = strchr(p, ':');
+ HostAndPort m;
+ if( colon ) {
+ int port = atoi(colon+1);
+ uassert(13095, "HostAndPort: bad port #", port > 0);
+ return HostAndPort(string(p,colon-p),port);
+ }
+ // no port specified.
+ return HostAndPort(p, cmdLine.port);
+ }
+
bool operator<(const HostAndPort& r) const { return _host < r._host || (_host==r._host&&_port<r._port); }
/* returns true if the host/port combo identifies this process instance. */