From 34bc3b759eeb6e115b33082de9edd1d7d4a2aed4 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Fri, 2 Aug 2024 19:42:05 -0500 Subject: [PATCH] updated build system --- support/3rd_party/include/utils/common.hpp | 14 +++++++++----- support/3rd_party/include/utils/config.hpp | 8 ++++++++ support/3rd_party/include/utils/string.hpp | 9 +++++++++ .../3rd_party/test/src/utils/encryption_test.cpp | 2 +- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/support/3rd_party/include/utils/common.hpp b/support/3rd_party/include/utils/common.hpp index c09513be..f34b0bdc 100644 --- a/support/3rd_party/include/utils/common.hpp +++ b/support/3rd_party/include/utils/common.hpp @@ -84,11 +84,15 @@ get_next_available_port(std::uint16_t first_port, [[nodiscard]] auto resolve_variables(std::wstring_view str) -> std::wstring; -// template implementations -template -[[nodiscard]] inline auto divide_with_ceiling(const val_t &n, - const val_t &d) -> val_t { - return n ? (n / d) + (n % d != 0) : 0; +template +[[nodiscard]] inline constexpr auto +divide_with_ceiling(result_t numerator, data_t denominator) -> result_t { + static_assert(std::is_integral_v>, + "denominator must be an integral type"); + + return denominator == 0 + ? 0 + : (numerator / denominator) + (numerator % denominator != 0); } #if defined(PROJECT_ENABLE_LIBSODIUM) diff --git a/support/3rd_party/include/utils/config.hpp b/support/3rd_party/include/utils/config.hpp index 32e549aa..c503ffcc 100644 --- a/support/3rd_party/include/utils/config.hpp +++ b/support/3rd_party/include/utils/config.hpp @@ -287,6 +287,14 @@ extern "C" { #define statfs64 statfs #endif // !defined(statfs64) +#if !defined(off64_t) +#define off64_t std::size_t +#endif // !defined(off64_t) + +#if !defined(__off64_t) +#define __off64_t off64_t +#endif // !defined(__off64_t) + namespace repertory { using data_buffer = std::vector; using mutex_lock = std::lock_guard; diff --git a/support/3rd_party/include/utils/string.hpp b/support/3rd_party/include/utils/string.hpp index 2d648cf7..b119c376 100644 --- a/support/3rd_party/include/utils/string.hpp +++ b/support/3rd_party/include/utils/string.hpp @@ -162,6 +162,9 @@ template [[nodiscard]] auto to_utf8(std::wstring_view str) -> std::string; +template +[[nodiscard]] inline auto zero_pad(string_t str, std::size_t count) -> string_t; + template struct chain_replace_with_hex final { explicit chain_replace_with_hex(string_t &value) : str(value) {} @@ -455,6 +458,12 @@ inline auto split(std::wstring_view str, std::wstring_view delim, bool should_trim) -> std::vector { return split_t(str, delim, should_trim); } + +template +inline auto zero_pad(string_t str, std::size_t count) -> string_t { + str.insert(str.begin(), count - str.length(), '0'); + return str; +} } // namespace repertory::utils::string #endif // REPERTORY_INCLUDE_UTILS_STRING_HPP_ diff --git a/support/3rd_party/test/src/utils/encryption_test.cpp b/support/3rd_party/test/src/utils/encryption_test.cpp index 94914031..cc66ab8d 100644 --- a/support/3rd_party/test/src/utils/encryption_test.cpp +++ b/support/3rd_party/test/src/utils/encryption_test.cpp @@ -21,7 +21,7 @@ */ #if defined(PROJECT_ENABLE_LIBSODIUM) && defined(PROJECT_ENABLE_BOOST) -#include "gtest/gtest.hpp" +#include "gtest/gtest.h" #include "utils/collection.hpp" #include "utils/encrypt.hpp"