4#include "../Containers/Vector.h"
5#include "../Strings/StringView.h"
53 [[nodiscard]]
bool owns(
StringView view)
const;
75 [[nodiscard]]
bool isEmpty()
const {
return data.isEmpty(); }
79 [[nodiscard]]
StringView view() const SC_LANGUAGE_LIFETIME_BOUND;
84 [[nodiscard]]
bool operator==(const
String& other)
const {
return view() == (other.view()); }
89 [[nodiscard]]
bool operator!=(
const String& other)
const {
return not operator==(other); }
113 return view() == other;
122 return view() != other;
139 [[nodiscard]]
auto nativeWritableBytesIncludingTerminator();
143 friend struct SmallStringTest;
150 template <
typename T>
155#pragma warning(disable : 4324)
180 if (not data.resizeWithoutInitializing(length + numZero))
192 for (
size_t idx = 0; idx < numZero; ++idx)
194 data.items[length + idx] = 0;
202 const bool isEmpty = data.
isEmpty();
203 const char* items = isEmpty ? nullptr : data.items;
207inline auto SC::String::nativeWritableBytesIncludingTerminator()
209#if SC_PLATFORM_WINDOWS
211 return reinterpret_cast<wchar_t*
>(data.data());
#define SC_COMPILER_EXPORT
Macro for symbol visibility in non-MSVC compilers.
Definition: Compiler.h:78
#define SC_COMPILER_EXTERN
Define compiler-specific export macros for DLL visibility.
Definition: Compiler.h:74
#define SC_ASSERT_RELEASE(e)
Assert expression e to be true.
Definition: Assert.h:66
StringEncoding
String Encoding (Ascii, Utf8, Utf16)
Definition: StringIterator.h:17
constexpr uint32_t StringEncodingGetSize(StringEncoding encoding)
Returns the number of bytes to represent an utf unit in the given encoding.
Definition: StringIterator.h:308
@ Utf16
Encoding is UTF16-LE.
Wraps an OS File descriptor to read and write to and from it.
Definition: FileDescriptor.h:57
Execute fs operations { exists, copy, delete } for { files and directories }.
Definition: FileSystem.h:25
Basic class template that must be partially specialized for each type.
Definition: Reflection.h:195
String with compile time configurable inline storage (small string optimization)
Definition: SmallString.h:21
Builds String out of a sequence of StringView or formatting through StringFormat.
Definition: StringBuilder.h:16
Converts String to a different encoding (UTF8, UTF16).
Definition: StringConverter.h:25
A non-modifiable owning string with associated encoding.
Definition: String.h:30
StringEncoding getEncoding() const
Get StringView encoding.
Definition: String.h:63
bool operator==(const StringView other) const
Check if current String is same as other StringView.
Definition: String.h:94
bool operator!=(const String &other) const
Check if current String is different from other String.
Definition: String.h:89
bool operator<(const StringView other) const
Check if current String is smaller to another StringView (using StringView::compare)
Definition: String.h:104
bool assign(StringView sv)
Assigns a StringView to this String, replacing existing contents.
Definition: String.h:175
bool operator!=(const char(&other)[N]) const
Check if current String is different from the ascii string literal.
Definition: String.h:120
String(const char(&text)[N])
Builds String with a null terminated char string literal.
Definition: String.h:45
size_t sizeInBytesIncludingTerminator() const
Get length of the string in bytes (including null terminator bytes)
Definition: String.h:67
String(StringEncoding encoding=StringEncoding::Utf8)
Builds an empty String with a given Encoding.
Definition: String.h:33
String(StringView sv)
Builds String from a StringView.
Definition: String.h:38
StringView view() const SC_LANGUAGE_LIFETIME_BOUND
Obtain a null-terminated StringView from current String.
Definition: String.h:200
String & operator=(const char(&text)[N])
Assigns an ascii string literal to current String.
Definition: String.h:131
bool isEmpty() const
Check if String is empty.
Definition: String.h:75
const char * bytesIncludingTerminator() const
Access current string content as read-only null-terminated const char*
Definition: String.h:71
bool operator!=(const StringView other) const
Check if current String is different from other StringView.
Definition: String.h:99
bool owns(StringView view) const
Checks if the memory pointed by the StringView is owned by this String.
Definition: String.h:169
bool operator==(const char(&other)[N]) const
Check if current String is equal to the ascii string literal.
Definition: String.h:111
Non-owning view over a range of characters with UTF Encoding.
Definition: StringView.h:47
constexpr bool isNullTerminated() const
Check if StringView is immediately followed by a null termination character.
Definition: StringView.h:227
constexpr const char * bytesWithoutTerminator() const
Directly access the memory of this StringView.
Definition: StringView.h:97
constexpr StringEncoding getEncoding() const
Get encoding of this StringView.
Definition: StringView.h:93
constexpr bool isEmpty() const
Check if StringView is empty.
Definition: StringView.h:223
constexpr size_t sizeInBytes() const
Get size of the StringView in bytes.
Definition: StringView.h:231
A contiguous sequence of heap allocated elements.
Definition: Vector.h:51