A non-modifiable owning string with associated encoding. More...
#include <String.h>
Public Member Functions | |
String (StringEncoding encoding=StringEncoding::Utf8) | |
Builds an empty String with a given Encoding. More... | |
String (StringView sv) | |
Builds String from a StringView. More... | |
String (Buffer &&otherData, StringEncoding encoding) | |
Builds a String from a buffer ensuring zero termination. More... | |
template<size_t N> | |
String (const char(&text)[N]) | |
Builds String with a null terminated char string literal. More... | |
bool | owns (StringView view) const |
Checks if the memory pointed by the StringView is owned by this String. More... | |
bool | assign (StringView sv) |
Assigns a StringView to this String, replacing existing contents. More... | |
StringEncoding | getEncoding () const |
Get StringView encoding. More... | |
size_t | sizeInBytesIncludingTerminator () const |
Get length of the string in bytes (including null terminator bytes) More... | |
const char * | bytesIncludingTerminator () const |
Access current string content as read-only null-terminated const char* More... | |
bool | isEmpty () const |
Check if String is empty. More... | |
StringView | view () const SC_LANGUAGE_LIFETIME_BOUND |
Obtain a null-terminated StringView from current String. More... | |
bool | operator== (const String &other) const |
Check if current String is same as other String. More... | |
bool | operator!= (const String &other) const |
Check if current String is different from other String. More... | |
bool | operator== (const StringView other) const |
Check if current String is same as other StringView. More... | |
bool | operator!= (const StringView other) const |
Check if current String is different from other StringView. More... | |
bool | operator< (const StringView other) const |
Check if current String is smaller to another StringView (using StringView::compare) More... | |
template<size_t N> | |
bool | operator== (const char(&other)[N]) const |
Check if current String is equal to the ascii string literal. More... | |
template<size_t N> | |
bool | operator!= (const char(&other)[N]) const |
Check if current String is different from the ascii string literal. More... | |
template<size_t N> | |
String & | operator= (const char(&text)[N]) |
Assigns an ascii string literal to current String. More... | |
String & | operator= (StringView view) |
Assigns (copy) contents of given StringView in current String. More... | |
Protected Member Functions | |
native_char_t * | nativeWritableBytesIncludingTerminator () |
String (StringEncoding encoding, SegmentHeader &header, uint32_t inlineCapacity) | |
String (Buffer &&otherData, StringEncoding encoding, SegmentHeader &header, uint32_t inlineCapacity) | |
Protected Attributes | |
StringEncoding | encoding |
Buffer | data |
Friends | |
struct | StringTest |
struct | StringBuilder |
struct | StringConverter |
struct | File |
struct | FileSystem |
template<typename T > | |
struct | Reflection::Reflect |
A non-modifiable owning string with associated encoding.
SC::String is (currently) implemented as a SC::Vector with the associated string encoding. A SC::StringView can be obtained from it calling SC::String::view method but it's up to the user making sure that the usage of such SC::StringView doesn't exceed lifetime of the SC::String it originated from (but thankfully Address Sanitizer will catch the issue if it goes un-noticed).
|
inline |
|
inline |
Builds String from a StringView.
sv | StringView to be assigned to this String |
SC::String::String | ( | Buffer && | otherData, |
StringEncoding | encoding | ||
) |
Builds a String from a buffer ensuring zero termination.
|
inline |
Builds String with a null terminated char string literal.
N | Length of the string literal (including null terminator) |
text | Pointer to string literal |
bool SC::String::assign | ( | StringView | sv | ) |
Assigns a StringView to this String, replacing existing contents.
sv | StringView to be assigned to this string |
true
if StringView is assigned successfully StringView::view
previously obtained
|
inline |
Access current string content as read-only null-terminated const char*
const char*
|
inline |
Get StringView encoding.
|
inline |
|
inline |
|
inline |
Check if current String is different from other StringView.
other | StringView to be checked |
true
if the String and StringView are different
|
inline |
Check if current String is smaller to another StringView (using StringView::compare)
other | StringView to be checked |
true
if the String is smaller than StringView (using StringView::compare) Assigns an ascii string literal to current String.
N | Length of string literal, including null terminator |
text | The string literal |
String & SC::String::operator= | ( | StringView | view | ) |
Assigns (copy) contents of given StringView in current String.
|
inline |
|
inline |
|
inline |
Check if current String is same as other StringView.
other | StringView to be checked |
true
if the String and StringView are equal bool SC::String::owns | ( | StringView | view | ) | const |
Checks if the memory pointed by the StringView is owned by this String.
view | StringView to be checked |
true
if StringView memory belongs to this String
|
inline |
Get length of the string in bytes (including null terminator bytes)
StringView SC::String::view | ( | ) | const |
Obtain a null-terminated StringView from current String.