111 explicit
WString(const
wchar_t* str) noexcept;
182 const wchar_t* text = data();
183 return text ? text + size() :
nullptr;
238 inline const wchar_t*
data() const noexcept {
239 return static_cast<const wchar_t*
>(m_text);
246 inline std::size_t
size() const noexcept {
247 return m_text.Length();
254 inline std::size_t
length() const noexcept {
262 inline bool empty() const noexcept {
272 inline wchar_t operator[](std::size_t index)
const noexcept {
273 return m_text[index];
280 inline explicit operator bool() const noexcept {
281 return static_cast<bool>(m_text);
296 inline operator std::wstring_view() const noexcept {
297 return static_cast<std::wstring_view
>(m_text);
304 inline explicit operator std::wstring()
const {
305 return static_cast<std::wstring
>(m_text);
313 inline explicit operator const wchar_t*()
const noexcept {
314 return static_cast<const wchar_t*
>(m_text);
321 explicit operator String() const noexcept;
378 static void Split(std::wstring_view str, std::vector<WString>& out)
noexcept;
386 static void Explode(std::wstring_view str,
wchar_t delimiter, std::queue<WString>& out)
noexcept;
393 return ToLower(
static_cast<std::wstring_view
>(*
this));
401 return ToUpper(
static_cast<std::wstring_view
>(*
this));
409 return SanitizeNewlines(
static_cast<std::wstring_view
>(*
this));
417 return RemoveWhitespace(
static_cast<std::wstring_view
>(*
this));
425 return IsInteger(
static_cast<std::wstring_view
>(*
this));
432 inline std::vector<WString>
Split() const noexcept {
433 std::vector<WString> out;
434 Split(
static_cast<std::wstring_view
>(*
this), out);
443 inline std::queue<WString>
Explode(
wchar_t delimiter)
const noexcept {
444 std::queue<WString> out;
445 Explode(
static_cast<std::wstring_view
>(*
this), delimiter, out);
462 return m_text == other.m_text;
471 return !(*
this == other);
480 return m_text == str;
489 return !(*
this == str);
498 return m_text <=> other.m_text;
506 inline std::strong_ordering
operator<=>(
const wchar_t* str)
const noexcept {
507 return m_text <=> str;
529 return stream << text.
Bytes();
574 return std::hash<std::wstring_view>{}(
static_cast<std::wstring_view
>(text));
Wide counterpart of String.
Definition wstring.hxx:91
std::vector< WString > Split() const noexcept
Whitespace-separated tokens.
Definition wstring.hxx:432
std::size_t size() const noexcept
Code-unit count; 0 when null or empty.
Definition wstring.hxx:246
const_reverse_iterator rbegin() const noexcept
Reverse begin.
Definition wstring.hxx:206
const_iterator cend() const noexcept
One past the last character, or null.
Definition wstring.hxx:198
const wchar_t * data() const noexcept
Contiguous pointer; null when the buffer is null.
Definition wstring.hxx:238
WString ToUpper() const noexcept
ASCII-letter upper case of this text.
Definition wstring.hxx:400
std::strong_ordering operator<=>(const WString &other) const noexcept
Content order.
Definition wstring.hxx:497
WString ToLower() const noexcept
ASCII-letter lower case of this text.
Definition wstring.hxx:392
static bool IsInteger(std::wstring_view str) noexcept
Optional sign plus ASCII digits.
bool operator!=(const WString &other) const noexcept
Content inequality.
Definition wstring.hxx:470
bool operator==(const wchar_t *str) const noexcept
Content equality with a wide C string.
Definition wstring.hxx:479
std::size_t length() const noexcept
Same as size.
Definition wstring.hxx:254
bool operator!=(const wchar_t *str) const noexcept
Content inequality with a wide C string.
Definition wstring.hxx:488
const_reverse_iterator rend() const noexcept
Reverse end.
Definition wstring.hxx:214
static void Explode(std::wstring_view str, wchar_t delimiter, std::queue< WString > &out) noexcept
Tokens on delimiter.
std::strong_ordering operator<=>(const wchar_t *str) const noexcept
Content order against a wide C string.
Definition wstring.hxx:506
std::reverse_iterator< const_iterator > const_reverse_iterator
Reverse observer.
Definition wstring.hxx:95
WString SanitizeNewlines() const noexcept
CR LF to LF on this text.
Definition wstring.hxx:408
bool empty() const noexcept
Whether size is zero.
Definition wstring.hxx:262
bool operator==(const WString &other) const noexcept
Content equality.
Definition wstring.hxx:461
static WString ToLower(std::wstring_view str) noexcept
ASCII-letter lower case; other code points copied.
void swap(WString &other) noexcept
Swaps buffers with other.
const wchar_t * const_iterator
Contiguous observer.
Definition wstring.hxx:94
const_reverse_iterator crbegin() const noexcept
Reverse begin.
Definition wstring.hxx:222
static WString SanitizeNewlines(std::wstring_view str) noexcept
Turns CR LF into LF.
static WString RemoveWhitespace(std::wstring_view str) noexcept
Drops iswspace code units.
const WCString & Bytes() const noexcept
Owned code units.
Definition wstring.hxx:327
wchar_t operator[](std::size_t index) const noexcept
Code unit at index.
Definition wstring.hxx:272
WString RemoveWhitespace() const noexcept
Drops iswspace code units from this text.
Definition wstring.hxx:416
const_reverse_iterator crend() const noexcept
Reverse end.
Definition wstring.hxx:230
static WString ToUpper(std::wstring_view str) noexcept
ASCII-letter upper case; other code points copied.
const_iterator cbegin() const noexcept
First character, or null.
Definition wstring.hxx:190
bool IsInteger() const noexcept
Whether this text is an integer token.
Definition wstring.hxx:424
static void Split(std::wstring_view str, std::vector< WString > &out) noexcept
Whitespace-separated tokens.
wchar_t value_type
Code unit type.
Definition wstring.hxx:93
WString() noexcept
Null text.
const_iterator end() const noexcept
One past the last character, or null.
Definition wstring.hxx:181
std::queue< WString > Explode(wchar_t delimiter) const noexcept
Tokens on delimiter.
Definition wstring.hxx:443
void swap(WCString &other) noexcept
void swap(String &left, String &right) noexcept
Swaps two texts.
Definition string.hxx:558
std::ostream & operator<<(std::ostream &stream, const String &text)
Writes text to stream.
Definition string.hxx:529
bool operator==(const char *str, const String &text) noexcept
Content equality.
Definition string.hxx:539
bool operator!=(const char *str, const String &text) noexcept
Content inequality.
Definition string.hxx:549
Root namespace of the StormByte suite.
String module: owned UTF-8 and wide text on top of StormByte::CString / StormByte::WCString.
std::size_t operator()(const StormByte::String::WString &text) const noexcept
Hashes text.
Definition wstring.hxx:573
#define STORMBYTE_STRING_PUBLIC
Definition visibility.h:53