This is a StringView version of Star::String I literally just copy-pasted it all from there
| 10 | // This is a StringView version of Star::String |
| 11 | // I literally just copy-pasted it all from there |
| 12 | class StringView { |
| 13 | public: |
| 14 | typedef String::Char Char; |
| 15 | |
| 16 | typedef U8ToU32Iterator<std::string_view::const_iterator> const_iterator; |
| 17 | typedef Char value_type; |
| 18 | typedef value_type const& const_reference; |
| 19 | |
| 20 | using CaseSensitivity = String::CaseSensitivity; |
| 21 | |
| 22 | StringView(); |
| 23 | StringView(StringView const& s); |
| 24 | StringView(StringView&& s) noexcept; |
| 25 | StringView(String const& s); |
| 26 | |
| 27 | // These assume utf8 input |
| 28 | StringView(char const* s); |
| 29 | StringView(char const* s, size_t n); |
| 30 | StringView(std::string_view const& s); |
| 31 | StringView(std::string_view&& s) noexcept; |
| 32 | StringView(std::string const& s); |
| 33 | |
| 34 | StringView(Char const* s); |
| 35 | StringView(Char const* s, size_t n); |
| 36 | |
| 37 | // const& to internal utf8 data |
| 38 | std::string_view const& utf8() const; |
| 39 | std::string_view takeUtf8(); |
| 40 | ByteArray utf8Bytes() const; |
| 41 | // Pointer to internal utf8 data, null-terminated. |
| 42 | char const* utf8Ptr() const; |
| 43 | size_t utf8Size() const; |
| 44 | |
| 45 | const_iterator begin() const; |
| 46 | const_iterator end() const; |
| 47 | |
| 48 | size_t size() const; |
| 49 | size_t length() const; |
| 50 | |
| 51 | bool empty() const; |
| 52 | |
| 53 | Char operator[](size_t index) const; |
| 54 | // Throws StringException if i out of range. |
| 55 | Char at(size_t i) const; |
| 56 | |
| 57 | bool endsWith(StringView end, CaseSensitivity cs = CaseSensitivity::CaseSensitive) const; |
| 58 | bool endsWith(Char end, CaseSensitivity cs = CaseSensitivity::CaseSensitive) const; |
| 59 | bool beginsWith(StringView beg, CaseSensitivity cs = CaseSensitivity::CaseSensitive) const; |
| 60 | bool beginsWith(Char beg, CaseSensitivity cs = CaseSensitivity::CaseSensitive) const; |
| 61 | |
| 62 | typedef function<void(StringView, size_t, size_t)> SplitCallback; |
| 63 | void forEachSplitAnyView(StringView pattern, SplitCallback) const; |
| 64 | void forEachSplitView(StringView pattern, SplitCallback) const; |
| 65 | |
| 66 | bool hasChar(Char c) const; |
| 67 | // Identical to hasChar, except, if string is empty, tests if c is |
| 68 | // whitespace. |
| 69 | bool hasCharOrWhitespace(Char c) const; |
no outgoing calls
no test coverage detected