diff --git a/src/common/string.cpp b/src/common/string.cpp index 08e0768fd..ecc2c8c33 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -161,6 +161,11 @@ String::String(const char* Text) : m_pStringData(const_cast Assign(Text); } +String::String(const char* Text, u32 Count) : m_pStringData(const_cast(&s_EmptyStringData)) +{ + AppendString(Text, Count); +} + String::String(String&& moveString) { Assign(moveString); diff --git a/src/common/string.h b/src/common/string.h index 3e35e3d34..05e145ed7 100644 --- a/src/common/string.h +++ b/src/common/string.h @@ -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