2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-09 07:07:42 +00:00

string_view refactor

This commit is contained in:
Jack Andersen
2017-11-12 20:13:53 -10:00
parent 942032688d
commit 4111d49d64
28 changed files with 388 additions and 406 deletions

View File

@@ -4,7 +4,7 @@
namespace hecl
{
std::string WideToUTF8(const std::wstring& src)
std::string WideToUTF8(std::wstring_view src)
{
std::string retval;
retval.reserve(src.length());
@@ -22,7 +22,7 @@ std::string WideToUTF8(const std::wstring& src)
return retval;
}
std::string Char16ToUTF8(const std::u16string& src)
std::string Char16ToUTF8(std::u16string_view src)
{
std::string retval;
retval.reserve(src.length());
@@ -40,11 +40,11 @@ std::string Char16ToUTF8(const std::u16string& src)
return retval;
}
std::wstring UTF8ToWide(const std::string& src)
std::wstring UTF8ToWide(std::string_view src)
{
std::wstring retval;
retval.reserve(src.length());
const utf8proc_uint8_t* buf = reinterpret_cast<const utf8proc_uint8_t*>(src.c_str());
const utf8proc_uint8_t* buf = reinterpret_cast<const utf8proc_uint8_t*>(src.data());
while (*buf)
{
utf8proc_int32_t wc;
@@ -60,11 +60,11 @@ std::wstring UTF8ToWide(const std::string& src)
return retval;
}
std::u16string UTF8ToChar16(const std::string& src)
std::u16string UTF8ToChar16(std::string_view src)
{
std::u16string retval;
retval.reserve(src.length());
const utf8proc_uint8_t* buf = reinterpret_cast<const utf8proc_uint8_t*>(src.c_str());
const utf8proc_uint8_t* buf = reinterpret_cast<const utf8proc_uint8_t*>(src.data());
while (*buf)
{
utf8proc_int32_t wc;