1 #ifndef TTKSTRINGVIEW_H
2 #define TTKSTRINGVIEW_H
28 template<
typename _CharT,
typename _Traits = std::
char_traits<_CharT>>
112 throw std::out_of_range(
"o exceeds length");
161 return l - c.length();
182 return l - sv.size();
262 c[
int(s[i - 1])] = i;
267 if(memcmp(s,
m_data + j, m) == 0)
399 const _CharT s[2] = { c,
'\0' };
407 return rc != 0 ? rc : (
m_length == sv.m_length ? 0 :
m_length < sv.m_length ? -1 : 1);
410 [[nodiscard]] constexpr
int compare(
const _CharT *
data)
const noexcept
420 return rc != 0 ? rc : (
m_length == s.length() ? 0 :
m_length < s.length() ? -1 : 1);
423 friend std::basic_ostream<_CharT>& operator<<(std::basic_ostream<_CharT> &os,
const TTKBaseStringView &sv)
425 os.write(sv.m_data, sv.m_length);
437 const _CharT *start = cur;
438 while(start < (line_end - 1) && *start == split_char)
443 const char *
end = start + 1;
444 while(end < (line_end - 1) && *end != split_char)
498 return std::_Hash_array_representation(sv.data(), sv.size());
500 return std::_Hash_impl::hash(sv.data(), sv.size());
511 return std::_Hash_array_representation(sv.data(), sv.size());
513 return std::_Hash_impl::hash(sv.data(), sv.size());
524 return std::_Hash_array_representation(sv.data(), sv.size());
526 return std::_Hash_impl::hash(sv.data(), sv.size());
537 return std::_Hash_array_representation(sv.data(), sv.size());
539 return std::_Hash_impl::hash(sv.data(), sv.size());
550 namespace string_view_literals
552 inline constexpr
TTKStringView operator""sv(
const char* s,
size_t l) noexcept
557 inline constexpr
TTKWStringView operator""sv(
const wchar_t* s,
size_t l) noexcept
586 #endif // TTKSTRINGVIEW_H
constexpr TTKBaseStringView substr(size_type a, size_type b) const noexcept
constexpr TTKBaseStringView(const _CharT(&data)[T])
constexpr const _CharT * data() const noexcept
bool operator>(const value_type &other) noexcept
constexpr const_reverse_iterator rend() const noexcept
constexpr int compare(const _CharT *data) const noexcept
size_t operator()(const TTKU32StringView sv) const noexcept
constexpr const _Tp & min(const _Tp &a, const _Tp &b) noexcept
constexpr TTKBaseStringView substr(size_type a) const noexcept
constexpr const_iterator cbegin() const noexcept
constexpr size_type find_first_of(const _CharT *s, size_type l=0) const noexcept
const_reverse_iterator reverse_iterator
constexpr size_type length() const noexcept
constexpr TTKBaseStringView(const _CharT *data, const size_type length)
const _CharT & at(size_type o) const
constexpr const_reverse_iterator rbegin() const noexcept
constexpr size_type find_first_of(_CharT c, size_type l=0) const noexcept
constexpr size_type find(const _CharT c) const noexcept
constexpr size_type find(const _CharT *c, size_type sl) const noexcept
constexpr size_type find_first_not_of(const _CharT *s, size_type o) const
const _CharT & const_reference
constexpr size_type rfind(const _CharT *s) const noexcept
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
bool operator==(const TTKBaseStringView &other) noexcept
TTKBaseStringView< wchar_t > TTKWStringView
constexpr const_iterator begin() const noexcept
constexpr TTKBaseStringView() noexcept
The class of the string view modules.
constexpr const _CharT & front() const noexcept
constexpr TTKBaseStringView(const _CharT *data)
const _CharT * const_pointer
std::reverse_iterator< const_iterator > const_reverse_iterator
constexpr size_type find_first_not_of(const value_type &s, size_type o) const
bool operator==(const _CharT *other) noexcept
bool operator<=(const value_type &other) noexcept
static constexpr size_type npos
constexpr const_iterator end() const noexcept
constexpr int compare(const value_type &s) const noexcept
size_t operator()(const TTKU16StringView sv) const noexcept
constexpr size_type find_first_not_of(const _CharT *s) const
constexpr size_type find(const value_type &c) const noexcept
bool operator!=(const TTKBaseStringView &other) noexcept
bool operator!=(const _CharT *other) noexcept
bool operator>=(const TTKBaseStringView &other) noexcept
constexpr size_type find(const TTKBaseStringView &sv) const noexcept
bool operator<(const value_type &other) noexcept
const _CharT * const_iterator
constexpr size_type size() const noexcept
constexpr const_reverse_iterator crend() const noexcept
value_type & operator<<(value_type &s)
TTKBaseStringView< char > TTKStringView
constexpr const_iterator cend() const noexcept
constexpr bool empty() const noexcept
size_t operator()(const TTKStringView sv) const noexcept
bool operator!=(const value_type &other) noexcept
TTKBaseStringView< char16_t > TTKU16StringView
bool operator<=(const TTKBaseStringView &other) noexcept
std::basic_string< _CharT > value_type
The namespace of the string_view literals.
constexpr size_type find(const _CharT *c) const noexcept
constexpr size_type find_first_not_of(_CharT c, size_type o=0) const
constexpr int compare(const TTKBaseStringView &sv) const noexcept
bool operator>(const TTKBaseStringView &other) noexcept
constexpr const _CharT & operator[](size_type o) const
constexpr TTKBaseStringView & operator=(const TTKBaseStringView &sv) noexcept
bool operator>(const _CharT *other) noexcept
bool operator>=(const _CharT *other) noexcept
constexpr size_type find_first_of(const value_type &s, size_type l=0) const noexcept
constexpr size_type find_first_not_of(const value_type &s) const
bool operator>=(const value_type &other) noexcept
friend value_type & operator+=(value_type &s, const TTKBaseStringView &sv)
bool operator<=(const _CharT *other) noexcept
TTKBaseStringView< char32_t > TTKU32StringView
bool operator<(const _CharT *other) noexcept
constexpr const _CharT & back() const noexcept
bool operator==(const value_type &other) noexcept
bool operator<(const TTKBaseStringView &other) noexcept
static TTKBaseStringView split(const _CharT *&cur, const _CharT *line_end, _CharT split_char)
constexpr const_reverse_iterator crbegin() const noexcept
constexpr size_type rfind(const _CharT c) const noexcept
size_t operator()(const TTKWStringView sv) const noexcept