From 277be6dd08633dbebfda93afdfc6b5cb57e053e0 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Mon, 8 Apr 2024 13:18:22 +0200 Subject: Use properly included standard library types by default --- src/other_tools/utils/curl_easy_handle.cpp | 12 ++++++------ src/other_tools/utils/curl_easy_handle.hpp | 9 +++++---- src/other_tools/utils/curl_url_handle.cpp | 16 +++++++++------- src/other_tools/utils/curl_url_handle.hpp | 5 +++-- 4 files changed, 23 insertions(+), 19 deletions(-) (limited to 'src/other_tools/utils') diff --git a/src/other_tools/utils/curl_easy_handle.cpp b/src/other_tools/utils/curl_easy_handle.cpp index 6939c6d1..2fcfb877 100644 --- a/src/other_tools/utils/curl_easy_handle.cpp +++ b/src/other_tools/utils/curl_easy_handle.cpp @@ -40,11 +40,11 @@ auto read_stream_data(gsl::not_null const& stream) noexcept std::rewind(stream); // create string buffer to hold stream content - std::string content(static_cast(size), '\0'); + std::string content(static_cast(size), '\0'); // read stream content into string buffer auto n = std::fread(content.data(), 1, content.size(), stream); - if (n != static_cast(size)) { + if (n != static_cast(size)) { Logger::Log(LogLevel::Warning, "Reading curl log from temporary file failed: read only {} " "bytes while {} were expected", @@ -87,8 +87,8 @@ auto CurlEasyHandle::Create( } auto CurlEasyHandle::EasyWriteToFile(gsl::owner data, - size_t size, - size_t nmemb, + std::size_t size, + std::size_t nmemb, gsl::owner userptr) -> std::streamsize { auto actual_size = static_cast(size * nmemb); @@ -98,8 +98,8 @@ auto CurlEasyHandle::EasyWriteToFile(gsl::owner data, } auto CurlEasyHandle::EasyWriteToString(gsl::owner data, - size_t size, - size_t nmemb, + std::size_t size, + std::size_t nmemb, gsl::owner userptr) -> std::streamsize { size_t actual_size = size * nmemb; diff --git a/src/other_tools/utils/curl_easy_handle.hpp b/src/other_tools/utils/curl_easy_handle.hpp index 1a3d31c3..81bcbed8 100644 --- a/src/other_tools/utils/curl_easy_handle.hpp +++ b/src/other_tools/utils/curl_easy_handle.hpp @@ -15,6 +15,7 @@ #ifndef INCLUDED_SRC_OTHER_TOOLS_UTILS_CURL_EASY_HANDLE_HPP #define INCLUDED_SRC_OTHER_TOOLS_UTILS_CURL_EASY_HANDLE_HPP +#include #include #include #include @@ -83,16 +84,16 @@ class CurlEasyHandle { /// \brief Overwrites write_callback to redirect to file instead of stdout. [[nodiscard]] auto static EasyWriteToFile(gsl::owner data, - size_t size, - size_t nmemb, + std::size_t size, + std::size_t nmemb, gsl::owner userptr) -> std::streamsize; /// \brief Overwrites write_callback to redirect to string instead of /// stdout. [[nodiscard]] auto static EasyWriteToString(gsl::owner data, - size_t size, - size_t nmemb, + std::size_t size, + std::size_t nmemb, gsl::owner userptr) -> std::streamsize; }; diff --git a/src/other_tools/utils/curl_url_handle.cpp b/src/other_tools/utils/curl_url_handle.cpp index 912691b4..142d1809 100644 --- a/src/other_tools/utils/curl_url_handle.cpp +++ b/src/other_tools/utils/curl_url_handle.cpp @@ -14,6 +14,7 @@ #include "src/other_tools/utils/curl_url_handle.hpp" +#include #include #include @@ -68,7 +69,7 @@ namespace { /// Returns the size of the key path if match successful, otherwise nullopt. [[nodiscard]] auto PathMatchSize(std::string const& key_path, std::string const& url_path) noexcept - -> std::optional { + -> std::optional { // split key path std::vector key_tokens{}; std::string token{}; @@ -495,8 +496,8 @@ auto CurlURLHandle::ParseConfigKey(std::string const& key) noexcept // create regex to find all possible matches of the parsed host in the // original key, where any '.' can also be a '*' std::stringstream pattern{}; - size_t old_index{}; - size_t index{}; + std::size_t old_index{}; + std::size_t index{}; while ((index = parsed_host.find('.', old_index)) != std::string::npos) { pattern << parsed_host.substr(old_index, index - old_index); @@ -508,13 +509,14 @@ auto CurlURLHandle::ParseConfigKey(std::string const& key) noexcept // for every match, replace the parsed host in the found position and // try to parse as usual - size_t host_len = parsed_host.length(); + std::size_t host_len = parsed_host.length(); for (auto it = std::sregex_iterator(key.begin(), key.end(), re); it != std::sregex_iterator(); ++it) { std::string new_key{key}; - new_key.replace( - static_cast(it->position()), host_len, parsed_host); + new_key.replace(static_cast(it->position()), + host_len, + parsed_host); // try to parse new key auto try_config_key = GetConfigStructFromKey(new_key); @@ -538,7 +540,7 @@ auto CurlURLHandle::ParseConfigKey(std::string const& key) noexcept auto CurlURLHandle::MatchConfigKey(std::string const& key) noexcept -> std::optional { try { - size_t host_len{}; + std::size_t host_len{}; bool user_matched{false}; // parse the given key diff --git a/src/other_tools/utils/curl_url_handle.hpp b/src/other_tools/utils/curl_url_handle.hpp index 3d1e6949..476277f3 100644 --- a/src/other_tools/utils/curl_url_handle.hpp +++ b/src/other_tools/utils/curl_url_handle.hpp @@ -15,6 +15,7 @@ #ifndef INCLUDED_SRC_OTHER_TOOLS_UTILS_CURL_URL_HANDLE_HPP #define INCLUDED_SRC_OTHER_TOOLS_UTILS_CURL_URL_HANDLE_HPP +#include #include #include #include @@ -56,10 +57,10 @@ struct ConfigKeyMatchDegree { // if a matching happened; bool matched{false}; // length of config key's host field if host was matched - size_t host_len{}; + std::size_t host_len{}; // length of config key's path field if path was matched; // comparison ends on a '/' char or the end of the path - size_t path_len{}; + std::size_t path_len{}; // signals a match for the user field between config key and remote URL, // only if user field exists in config key bool user_matched{false}; -- cgit v1.2.3