aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-11-04 09:03:04 +0100
committerMarcoFalke <falke.marco@gmail.com>2021-11-09 17:42:13 +0100
commitfaa3ec2304051be7cfbe301cfbfbda3faf7514fc (patch)
treed4bd1d6efd163452352e275beec7674de246d9af /src/util
parentfa18038f519db76befb9a7bd0b1540143bfeb12b (diff)
span: Add std::byte helpers
Also, add Span<std::byte> interface to strencondings.
Diffstat (limited to 'src/util')
-rw-r--r--src/util/strencodings.cpp5
-rw-r--r--src/util/strencodings.h4
2 files changed, 3 insertions, 6 deletions
diff --git a/src/util/strencodings.cpp b/src/util/strencodings.cpp
index 15bd07b374..cc737f724c 100644
--- a/src/util/strencodings.cpp
+++ b/src/util/strencodings.cpp
@@ -138,11 +138,6 @@ std::string EncodeBase64(Span<const unsigned char> input)
return str;
}
-std::string EncodeBase64(const std::string& str)
-{
- return EncodeBase64(MakeUCharSpan(str));
-}
-
std::vector<unsigned char> DecodeBase64(const char* p, bool* pf_invalid)
{
static const int decode64_table[256] =
diff --git a/src/util/strencodings.h b/src/util/strencodings.h
index eedb5ec2f8..f5e636726a 100644
--- a/src/util/strencodings.h
+++ b/src/util/strencodings.h
@@ -50,7 +50,8 @@ bool IsHexNumber(const std::string& str);
std::vector<unsigned char> DecodeBase64(const char* p, bool* pf_invalid = nullptr);
std::string DecodeBase64(const std::string& str, bool* pf_invalid = nullptr);
std::string EncodeBase64(Span<const unsigned char> input);
-std::string EncodeBase64(const std::string& str);
+inline std::string EncodeBase64(Span<const std::byte> input) { return EncodeBase64(MakeUCharSpan(input)); }
+inline std::string EncodeBase64(const std::string& str) { return EncodeBase64(MakeUCharSpan(str)); }
std::vector<unsigned char> DecodeBase32(const char* p, bool* pf_invalid = nullptr);
std::string DecodeBase32(const std::string& str, bool* pf_invalid = nullptr);
@@ -189,6 +190,7 @@ std::optional<T> ToIntegral(const std::string& str)
*/
std::string HexStr(const Span<const uint8_t> s);
inline std::string HexStr(const Span<const char> s) { return HexStr(MakeUCharSpan(s)); }
+inline std::string HexStr(const Span<const std::byte> s) { return HexStr(MakeUCharSpan(s)); }
/**
* Format a paragraph of text to a fixed width, adding spaces for