summaryrefslogtreecommitdiff
path: root/src/common/hex_util.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/hex_util.h')
-rw-r--r--src/common/hex_util.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/common/hex_util.h b/src/common/hex_util.h
index a0a0e78a4..120f1a5e6 100644
--- a/src/common/hex_util.h
+++ b/src/common/hex_util.h
@@ -14,7 +14,7 @@
14 14
15namespace Common { 15namespace Common {
16 16
17constexpr u8 ToHexNibble(char c) { 17[[nodiscard]] constexpr u8 ToHexNibble(char c) {
18 if (c >= 65 && c <= 70) { 18 if (c >= 65 && c <= 70) {
19 return c - 55; 19 return c - 55;
20 } 20 }
@@ -26,10 +26,10 @@ constexpr u8 ToHexNibble(char c) {
26 return c - 48; 26 return c - 48;
27} 27}
28 28
29std::vector<u8> HexStringToVector(std::string_view str, bool little_endian); 29[[nodiscard]] std::vector<u8> HexStringToVector(std::string_view str, bool little_endian);
30 30
31template <std::size_t Size, bool le = false> 31template <std::size_t Size, bool le = false>
32constexpr std::array<u8, Size> HexStringToArray(std::string_view str) { 32[[nodiscard]] constexpr std::array<u8, Size> HexStringToArray(std::string_view str) {
33 std::array<u8, Size> out{}; 33 std::array<u8, Size> out{};
34 if constexpr (le) { 34 if constexpr (le) {
35 for (std::size_t i = 2 * Size - 2; i <= 2 * Size; i -= 2) { 35 for (std::size_t i = 2 * Size - 2; i <= 2 * Size; i -= 2) {
@@ -44,7 +44,7 @@ constexpr std::array<u8, Size> HexStringToArray(std::string_view str) {
44} 44}
45 45
46template <typename ContiguousContainer> 46template <typename ContiguousContainer>
47std::string HexToString(const ContiguousContainer& data, bool upper = true) { 47[[nodiscard]] std::string HexToString(const ContiguousContainer& data, bool upper = true) {
48 static_assert(std::is_same_v<typename ContiguousContainer::value_type, u8>, 48 static_assert(std::is_same_v<typename ContiguousContainer::value_type, u8>,
49 "Underlying type within the contiguous container must be u8."); 49 "Underlying type within the contiguous container must be u8.");
50 50
@@ -60,11 +60,11 @@ std::string HexToString(const ContiguousContainer& data, bool upper = true) {
60 return out; 60 return out;
61} 61}
62 62
63constexpr std::array<u8, 16> AsArray(const char (&data)[17]) { 63[[nodiscard]] constexpr std::array<u8, 16> AsArray(const char (&data)[17]) {
64 return HexStringToArray<16>(data); 64 return HexStringToArray<16>(data);
65} 65}
66 66
67constexpr std::array<u8, 32> AsArray(const char (&data)[65]) { 67[[nodiscard]] constexpr std::array<u8, 32> AsArray(const char (&data)[65]) {
68 return HexStringToArray<32>(data); 68 return HexStringToArray<32>(data);
69} 69}
70 70