From 9b9f3a6c631b779a8dac4212128ca9c4163f1bce Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 22 Aug 2010 11:16:08 +0000 Subject: [PATCH] 2010-08-22 Tatsuhiro Tsujikawa Removed uitos(). Use util::uitos() instead. * src/SocketCore.cc --- ChangeLog | 5 +++++ src/SocketCore.cc | 28 ++++++---------------------- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 948f1f29..4111291b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-08-22 Tatsuhiro Tsujikawa + + Removed uitos(). Use util::uitos() instead. + * src/SocketCore.cc + 2010-08-21 Tatsuhiro Tsujikawa Don't try to send empty string. diff --git a/src/SocketCore.cc b/src/SocketCore.cc index a445b35c..220149eb 100644 --- a/src/SocketCore.cc +++ b/src/SocketCore.cc @@ -168,22 +168,6 @@ SocketCore::~SocketCore() { #endif // HAVE_LIBGNUTLS } -template -std::string uitos(T value) -{ - std::string str; - if(value == 0) { - str = "0"; - return str; - } - while(value) { - char digit = value%10+'0'; - str.insert(str.begin(), digit); - value /= 10; - } - return str; -} - void SocketCore::create(int family, int protocol) { closeConnection(); @@ -237,8 +221,8 @@ static sock_t bindTo int getaddrinfoFlags, std::string& error) { struct addrinfo* res; - int s = callGetaddrinfo(&res, host, uitos(port).c_str(), family, sockType, - getaddrinfoFlags, 0); + int s = callGetaddrinfo(&res, host, util::uitos(port).c_str(), + family, sockType, getaddrinfoFlags, 0); if(s) { error = gai_strerror(s); return -1; @@ -392,8 +376,8 @@ void SocketCore::establishConnection(const std::string& host, uint16_t port) std::string error; struct addrinfo* res; int s; - s = callGetaddrinfo(&res, host.c_str(), uitos(port).c_str(), protocolFamily_, - sockType_, 0, 0); + s = callGetaddrinfo(&res, host.c_str(), util::uitos(port).c_str(), + protocolFamily_, sockType_, 0, 0); if(s) { throw DL_ABORT_EX(StringFormat(EX_RESOLVE_HOSTNAME, host.c_str(), gai_strerror(s)).str()); @@ -1139,8 +1123,8 @@ ssize_t SocketCore::writeData(const char* data, size_t len, struct addrinfo* res; int s; - s = callGetaddrinfo(&res, host.c_str(), uitos(port).c_str(), protocolFamily_, - sockType_, 0, 0); + s = callGetaddrinfo(&res, host.c_str(), util::uitos(port).c_str(), + protocolFamily_, sockType_, 0, 0); if(s) { throw DL_ABORT_EX(StringFormat(EX_SOCKET_SEND, gai_strerror(s)).str()); }