38 lines
1.3 KiB
C++
38 lines
1.3 KiB
C++
#ifndef ARBUTILS_CONSTSTRING_HPP
|
|
#define ARBUTILS_CONSTSTRING_HPP
|
|
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <cstring>
|
|
#include <string>
|
|
#include "__ConstStringCore.hpp"
|
|
|
|
ConstStringCore(
|
|
ConstString,
|
|
inline static uint32_t constexpr Hash(char const* input) {
|
|
return (*input) ? static_cast<uint32_t>((*input)) + 33 * Hash(input + 1) : 5381;
|
|
};)
|
|
|
|
inline constexpr Arbutils::ConstString
|
|
operator"" _const(const char* c, size_t l) {
|
|
return Arbutils::ConstString(c, l);
|
|
}
|
|
inline constexpr Arbutils::ConstString operator"" _c(const char* c, size_t l) { return Arbutils::ConstString(c, l); }
|
|
|
|
ConstStringCore(
|
|
CaseInsensitiveConstString,
|
|
inline static constexpr char charToLower(const char c) {
|
|
return (c >= 'A' && c <= 'Z') ? c + ('a' - 'A') : c;
|
|
} inline static uint32_t constexpr Hash(char const* input) {
|
|
return charToLower(*input) ? static_cast<uint32_t>(charToLower(*input)) + 33 * Hash(input + 1) : 5381;
|
|
};);
|
|
|
|
inline constexpr Arbutils::CaseInsensitiveConstString operator"" _const_nocase(const char* c, size_t l) {
|
|
return Arbutils::CaseInsensitiveConstString(c, l);
|
|
}
|
|
inline constexpr Arbutils::CaseInsensitiveConstString operator"" _cnc(const char* c, size_t l) {
|
|
return Arbutils::CaseInsensitiveConstString(c, l);
|
|
}
|
|
|
|
#endif // ARBUTILS_CONSTSTRING_HPP
|