mirror of https://github.com/AxioDL/metaforce.git
hecl/hecl: Make string conv operator+ instances friend functions
Makes both operators symmetrical to one another.
This commit is contained in:
parent
c7aae83a75
commit
dae3e6123f
hecl/include/hecl
|
@ -111,50 +111,66 @@ class SystemUTF8Conv {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SystemUTF8Conv(SystemStringView str) : m_utf8(WideToUTF8(str)) {}
|
explicit SystemUTF8Conv(SystemStringView str) : m_utf8(WideToUTF8(str)) {}
|
||||||
|
|
||||||
std::string_view str() const { return m_utf8; }
|
std::string_view str() const { return m_utf8; }
|
||||||
const char* c_str() const { return m_utf8.c_str(); }
|
const char* c_str() const { return m_utf8.c_str(); }
|
||||||
std::string operator+(std::string_view other) const { return m_utf8 + other.data(); }
|
|
||||||
};
|
friend std::string operator+(const SystemUTF8Conv& lhs, std::string_view rhs) { return lhs.m_utf8 + rhs.data(); }
|
||||||
inline std::string operator+(std::string_view lhs, const SystemUTF8Conv& rhs) {
|
friend std::string operator+(std::string_view lhs, const SystemUTF8Conv& rhs) {
|
||||||
return std::string(lhs).append(rhs.str());
|
return std::string(lhs).append(rhs.m_utf8);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class SystemStringConv {
|
class SystemStringConv {
|
||||||
std::wstring m_sys;
|
std::wstring m_sys;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SystemStringConv(std::string_view str) : m_sys(UTF8ToWide(str)) {}
|
explicit SystemStringConv(std::string_view str) : m_sys(UTF8ToWide(str)) {}
|
||||||
|
|
||||||
SystemStringView sys_str() const { return m_sys; }
|
SystemStringView sys_str() const { return m_sys; }
|
||||||
const SystemChar* c_str() const { return m_sys.c_str(); }
|
const SystemChar* c_str() const { return m_sys.c_str(); }
|
||||||
std::wstring operator+(const std::wstring_view other) const { return m_sys + other.data(); }
|
|
||||||
};
|
friend std::wstring operator+(const SystemStringConv& lhs, const std::wstring_view rhs) {
|
||||||
inline std::wstring operator+(std::wstring_view lhs, const SystemStringConv& rhs) {
|
return lhs.m_sys + rhs.data();
|
||||||
return std::wstring(lhs).append(rhs.sys_str());
|
|
||||||
}
|
}
|
||||||
|
friend std::wstring operator+(std::wstring_view lhs, const SystemStringConv& rhs) {
|
||||||
|
return std::wstring(lhs).append(rhs.m_sys);
|
||||||
|
}
|
||||||
|
};
|
||||||
#else
|
#else
|
||||||
class SystemUTF8Conv {
|
class SystemUTF8Conv {
|
||||||
std::string_view m_utf8;
|
std::string_view m_utf8;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SystemUTF8Conv(SystemStringView str) : m_utf8(str) {}
|
explicit SystemUTF8Conv(SystemStringView str) : m_utf8(str) {}
|
||||||
|
|
||||||
std::string_view str() const { return m_utf8; }
|
std::string_view str() const { return m_utf8; }
|
||||||
const char* c_str() const { return m_utf8.data(); }
|
const char* c_str() const { return m_utf8.data(); }
|
||||||
std::string operator+(std::string_view other) const { return std::string(m_utf8).append(other); }
|
|
||||||
};
|
friend std::string operator+(const SystemUTF8Conv& lhs, std::string_view rhs) {
|
||||||
inline std::string operator+(std::string_view lhs, const SystemUTF8Conv& rhs) {
|
return std::string(lhs.m_utf8).append(rhs);
|
||||||
return std::string(lhs).append(rhs.str());
|
|
||||||
}
|
}
|
||||||
|
friend std::string operator+(std::string_view lhs, const SystemUTF8Conv& rhs) {
|
||||||
|
return std::string(lhs).append(rhs.m_utf8);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class SystemStringConv {
|
class SystemStringConv {
|
||||||
std::string_view m_sys;
|
std::string_view m_sys;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SystemStringConv(std::string_view str) : m_sys(str) {}
|
explicit SystemStringConv(std::string_view str) : m_sys(str) {}
|
||||||
|
|
||||||
SystemStringView sys_str() const { return m_sys; }
|
SystemStringView sys_str() const { return m_sys; }
|
||||||
const SystemChar* c_str() const { return m_sys.data(); }
|
const SystemChar* c_str() const { return m_sys.data(); }
|
||||||
std::string operator+(std::string_view other) const { return std::string(m_sys).append(other); }
|
|
||||||
};
|
friend std::string operator+(const SystemStringConv& lhs, std::string_view rhs) {
|
||||||
inline std::string operator+(std::string_view lhs, const SystemStringConv& rhs) {
|
return std::string(lhs.m_sys).append(rhs);
|
||||||
return std::string(lhs).append(rhs.sys_str());
|
|
||||||
}
|
}
|
||||||
|
friend std::string operator+(std::string_view lhs, const SystemStringConv& rhs) {
|
||||||
|
return std::string(lhs).append(rhs.m_sys);
|
||||||
|
}
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void SanitizePath(std::string& path);
|
void SanitizePath(std::string& path);
|
||||||
|
|
Loading…
Reference in New Issue