From 26fac5bf7e87dd5704a967ee4c744228b93d20b7 Mon Sep 17 00:00:00 2001 From: Alexander Zaitsev Date: Fri, 13 Mar 2020 03:56:35 +0300 Subject: fix: use std::size_t instead of size_t - use C++ size_t from std namespace instead of a version from global namespace Tested: - Local build - Unit-tests --- src/net/BoostHttpOnlySslClient.cpp | 4 +++- src/net/CurlHttpClient.cpp | 4 +++- src/net/HttpParser.cpp | 11 ++++++----- src/net/Url.cpp | 4 +++- 4 files changed, 15 insertions(+), 8 deletions(-) (limited to 'src/net') diff --git a/src/net/BoostHttpOnlySslClient.cpp b/src/net/BoostHttpOnlySslClient.cpp index d0fde8e..836b06a 100644 --- a/src/net/BoostHttpOnlySslClient.cpp +++ b/src/net/BoostHttpOnlySslClient.cpp @@ -1,5 +1,7 @@ #include "tgbot/net/BoostHttpOnlySslClient.h" +#include + #include using namespace std; @@ -59,7 +61,7 @@ string BoostHttpOnlySslClient::makeRequest(const Url& url, const vector + #include namespace TgBot { @@ -14,7 +16,7 @@ CurlHttpClient::~CurlHttpClient() { curl_easy_cleanup(curlSettings); } -static size_t curlWriteString(char* ptr, size_t size, size_t nmemb, void* userdata) { +static std::size_t curlWriteString(char* ptr, std::size_t size, std::size_t nmemb, void* userdata) { static_cast(userdata)->append(ptr, size * nmemb); return size * nmemb; }; diff --git a/src/net/HttpParser.cpp b/src/net/HttpParser.cpp index 386a4d9..8006c85 100644 --- a/src/net/HttpParser.cpp +++ b/src/net/HttpParser.cpp @@ -1,5 +1,6 @@ #include "tgbot/net/HttpParser.h" +#include #include #include @@ -133,10 +134,10 @@ string HttpParser::generateResponse(const string& data, const string& mimeType, unordered_map HttpParser::parseHeader(const string& data, bool isRequest) const { unordered_map headers; - size_t lineStart = 0; - size_t lineEnd = 0; - size_t lineSepPos = 0; - size_t lastLineEnd = string::npos; + std::size_t lineStart = 0; + std::size_t lineEnd = 0; + std::size_t lineSepPos = 0; + std::size_t lastLineEnd = string::npos; while (lastLineEnd != lineEnd) { lastLineEnd = lineEnd; bool isFirstLine = lineEnd == 0; @@ -167,7 +168,7 @@ unordered_map HttpParser::parseHeader(const string& data, bool i } string HttpParser::extractBody(const string& data) const { - size_t headerEnd = data.find("\r\n\r\n"); + std::size_t headerEnd = data.find("\r\n\r\n"); if (headerEnd == string::npos) { return data; } diff --git a/src/net/Url.cpp b/src/net/Url.cpp index c767b47..016a97f 100644 --- a/src/net/Url.cpp +++ b/src/net/Url.cpp @@ -1,5 +1,7 @@ #include "tgbot/net/Url.h" +#include + #include "tgbot/tools/StringTools.h" using namespace std; @@ -12,7 +14,7 @@ Url::Url(const string& url) { bool isPathParsed = false; bool isQueryParsed = false; - for (size_t i = 0, count = url.length(); i < count; ++i) { + for (std::size_t i = 0, count = url.length(); i < count; ++i) { char c = url[i]; if (!isProtocolParsed) { -- cgit v1.2.3