16namespace Azure {
namespace Core {
namespace _internal {
22 struct StringExtensions final
24 static constexpr char ToUpper(
char c)
noexcept
26 return (c <
'a' || c >
'z') ? c : c - (
'a' -
'A');
29 static constexpr char ToLower(
char c)
noexcept
31 return (c <
'A' || c >
'Z') ? c : c + (
'a' -
'A');
34 static constexpr bool IsDigit(
char c)
noexcept {
return c >=
'0' && c <=
'9'; }
36 static constexpr bool IsHexDigit(
char c)
noexcept
38 return IsDigit(c) || (c >=
'A' && c <=
'F') || (c >=
'a' && c <=
'f');
41 static constexpr bool IsAlphaNumeric(
char c)
noexcept
43 return IsDigit(c) || (c >=
'A' && c <=
'Z') || (c >=
'a' && c <=
'z');
46 static constexpr bool IsSpace(
char c)
noexcept {
return c ==
' ' || (c >=
'\t' && c <=
'\r'); }
48 static constexpr bool IsPrintable(
char c)
noexcept {
return c >=
' ' && c <=
'~'; }
50 struct CaseInsensitiveComparator final
52 bool operator()(std::string
const& lhs, std::string
const& rhs)
const
54 return std::lexicographical_compare(
55 lhs.begin(), lhs.end(), rhs.begin(), rhs.end(), [](
auto l,
auto r) {
56 return ToLower(l) < ToLower(r);
61 static bool LocaleInvariantCaseInsensitiveEqual(
62 std::string
const& lhs,
63 std::string
const& rhs)
noexcept
65 auto const rhsSize = rhs.size();
66 if (lhs.size() != rhsSize)
71 auto const lhsData = lhs.c_str();
72 auto const rhsData = rhs.c_str();
73 for (
size_t i = 0; i < rhsSize; ++i)
75 if (ToLower(lhsData[i]) != ToLower(rhsData[i]))
84 static std::string ToLower(std::string src)
86 std::transform(src.begin(), src.end(), src.begin(), [](
auto c) { return ToLower(c); });
90 static std::string ToUpper(std::string src)
92 std::transform(src.begin(), src.end(), src.begin(), [](
auto c) { return ToUpper(c); });
96 static std::vector<std::string> Split(
99 bool removeEmptyEntries =
false)
101 std::vector<std::string> result;
103 const auto len = s.size();
107 auto end = s.find(separator, start);
108 if (end == std::string::npos)
112 if (!removeEmptyEntries || start < end)
114 result.push_back(s.substr(start, end - start));
Compute the hash value for the input binary data, using SHA256, SHA384 and SHA512.
Definition azure_assert.hpp:57