Arbutils/src/ConstString.hpp

38 lines
1.3 KiB
C++
Raw Normal View History

2020-02-26 11:57:18 +00:00
#ifndef ARBUTILS_CONSTSTRING_HPP
#define ARBUTILS_CONSTSTRING_HPP
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <string>
2020-02-27 16:22:06 +00:00
#include "__ConstStringCore.hpp"
2020-02-27 16:22:06 +00:00
ConstStringCore(
ConstString,
inline static uint32_t constexpr Hash(char const* input) {
return (*input) ? static_cast<uint32_t>((*input)) + 33 * Hash(input + 1) : 5381;
};)
2020-02-26 11:57:18 +00:00
2020-02-27 16:22:06 +00:00
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); }
2020-02-27 16:22:06 +00:00
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);
2020-02-26 11:57:18 +00:00
}
#endif // ARBUTILS_CONSTSTRING_HPP