mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-30 01:25:51 +00:00
Common/String: Support constructing from string_view
This commit is contained in:
parent
84b0522abc
commit
aa383d0bda
|
@ -166,6 +166,11 @@ String::String(String&& moveString)
|
|||
Assign(moveString);
|
||||
}
|
||||
|
||||
String::String(const std::string_view& sv)
|
||||
{
|
||||
AppendString(sv.data(), static_cast<u32>(sv.size()));
|
||||
}
|
||||
|
||||
String::~String()
|
||||
{
|
||||
StringDataRelease(m_pStringData);
|
||||
|
|
|
@ -54,6 +54,9 @@ public:
|
|||
// Construct a string from a data object, does not increment the reference count on the string data, use carefully.
|
||||
explicit String(StringData* pStringData) : m_pStringData(pStringData) {}
|
||||
|
||||
// Creates string from string_view.
|
||||
String(const std::string_view& sv);
|
||||
|
||||
// Destructor. Child classes may not have any destructors, as this is not virtual.
|
||||
~String();
|
||||
|
||||
|
@ -307,6 +310,12 @@ public:
|
|||
Assign(copyString.GetCharArray());
|
||||
}
|
||||
|
||||
StackString(const std::string_view& sv) : String(&m_sStringData)
|
||||
{
|
||||
InitStackStringData();
|
||||
AppendString(sv.data(), static_cast<u32>(sv.size()));
|
||||
}
|
||||
|
||||
// Override the fromstring method
|
||||
static StackString FromFormat(const char* FormatString, ...)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue