From: Mikko Rasa Date: Mon, 16 May 2016 15:15:10 +0000 (+0300) Subject: Use string::size_type to store string offsets X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=b4e0f7ed23f24e78fd09c9b7f206279e16d38c1e;p=libs%2Fnet.git Use string::size_type to store string offsets --- diff --git a/source/http/message.cpp b/source/http/message.cpp index 21d2c4b..92321e8 100644 --- a/source/http/message.cpp +++ b/source/http/message.cpp @@ -97,7 +97,7 @@ unsigned Message::parse_content(const string &d) unsigned Message::parse_headers(const string &d) { - unsigned start = 0; + string::size_type start = 0; while(1) { string::size_type lf = d.find('\n', start); @@ -106,7 +106,7 @@ unsigned Message::parse_headers(const string &d) if(lf==start || (d[start]=='\r' && lf==start+1)) return lf+1; - unsigned colon = d.find(':', start); + string::size_type colon = d.find(':', start); if(colon>lf) throw invalid_argument("Message::parse_headers"); diff --git a/source/http/request.cpp b/source/http/request.cpp index f050e04..54b0bee 100644 --- a/source/http/request.cpp +++ b/source/http/request.cpp @@ -27,7 +27,7 @@ string Request::str() const Request Request::parse(const string &str) { - unsigned lf = str.find('\n'); + string::size_type lf = str.find('\n'); vector parts = split(str.substr(0, lf-(str[lf-1]=='\r')), ' ', 2); if(parts.size()<3) throw invalid_argument("Request::parse"); diff --git a/source/http/response.cpp b/source/http/response.cpp index 85e279f..739a20f 100644 --- a/source/http/response.cpp +++ b/source/http/response.cpp @@ -23,7 +23,7 @@ Response Response::parse(const string &str) { Response result; - unsigned lf = str.find('\n'); + string::size_type lf = str.find('\n'); vector parts = split(str.substr(0, lf), ' ', 2); if(parts.size()<2) throw invalid_argument("Response::parse"); diff --git a/source/http/server.cpp b/source/http/server.cpp index fc6d61f..f0474fd 100644 --- a/source/http/server.cpp +++ b/source/http/server.cpp @@ -106,7 +106,7 @@ void Server::client_data_available(Client &cl) cl.request = new Request(Request::parse(cl.in_buf)); string addr_str = cl.sock->get_peer_address().str(); - unsigned colon = addr_str.find(':'); + string::size_type colon = addr_str.find(':'); cl.request->set_header("-Client-Host", addr_str.substr(0, colon)); if(cl.request->get_method()!="GET" && cl.request->get_method()!="POST") diff --git a/source/net/resolve.cpp b/source/net/resolve.cpp index 097fea3..88497fa 100644 --- a/source/net/resolve.cpp +++ b/source/net/resolve.cpp @@ -54,7 +54,7 @@ SockAddr *resolve(const string &str, Family family) string host, serv; if(str[0]=='[') { - unsigned bracket = str.find(']'); + string::size_type bracket = str.find(']'); host = str.substr(1, bracket-1); string::size_type colon = str.find(':', bracket); if(colon!=string::npos)