Address compiler warnings #10
This commit is contained in:
@ -38,11 +38,13 @@ void calculate_allocation_size(bool directory, std::uint64_t file_size,
|
||||
|
||||
template <typename t>
|
||||
[[nodiscard]] auto collection_excludes(t collection,
|
||||
const typename t::value_type &v) -> bool;
|
||||
const typename t::value_type &val)
|
||||
-> bool;
|
||||
|
||||
template <typename t>
|
||||
[[nodiscard]] auto collection_includes(t collection,
|
||||
const typename t::value_type &v) -> bool;
|
||||
const typename t::value_type &val)
|
||||
-> bool;
|
||||
|
||||
[[nodiscard]] auto compare_version_strings(std::string version1,
|
||||
std::string version2) -> int;
|
||||
@ -53,7 +55,8 @@ template <typename t>
|
||||
|
||||
[[nodiscard]] auto create_uuid_string() -> std::string;
|
||||
|
||||
[[nodiscard]] auto create_volume_label(const provider_type &pt) -> std::string;
|
||||
[[nodiscard]] auto create_volume_label(const provider_type &prov)
|
||||
-> std::string;
|
||||
|
||||
template <typename t>
|
||||
[[nodiscard]] auto divide_with_ceiling(const t &n, const t &d) -> t;
|
||||
@ -66,7 +69,7 @@ template <typename t>
|
||||
-> std::string;
|
||||
|
||||
template <typename t>
|
||||
[[nodiscard]] auto from_hex_string(const std::string &str, t &v) -> bool;
|
||||
[[nodiscard]] auto from_hex_string(const std::string &str, t &val) -> bool;
|
||||
|
||||
[[nodiscard]] auto generate_random_string(std::uint16_t length) -> std::string;
|
||||
|
||||
@ -77,7 +80,7 @@ template <typename t>
|
||||
|
||||
[[nodiscard]] auto get_file_time_now() -> std::uint64_t;
|
||||
|
||||
void get_local_time_now(struct tm &localTime);
|
||||
void get_local_time_now(struct tm &local_time);
|
||||
|
||||
[[nodiscard]] auto get_next_available_port(std::uint16_t first_port,
|
||||
std::uint16_t &available_port)
|
||||
@ -85,11 +88,12 @@ void get_local_time_now(struct tm &localTime);
|
||||
|
||||
[[nodiscard]] auto get_time_now() -> std::uint64_t;
|
||||
|
||||
template <typename t>
|
||||
[[nodiscard]] auto random_between(const t &begin, const t &end) -> t;
|
||||
template <typename data_type>
|
||||
[[nodiscard]] auto random_between(const data_type &begin, const data_type &end)
|
||||
-> data_type;
|
||||
|
||||
template <typename t>
|
||||
void remove_element_from(t &v, const typename t::value_type &value);
|
||||
void remove_element_from(t &collection, const typename t::value_type &val);
|
||||
|
||||
[[nodiscard]] auto reset_curl(CURL *curl_handle) -> CURL *;
|
||||
|
||||
@ -97,28 +101,30 @@ void remove_element_from(t &v, const typename t::value_type &value);
|
||||
-> bool;
|
||||
|
||||
void spin_wait_for_mutex(std::function<bool()> complete,
|
||||
std::condition_variable &cv, std::mutex &mtx,
|
||||
const std::string &txt = "");
|
||||
std::condition_variable &cond, std::mutex &mtx,
|
||||
const std::string &text = "");
|
||||
|
||||
void spin_wait_for_mutex(bool &complete, std::condition_variable &cv,
|
||||
std::mutex &mtx, const std::string &txt = "");
|
||||
void spin_wait_for_mutex(bool &complete, std::condition_variable &cond,
|
||||
std::mutex &mtx, const std::string &text = "");
|
||||
|
||||
template <typename t>
|
||||
[[nodiscard]] auto to_hex_string(const t &v) -> std::string;
|
||||
[[nodiscard]] auto to_hex_string(const t &val) -> std::string;
|
||||
|
||||
// template implementations
|
||||
template <typename t>
|
||||
[[nodiscard]] auto collection_excludes(t collection,
|
||||
const typename t::value_type &v)
|
||||
const typename t::value_type &val)
|
||||
-> bool {
|
||||
return std::find(collection.begin(), collection.end(), v) == collection.end();
|
||||
return std::find(collection.begin(), collection.end(), val) ==
|
||||
collection.end();
|
||||
}
|
||||
|
||||
template <typename t>
|
||||
[[nodiscard]] auto collection_includes(t collection,
|
||||
const typename t::value_type &v)
|
||||
const typename t::value_type &val)
|
||||
-> bool {
|
||||
return std::find(collection.begin(), collection.end(), v) != collection.end();
|
||||
return std::find(collection.begin(), collection.end(), val) !=
|
||||
collection.end();
|
||||
}
|
||||
|
||||
template <typename t>
|
||||
@ -127,12 +133,14 @@ template <typename t>
|
||||
}
|
||||
|
||||
template <typename t>
|
||||
[[nodiscard]] auto from_hex_string(const std::string &str, t &v) -> bool {
|
||||
v.clear();
|
||||
if (not(str.length() % 2u)) {
|
||||
for (std::size_t i = 0u; i < str.length(); i += 2u) {
|
||||
v.emplace_back(static_cast<typename t::value_type>(
|
||||
strtol(str.substr(i, 2u).c_str(), nullptr, 16)));
|
||||
[[nodiscard]] auto from_hex_string(const std::string &str, t &val) -> bool {
|
||||
static constexpr const auto base16 = 16;
|
||||
|
||||
val.clear();
|
||||
if (not(str.length() % 2U)) {
|
||||
for (std::size_t i = 0U; i < str.length(); i += 2U) {
|
||||
val.emplace_back(static_cast<typename t::value_type>(
|
||||
strtol(str.substr(i, 2U).c_str(), nullptr, base16)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -140,30 +148,32 @@ template <typename t>
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename t>
|
||||
[[nodiscard]] auto random_between(const t &begin, const t &end) -> t {
|
||||
srand(static_cast<unsigned int>(get_time_now()));
|
||||
return begin + static_cast<t>(rand()) % ((end + 1) - begin);
|
||||
template <typename data_type>
|
||||
[[nodiscard]] auto random_between(const data_type &begin, const data_type &end)
|
||||
-> data_type {
|
||||
return begin + repertory_rand<data_type>() % ((end + 1) - begin);
|
||||
}
|
||||
|
||||
template <typename t>
|
||||
void remove_element_from(t &v, const typename t::value_type &value) {
|
||||
v.erase(std::remove(v.begin(), v.end(), value), v.end());
|
||||
void remove_element_from(t &collection, const typename t::value_type &value) {
|
||||
collection.erase(std::remove(collection.begin(), collection.end(), value),
|
||||
collection.end());
|
||||
}
|
||||
|
||||
template <typename t>
|
||||
[[nodiscard]] auto to_hex_string(const t &value) -> std::string {
|
||||
std::string ret{};
|
||||
|
||||
std::array<char, 3> h{};
|
||||
std::array<char, 3> tmp{};
|
||||
for (const auto &num : value) {
|
||||
#ifdef _WIN32
|
||||
sprintf_s(h.data(), h.size() - 1U, "%x", static_cast<std::uint8_t>(num));
|
||||
#else
|
||||
sprintf(h.data(), "%x", static_cast<std::uint8_t>(num));
|
||||
sprintf(tmp.data(), "%x", static_cast<std::uint8_t>(num));
|
||||
#endif
|
||||
|
||||
ret += (strlen(h.data()) == 1) ? std::string("0") + h.data() : h.data();
|
||||
ret +=
|
||||
(strlen(tmp.data()) == 1) ? std::string("0") + tmp.data() : tmp.data();
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
Reference in New Issue
Block a user