Sese Framework
2.3.0
A cross-platform framework
|
String view. More...
#include <SString.h>
Classes | |
class | Iterator |
Unicode character iterator. More... | |
Public Member Functions | |
SStringView () noexcept=default | |
SStringView (const char *u8str) noexcept | |
virtual | ~SStringView ()=default |
Iterator | begin () |
Iterator | end () |
bool | null () const |
bool | empty () const |
size_t | len () const |
virtual size_t | size () const |
const char * | data () const |
int32_t | find (const SStringView &str) const |
int32_t | find (const char *u8str) const |
int32_t | findByBytes (const char *bytes) const |
SString | trim () const |
SString | reverse () const |
SString | append (const SStringView &str) const |
SString | append (const char *u8str) const |
std::vector< SString > | split (const SStringView &str) const |
std::vector< SString > | split (const char *str) const |
SString | substring (size_t begin) const |
SString | substring (size_t begin, size_t len) const |
Extract substring [begin, begin + len - 1]. | |
bool | endsWith (const SStringView &suffix) const |
Check if the string ends with a given substring. | |
bool | endsWith (const std::string_view &suffix) const |
Check if the string ends with a given substring. | |
bool | startsWith (const SStringView &prefix) const |
Check if the string starts with a given substring. | |
bool | startsWith (const std::string_view &prefix) const |
Check if the string starts with a given substring. | |
bool | isLower () const |
Check if the letter is entirely lowercase. | |
bool | isUpper () const |
Check if the letter is entirely uppercase. | |
SString | toLower () const |
Create a copy with all letters converted to lowercase. | |
SString | toUpper () const |
Create a copy with all letters converted to uppercase. | |
SChar | at (size_t index) const |
std::vector< SChar > | toChars () const |
std::string | toString () const |
std::wstring | toWString () const |
std::unique_ptr< wchar_t[]> | toCWString () const |
SChar | operator[] (size_t index) const |
bool | operator!= (const SStringView &str) const |
bool | operator!= (const char *u8str) const |
bool | operator== (const SStringView &str) const |
bool | operator== (const char *u8str) const |
SString | operator+ (const SStringView &str) const |
SString | operator+ (const char *u8str) const |
Protected Attributes | |
char * | _data = nullptr |
size_t | _size = 0 |
String view.
|
defaultnoexcept |
|
explicitnoexcept |
References sstr::getByteLengthFromUTF8String().
|
virtualdefault |
SString SStringView::append | ( | const char * | u8str | ) | const |
Append string to the end
u8str | String to append |
References sstr::SString::_capacity, _data, _size, BLOCK_SIZE, and len().
|
nodiscard |
Append string to the end
str | String to append |
References sstr::SString::_capacity, _data, _size, and BLOCK_SIZE.
Referenced by operator+(), and operator+().
|
nodiscard |
References _data, _size, c, sstr::getSizeFromUTF8Char(), sstr::getUnicodeCharFromUTF8Char(), and null_char.
Referenced by operator[](), substring(), and substring().
SStringView::IteratorType SStringView::begin | ( | ) |
Referenced by substring(), and substring().
|
nodiscard |
Get buffer pointer
References _data.
Referenced by find(), sese::text::AbstractStringBuffer::insertAt(), sstr::SString::operator+=(), and sese::io::OutputStream::write().
|
nodiscard |
Check if the string is empty
true | String is empty |
false | String is not empty |
References _data.
|
nodiscard |
|
nodiscard |
int32_t SStringView::find | ( | const char * | u8str | ) | const |
Find substring, with index units in characters
u8str | Substring |
References _data, sstr::BM(), count(), and sstr::getSizeFromUTF8Char().
|
nodiscard |
int32_t SStringView::findByBytes | ( | const char * | bytes | ) | const |
Find byte string, with index units in bytes
bytes | Substring |
References _data, and sstr::BM().
|
nodiscard |
|
nodiscard |
|
nodiscard |
Get the number of characters in the string
References _data, _size, sstr::getSizeFromUTF8Char(), and len().
Referenced by sese::text::AbstractStringBuffer::append(), append(), sese::text::AbstractStringBuffer::insertAt(), sese::text::AbstractStringBuffer::insertAt(), len(), sstr::SString::operator+=(), substring(), toChars(), and toCWString().
|
nodiscard |
bool SStringView::operator!= | ( | const char * | u8str | ) | const |
References _data.
bool SStringView::operator!= | ( | const SStringView & | str | ) | const |
References _data.
SString SStringView::operator+ | ( | const SStringView & | str | ) | const |
References append().
bool SStringView::operator== | ( | const char * | u8str | ) | const |
References _data.
bool SStringView::operator== | ( | const SStringView & | str | ) | const |
References _data.
|
nodiscard |
Reverse the string
References _data, _size, BLOCK_SIZE, and sstr::getSizeFromUTF8Char().
|
nodiscardvirtual |
Get the number of bytes in the string
Reimplemented in sstr::SString.
References _data, and sstr::getByteLengthFromUTF8String().
Referenced by sstr::SString::operator+=(), split(), startsWith(), toCWString(), and sese::io::OutputStream::write().
std::vector< SString > SStringView::split | ( | const char * | str | ) | const |
Split the string
str | Delimiter |
References _data, sstr::BM(), sstr::SString::fromUTF8(), sstr::getByteLengthFromUTF8String(), and size().
|
nodiscard |
|
nodiscard |
|
nodiscard |
|
nodiscard |
Extract substring [begin, len - 1]
begin | Starting index of the substring |
References sstr::SString::_capacity, _data, _size, at(), begin(), and BLOCK_SIZE.
|
nodiscard |
Extract substring [begin, begin + len - 1].
begin | Starting index of the substring |
len | Length to extract |
References sstr::SString::_capacity, _data, _size, at(), begin(), BLOCK_SIZE, count(), sstr::getSizeFromUTF8Char(), and len().
|
nodiscard |
|
nodiscard |
References _data, _size, count(), sstr::getSizeFromUTF8Char(), sstr::getUnicodeCharFromUTF8Char(), len(), and size().
Referenced by toWString().
|
nodiscard |
|
nodiscard |
References _data.
|
nodiscard |
|
nodiscard |
References toCWString().
|
nodiscard |
Trim whitespace from both ends of the string
References _data, _size, and BLOCK_SIZE.
|
protected |
Referenced by append(), append(), at(), begin(), data(), empty(), end(), endsWith(), endsWith(), find(), findByBytes(), sstr::SString::fromSChars(), sstr::SString::fromSChars(), sstr::SString::fromUCS2LE(), sstr::SString::fromUTF8(), isLower(), isUpper(), len(), null(), operator!=(), operator!=(), sstr::SString::operator+=(), sstr::SString::operator+=(), operator==(), operator==(), reverse(), size(), split(), split(), sstr::SString::SString(), sstr::SString::SString(), startsWith(), startsWith(), substring(), substring(), toChars(), toCWString(), sstr::SString::toLower(), toLower(), toString(), sstr::SString::toUpper(), toUpper(), and trim().
|
protected |
Referenced by append(), append(), at(), begin(), end(), endsWith(), endsWith(), sstr::SString::fromSChars(), sstr::SString::fromSChars(), sstr::SString::fromUCS2LE(), sstr::SString::fromUTF8(), isLower(), isUpper(), len(), sstr::SString::operator+=(), sstr::SString::operator+=(), reverse(), sstr::SString::size(), sstr::SString::SString(), sstr::SString::SString(), startsWith(), startsWith(), substring(), substring(), toChars(), toCWString(), toLower(), toUpper(), and trim().