String: Add a new constructor

This commit is contained in:
Silent 2021-03-12 19:59:39 +01:00
parent 5e07b23cfb
commit 787ab5dbd0
No known key found for this signature in database
GPG Key ID: AE53149BB0C45AF1
2 changed files with 14 additions and 0 deletions

View File

@ -161,6 +161,11 @@ String::String(const char* Text) : m_pStringData(const_cast<String::StringData*>
Assign(Text); Assign(Text);
} }
String::String(const char* Text, u32 Count) : m_pStringData(const_cast<String::StringData*>(&s_EmptyStringData))
{
AppendString(Text, Count);
}
String::String(String&& moveString) String::String(String&& moveString)
{ {
Assign(moveString); Assign(moveString);

View File

@ -46,6 +46,9 @@ public:
// For strings that do not allocate any space on the heap, see StaticString. // For strings that do not allocate any space on the heap, see StaticString.
String(const char* Text); String(const char* Text);
// Creates a string contained the specified text (with length).
String(const char* Text, u32 Count);
// Creates a string using the same buffer as another string (copy-on-write). // Creates a string using the same buffer as another string (copy-on-write).
String(const String& copyString); String(const String& copyString);
@ -315,6 +318,12 @@ public:
Assign(Text); Assign(Text);
} }
StackString(const char* Text, u32 Count) : String(&m_sStringData)
{
InitStackStringData();
AppendString(Text, Count);
}
StackString(const String& copyString) : String(&m_sStringData) StackString(const String& copyString) : String(&m_sStringData)
{ {
// force a copy by passing it a string pointer, instead of a string object // force a copy by passing it a string pointer, instead of a string object