112 explicit
String(const
char* str) noexcept;
183 const char* text = data();
184 return text ? text + size() :
nullptr;
239 inline const char*
data() const noexcept {
240 return static_cast<const char*
>(m_text);
247 inline std::size_t
size() const noexcept {
248 return m_text.Length();
255 inline std::size_t
length() const noexcept {
263 inline bool empty() const noexcept {
274 return m_text[index];
281 inline explicit operator bool() const noexcept {
282 return static_cast<bool>(m_text);
297 inline operator std::string_view() const noexcept {
298 return static_cast<std::string_view
>(m_text);
305 inline explicit operator std::string()
const {
306 return static_cast<std::string
>(m_text);
314 inline explicit operator const char*()
const noexcept {
315 return static_cast<const char*
>(m_text);
328 inline const
CString& Bytes() const noexcept {
379 static void Split(std::string_view str, std::vector<String>& out)
noexcept;
387 static void Explode(std::string_view str,
char delimiter, std::queue<String>& out)
noexcept;
394 return ToLower(
static_cast<std::string_view
>(*
this));
402 return ToUpper(
static_cast<std::string_view
>(*
this));
410 return SanitizeNewlines(
static_cast<std::string_view
>(*
this));
418 return RemoveWhitespace(
static_cast<std::string_view
>(*
this));
426 return IsInteger(
static_cast<std::string_view
>(*
this));
433 inline std::vector<String>
Split() const noexcept {
434 std::vector<String> out;
435 Split(
static_cast<std::string_view
>(*
this), out);
444 inline std::queue<String>
Explode(
char delimiter)
const noexcept {
445 std::queue<String> out;
446 Explode(
static_cast<std::string_view
>(*
this), delimiter, out);
463 return m_text == other.m_text;
472 return !(*
this == other);
481 return m_text == str;
490 return !(*
this == str);
499 return m_text <=> other.m_text;
507 inline std::strong_ordering
operator<=>(
const char* str)
const noexcept {
508 return m_text <=> str;
530 return stream << text.Bytes();
575 return std::hash<std::string_view>{}(
static_cast<std::string_view
>(text));
Owned UTF-8 text composed of StormByte::CString.
Definition string.hxx:92
std::strong_ordering operator<=>(const String &other) const noexcept
Content order.
Definition string.hxx:498
char value_type
Byte type.
Definition string.hxx:94
std::size_t length() const noexcept
Same as size.
Definition string.hxx:255
std::vector< String > Split() const noexcept
Whitespace-separated tokens.
Definition string.hxx:433
const_iterator cbegin() const noexcept
First character, or null.
Definition string.hxx:191
String ToUpper() const noexcept
ASCII-letter upper case of this text.
Definition string.hxx:401
bool operator!=(const String &other) const noexcept
Content inequality.
Definition string.hxx:471
static String RemoveWhitespace(std::string_view str) noexcept
Drops isspace bytes.
std::reverse_iterator< const_iterator > const_reverse_iterator
Reverse observer.
Definition string.hxx:96
std::queue< String > Explode(char delimiter) const noexcept
Tokens on delimiter.
Definition string.hxx:444
bool empty() const noexcept
Whether size is zero.
Definition string.hxx:263
static String ToLower(std::string_view str) noexcept
ASCII-letter lower case; UTF-8 otherwise copied.
void swap(String &other) noexcept
Swaps buffers with other.
static String ToUpper(std::string_view str) noexcept
ASCII-letter upper case; UTF-8 otherwise copied.
bool operator==(const String &other) const noexcept
Content equality.
Definition string.hxx:462
const_reverse_iterator rbegin() const noexcept
Reverse begin.
Definition string.hxx:207
String ToLower() const noexcept
ASCII-letter lower case of this text.
Definition string.hxx:393
const_iterator end() const noexcept
One past the last character, or null.
Definition string.hxx:182
static void Split(std::string_view str, std::vector< String > &out) noexcept
Whitespace-separated tokens.
static bool IsInteger(std::string_view str) noexcept
Optional sign plus ASCII digits.
bool operator==(const char *str) const noexcept
Content equality with a C string.
Definition string.hxx:480
static void Explode(std::string_view str, char delimiter, std::queue< String > &out) noexcept
Tokens on delimiter.
String() noexcept
Null text.
String RemoveWhitespace() const noexcept
Drops isspace bytes from this text.
Definition string.hxx:417
std::size_t size() const noexcept
Byte count; 0 when null or empty.
Definition string.hxx:247
String SanitizeNewlines() const noexcept
CR LF to LF on this text.
Definition string.hxx:409
const_iterator cend() const noexcept
One past the last character, or null.
Definition string.hxx:199
std::strong_ordering operator<=>(const char *str) const noexcept
Content order against a C string.
Definition string.hxx:507
const char * const_iterator
Contiguous observer.
Definition string.hxx:95
static String SanitizeNewlines(std::string_view str) noexcept
Turns CR LF into LF.
const char * data() const noexcept
Contiguous pointer; null when the buffer is null.
Definition string.hxx:239
char operator[](std::size_t index) const noexcept
Byte at index.
Definition string.hxx:273
const_reverse_iterator rend() const noexcept
Reverse end.
Definition string.hxx:215
bool operator!=(const char *str) const noexcept
Content inequality with a C string.
Definition string.hxx:489
bool IsInteger() const noexcept
Whether this text is an integer token.
Definition string.hxx:425
const_reverse_iterator crend() const noexcept
Reverse end.
Definition string.hxx:231
const_reverse_iterator crbegin() const noexcept
Reverse begin.
Definition string.hxx:223
Wide counterpart of String.
Definition wstring.hxx:91
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::String &text) const noexcept
Hashes text.
Definition string.hxx:574
#define STORMBYTE_STRING_PUBLIC
Definition visibility.h:53