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);
}
String::String(const char* Text, u32 Count) : m_pStringData(const_cast<String::StringData*>(&s_EmptyStringData))
{
AppendString(Text, Count);
}
String::String(String&& moveString)
{
Assign(moveString);

View file

@ -46,6 +46,9 @@ public:
// For strings that do not allocate any space on the heap, see StaticString.
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).
String(const String& copyString);
@ -315,6 +318,12 @@ public:
Assign(Text);
}
StackString(const char* Text, u32 Count) : String(&m_sStringData)
{
InitStackStringData();
AppendString(Text, Count);
}
StackString(const String& copyString) : String(&m_sStringData)
{
// force a copy by passing it a string pointer, instead of a string object