4#include "../Foundation/StringSpan.h"
5#include "../Memory/Buffer.h"
9struct SC_COMPILER_EXPORT String;
32 String(StringEncoding encoding = StringEncoding::Utf8) : encoding(encoding) {}
66 [[nodiscard]] StringEncoding
getEncoding()
const {
return encoding; }
78 [[nodiscard]]
bool isEmpty()
const {
return data.isEmpty(); }
87 [[nodiscard]]
bool operator==(const
String& other)
const {
return view() == (other.view()); }
111 return view() == other;
120 return view() != other;
147 friend struct StringTest;
148 template <
typename T>
149 friend struct Reflection::Reflect;
151 template <
typename T>
152 friend struct GrowableBuffer;
157 IGrowableBuffer::DirectAccess& da;
161 bool tryGrowTo(
size_t newSize);
164 StringEncoding encoding;
177 SmallString(StringEncoding encoding = StringEncoding::Utf8) :
String(encoding, N) {}
211struct SC_COMPILER_EXPORT GrowableBuffer<String> final :
public IGrowableBuffer
214 GrowableBuffer(
String&
string) : gi(
string, IGrowableBuffer::directAccess) {}
215 virtual bool tryGrowTo(
size_t newSize)
override {
return gi.tryGrowTo(newSize); }
219struct SC_COMPILER_EXPORT GrowableBuffer<SmallString<N>> final :
public IGrowableBuffer
222 GrowableBuffer(
String&
string) : gi(
string, IGrowableBuffer::directAccess) {}
223 virtual bool tryGrowTo(
size_t newSize)
override {
return gi.tryGrowTo(newSize); }
#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:42
constexpr T && move(T &value)
Converts an lvalue to an rvalue reference.
Definition Compiler.h:257
unsigned long long uint64_t
Platform independent (8) bytes unsigned int.
Definition PrimitiveTypes.h:42
unsigned int uint32_t
Platform independent (4) bytes unsigned int.
Definition PrimitiveTypes.h:38
char native_char_t
The native char for the platform (wchar_t (4 bytes) on Windows, char (1 byte) everywhere else )
Definition PrimitiveTypes.h:34
An heap allocated byte buffer that can optionally use an inline buffer.
Definition Buffer.h:29
String with compile time configurable inline storage (small string optimization)
Definition String.h:175
An read-only view over a string (to avoid including Strings library when parsing is not needed).
Definition StringSpan.h:37
A non-modifiable owning string with associated encoding.
Definition String.h:29
StringEncoding getEncoding() const
Get StringSpan encoding.
Definition String.h:66
bool operator!=(const String &other) const
Check if current String is different from other String.
Definition String.h:92
bool operator==(const String &other) const
Check if current String is same as other String.
Definition String.h:87
bool operator<(const StringSpan other) const
Check if current String is smaller to another StringView (using StringView::compare)
Definition String.h:126
bool operator!=(const char(&other)[N]) const
Check if current String is different from the ascii string literal.
Definition String.h:118
StringSpan view() const SC_LANGUAGE_LIFETIME_BOUND
Obtain a null-terminated StringSpan from current String.
String(const char(&text)[N])
Builds String with a null terminated char string literal.
Definition String.h:48
bool owns(StringSpan view) const
Checks if the memory pointed by the StringSpan is owned by this String.
size_t sizeInBytesIncludingTerminator() const
Get length of the string in bytes (including null terminator bytes)
Definition String.h:70
String(StringEncoding encoding=StringEncoding::Utf8)
Builds an empty String with a given Encoding.
Definition String.h:32
bool operator!=(const StringSpan other) const
Check if current String is different from other StringSpan.
Definition String.h:102
String & operator=(const char(&text)[N])
Assigns an ascii string literal to current String.
Definition String.h:134
bool assign(StringSpan sv)
Assigns a StringSpan to this String, replacing existing contents.
bool operator==(const StringSpan other) const
Check if current String is same as other StringSpan.
Definition String.h:97
String & operator=(StringSpan view)
Assigns (copy) contents of given StringSpan in current String.
bool isEmpty() const
Check if String is empty.
Definition String.h:78
const char * bytesIncludingTerminator() const
Access current string content as read-only null-terminated const char*
Definition String.h:74
String(Buffer &&otherData, StringEncoding encoding)
Builds a String from a buffer ensuring zero termination.
String(StringSpan sv)
Builds String from a StringSpan.
Definition String.h:37
bool operator==(const char(&other)[N]) const
Check if current String is equal to the ascii string literal.
Definition String.h:109