diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2024-08-27 16:52:18 +0200 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2024-09-09 13:07:13 +0200 |
commit | 52dc6e82e94f11047e907e04a64d13fd877d4e49 (patch) | |
tree | 045b5c5f87e9bc659ecc98c1b942ea73ddaf8ce6 /src/utils/cpp | |
parent | 31b1aab24c24b5e4d48979aa61576b20a8ec034d (diff) | |
download | justbuild-52dc6e82e94f11047e907e04a64d13fd877d4e49.tar.gz |
Implement HashInfo class
...that validates hashes and stores some additional information about them.
Diffstat (limited to 'src/utils/cpp')
-rw-r--r-- | src/utils/cpp/hex_string.hpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/utils/cpp/hex_string.hpp b/src/utils/cpp/hex_string.hpp index 23544d49..4b0124c4 100644 --- a/src/utils/cpp/hex_string.hpp +++ b/src/utils/cpp/hex_string.hpp @@ -15,6 +15,8 @@ #ifndef INCLUDED_SRC_UTILS_CPP_HEX_STRING_HPP #define INCLUDED_SRC_UTILS_CPP_HEX_STRING_HPP +#include <algorithm> +#include <cctype> #include <cstddef> #include <iomanip> #include <iostream> @@ -22,6 +24,12 @@ #include <sstream> #include <string> +[[nodiscard]] static inline auto IsHexString(std::string const& s) noexcept + -> bool { + return std::all_of( + s.begin(), s.end(), [](unsigned char c) { return std::isxdigit(c); }); +} + [[nodiscard]] static inline auto ToHexString(std::string const& bytes) -> std::string { std::ostringstream ss{}; |