summaryrefslogtreecommitdiff
path: root/src/utils/cpp
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2024-08-27 16:52:18 +0200
committerMaksim Denisov <denisov.maksim@huawei.com>2024-09-09 13:07:13 +0200
commit52dc6e82e94f11047e907e04a64d13fd877d4e49 (patch)
tree045b5c5f87e9bc659ecc98c1b942ea73ddaf8ce6 /src/utils/cpp
parent31b1aab24c24b5e4d48979aa61576b20a8ec034d (diff)
downloadjustbuild-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.hpp8
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{};