#pragma once #include #include class String; class StringView { typedef const char* Iterator; public: StringView(const char* c_str); StringView(const char* c_str, usize length); StringView(); StringView(const StringView&); StringView& operator=(const StringView&); Result to_string(); const char* chars() const { return m_string; } usize length() const { return m_length; } bool is_empty() const { return m_length == 0; } const char& operator[](usize) const; bool operator==(const char* other) const; bool operator==(StringView other) const; Result> split(StringView delim) const; Result> split_once(char delim) const; Result> split_view(char delim) const; bool contains(char v) const; static StringView from_fixed_size_cstring(const char* string, usize max); Result to_uint() const; Iterator begin() const { return m_string; } Iterator end() const { return m_string + m_length; } private: const char* m_string { nullptr }; usize m_length { 0 }; }; inline StringView operator""_sv(const char* cstring) { return StringView { cstring }; } inline StringView operator""_sv(const char* cstring, usize length) { return StringView { cstring, length }; }