summaryrefslogtreecommitdiff
path: root/src/utils/cpp/hex_string.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/cpp/hex_string.hpp')
-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{};