summaryrefslogtreecommitdiffstats
path: root/src/common/hex_util.h
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2019-06-12 23:27:06 +0200
committerLioncash <mathew1800@gmail.com>2019-06-12 23:54:05 +0200
commita62088539ed02a8569814601b3b99b713c5d8a34 (patch)
tree03fe279e7651c55291f702f5a8b518cb07e35812 /src/common/hex_util.h
parentMerge pull request #2578 from lioncash/cnmt (diff)
downloadyuzu-a62088539ed02a8569814601b3b99b713c5d8a34.tar
yuzu-a62088539ed02a8569814601b3b99b713c5d8a34.tar.gz
yuzu-a62088539ed02a8569814601b3b99b713c5d8a34.tar.bz2
yuzu-a62088539ed02a8569814601b3b99b713c5d8a34.tar.lz
yuzu-a62088539ed02a8569814601b3b99b713c5d8a34.tar.xz
yuzu-a62088539ed02a8569814601b3b99b713c5d8a34.tar.zst
yuzu-a62088539ed02a8569814601b3b99b713c5d8a34.zip
Diffstat (limited to '')
-rw-r--r--src/common/hex_util.h11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/common/hex_util.h b/src/common/hex_util.h
index 68f003cb6..a64c9b485 100644
--- a/src/common/hex_util.h
+++ b/src/common/hex_util.h
@@ -7,6 +7,7 @@
#include <array>
#include <cstddef>
#include <string>
+#include <type_traits>
#include <vector>
#include <fmt/format.h>
#include "common/common_types.h"
@@ -30,13 +31,15 @@ std::array<u8, Size> HexStringToArray(std::string_view str) {
return out;
}
-std::string HexVectorToString(const std::vector<u8>& vector, bool upper = true);
+template <typename ContiguousContainer>
+std::string HexToString(const ContiguousContainer& data, bool upper = true) {
+ static_assert(std::is_same_v<typename ContiguousContainer::value_type, u8>,
+ "Underlying type within the contiguous container must be u8.");
-template <std::size_t Size>
-std::string HexArrayToString(std::array<u8, Size> array, bool upper = true) {
std::string out;
- for (u8 c : array)
+ for (const u8 c : data) {
out += fmt::format(upper ? "{:02X}" : "{:02x}", c);
+ }
return out;
}