Misc: Pass most string_views by value instead of reference

This commit is contained in:
Stenzek 2024-05-15 09:42:40 +10:00 committed by Connor McLaughlin
parent 9fac941570
commit 12a0644315
80 changed files with 415 additions and 429 deletions

View File

@ -137,7 +137,7 @@ static inline void PathAppendString(std::string& dst, const T& src)
} }
} }
std::string Path::SanitizeFileName(const std::string_view& str, bool strip_slashes /* = true */) std::string Path::SanitizeFileName(const std::string_view str, bool strip_slashes /* = true */)
{ {
std::string ret; std::string ret;
ret.reserve(str.length()); ret.reserve(str.length());
@ -191,7 +191,7 @@ void Path::SanitizeFileName(std::string* str, bool strip_slashes /* = true */)
#endif #endif
} }
bool Path::IsValidFileName(const std::string_view& str, bool allow_slashes) bool Path::IsValidFileName(const std::string_view str, bool allow_slashes)
{ {
const size_t len = str.length(); const size_t len = str.length();
size_t pos = 0; size_t pos = 0;
@ -272,7 +272,7 @@ std::wstring FileSystem::GetWin32Path(std::string_view str)
#endif #endif
bool Path::IsAbsolute(const std::string_view& path) bool Path::IsAbsolute(const std::string_view path)
{ {
#ifdef _WIN32 #ifdef _WIN32
return (path.length() >= 3 && ((path[0] >= 'A' && path[0] <= 'Z') || (path[0] >= 'a' && path[0] <= 'z')) && return (path.length() >= 3 && ((path[0] >= 'A' && path[0] <= 'Z') || (path[0] >= 'a' && path[0] <= 'z')) &&
@ -283,7 +283,7 @@ bool Path::IsAbsolute(const std::string_view& path)
#endif #endif
} }
std::string Path::RealPath(const std::string_view& path) std::string Path::RealPath(const std::string_view path)
{ {
// Resolve non-absolute paths first. // Resolve non-absolute paths first.
std::vector<std::string_view> components; std::vector<std::string_view> components;
@ -457,7 +457,7 @@ std::string Path::RealPath(const std::string_view& path)
return realpath; return realpath;
} }
std::string Path::ToNativePath(const std::string_view& path) std::string Path::ToNativePath(const std::string_view path)
{ {
std::string ret; std::string ret;
PathAppendString(ret, path); PathAppendString(ret, path);
@ -477,7 +477,7 @@ void Path::ToNativePath(std::string* path)
*path = Path::ToNativePath(*path); *path = Path::ToNativePath(*path);
} }
std::string Path::Canonicalize(const std::string_view& path) std::string Path::Canonicalize(const std::string_view path)
{ {
std::vector<std::string_view> components = Path::SplitNativePath(path); std::vector<std::string_view> components = Path::SplitNativePath(path);
std::vector<std::string_view> new_components; std::vector<std::string_view> new_components;
@ -513,7 +513,7 @@ void Path::Canonicalize(std::string* path)
*path = Canonicalize(*path); *path = Canonicalize(*path);
} }
std::string Path::MakeRelative(const std::string_view& path, const std::string_view& relative_to) std::string Path::MakeRelative(const std::string_view path, const std::string_view relative_to)
{ {
// simple algorithm, we just work on the components. could probably be better, but it'll do for now. // simple algorithm, we just work on the components. could probably be better, but it'll do for now.
std::vector<std::string_view> path_components(SplitNativePath(path)); std::vector<std::string_view> path_components(SplitNativePath(path));
@ -560,7 +560,7 @@ std::string Path::MakeRelative(const std::string_view& path, const std::string_v
return JoinNativePath(new_components); return JoinNativePath(new_components);
} }
std::string_view Path::GetExtension(const std::string_view& path) std::string_view Path::GetExtension(const std::string_view path)
{ {
const std::string_view::size_type pos = path.rfind('.'); const std::string_view::size_type pos = path.rfind('.');
if (pos == std::string_view::npos) if (pos == std::string_view::npos)
@ -569,7 +569,7 @@ std::string_view Path::GetExtension(const std::string_view& path)
return path.substr(pos + 1); return path.substr(pos + 1);
} }
std::string_view Path::StripExtension(const std::string_view& path) std::string_view Path::StripExtension(const std::string_view path)
{ {
const std::string_view::size_type pos = path.rfind('.'); const std::string_view::size_type pos = path.rfind('.');
if (pos == std::string_view::npos) if (pos == std::string_view::npos)
@ -578,7 +578,7 @@ std::string_view Path::StripExtension(const std::string_view& path)
return path.substr(0, pos); return path.substr(0, pos);
} }
std::string Path::ReplaceExtension(const std::string_view& path, const std::string_view& new_extension) std::string Path::ReplaceExtension(const std::string_view path, const std::string_view new_extension)
{ {
const std::string_view::size_type pos = path.rfind('.'); const std::string_view::size_type pos = path.rfind('.');
if (pos == std::string_view::npos) if (pos == std::string_view::npos)
@ -589,7 +589,7 @@ std::string Path::ReplaceExtension(const std::string_view& path, const std::stri
return ret; return ret;
} }
static std::string_view::size_type GetLastSeperatorPosition(const std::string_view& filename, bool include_separator) static std::string_view::size_type GetLastSeperatorPosition(const std::string_view filename, bool include_separator)
{ {
std::string_view::size_type last_separator = filename.rfind('/'); std::string_view::size_type last_separator = filename.rfind('/');
if (include_separator && last_separator != std::string_view::npos) if (include_separator && last_separator != std::string_view::npos)
@ -609,7 +609,7 @@ static std::string_view::size_type GetLastSeperatorPosition(const std::string_vi
return last_separator; return last_separator;
} }
std::string_view Path::GetDirectory(const std::string_view& path) std::string_view Path::GetDirectory(const std::string_view path)
{ {
const std::string::size_type pos = GetLastSeperatorPosition(path, false); const std::string::size_type pos = GetLastSeperatorPosition(path, false);
if (pos == std::string_view::npos) if (pos == std::string_view::npos)
@ -618,7 +618,7 @@ std::string_view Path::GetDirectory(const std::string_view& path)
return path.substr(0, pos); return path.substr(0, pos);
} }
std::string_view Path::GetFileName(const std::string_view& path) std::string_view Path::GetFileName(const std::string_view path)
{ {
const std::string_view::size_type pos = GetLastSeperatorPosition(path, true); const std::string_view::size_type pos = GetLastSeperatorPosition(path, true);
if (pos == std::string_view::npos) if (pos == std::string_view::npos)
@ -627,7 +627,7 @@ std::string_view Path::GetFileName(const std::string_view& path)
return path.substr(pos); return path.substr(pos);
} }
std::string_view Path::GetFileTitle(const std::string_view& path) std::string_view Path::GetFileTitle(const std::string_view path)
{ {
const std::string_view filename(GetFileName(path)); const std::string_view filename(GetFileName(path));
const std::string::size_type pos = filename.rfind('.'); const std::string::size_type pos = filename.rfind('.');
@ -637,7 +637,7 @@ std::string_view Path::GetFileTitle(const std::string_view& path)
return filename.substr(0, pos); return filename.substr(0, pos);
} }
std::string Path::ChangeFileName(const std::string_view& path, const std::string_view& new_filename) std::string Path::ChangeFileName(const std::string_view path, const std::string_view new_filename)
{ {
std::string ret; std::string ret;
PathAppendString(ret, path); PathAppendString(ret, path);
@ -664,12 +664,12 @@ std::string Path::ChangeFileName(const std::string_view& path, const std::string
return ret; return ret;
} }
void Path::ChangeFileName(std::string* path, const std::string_view& new_filename) void Path::ChangeFileName(std::string* path, const std::string_view new_filename)
{ {
*path = ChangeFileName(*path, new_filename); *path = ChangeFileName(*path, new_filename);
} }
std::string Path::AppendDirectory(const std::string_view& path, const std::string_view& new_dir) std::string Path::AppendDirectory(const std::string_view path, const std::string_view new_dir)
{ {
std::string ret; std::string ret;
if (!new_dir.empty()) if (!new_dir.empty())
@ -711,12 +711,12 @@ std::string Path::AppendDirectory(const std::string_view& path, const std::strin
return ret; return ret;
} }
void Path::AppendDirectory(std::string* path, const std::string_view& new_dir) void Path::AppendDirectory(std::string* path, const std::string_view new_dir)
{ {
*path = AppendDirectory(*path, new_dir); *path = AppendDirectory(*path, new_dir);
} }
std::vector<std::string_view> Path::SplitWindowsPath(const std::string_view& path) std::vector<std::string_view> Path::SplitWindowsPath(const std::string_view path)
{ {
std::vector<std::string_view> parts; std::vector<std::string_view> parts;
@ -754,7 +754,7 @@ std::string Path::JoinWindowsPath(const std::vector<std::string_view>& component
return StringUtil::JoinString(components.begin(), components.end(), '\\'); return StringUtil::JoinString(components.begin(), components.end(), '\\');
} }
std::vector<std::string_view> Path::SplitNativePath(const std::string_view& path) std::vector<std::string_view> Path::SplitNativePath(const std::string_view path)
{ {
#ifdef _WIN32 #ifdef _WIN32
return SplitWindowsPath(path); return SplitWindowsPath(path);
@ -821,7 +821,7 @@ std::vector<std::string> FileSystem::GetRootDirectoryList()
return results; return results;
} }
std::string Path::BuildRelativePath(const std::string_view& filename, const std::string_view& new_filename) std::string Path::BuildRelativePath(const std::string_view filename, const std::string_view new_filename)
{ {
std::string new_string; std::string new_string;
@ -832,7 +832,7 @@ std::string Path::BuildRelativePath(const std::string_view& filename, const std:
return new_string; return new_string;
} }
std::string Path::Combine(const std::string_view& base, const std::string_view& next) std::string Path::Combine(const std::string_view base, const std::string_view next)
{ {
std::string ret; std::string ret;
ret.reserve(base.length() + next.length() + 1); ret.reserve(base.length() + next.length() + 1);
@ -1171,7 +1171,7 @@ bool FileSystem::WriteBinaryFile(const char* filename, const void* data, size_t
return true; return true;
} }
bool FileSystem::WriteStringToFile(const char* filename, const std::string_view& sv) bool FileSystem::WriteStringToFile(const char* filename, const std::string_view sv)
{ {
ManagedCFilePtr fp = OpenManagedCFile(filename, "wb"); ManagedCFilePtr fp = OpenManagedCFile(filename, "wb");
if (!fp) if (!fp)

View File

@ -130,7 +130,7 @@ namespace FileSystem
std::optional<std::string> ReadFileToString(const char* filename); std::optional<std::string> ReadFileToString(const char* filename);
std::optional<std::string> ReadFileToString(std::FILE* fp); std::optional<std::string> ReadFileToString(std::FILE* fp);
bool WriteBinaryFile(const char* filename, const void* data, size_t data_length); bool WriteBinaryFile(const char* filename, const void* data, size_t data_length);
bool WriteStringToFile(const char* filename, const std::string_view& sv); bool WriteStringToFile(const char* filename, const std::string_view sv);
/// creates a directory in the local filesystem /// creates a directory in the local filesystem
/// if the directory already exists, the return value will be true. /// if the directory already exists, the return value will be true.

View File

@ -47,7 +47,7 @@ static constexpr FormatHandler s_format_handlers[] = {
{"webp", WebPBufferLoader, WebPBufferSaver, WebPFileLoader, WebPFileSaver}, {"webp", WebPBufferLoader, WebPBufferSaver, WebPFileLoader, WebPFileSaver},
}; };
static const FormatHandler* GetFormatHandler(const std::string_view& extension) static const FormatHandler* GetFormatHandler(const std::string_view extension)
{ {
for (const FormatHandler& handler : s_format_handlers) for (const FormatHandler& handler : s_format_handlers)
{ {

View File

@ -12,68 +12,68 @@
namespace Path namespace Path
{ {
/// Converts any forward slashes to backslashes on Win32. /// Converts any forward slashes to backslashes on Win32.
std::string ToNativePath(const std::string_view& path); std::string ToNativePath(const std::string_view path);
void ToNativePath(std::string* path); void ToNativePath(std::string* path);
/// Builds a path relative to the specified file /// Builds a path relative to the specified file
std::string BuildRelativePath(const std::string_view& filename, const std::string_view& new_filename); std::string BuildRelativePath(const std::string_view filename, const std::string_view new_filename);
/// Joins path components together, producing a new path. /// Joins path components together, producing a new path.
std::string Combine(const std::string_view& base, const std::string_view& next); std::string Combine(const std::string_view base, const std::string_view next);
/// Removes all .. and . components from a path. /// Removes all .. and . components from a path.
std::string Canonicalize(const std::string_view& path); std::string Canonicalize(const std::string_view path);
void Canonicalize(std::string* path); void Canonicalize(std::string* path);
/// Sanitizes a filename for use in a filesystem. /// Sanitizes a filename for use in a filesystem.
std::string SanitizeFileName(const std::string_view& str, bool strip_slashes = true); std::string SanitizeFileName(const std::string_view str, bool strip_slashes = true);
void SanitizeFileName(std::string* str, bool strip_slashes = true); void SanitizeFileName(std::string* str, bool strip_slashes = true);
/// Returns true if the specified filename is valid on this operating system. /// Returns true if the specified filename is valid on this operating system.
bool IsValidFileName(const std::string_view& str, bool allow_slashes = false); bool IsValidFileName(const std::string_view str, bool allow_slashes = false);
/// Returns true if the specified path is an absolute path (C:\Path on Windows or /path on Unix). /// Returns true if the specified path is an absolute path (C:\Path on Windows or /path on Unix).
bool IsAbsolute(const std::string_view& path); bool IsAbsolute(const std::string_view path);
/// Resolves any symbolic links in the specified path. /// Resolves any symbolic links in the specified path.
std::string RealPath(const std::string_view& path); std::string RealPath(const std::string_view path);
/// Makes the specified path relative to another (e.g. /a/b/c, /a/b -> ../c). /// Makes the specified path relative to another (e.g. /a/b/c, /a/b -> ../c).
/// Both paths must be relative, otherwise this function will just return the input path. /// Both paths must be relative, otherwise this function will just return the input path.
std::string MakeRelative(const std::string_view& path, const std::string_view& relative_to); std::string MakeRelative(const std::string_view path, const std::string_view relative_to);
/// Returns a view of the extension of a filename. /// Returns a view of the extension of a filename.
std::string_view GetExtension(const std::string_view& path); std::string_view GetExtension(const std::string_view path);
/// Removes the extension of a filename. /// Removes the extension of a filename.
std::string_view StripExtension(const std::string_view& path); std::string_view StripExtension(const std::string_view path);
/// Replaces the extension of a filename with another. /// Replaces the extension of a filename with another.
std::string ReplaceExtension(const std::string_view& path, const std::string_view& new_extension); std::string ReplaceExtension(const std::string_view path, const std::string_view new_extension);
/// Returns the directory component of a filename. /// Returns the directory component of a filename.
std::string_view GetDirectory(const std::string_view& path); std::string_view GetDirectory(const std::string_view path);
/// Returns the filename component of a filename. /// Returns the filename component of a filename.
std::string_view GetFileName(const std::string_view& path); std::string_view GetFileName(const std::string_view path);
/// Returns the file title (less the extension and path) from a filename. /// Returns the file title (less the extension and path) from a filename.
std::string_view GetFileTitle(const std::string_view& path); std::string_view GetFileTitle(const std::string_view path);
/// Changes the filename in a path. /// Changes the filename in a path.
std::string ChangeFileName(const std::string_view& path, const std::string_view& new_filename); std::string ChangeFileName(const std::string_view path, const std::string_view new_filename);
void ChangeFileName(std::string* path, const std::string_view& new_filename); void ChangeFileName(std::string* path, const std::string_view new_filename);
/// Appends a directory to a path. /// Appends a directory to a path.
std::string AppendDirectory(const std::string_view& path, const std::string_view& new_dir); std::string AppendDirectory(const std::string_view path, const std::string_view new_dir);
void AppendDirectory(std::string* path, const std::string_view& new_dir); void AppendDirectory(std::string* path, const std::string_view new_dir);
/// Splits a path into its components, handling both Windows and Unix separators. /// Splits a path into its components, handling both Windows and Unix separators.
std::vector<std::string_view> SplitWindowsPath(const std::string_view& path); std::vector<std::string_view> SplitWindowsPath(const std::string_view path);
std::string JoinWindowsPath(const std::vector<std::string_view>& components); std::string JoinWindowsPath(const std::vector<std::string_view>& components);
/// Splits a path into its components, only handling native separators. /// Splits a path into its components, only handling native separators.
std::vector<std::string_view> SplitNativePath(const std::string_view& path); std::vector<std::string_view> SplitNativePath(const std::string_view path);
std::string JoinNativePath(const std::vector<std::string_view>& components); std::string JoinNativePath(const std::vector<std::string_view>& components);
/// URL encodes the specified string. /// URL encodes the specified string.

View File

@ -162,7 +162,7 @@ namespace StringUtil
return len; return len;
} }
std::size_t Strlcpy(char* dst, const std::string_view& src, std::size_t size) std::size_t Strlcpy(char* dst, const std::string_view src, std::size_t size)
{ {
std::size_t len = src.length(); std::size_t len = src.length();
if (len < size) if (len < size)
@ -178,7 +178,7 @@ namespace StringUtil
return len; return len;
} }
std::optional<std::vector<u8>> DecodeHex(const std::string_view& in) std::optional<std::vector<u8>> DecodeHex(const std::string_view in)
{ {
std::vector<u8> data; std::vector<u8> data;
data.reserve(in.size() / 2); data.reserve(in.size() / 2);
@ -204,7 +204,7 @@ namespace StringUtil
return ss.str(); return ss.str();
} }
std::string toLower(const std::string_view& input) std::string toLower(const std::string_view input)
{ {
std::string newStr; std::string newStr;
std::transform(input.begin(), input.end(), std::back_inserter(newStr), std::transform(input.begin(), input.end(), std::back_inserter(newStr),
@ -212,7 +212,7 @@ namespace StringUtil
return newStr; return newStr;
} }
std::string toUpper(const std::string_view& input) std::string toUpper(const std::string_view input)
{ {
std::string newStr; std::string newStr;
std::transform(input.begin(), input.end(), std::back_inserter(newStr), std::transform(input.begin(), input.end(), std::back_inserter(newStr),
@ -220,7 +220,7 @@ namespace StringUtil
return newStr; return newStr;
} }
bool compareNoCase(const std::string_view& str1, const std::string_view& str2) bool compareNoCase(const std::string_view str1, const std::string_view str2)
{ {
if (str1.length() != str2.length()) if (str1.length() != str2.length())
{ {
@ -241,7 +241,7 @@ namespace StringUtil
return lines; return lines;
} }
std::string_view StripWhitespace(const std::string_view& str) std::string_view StripWhitespace(const std::string_view str)
{ {
std::string_view::size_type start = 0; std::string_view::size_type start = 0;
while (start < str.size() && std::isspace(str[start])) while (start < str.size() && std::isspace(str[start]))
@ -277,7 +277,7 @@ namespace StringUtil
} }
} }
std::vector<std::string_view> SplitString(const std::string_view& str, char delimiter, bool skip_empty /*= true*/) std::vector<std::string_view> SplitString(const std::string_view str, char delimiter, bool skip_empty /*= true*/)
{ {
std::vector<std::string_view> res; std::vector<std::string_view> res;
std::string_view::size_type last_pos = 0; std::string_view::size_type last_pos = 0;
@ -301,14 +301,14 @@ namespace StringUtil
return res; return res;
} }
std::string ReplaceAll(const std::string_view& subject, const std::string_view& search, const std::string_view& replacement) std::string ReplaceAll(const std::string_view subject, const std::string_view search, const std::string_view replacement)
{ {
std::string ret(subject); std::string ret(subject);
ReplaceAll(&ret, search, replacement); ReplaceAll(&ret, search, replacement);
return ret; return ret;
} }
void ReplaceAll(std::string* subject, const std::string_view& search, const std::string_view& replacement) void ReplaceAll(std::string* subject, const std::string_view search, const std::string_view replacement)
{ {
if (!subject->empty()) if (!subject->empty())
{ {
@ -321,7 +321,7 @@ namespace StringUtil
} }
} }
bool ParseAssignmentString(const std::string_view& str, std::string_view* key, std::string_view* value) bool ParseAssignmentString(const std::string_view str, std::string_view* key, std::string_view* value)
{ {
const std::string_view::size_type pos = str.find('='); const std::string_view::size_type pos = str.find('=');
if (pos == std::string_view::npos) if (pos == std::string_view::npos)
@ -431,7 +431,7 @@ namespace StringUtil
return 1; return 1;
} }
size_t DecodeUTF8(const std::string_view& str, size_t offset, char32_t* ch) size_t DecodeUTF8(const std::string_view str, size_t offset, char32_t* ch)
{ {
return DecodeUTF8(str.data() + offset, str.length() - offset, ch); return DecodeUTF8(str.data() + offset, str.length() - offset, ch);
} }
@ -441,7 +441,7 @@ namespace StringUtil
return DecodeUTF8(str.data() + offset, str.length() - offset, ch); return DecodeUTF8(str.data() + offset, str.length() - offset, ch);
} }
std::string Ellipsise(const std::string_view& str, u32 max_length, const char* ellipsis /*= "..."*/) std::string Ellipsise(const std::string_view str, u32 max_length, const char* ellipsis /*= "..."*/)
{ {
std::string ret; std::string ret;
ret.reserve(max_length); ret.reserve(max_length);
@ -483,7 +483,7 @@ namespace StringUtil
} }
#ifdef _WIN32 #ifdef _WIN32
std::wstring UTF8StringToWideString(const std::string_view& str) std::wstring UTF8StringToWideString(const std::string_view str)
{ {
std::wstring ret; std::wstring ret;
if (!UTF8StringToWideString(ret, str)) if (!UTF8StringToWideString(ret, str))
@ -492,7 +492,7 @@ namespace StringUtil
return ret; return ret;
} }
bool UTF8StringToWideString(std::wstring& dest, const std::string_view& str) bool UTF8StringToWideString(std::wstring& dest, const std::string_view str)
{ {
int wlen = MultiByteToWideChar(CP_UTF8, 0, str.data(), static_cast<int>(str.length()), nullptr, 0); int wlen = MultiByteToWideChar(CP_UTF8, 0, str.data(), static_cast<int>(str.length()), nullptr, 0);
if (wlen < 0) if (wlen < 0)

View File

@ -52,7 +52,7 @@ namespace StringUtil
std::size_t Strlcpy(char* dst, const char* src, std::size_t size); std::size_t Strlcpy(char* dst, const char* src, std::size_t size);
/// Strlcpy from string_view. /// Strlcpy from string_view.
std::size_t Strlcpy(char* dst, const std::string_view& src, std::size_t size); std::size_t Strlcpy(char* dst, const std::string_view src, std::size_t size);
/// Platform-independent strcasecmp /// Platform-independent strcasecmp
static inline int Strcasecmp(const char* s1, const char* s2) static inline int Strcasecmp(const char* s1, const char* s2)
@ -76,7 +76,7 @@ namespace StringUtil
/// Wrapper around std::from_chars /// Wrapper around std::from_chars
template <typename T, std::enable_if_t<std::is_integral<T>::value, bool> = true> template <typename T, std::enable_if_t<std::is_integral<T>::value, bool> = true>
inline std::optional<T> FromChars(const std::string_view& str, int base = 10) inline std::optional<T> FromChars(const std::string_view str, int base = 10)
{ {
T value; T value;
@ -87,7 +87,7 @@ namespace StringUtil
return value; return value;
} }
template <typename T, std::enable_if_t<std::is_integral<T>::value, bool> = true> template <typename T, std::enable_if_t<std::is_integral<T>::value, bool> = true>
inline std::optional<T> FromChars(const std::string_view& str, int base, std::string_view* endptr) inline std::optional<T> FromChars(const std::string_view str, int base, std::string_view* endptr)
{ {
T value; T value;
@ -104,7 +104,7 @@ namespace StringUtil
} }
template <typename T, std::enable_if_t<std::is_floating_point<T>::value, bool> = true> template <typename T, std::enable_if_t<std::is_floating_point<T>::value, bool> = true>
inline std::optional<T> FromChars(const std::string_view& str) inline std::optional<T> FromChars(const std::string_view str)
{ {
T value; T value;
@ -115,7 +115,7 @@ namespace StringUtil
return value; return value;
} }
template <typename T, std::enable_if_t<std::is_floating_point<T>::value, bool> = true> template <typename T, std::enable_if_t<std::is_floating_point<T>::value, bool> = true>
inline std::optional<T> FromChars(const std::string_view& str, std::string_view* endptr) inline std::optional<T> FromChars(const std::string_view str, std::string_view* endptr)
{ {
T value; T value;
@ -177,7 +177,7 @@ namespace StringUtil
/// Explicit override for booleans /// Explicit override for booleans
template <> template <>
inline std::optional<bool> FromChars(const std::string_view& str, int base) inline std::optional<bool> FromChars(const std::string_view str, int base)
{ {
if (Strncasecmp("true", str.data(), str.length()) == 0 || Strncasecmp("yes", str.data(), str.length()) == 0 || if (Strncasecmp("true", str.data(), str.length()) == 0 || Strncasecmp("yes", str.data(), str.length()) == 0 ||
Strncasecmp("on", str.data(), str.length()) == 0 || Strncasecmp("1", str.data(), str.length()) == 0 || Strncasecmp("on", str.data(), str.length()) == 0 || Strncasecmp("1", str.data(), str.length()) == 0 ||
@ -203,26 +203,26 @@ namespace StringUtil
} }
/// Encode/decode hexadecimal byte buffers /// Encode/decode hexadecimal byte buffers
std::optional<std::vector<u8>> DecodeHex(const std::string_view& str); std::optional<std::vector<u8>> DecodeHex(const std::string_view str);
std::string EncodeHex(const u8* data, int length); std::string EncodeHex(const u8* data, int length);
/// StartsWith/EndsWith variants which aren't case sensitive. /// StartsWith/EndsWith variants which aren't case sensitive.
static inline bool StartsWithNoCase(const std::string_view& str, const std::string_view& prefix) static inline bool StartsWithNoCase(const std::string_view str, const std::string_view prefix)
{ {
return (!str.empty() && Strncasecmp(str.data(), prefix.data(), prefix.length()) == 0); return (!str.empty() && Strncasecmp(str.data(), prefix.data(), prefix.length()) == 0);
} }
static inline bool EndsWithNoCase(const std::string_view& str, const std::string_view& suffix) static inline bool EndsWithNoCase(const std::string_view str, const std::string_view suffix)
{ {
const std::size_t suffix_length = suffix.length(); const std::size_t suffix_length = suffix.length();
return (str.length() >= suffix_length && Strncasecmp(str.data() + (str.length() - suffix_length), suffix.data(), suffix_length) == 0); return (str.length() >= suffix_length && Strncasecmp(str.data() + (str.length() - suffix_length), suffix.data(), suffix_length) == 0);
} }
/// Strip whitespace from the start/end of the string. /// Strip whitespace from the start/end of the string.
std::string_view StripWhitespace(const std::string_view& str); std::string_view StripWhitespace(const std::string_view str);
void StripWhitespace(std::string* str); void StripWhitespace(std::string* str);
/// Splits a string based on a single character delimiter. /// Splits a string based on a single character delimiter.
std::vector<std::string_view> SplitString(const std::string_view& str, char delimiter, bool skip_empty = true); std::vector<std::string_view> SplitString(const std::string_view str, char delimiter, bool skip_empty = true);
/// Joins a string together using the specified delimiter. /// Joins a string together using the specified delimiter.
template <typename T> template <typename T>
@ -238,7 +238,7 @@ namespace StringUtil
return ret; return ret;
} }
template <typename T> template <typename T>
static inline std::string JoinString(const T& start, const T& end, const std::string_view& delimiter) static inline std::string JoinString(const T& start, const T& end, const std::string_view delimiter)
{ {
std::string ret; std::string ret;
for (auto it = start; it != end; ++it) for (auto it = start; it != end; ++it)
@ -251,11 +251,11 @@ namespace StringUtil
} }
/// Replaces all instances of search in subject with replacement. /// Replaces all instances of search in subject with replacement.
std::string ReplaceAll(const std::string_view& subject, const std::string_view& search, const std::string_view& replacement); std::string ReplaceAll(const std::string_view subject, const std::string_view search, const std::string_view replacement);
void ReplaceAll(std::string* subject, const std::string_view& search, const std::string_view& replacement); void ReplaceAll(std::string* subject, const std::string_view search, const std::string_view replacement);
/// Parses an assignment string (Key = Value) into its two components. /// Parses an assignment string (Key = Value) into its two components.
bool ParseAssignmentString(const std::string_view& str, std::string_view* key, std::string_view* value); bool ParseAssignmentString(const std::string_view str, std::string_view* key, std::string_view* value);
/// Appends a UTF-16/UTF-32 codepoint to a UTF-8 string. /// Appends a UTF-16/UTF-32 codepoint to a UTF-8 string.
void AppendUTF16CharacterToUTF8(std::string& s, u16 ch); void AppendUTF16CharacterToUTF8(std::string& s, u16 ch);
@ -266,11 +266,11 @@ namespace StringUtil
/// Decodes UTF-8 to a single codepoint, updating the position parameter. /// Decodes UTF-8 to a single codepoint, updating the position parameter.
/// Returns the number of bytes the codepoint took in the original string. /// Returns the number of bytes the codepoint took in the original string.
size_t DecodeUTF8(const void* bytes, size_t length, char32_t* ch); size_t DecodeUTF8(const void* bytes, size_t length, char32_t* ch);
size_t DecodeUTF8(const std::string_view& str, size_t offset, char32_t* ch); size_t DecodeUTF8(const std::string_view str, size_t offset, char32_t* ch);
size_t DecodeUTF8(const std::string& str, size_t offset, char32_t* ch); size_t DecodeUTF8(const std::string& str, size_t offset, char32_t* ch);
// Replaces the end of a string with ellipsis if it exceeds the specified length. // Replaces the end of a string with ellipsis if it exceeds the specified length.
std::string Ellipsise(const std::string_view& str, u32 max_length, const char* ellipsis = "..."); std::string Ellipsise(const std::string_view str, u32 max_length, const char* ellipsis = "...");
void EllipsiseInPlace(std::string& str, u32 max_length, const char* ellipsis = "..."); void EllipsiseInPlace(std::string& str, u32 max_length, const char* ellipsis = "...");
/// Strided memcpy/memcmp. /// Strided memcpy/memcmp.
@ -313,15 +313,15 @@ namespace StringUtil
return 0; return 0;
} }
std::string toLower(const std::string_view& str); std::string toLower(const std::string_view str);
std::string toUpper(const std::string_view& str); std::string toUpper(const std::string_view str);
bool compareNoCase(const std::string_view& str1, const std::string_view& str2); bool compareNoCase(const std::string_view str1, const std::string_view str2);
std::vector<std::string> splitOnNewLine(const std::string& str); std::vector<std::string> splitOnNewLine(const std::string& str);
#ifdef _WIN32 #ifdef _WIN32
/// Converts the specified UTF-8 string to a wide string. /// Converts the specified UTF-8 string to a wide string.
std::wstring UTF8StringToWideString(const std::string_view& str); std::wstring UTF8StringToWideString(const std::string_view str);
bool UTF8StringToWideString(std::wstring& dest, const std::string_view& str); bool UTF8StringToWideString(std::wstring& dest, const std::string_view str);
/// Converts the specified wide string to a UTF-8 string. /// Converts the specified wide string to a UTF-8 string.
std::string WideStringToUTF8String(const std::wstring_view& str); std::string WideStringToUTF8String(const std::wstring_view& str);
@ -333,7 +333,7 @@ namespace StringUtil
std::string& AppendU128ToString(const u128& u, std::string& s); std::string& AppendU128ToString(const u128& u, std::string& s);
template <typename ContainerType> template <typename ContainerType>
static inline bool ContainsSubString(const ContainerType& haystack, const std::string_view& needle) static inline bool ContainsSubString(const ContainerType& haystack, const std::string_view needle)
{ {
using ValueType = typename ContainerType::value_type; using ValueType = typename ContainerType::value_type;
if (needle.empty()) if (needle.empty())

View File

@ -165,40 +165,30 @@ void Host::SetDefaultUISettings(SettingsInterface& si)
// nothing // nothing
} }
void Host::ReportErrorAsync(const std::string_view& title, const std::string_view& message) void Host::ReportErrorAsync(const std::string_view title, const std::string_view message)
{ {
if (!title.empty() && !message.empty()) if (!title.empty() && !message.empty())
{ ERROR_LOG("ReportErrorAsync: {}: {}", title, message);
Console.Error(
"ReportErrorAsync: %.*s: %.*s", static_cast<int>(title.size()), title.data(), static_cast<int>(message.size()), message.data());
}
else if (!message.empty()) else if (!message.empty())
{ ERROR_LOG("ReportErrorAsync: {}", message);
Console.Error("ReportErrorAsync: %.*s", static_cast<int>(message.size()), message.data());
}
} }
bool Host::ConfirmMessage(const std::string_view& title, const std::string_view& message) bool Host::ConfirmMessage(const std::string_view title, const std::string_view message)
{ {
if (!title.empty() && !message.empty()) if (!title.empty() && !message.empty())
{ ERROR_LOG("ConfirmMessage: {}: {}", title, message);
Console.Error(
"ConfirmMessage: %.*s: %.*s", static_cast<int>(title.size()), title.data(), static_cast<int>(message.size()), message.data());
}
else if (!message.empty()) else if (!message.empty())
{ ERROR_LOG("ConfirmMessage: {}", message);
Console.Error("ConfirmMessage: %.*s", static_cast<int>(message.size()), message.data());
}
return true; return true;
} }
void Host::OpenURL(const std::string_view& url) void Host::OpenURL(const std::string_view url)
{ {
// noop // noop
} }
bool Host::CopyTextToClipboard(const std::string_view& text) bool Host::CopyTextToClipboard(const std::string_view text)
{ {
return false; return false;
} }
@ -315,15 +305,15 @@ void Host::OnPerformanceMetricsUpdated()
{ {
} }
void Host::OnSaveStateLoading(const std::string_view& filename) void Host::OnSaveStateLoading(const std::string_view filename)
{ {
} }
void Host::OnSaveStateLoaded(const std::string_view& filename, bool was_successful) void Host::OnSaveStateLoaded(const std::string_view filename, bool was_successful)
{ {
} }
void Host::OnSaveStateSaved(const std::string_view& filename) void Host::OnSaveStateSaved(const std::string_view filename)
{ {
} }
@ -411,7 +401,7 @@ void Host::OpenHostFileSelectorAsync(std::string_view title, bool select_directo
callback(std::string()); callback(std::string());
} }
std::optional<u32> InputManager::ConvertHostKeyboardStringToCode(const std::string_view& str) std::optional<u32> InputManager::ConvertHostKeyboardStringToCode(const std::string_view str)
{ {
return std::nullopt; return std::nullopt;
} }
@ -732,7 +722,7 @@ void Host::PumpMessagesOnCPUThread()
} }
s32 Host::Internal::GetTranslatedStringImpl( s32 Host::Internal::GetTranslatedStringImpl(
const std::string_view& context, const std::string_view& msg, char* tbuf, size_t tbuf_space) const std::string_view context, const std::string_view msg, char* tbuf, size_t tbuf_space)
{ {
if (msg.size() > tbuf_space) if (msg.size() > tbuf_space)
return -1; return -1;

View File

@ -69,7 +69,7 @@ namespace QtHost
{ {
static void InitializeEarlyConsole(); static void InitializeEarlyConsole();
static void PrintCommandLineVersion(); static void PrintCommandLineVersion();
static void PrintCommandLineHelp(const std::string_view& progname); static void PrintCommandLineHelp(const std::string_view progname);
static std::shared_ptr<VMBootParameters>& AutoBoot(std::shared_ptr<VMBootParameters>& autoboot); static std::shared_ptr<VMBootParameters>& AutoBoot(std::shared_ptr<VMBootParameters>& autoboot);
static bool ParseCommandLineOptions(const QStringList& args, std::shared_ptr<VMBootParameters>& autoboot); static bool ParseCommandLineOptions(const QStringList& args, std::shared_ptr<VMBootParameters>& autoboot);
static bool InitializeConfig(); static bool InitializeConfig();
@ -1085,17 +1085,17 @@ void Host::OnPerformanceMetricsUpdated()
g_emu_thread->updatePerformanceMetrics(false); g_emu_thread->updatePerformanceMetrics(false);
} }
void Host::OnSaveStateLoading(const std::string_view& filename) void Host::OnSaveStateLoading(const std::string_view filename)
{ {
emit g_emu_thread->onSaveStateLoading(QtUtils::StringViewToQString(filename)); emit g_emu_thread->onSaveStateLoading(QtUtils::StringViewToQString(filename));
} }
void Host::OnSaveStateLoaded(const std::string_view& filename, bool was_successful) void Host::OnSaveStateLoaded(const std::string_view filename, bool was_successful)
{ {
emit g_emu_thread->onSaveStateLoaded(QtUtils::StringViewToQString(filename), was_successful); emit g_emu_thread->onSaveStateLoaded(QtUtils::StringViewToQString(filename), was_successful);
} }
void Host::OnSaveStateSaved(const std::string_view& filename) void Host::OnSaveStateSaved(const std::string_view filename)
{ {
emit g_emu_thread->onSaveStateSaved(QtUtils::StringViewToQString(filename)); emit g_emu_thread->onSaveStateSaved(QtUtils::StringViewToQString(filename));
} }
@ -1618,36 +1618,31 @@ bool QtHost::DownloadFile(QWidget* parent, const QString& title, std::string url
return true; return true;
} }
void Host::ReportErrorAsync(const std::string_view& title, const std::string_view& message) void Host::ReportErrorAsync(const std::string_view title, const std::string_view message)
{ {
if (!title.empty() && !message.empty()) if (!title.empty() && !message.empty())
{ ERROR_LOG("ReportErrorAsync: {}: {}", title, message);
Console.Error(
"ReportErrorAsync: %.*s: %.*s", static_cast<int>(title.size()), title.data(), static_cast<int>(message.size()), message.data());
}
else if (!message.empty()) else if (!message.empty())
{ ERROR_LOG("ReportErrorAsync: {}", message);
Console.Error("ReportErrorAsync: %.*s", static_cast<int>(message.size()), message.data());
}
QMetaObject::invokeMethod(g_main_window, "reportError", Qt::QueuedConnection, QMetaObject::invokeMethod(g_main_window, "reportError", Qt::QueuedConnection,
Q_ARG(const QString&, title.empty() ? QString() : QString::fromUtf8(title.data(), title.size())), Q_ARG(const QString&, title.empty() ? QString() : QString::fromUtf8(title.data(), title.size())),
Q_ARG(const QString&, message.empty() ? QString() : QString::fromUtf8(message.data(), message.size()))); Q_ARG(const QString&, message.empty() ? QString() : QString::fromUtf8(message.data(), message.size())));
} }
bool Host::ConfirmMessage(const std::string_view& title, const std::string_view& message) bool Host::ConfirmMessage(const std::string_view title, const std::string_view message)
{ {
const QString qtitle(QString::fromUtf8(title.data(), title.size())); const QString qtitle(QString::fromUtf8(title.data(), title.size()));
const QString qmessage(QString::fromUtf8(message.data(), message.size())); const QString qmessage(QString::fromUtf8(message.data(), message.size()));
return g_emu_thread->confirmMessage(qtitle, qmessage); return g_emu_thread->confirmMessage(qtitle, qmessage);
} }
void Host::OpenURL(const std::string_view& url) void Host::OpenURL(const std::string_view url)
{ {
QtHost::RunOnUIThread([url = QtUtils::StringViewToQString(url)]() { QtUtils::OpenURL(g_main_window, QUrl(url)); }); QtHost::RunOnUIThread([url = QtUtils::StringViewToQString(url)]() { QtUtils::OpenURL(g_main_window, QUrl(url)); });
} }
bool Host::CopyTextToClipboard(const std::string_view& text) bool Host::CopyTextToClipboard(const std::string_view text)
{ {
QtHost::RunOnUIThread([text = QtUtils::StringViewToQString(text)]() { QtHost::RunOnUIThread([text = QtUtils::StringViewToQString(text)]() {
QClipboard* clipboard = QGuiApplication::clipboard(); QClipboard* clipboard = QGuiApplication::clipboard();
@ -1801,7 +1796,7 @@ void QtHost::PrintCommandLineVersion()
std::fprintf(stderr, "\n"); std::fprintf(stderr, "\n");
} }
void QtHost::PrintCommandLineHelp(const std::string_view& progname) void QtHost::PrintCommandLineHelp(const std::string_view progname)
{ {
PrintCommandLineVersion(); PrintCommandLineVersion();
fmt::print(stderr, "Usage: {} [parameters] [--] [boot filename]\n", progname); fmt::print(stderr, "Usage: {} [parameters] [--] [boot filename]\n", progname);

View File

@ -460,7 +460,7 @@ static constexpr const KeyCodeName s_qt_key_names[] = {
{Qt::Key_Camera, "Camera", nullptr}, {Qt::Key_Camera, "Camera", nullptr},
{Qt::Key_CameraFocus, "CameraFocus", nullptr}}; {Qt::Key_CameraFocus, "CameraFocus", nullptr}};
std::optional<u32> InputManager::ConvertHostKeyboardStringToCode(const std::string_view& str) std::optional<u32> InputManager::ConvertHostKeyboardStringToCode(const std::string_view str)
{ {
std::string_view compare_name = str; std::string_view compare_name = str;
u32 modifier_bits = 0; u32 modifier_bits = 0;

View File

@ -189,7 +189,7 @@ namespace QtUtils
return OpenURL(parent, QUrl(url)); return OpenURL(parent, QUrl(url));
} }
QString StringViewToQString(const std::string_view& str) QString StringViewToQString(const std::string_view str)
{ {
return str.empty() ? QString() : QString::fromUtf8(str.data(), str.size()); return str.empty() ? QString() : QString::fromUtf8(str.data(), str.size());
} }

View File

@ -68,7 +68,7 @@ namespace QtUtils
void OpenURL(QWidget* parent, const QString& url); void OpenURL(QWidget* parent, const QString& url);
/// Converts a std::string_view to a QString safely. /// Converts a std::string_view to a QString safely.
QString StringViewToQString(const std::string_view& str); QString StringViewToQString(const std::string_view str);
/// Sets a widget to italics if the setting value is inherited. /// Sets a widget to italics if the setting value is inherited.
void SetWidgetFontForInheritedSetting(QWidget* widget, bool inherited); void SetWidgetFontForInheritedSetting(QWidget* widget, bool inherited);

View File

@ -192,7 +192,7 @@ void GameCheatSettingsWidget::reloadList()
} }
} }
QTreeWidgetItem* GameCheatSettingsWidget::getTreeWidgetParent(const std::string_view& parent) QTreeWidgetItem* GameCheatSettingsWidget::getTreeWidgetParent(const std::string_view parent)
{ {
if (parent.empty()) if (parent.empty())
return nullptr; return nullptr;

View File

@ -43,7 +43,7 @@ private Q_SLOTS:
void reloadList(); void reloadList();
private: private:
QTreeWidgetItem* getTreeWidgetParent(const std::string_view& parent); QTreeWidgetItem* getTreeWidgetParent(const std::string_view parent);
void populateTreeWidgetItem(QTreeWidgetItem* item, const Patch::PatchInfo& pi, bool enabled); void populateTreeWidgetItem(QTreeWidgetItem* item, const Patch::PatchInfo& pi, bool enabled);
void setCheatEnabled(std::string name, bool enabled, bool save_and_reload_settings); void setCheatEnabled(std::string name, bool enabled, bool save_and_reload_settings);
void setStateForAll(bool enabled); void setStateForAll(bool enabled);

View File

@ -644,7 +644,7 @@ void SettingsWindow::saveAndReloadGameSettings()
g_emu_thread->reloadGameSettings(); g_emu_thread->reloadGameSettings();
} }
void SettingsWindow::openGamePropertiesDialog(const GameList::Entry* game, const std::string_view& title, std::string serial, u32 disc_crc) void SettingsWindow::openGamePropertiesDialog(const GameList::Entry* game, const std::string_view title, std::string serial, u32 disc_crc)
{ {
std::string filename = VMManager::GetGameSettingsPath(serial, disc_crc); std::string filename = VMManager::GetGameSettingsPath(serial, disc_crc);

View File

@ -45,7 +45,7 @@ public:
u32 disc_crc, QString filename = QString()); u32 disc_crc, QString filename = QString());
~SettingsWindow(); ~SettingsWindow();
static void openGamePropertiesDialog(const GameList::Entry* game, const std::string_view& title, std::string serial, u32 disc_crc); static void openGamePropertiesDialog(const GameList::Entry* game, const std::string_view title, std::string serial, u32 disc_crc);
static void closeGamePropertiesDialogs(); static void closeGamePropertiesDialogs();
SettingsInterface* getSettingsInterface() const; SettingsInterface* getSettingsInterface() const;

View File

@ -56,9 +56,9 @@ namespace QtHost
const char16_t* used_glyphs; const char16_t* used_glyphs;
}; };
static void UpdateGlyphRangesAndClearCache(QWidget* dialog_parent, const std::string_view& language); static void UpdateGlyphRangesAndClearCache(QWidget* dialog_parent, const std::string_view language);
static bool DownloadMissingFont(QWidget* dialog_parent, const char* font_name, const std::string& path); static bool DownloadMissingFont(QWidget* dialog_parent, const char* font_name, const std::string& path);
static const GlyphInfo* GetGlyphInfo(const std::string_view& language); static const GlyphInfo* GetGlyphInfo(const std::string_view language);
static constexpr const char* DEFAULT_IMGUI_FONT_NAME = "Roboto-Regular.ttf"; static constexpr const char* DEFAULT_IMGUI_FONT_NAME = "Roboto-Regular.ttf";
@ -197,7 +197,7 @@ const char* QtHost::GetDefaultLanguage()
} }
s32 Host::Internal::GetTranslatedStringImpl( s32 Host::Internal::GetTranslatedStringImpl(
const std::string_view& context, const std::string_view& msg, char* tbuf, size_t tbuf_space) const std::string_view context, const std::string_view msg, char* tbuf, size_t tbuf_space)
{ {
// This is really awful. Thankfully we're caching the results... // This is really awful. Thankfully we're caching the results...
const std::string temp_context(context); const std::string temp_context(context);
@ -269,7 +269,7 @@ static constexpr const ImWchar s_central_european_ranges[] = {
0x0100, 0x017F, // Central European diacritics 0x0100, 0x017F, // Central European diacritics
}; };
void QtHost::UpdateGlyphRangesAndClearCache(QWidget* dialog_parent, const std::string_view& language) void QtHost::UpdateGlyphRangesAndClearCache(QWidget* dialog_parent, const std::string_view language)
{ {
const GlyphInfo* gi = GetGlyphInfo(language); const GlyphInfo* gi = GetGlyphInfo(language);
@ -418,7 +418,7 @@ static constexpr const QtHost::GlyphInfo s_glyph_info[] = {
}; };
// clang-format on // clang-format on
const QtHost::GlyphInfo* QtHost::GetGlyphInfo(const std::string_view& language) const QtHost::GlyphInfo* QtHost::GetGlyphInfo(const std::string_view language)
{ {
for (const GlyphInfo& it : s_glyph_info) for (const GlyphInfo& it : s_glyph_info)
{ {

View File

@ -108,7 +108,7 @@ namespace Achievements
}; };
} // namespace } // namespace
static void ReportError(const std::string_view& sv); static void ReportError(const std::string_view sv);
template <typename... T> template <typename... T>
static void ReportFmtError(fmt::format_string<T...> fmt, T&&... args); static void ReportFmtError(fmt::format_string<T...> fmt, T&&... args);
template <typename... T> template <typename... T>
@ -168,7 +168,7 @@ namespace Achievements
static void UpdateRichPresence(std::unique_lock<std::recursive_mutex>& lock); static void UpdateRichPresence(std::unique_lock<std::recursive_mutex>& lock);
static std::string GetAchievementBadgePath(const rc_client_achievement_t* achievement, int state); static std::string GetAchievementBadgePath(const rc_client_achievement_t* achievement, int state);
static std::string GetUserBadgePath(const std::string_view& username); static std::string GetUserBadgePath(const std::string_view username);
static std::string GetLeaderboardUserBadgePath(const rc_client_leaderboard_entry_t* entry); static std::string GetLeaderboardUserBadgePath(const rc_client_leaderboard_entry_t* entry);
static void DrawAchievement(const rc_client_achievement_t* cheevo); static void DrawAchievement(const rc_client_achievement_t* cheevo);
@ -242,7 +242,7 @@ void Achievements::EndLoadingScreen(bool was_running_idle)
ImGuiFullscreen::CloseBackgroundProgressDialog("achievements_loading"); ImGuiFullscreen::CloseBackgroundProgressDialog("achievements_loading");
} }
void Achievements::ReportError(const std::string_view& sv) void Achievements::ReportError(const std::string_view sv)
{ {
std::string error = fmt::format("Achievements error: {}", sv); std::string error = fmt::format("Achievements error: {}", sv);
Console.Error(error); Console.Error(error);
@ -1591,7 +1591,7 @@ std::string Achievements::GetAchievementBadgePath(const rc_client_achievement_t*
return path; return path;
} }
std::string Achievements::GetUserBadgePath(const std::string_view& username) std::string Achievements::GetUserBadgePath(const std::string_view username)
{ {
// definitely want to sanitize usernames... :) // definitely want to sanitize usernames... :)
std::string path; std::string path;

View File

@ -378,7 +378,7 @@ s32 cdvdWriteConfig(const u8* config)
return 0; return 0;
} }
static bool cdvdUncheckedLoadDiscElf(ElfObject* elfo, IsoReader& isor, const std::string_view& elfpath, bool isPSXElf, Error* error) static bool cdvdUncheckedLoadDiscElf(ElfObject* elfo, IsoReader& isor, const std::string_view elfpath, bool isPSXElf, Error* error)
{ {
// Strip out cdrom: prefix, and any leading slashes. // Strip out cdrom: prefix, and any leading slashes.
size_t start_pos = (elfpath[5] == '0') ? 7 : 6; size_t start_pos = (elfpath[5] == '0') ? 7 : 6;
@ -416,7 +416,7 @@ static bool cdvdUncheckedLoadDiscElf(ElfObject* elfo, IsoReader& isor, const std
return elfo->OpenIsoFile(std::move(iso_filename), isor, isPSXElf, error); return elfo->OpenIsoFile(std::move(iso_filename), isor, isPSXElf, error);
} }
bool cdvdLoadElf(ElfObject* elfo, const std::string_view& elfpath, bool isPSXElf, Error* error) bool cdvdLoadElf(ElfObject* elfo, const std::string_view elfpath, bool isPSXElf, Error* error)
{ {
if (R3000A::ioman::is_host(elfpath)) if (R3000A::ioman::is_host(elfpath))
{ {
@ -439,7 +439,7 @@ bool cdvdLoadElf(ElfObject* elfo, const std::string_view& elfpath, bool isPSXElf
} }
} }
bool cdvdLoadDiscElf(ElfObject* elfo, IsoReader& isor, const std::string_view& elfpath, bool isPSXElf, Error* error) bool cdvdLoadDiscElf(ElfObject* elfo, IsoReader& isor, const std::string_view elfpath, bool isPSXElf, Error* error)
{ {
if (!elfpath.starts_with("cdrom:") && !elfpath.starts_with("cdrom0:")) if (!elfpath.starts_with("cdrom:") && !elfpath.starts_with("cdrom0:"))
return false; return false;

View File

@ -180,8 +180,8 @@ extern void cdvdWrite(u8 key, u8 rt);
extern void cdvdGetDiscInfo(std::string* out_serial, std::string* out_elf_path, std::string* out_version, u32* out_crc, extern void cdvdGetDiscInfo(std::string* out_serial, std::string* out_elf_path, std::string* out_version, u32* out_crc,
CDVDDiscType* out_disc_type); CDVDDiscType* out_disc_type);
extern u32 cdvdGetElfCRC(const std::string& path); extern u32 cdvdGetElfCRC(const std::string& path);
extern bool cdvdLoadElf(ElfObject* elfo, const std::string_view& elfpath, bool isPSXElf, Error* error); extern bool cdvdLoadElf(ElfObject* elfo, const std::string_view elfpath, bool isPSXElf, Error* error);
extern bool cdvdLoadDiscElf(ElfObject* elfo, IsoReader& isor, const std::string_view& elfpath, bool isPSXElf, Error* error); extern bool cdvdLoadDiscElf(ElfObject* elfo, IsoReader& isor, const std::string_view elfpath, bool isPSXElf, Error* error);
extern s32 cdvdCtrlTrayOpen(); extern s32 cdvdCtrlTrayOpen();
extern s32 cdvdCtrlTrayClose(); extern s32 cdvdCtrlTrayClose();

View File

@ -17,7 +17,7 @@ IsoReader::IsoReader() = default;
IsoReader::~IsoReader() = default; IsoReader::~IsoReader() = default;
std::string_view IsoReader::RemoveVersionIdentifierFromPath(const std::string_view& path) std::string_view IsoReader::RemoveVersionIdentifierFromPath(const std::string_view path)
{ {
const std::string_view::size_type pos = path.find(';'); const std::string_view::size_type pos = path.find(';');
return (pos != std::string_view::npos) ? path.substr(0, pos) : path; return (pos != std::string_view::npos) ? path.substr(0, pos) : path;
@ -71,7 +71,7 @@ bool IsoReader::ReadPVD(Error* error)
return false; return false;
} }
std::optional<IsoReader::ISODirectoryEntry> IsoReader::LocateFile(const std::string_view& path, Error* error) std::optional<IsoReader::ISODirectoryEntry> IsoReader::LocateFile(const std::string_view path, Error* error)
{ {
const ISODirectoryEntry* root_de = reinterpret_cast<const ISODirectoryEntry*>(m_pvd.root_directory_entry); const ISODirectoryEntry* root_de = reinterpret_cast<const ISODirectoryEntry*>(m_pvd.root_directory_entry);
if (path.empty() || path == "/" || path == "\\") if (path.empty() || path == "/" || path == "\\")
@ -115,7 +115,7 @@ std::string_view IsoReader::GetDirectoryEntryFileName(const u8* sector, u32 de_s
} }
std::optional<IsoReader::ISODirectoryEntry> IsoReader::LocateFile( std::optional<IsoReader::ISODirectoryEntry> IsoReader::LocateFile(
const std::string_view& path, u8* sector_buffer, u32 directory_record_lba, u32 directory_record_size, Error* error) const std::string_view path, u8* sector_buffer, u32 directory_record_lba, u32 directory_record_size, Error* error)
{ {
if (directory_record_size == 0) if (directory_record_size == 0)
{ {
@ -191,7 +191,7 @@ std::optional<IsoReader::ISODirectoryEntry> IsoReader::LocateFile(
return std::nullopt; return std::nullopt;
} }
std::vector<std::string> IsoReader::GetFilesInDirectory(const std::string_view& path, Error* error) std::vector<std::string> IsoReader::GetFilesInDirectory(const std::string_view path, Error* error)
{ {
std::string base_path(path); std::string base_path(path);
u32 directory_record_lsn; u32 directory_record_lsn;
@ -252,7 +252,7 @@ std::vector<std::string> IsoReader::GetFilesInDirectory(const std::string_view&
return files; return files;
} }
bool IsoReader::FileExists(const std::string_view& path, Error* error) bool IsoReader::FileExists(const std::string_view path, Error* error)
{ {
auto de = LocateFile(path, error); auto de = LocateFile(path, error);
if (!de) if (!de)
@ -261,7 +261,7 @@ bool IsoReader::FileExists(const std::string_view& path, Error* error)
return (de->flags & ISODirectoryEntryFlag_Directory) == 0; return (de->flags & ISODirectoryEntryFlag_Directory) == 0;
} }
bool IsoReader::DirectoryExists(const std::string_view& path, Error* error) bool IsoReader::DirectoryExists(const std::string_view path, Error* error)
{ {
auto de = LocateFile(path, error); auto de = LocateFile(path, error);
if (!de) if (!de)
@ -270,7 +270,7 @@ bool IsoReader::DirectoryExists(const std::string_view& path, Error* error)
return (de->flags & ISODirectoryEntryFlag_Directory) == ISODirectoryEntryFlag_Directory; return (de->flags & ISODirectoryEntryFlag_Directory) == ISODirectoryEntryFlag_Directory;
} }
bool IsoReader::ReadFile(const std::string_view& path, std::vector<u8>* data, Error* error) bool IsoReader::ReadFile(const std::string_view path, std::vector<u8>* data, Error* error)
{ {
auto de = LocateFile(path, error); auto de = LocateFile(path, error);
if (!de) if (!de)

View File

@ -136,7 +136,7 @@ public:
IsoReader(); IsoReader();
~IsoReader(); ~IsoReader();
static std::string_view RemoveVersionIdentifierFromPath(const std::string_view& path); static std::string_view RemoveVersionIdentifierFromPath(const std::string_view path);
const ISOPrimaryVolumeDescriptor& GetPVD() const { return m_pvd; } const ISOPrimaryVolumeDescriptor& GetPVD() const { return m_pvd; }
@ -144,13 +144,13 @@ public:
// ... once I have the energy to make CDVD not depend on a global object. // ... once I have the energy to make CDVD not depend on a global object.
bool Open(Error* error = nullptr); bool Open(Error* error = nullptr);
std::vector<std::string> GetFilesInDirectory(const std::string_view& path, Error* error = nullptr); std::vector<std::string> GetFilesInDirectory(const std::string_view path, Error* error = nullptr);
std::optional<ISODirectoryEntry> LocateFile(const std::string_view& path, Error* error); std::optional<ISODirectoryEntry> LocateFile(const std::string_view path, Error* error);
bool FileExists(const std::string_view& path, Error* error = nullptr); bool FileExists(const std::string_view path, Error* error = nullptr);
bool DirectoryExists(const std::string_view& path, Error* error = nullptr); bool DirectoryExists(const std::string_view path, Error* error = nullptr);
bool ReadFile(const std::string_view& path, std::vector<u8>* data, Error* error = nullptr); bool ReadFile(const std::string_view path, std::vector<u8>* data, Error* error = nullptr);
bool ReadFile(const ISODirectoryEntry& de, std::vector<u8>* data, Error* error = nullptr); bool ReadFile(const ISODirectoryEntry& de, std::vector<u8>* data, Error* error = nullptr);
private: private:
@ -159,7 +159,7 @@ private:
bool ReadSector(u8* buf, u32 lsn, Error* error); bool ReadSector(u8* buf, u32 lsn, Error* error);
bool ReadPVD(Error* error); bool ReadPVD(Error* error);
std::optional<ISODirectoryEntry> LocateFile(const std::string_view& path, u8* sector_buffer, std::optional<ISODirectoryEntry> LocateFile(const std::string_view path, u8* sector_buffer,
u32 directory_record_lba, u32 directory_record_size, Error* error); u32 directory_record_lba, u32 directory_record_size, Error* error);
ISOPrimaryVolumeDescriptor m_pvd = {}; ISOPrimaryVolumeDescriptor m_pvd = {};

View File

@ -949,7 +949,7 @@ struct Pcsx2Config
bool operator!=(const SpeedhackOptions& right) const; bool operator!=(const SpeedhackOptions& right) const;
static const char* GetSpeedHackName(SpeedHack id); static const char* GetSpeedHackName(SpeedHack id);
static std::optional<SpeedHack> ParseSpeedHackName(const std::string_view& name); static std::optional<SpeedHack> ParseSpeedHackName(const std::string_view name);
}; };
struct DebugOptions struct DebugOptions

View File

@ -52,9 +52,9 @@ enum class GSDisplayAlignment
class SmallStringBase; class SmallStringBase;
// Returns the ID for the specified function, otherwise -1. // Returns the ID for the specified function, otherwise -1.
s16 GSLookupGetSkipCountFunctionId(const std::string_view& name); s16 GSLookupGetSkipCountFunctionId(const std::string_view name);
s16 GSLookupBeforeDrawFunctionId(const std::string_view& name); s16 GSLookupBeforeDrawFunctionId(const std::string_view name);
s16 GSLookupMoveHandlerFunctionId(const std::string_view& name); s16 GSLookupMoveHandlerFunctionId(const std::string_view name);
bool GSopen(const Pcsx2Config::GSOptions& config, GSRendererType renderer, u8* basemem); bool GSopen(const Pcsx2Config::GSOptions& config, GSRendererType renderer, u8* basemem);
bool GSreopen(bool recreate_device, bool recreate_renderer, GSRendererType new_renderer, bool GSreopen(bool recreate_device, bool recreate_renderer, GSRendererType new_renderer,

View File

@ -84,7 +84,7 @@ std::vector<std::string> D3D::GetAdapterNames(IDXGIFactory5* factory)
return adapter_names; return adapter_names;
} }
std::vector<std::string> D3D::GetFullscreenModes(IDXGIFactory5* factory, const std::string_view& adapter_name) std::vector<std::string> D3D::GetFullscreenModes(IDXGIFactory5* factory, const std::string_view adapter_name)
{ {
std::vector<std::string> modes; std::vector<std::string> modes;
HRESULT hr; HRESULT hr;
@ -196,7 +196,7 @@ bool D3D::GetRequestedExclusiveFullscreenModeDesc(IDXGIFactory5* factory, const
return true; return true;
} }
wil::com_ptr_nothrow<IDXGIAdapter1> D3D::GetAdapterByName(IDXGIFactory5* factory, const std::string_view& name) wil::com_ptr_nothrow<IDXGIAdapter1> D3D::GetAdapterByName(IDXGIFactory5* factory, const std::string_view name)
{ {
if (name.empty()) if (name.empty())
return {}; return {};
@ -242,7 +242,7 @@ wil::com_ptr_nothrow<IDXGIAdapter1> D3D::GetFirstAdapter(IDXGIFactory5* factory)
return adapter; return adapter;
} }
wil::com_ptr_nothrow<IDXGIAdapter1> D3D::GetChosenOrFirstAdapter(IDXGIFactory5* factory, const std::string_view& name) wil::com_ptr_nothrow<IDXGIAdapter1> D3D::GetChosenOrFirstAdapter(IDXGIFactory5* factory, const std::string_view name)
{ {
wil::com_ptr_nothrow<IDXGIAdapter1> adapter = GetAdapterByName(factory, name); wil::com_ptr_nothrow<IDXGIAdapter1> adapter = GetAdapterByName(factory, name);
if (!adapter) if (!adapter)
@ -479,7 +479,7 @@ GSRendererType D3D::GetPreferredRenderer()
#endif // _M_X86 #endif // _M_X86
wil::com_ptr_nothrow<ID3DBlob> D3D::CompileShader(D3D::ShaderType type, D3D_FEATURE_LEVEL feature_level, bool debug, wil::com_ptr_nothrow<ID3DBlob> D3D::CompileShader(D3D::ShaderType type, D3D_FEATURE_LEVEL feature_level, bool debug,
const std::string_view& code, const D3D_SHADER_MACRO* macros /* = nullptr */, const std::string_view code, const D3D_SHADER_MACRO* macros /* = nullptr */,
const char* entry_point /* = "main" */) const char* entry_point /* = "main" */)
{ {
const char* target; const char* target;

View File

@ -23,20 +23,20 @@ namespace D3D
std::vector<std::string> GetAdapterNames(IDXGIFactory5* factory); std::vector<std::string> GetAdapterNames(IDXGIFactory5* factory);
// returns a list of fullscreen modes for the specified adapter // returns a list of fullscreen modes for the specified adapter
std::vector<std::string> GetFullscreenModes(IDXGIFactory5* factory, const std::string_view& adapter_name); std::vector<std::string> GetFullscreenModes(IDXGIFactory5* factory, const std::string_view adapter_name);
// returns the fullscreen mode to use for the specified dimensions // returns the fullscreen mode to use for the specified dimensions
bool GetRequestedExclusiveFullscreenModeDesc(IDXGIFactory5* factory, const RECT& window_rect, u32 width, u32 height, bool GetRequestedExclusiveFullscreenModeDesc(IDXGIFactory5* factory, const RECT& window_rect, u32 width, u32 height,
float refresh_rate, DXGI_FORMAT format, DXGI_MODE_DESC* fullscreen_mode, IDXGIOutput** output); float refresh_rate, DXGI_FORMAT format, DXGI_MODE_DESC* fullscreen_mode, IDXGIOutput** output);
// get an adapter based on name // get an adapter based on name
wil::com_ptr_nothrow<IDXGIAdapter1> GetAdapterByName(IDXGIFactory5* factory, const std::string_view& name); wil::com_ptr_nothrow<IDXGIAdapter1> GetAdapterByName(IDXGIFactory5* factory, const std::string_view name);
// returns the first adapter in the system // returns the first adapter in the system
wil::com_ptr_nothrow<IDXGIAdapter1> GetFirstAdapter(IDXGIFactory5* factory); wil::com_ptr_nothrow<IDXGIAdapter1> GetFirstAdapter(IDXGIFactory5* factory);
// returns the adapter specified in the configuration, or the default // returns the adapter specified in the configuration, or the default
wil::com_ptr_nothrow<IDXGIAdapter1> GetChosenOrFirstAdapter(IDXGIFactory5* factory, const std::string_view& name); wil::com_ptr_nothrow<IDXGIAdapter1> GetChosenOrFirstAdapter(IDXGIFactory5* factory, const std::string_view name);
// returns a utf-8 string of the specified adapter's name // returns a utf-8 string of the specified adapter's name
std::string GetAdapterName(IDXGIAdapter1* adapter); std::string GetAdapterName(IDXGIAdapter1* adapter);
@ -68,5 +68,5 @@ namespace D3D
}; };
wil::com_ptr_nothrow<ID3DBlob> CompileShader(ShaderType type, D3D_FEATURE_LEVEL feature_level, bool debug, wil::com_ptr_nothrow<ID3DBlob> CompileShader(ShaderType type, D3D_FEATURE_LEVEL feature_level, bool debug,
const std::string_view& code, const D3D_SHADER_MACRO* macros = nullptr, const char* entry_point = "main"); const std::string_view code, const D3D_SHADER_MACRO* macros = nullptr, const char* entry_point = "main");
}; // namespace D3D }; // namespace D3D

View File

@ -218,7 +218,7 @@ std::string D3D11ShaderCache::GetCacheBaseFileName(D3D_FEATURE_LEVEL feature_lev
} }
D3D11ShaderCache::CacheIndexKey D3D11ShaderCache::GetCacheKey( D3D11ShaderCache::CacheIndexKey D3D11ShaderCache::GetCacheKey(
D3D::ShaderType type, const std::string_view& shader_code, const D3D_SHADER_MACRO* macros, const char* entry_point) D3D::ShaderType type, const std::string_view shader_code, const D3D_SHADER_MACRO* macros, const char* entry_point)
{ {
union union
{ {
@ -263,7 +263,7 @@ D3D11ShaderCache::CacheIndexKey D3D11ShaderCache::GetCacheKey(
} }
wil::com_ptr_nothrow<ID3DBlob> D3D11ShaderCache::GetShaderBlob(D3D::ShaderType type, wil::com_ptr_nothrow<ID3DBlob> D3D11ShaderCache::GetShaderBlob(D3D::ShaderType type,
const std::string_view& shader_code, const D3D_SHADER_MACRO* macros /* = nullptr */, const std::string_view shader_code, const D3D_SHADER_MACRO* macros /* = nullptr */,
const char* entry_point /* = "main" */) const char* entry_point /* = "main" */)
{ {
const auto key = GetCacheKey(type, shader_code, macros, entry_point); const auto key = GetCacheKey(type, shader_code, macros, entry_point);
@ -284,7 +284,7 @@ wil::com_ptr_nothrow<ID3DBlob> D3D11ShaderCache::GetShaderBlob(D3D::ShaderType t
} }
wil::com_ptr_nothrow<ID3D11VertexShader> D3D11ShaderCache::GetVertexShader(ID3D11Device* device, wil::com_ptr_nothrow<ID3D11VertexShader> D3D11ShaderCache::GetVertexShader(ID3D11Device* device,
const std::string_view& shader_code, const D3D_SHADER_MACRO* macros /* = nullptr */, const std::string_view shader_code, const D3D_SHADER_MACRO* macros /* = nullptr */,
const char* entry_point /* = "main" */) const char* entry_point /* = "main" */)
{ {
wil::com_ptr_nothrow<ID3DBlob> blob = GetShaderBlob(D3D::ShaderType::Vertex, shader_code, macros, entry_point); wil::com_ptr_nothrow<ID3DBlob> blob = GetShaderBlob(D3D::ShaderType::Vertex, shader_code, macros, entry_point);
@ -305,7 +305,7 @@ wil::com_ptr_nothrow<ID3D11VertexShader> D3D11ShaderCache::GetVertexShader(ID3D1
bool D3D11ShaderCache::GetVertexShaderAndInputLayout(ID3D11Device* device, ID3D11VertexShader** vs, bool D3D11ShaderCache::GetVertexShaderAndInputLayout(ID3D11Device* device, ID3D11VertexShader** vs,
ID3D11InputLayout** il, const D3D11_INPUT_ELEMENT_DESC* layout, size_t layout_size, ID3D11InputLayout** il, const D3D11_INPUT_ELEMENT_DESC* layout, size_t layout_size,
const std::string_view& shader_code, const D3D_SHADER_MACRO* macros /* = nullptr */, const std::string_view shader_code, const D3D_SHADER_MACRO* macros /* = nullptr */,
const char* entry_point /* = "main" */) const char* entry_point /* = "main" */)
{ {
wil::com_ptr_nothrow<ID3DBlob> blob = GetShaderBlob(D3D::ShaderType::Vertex, shader_code, macros, entry_point); wil::com_ptr_nothrow<ID3DBlob> blob = GetShaderBlob(D3D::ShaderType::Vertex, shader_code, macros, entry_point);
@ -332,7 +332,7 @@ bool D3D11ShaderCache::GetVertexShaderAndInputLayout(ID3D11Device* device, ID3D1
} }
wil::com_ptr_nothrow<ID3D11PixelShader> D3D11ShaderCache::GetPixelShader(ID3D11Device* device, wil::com_ptr_nothrow<ID3D11PixelShader> D3D11ShaderCache::GetPixelShader(ID3D11Device* device,
const std::string_view& shader_code, const D3D_SHADER_MACRO* macros /* = nullptr */, const std::string_view shader_code, const D3D_SHADER_MACRO* macros /* = nullptr */,
const char* entry_point /* = "main" */) const char* entry_point /* = "main" */)
{ {
wil::com_ptr_nothrow<ID3DBlob> blob = GetShaderBlob(D3D::ShaderType::Pixel, shader_code, macros, entry_point); wil::com_ptr_nothrow<ID3DBlob> blob = GetShaderBlob(D3D::ShaderType::Pixel, shader_code, macros, entry_point);
@ -352,7 +352,7 @@ wil::com_ptr_nothrow<ID3D11PixelShader> D3D11ShaderCache::GetPixelShader(ID3D11D
} }
wil::com_ptr_nothrow<ID3D11ComputeShader> D3D11ShaderCache::GetComputeShader(ID3D11Device* device, wil::com_ptr_nothrow<ID3D11ComputeShader> D3D11ShaderCache::GetComputeShader(ID3D11Device* device,
const std::string_view& shader_code, const D3D_SHADER_MACRO* macros /* = nullptr */, const std::string_view shader_code, const D3D_SHADER_MACRO* macros /* = nullptr */,
const char* entry_point /* = "main" */) const char* entry_point /* = "main" */)
{ {
wil::com_ptr_nothrow<ID3DBlob> blob = GetShaderBlob(D3D::ShaderType::Compute, shader_code, macros, entry_point); wil::com_ptr_nothrow<ID3DBlob> blob = GetShaderBlob(D3D::ShaderType::Compute, shader_code, macros, entry_point);
@ -372,7 +372,7 @@ wil::com_ptr_nothrow<ID3D11ComputeShader> D3D11ShaderCache::GetComputeShader(ID3
} }
wil::com_ptr_nothrow<ID3DBlob> D3D11ShaderCache::CompileAndAddShaderBlob(const CacheIndexKey& key, wil::com_ptr_nothrow<ID3DBlob> D3D11ShaderCache::CompileAndAddShaderBlob(const CacheIndexKey& key,
const std::string_view& shader_code, const D3D_SHADER_MACRO* macros, const char* entry_point) const std::string_view shader_code, const D3D_SHADER_MACRO* macros, const char* entry_point)
{ {
wil::com_ptr_nothrow<ID3DBlob> blob = wil::com_ptr_nothrow<ID3DBlob> blob =
D3D::CompileShader(key.shader_type, m_feature_level, m_debug, shader_code, macros, entry_point); D3D::CompileShader(key.shader_type, m_feature_level, m_debug, shader_code, macros, entry_point);

View File

@ -22,21 +22,21 @@ public:
bool Open(D3D_FEATURE_LEVEL feature_level, bool debug); bool Open(D3D_FEATURE_LEVEL feature_level, bool debug);
void Close(); void Close();
wil::com_ptr_nothrow<ID3DBlob> GetShaderBlob(D3D::ShaderType type, const std::string_view& shader_code, wil::com_ptr_nothrow<ID3DBlob> GetShaderBlob(D3D::ShaderType type, const std::string_view shader_code,
const D3D_SHADER_MACRO* macros = nullptr, const char* entry_point = "main"); const D3D_SHADER_MACRO* macros = nullptr, const char* entry_point = "main");
wil::com_ptr_nothrow<ID3D11VertexShader> GetVertexShader(ID3D11Device* device, const std::string_view& shader_code, wil::com_ptr_nothrow<ID3D11VertexShader> GetVertexShader(ID3D11Device* device, const std::string_view shader_code,
const D3D_SHADER_MACRO* macros = nullptr, const char* entry_point = "main"); const D3D_SHADER_MACRO* macros = nullptr, const char* entry_point = "main");
bool GetVertexShaderAndInputLayout(ID3D11Device* device, ID3D11VertexShader** vs, ID3D11InputLayout** il, bool GetVertexShaderAndInputLayout(ID3D11Device* device, ID3D11VertexShader** vs, ID3D11InputLayout** il,
const D3D11_INPUT_ELEMENT_DESC* layout, size_t layout_size, const std::string_view& shader_code, const D3D11_INPUT_ELEMENT_DESC* layout, size_t layout_size, const std::string_view shader_code,
const D3D_SHADER_MACRO* macros = nullptr, const char* entry_point = "main"); const D3D_SHADER_MACRO* macros = nullptr, const char* entry_point = "main");
wil::com_ptr_nothrow<ID3D11PixelShader> GetPixelShader(ID3D11Device* device, const std::string_view& shader_code, wil::com_ptr_nothrow<ID3D11PixelShader> GetPixelShader(ID3D11Device* device, const std::string_view shader_code,
const D3D_SHADER_MACRO* macros = nullptr, const char* entry_point = "main"); const D3D_SHADER_MACRO* macros = nullptr, const char* entry_point = "main");
wil::com_ptr_nothrow<ID3D11ComputeShader> GetComputeShader(ID3D11Device* device, wil::com_ptr_nothrow<ID3D11ComputeShader> GetComputeShader(ID3D11Device* device,
const std::string_view& shader_code, const D3D_SHADER_MACRO* macros = nullptr, const std::string_view shader_code, const D3D_SHADER_MACRO* macros = nullptr,
const char* entry_point = "main"); const char* entry_point = "main");
private: private:
@ -75,14 +75,14 @@ private:
using CacheIndex = std::unordered_map<CacheIndexKey, CacheIndexData, CacheIndexEntryHasher>; using CacheIndex = std::unordered_map<CacheIndexKey, CacheIndexData, CacheIndexEntryHasher>;
static std::string GetCacheBaseFileName(D3D_FEATURE_LEVEL feature_level, bool debug); static std::string GetCacheBaseFileName(D3D_FEATURE_LEVEL feature_level, bool debug);
static CacheIndexKey GetCacheKey(D3D::ShaderType type, const std::string_view& shader_code, static CacheIndexKey GetCacheKey(D3D::ShaderType type, const std::string_view shader_code,
const D3D_SHADER_MACRO* macros, const char* entry_point); const D3D_SHADER_MACRO* macros, const char* entry_point);
bool CreateNew(const std::string& index_filename, const std::string& blob_filename); bool CreateNew(const std::string& index_filename, const std::string& blob_filename);
bool ReadExisting(const std::string& index_filename, const std::string& blob_filename); bool ReadExisting(const std::string& index_filename, const std::string& blob_filename);
wil::com_ptr_nothrow<ID3DBlob> CompileAndAddShaderBlob(const CacheIndexKey& key, wil::com_ptr_nothrow<ID3DBlob> CompileAndAddShaderBlob(const CacheIndexKey& key,
const std::string_view& shader_code, const D3D_SHADER_MACRO* macros, const char* entry_point); const std::string_view shader_code, const D3D_SHADER_MACRO* macros, const char* entry_point);
std::FILE* m_index_file = nullptr; std::FILE* m_index_file = nullptr;
std::FILE* m_blob_file = nullptr; std::FILE* m_blob_file = nullptr;

View File

@ -253,7 +253,7 @@ bool D3D12ShaderCache::ReadExisting(const std::string& index_filename, const std
return true; return true;
} }
std::string D3D12ShaderCache::GetCacheBaseFileName(const std::string_view& type, D3D_FEATURE_LEVEL feature_level, bool debug) std::string D3D12ShaderCache::GetCacheBaseFileName(const std::string_view type, D3D_FEATURE_LEVEL feature_level, bool debug)
{ {
std::string base_filename = "d3d12_"; std::string base_filename = "d3d12_";
base_filename += type; base_filename += type;
@ -286,7 +286,7 @@ union MD5Hash
}; };
D3D12ShaderCache::CacheIndexKey D3D12ShaderCache::GetShaderCacheKey( D3D12ShaderCache::CacheIndexKey D3D12ShaderCache::GetShaderCacheKey(
EntryType type, const std::string_view& shader_code, const D3D_SHADER_MACRO* macros, const char* entry_point) EntryType type, const std::string_view shader_code, const D3D_SHADER_MACRO* macros, const char* entry_point)
{ {
union union
{ {

View File

@ -95,9 +95,9 @@ private:
using CacheIndex = std::unordered_map<CacheIndexKey, CacheIndexData, CacheIndexEntryHasher>; using CacheIndex = std::unordered_map<CacheIndexKey, CacheIndexData, CacheIndexEntryHasher>;
static std::string GetCacheBaseFileName(const std::string_view& type, D3D_FEATURE_LEVEL feature_level, bool debug); static std::string GetCacheBaseFileName(const std::string_view type, D3D_FEATURE_LEVEL feature_level, bool debug);
static CacheIndexKey GetShaderCacheKey( static CacheIndexKey GetShaderCacheKey(
EntryType type, const std::string_view& shader_code, const D3D_SHADER_MACRO* macros, const char* entry_point); EntryType type, const std::string_view shader_code, const D3D_SHADER_MACRO* macros, const char* entry_point);
static CacheIndexKey GetPipelineCacheKey(const D3D12_GRAPHICS_PIPELINE_STATE_DESC& gpdesc); static CacheIndexKey GetPipelineCacheKey(const D3D12_GRAPHICS_PIPELINE_STATE_DESC& gpdesc);
static CacheIndexKey GetPipelineCacheKey(const D3D12_COMPUTE_PIPELINE_STATE_DESC& gpdesc); static CacheIndexKey GetPipelineCacheKey(const D3D12_COMPUTE_PIPELINE_STATE_DESC& gpdesc);

View File

@ -1505,7 +1505,7 @@ const GSHwHack::Entry<GSRendererHW::MV_Ptr> GSHwHack::s_move_handler_functions[]
#undef CRC_F #undef CRC_F
s16 GSLookupGetSkipCountFunctionId(const std::string_view& name) s16 GSLookupGetSkipCountFunctionId(const std::string_view name)
{ {
for (u32 i = 0; i < std::size(GSHwHack::s_get_skip_count_functions); i++) for (u32 i = 0; i < std::size(GSHwHack::s_get_skip_count_functions); i++)
{ {
@ -1516,7 +1516,7 @@ s16 GSLookupGetSkipCountFunctionId(const std::string_view& name)
return -1; return -1;
} }
s16 GSLookupBeforeDrawFunctionId(const std::string_view& name) s16 GSLookupBeforeDrawFunctionId(const std::string_view name)
{ {
for (u32 i = 0; i < std::size(GSHwHack::s_before_draw_functions); i++) for (u32 i = 0; i < std::size(GSHwHack::s_before_draw_functions); i++)
{ {
@ -1527,7 +1527,7 @@ s16 GSLookupBeforeDrawFunctionId(const std::string_view& name)
return -1; return -1;
} }
s16 GSLookupMoveHandlerFunctionId(const std::string_view& name) s16 GSLookupMoveHandlerFunctionId(const std::string_view name)
{ {
for (u32 i = 0; i < std::size(GSHwHack::s_move_handler_functions); i++) for (u32 i = 0; i < std::size(GSHwHack::s_move_handler_functions); i++)
{ {

View File

@ -28,7 +28,7 @@ static constexpr LoaderDefinition s_loaders[] = {
}; };
GSTextureReplacements::ReplacementTextureLoader GSTextureReplacements::GetLoader(const std::string_view& filename) GSTextureReplacements::ReplacementTextureLoader GSTextureReplacements::GetLoader(const std::string_view filename)
{ {
const std::string_view extension(Path::GetExtension(filename)); const std::string_view extension(Path::GetExtension(filename));
if (extension.empty()) if (extension.empty())

View File

@ -49,7 +49,7 @@ namespace GSTextureReplacements
/// Loader will take a filename and interpret the format (e.g. DDS, PNG, etc). /// Loader will take a filename and interpret the format (e.g. DDS, PNG, etc).
using ReplacementTextureLoader = bool (*)(const std::string& filename, GSTextureReplacements::ReplacementTexture* tex, bool only_base_image); using ReplacementTextureLoader = bool (*)(const std::string& filename, GSTextureReplacements::ReplacementTexture* tex, bool only_base_image);
ReplacementTextureLoader GetLoader(const std::string_view& filename); ReplacementTextureLoader GetLoader(const std::string_view filename);
/// Saves an image buffer to a PNG file (for dumping). /// Saves an image buffer to a PNG file (for dumping).
bool SavePNGImage(const std::string& filename, u32 width, u32 height, const u8* buffer, u32 pitch); bool SavePNGImage(const std::string& filename, u32 width, u32 height, const u8* buffer, u32 pitch);

View File

@ -491,7 +491,7 @@ void GLProgram::BindUniformBlock(const char* name, u32 index)
glUniformBlockBinding(m_program_id, location, index); glUniformBlockBinding(m_program_id, location, index);
} }
void GLProgram::SetName(const std::string_view& name) void GLProgram::SetName(const std::string_view name)
{ {
if (name.empty()) if (name.empty())
return; return;

View File

@ -73,7 +73,7 @@ public:
void BindUniformBlock(const char* name, u32 index); void BindUniformBlock(const char* name, u32 index);
void SetName(const std::string_view& name); void SetName(const std::string_view name);
void SetFormattedName(const char* format, ...); void SetFormattedName(const char* format, ...);
GLProgram& operator=(const GLProgram&) = delete; GLProgram& operator=(const GLProgram&) = delete;

View File

@ -224,7 +224,7 @@ bool GLShaderCache::Recreate()
} }
GLShaderCache::CacheIndexKey GLShaderCache::GetCacheKey( GLShaderCache::CacheIndexKey GLShaderCache::GetCacheKey(
const std::string_view& vertex_shader, const std::string_view& fragment_shader) const std::string_view vertex_shader, const std::string_view fragment_shader)
{ {
union ShaderHash union ShaderHash
{ {
@ -363,8 +363,8 @@ bool GLShaderCache::WriteToBlobFile(const CacheIndexKey& key, const std::vector<
return true; return true;
} }
std::optional<GLProgram> GLShaderCache::CompileProgram(const std::string_view& vertex_shader, std::optional<GLProgram> GLShaderCache::CompileProgram(const std::string_view vertex_shader,
const std::string_view& fragment_shader, const PreLinkCallback& callback, bool set_retrievable) const std::string_view fragment_shader, const PreLinkCallback& callback, bool set_retrievable)
{ {
GLProgram prog; GLProgram prog;
if (!prog.Compile(vertex_shader, fragment_shader)) if (!prog.Compile(vertex_shader, fragment_shader))
@ -383,7 +383,7 @@ std::optional<GLProgram> GLShaderCache::CompileProgram(const std::string_view& v
} }
std::optional<GLProgram> GLShaderCache::CompileComputeProgram( std::optional<GLProgram> GLShaderCache::CompileComputeProgram(
const std::string_view& glsl, const PreLinkCallback& callback, bool set_retrievable) const std::string_view glsl, const PreLinkCallback& callback, bool set_retrievable)
{ {
GLProgram prog; GLProgram prog;
if (!prog.CompileCompute(glsl)) if (!prog.CompileCompute(glsl))
@ -402,7 +402,7 @@ std::optional<GLProgram> GLShaderCache::CompileComputeProgram(
} }
std::optional<GLProgram> GLShaderCache::CompileAndAddProgram(const CacheIndexKey& key, std::optional<GLProgram> GLShaderCache::CompileAndAddProgram(const CacheIndexKey& key,
const std::string_view& vertex_shader, const std::string_view& fragment_shader, const PreLinkCallback& callback) const std::string_view vertex_shader, const std::string_view fragment_shader, const PreLinkCallback& callback)
{ {
#ifdef PCSX2_DEVBUILD #ifdef PCSX2_DEVBUILD
Common::Timer timer; Common::Timer timer;
@ -501,7 +501,7 @@ bool GLShaderCache::GetComputeProgram(
} }
std::optional<GLProgram> GLShaderCache::CompileAndAddComputeProgram( std::optional<GLProgram> GLShaderCache::CompileAndAddComputeProgram(
const CacheIndexKey& key, const std::string_view& glsl, const PreLinkCallback& callback) const CacheIndexKey& key, const std::string_view glsl, const PreLinkCallback& callback)
{ {
#ifdef PCSX2_DEVBUILD #ifdef PCSX2_DEVBUILD
Common::Timer timer; Common::Timer timer;

View File

@ -67,7 +67,7 @@ private:
using CacheIndex = std::unordered_map<CacheIndexKey, CacheIndexData, CacheIndexEntryHasher>; using CacheIndex = std::unordered_map<CacheIndexKey, CacheIndexData, CacheIndexEntryHasher>;
static CacheIndexKey GetCacheKey(const std::string_view& vertex_shader, const std::string_view& fragment_shader); static CacheIndexKey GetCacheKey(const std::string_view vertex_shader, const std::string_view fragment_shader);
std::string GetIndexFileName() const; std::string GetIndexFileName() const;
std::string GetBlobFileName() const; std::string GetBlobFileName() const;
@ -78,15 +78,15 @@ private:
bool WriteToBlobFile(const CacheIndexKey& key, const std::vector<u8>& prog_data, u32 prog_format); bool WriteToBlobFile(const CacheIndexKey& key, const std::vector<u8>& prog_data, u32 prog_format);
std::optional<GLProgram> CompileProgram(const std::string_view& vertex_shader, std::optional<GLProgram> CompileProgram(const std::string_view vertex_shader,
const std::string_view& fragment_shader, const PreLinkCallback& callback, bool set_retrievable); const std::string_view fragment_shader, const PreLinkCallback& callback, bool set_retrievable);
std::optional<GLProgram> CompileAndAddProgram(const CacheIndexKey& key, const std::string_view& vertex_shader, std::optional<GLProgram> CompileAndAddProgram(const CacheIndexKey& key, const std::string_view vertex_shader,
const std::string_view& fragment_shader, const PreLinkCallback& callback); const std::string_view fragment_shader, const PreLinkCallback& callback);
std::optional<GLProgram> CompileComputeProgram( std::optional<GLProgram> CompileComputeProgram(
const std::string_view& glsl, const PreLinkCallback& callback, bool set_retrievable); const std::string_view glsl, const PreLinkCallback& callback, bool set_retrievable);
std::optional<GLProgram> CompileAndAddComputeProgram( std::optional<GLProgram> CompileAndAddComputeProgram(
const CacheIndexKey& key, const std::string_view& glsl, const PreLinkCallback& callback); const CacheIndexKey& key, const std::string_view glsl, const PreLinkCallback& callback);
std::FILE* m_index_file = nullptr; std::FILE* m_index_file = nullptr;
std::FILE* m_blob_file = nullptr; std::FILE* m_blob_file = nullptr;

View File

@ -1249,14 +1249,14 @@ GSTexture* GSDeviceOGL::InitPrimDateTexture(GSTexture* rt, const GSVector4i& are
return tex; return tex;
} }
std::string GSDeviceOGL::GetShaderSource(const std::string_view& entry, GLenum type, const std::string_view& glsl_h_code, const std::string_view& macro_sel) std::string GSDeviceOGL::GetShaderSource(const std::string_view entry, GLenum type, const std::string_view glsl_h_code, const std::string_view macro_sel)
{ {
std::string src = GenGlslHeader(entry, type, macro_sel); std::string src = GenGlslHeader(entry, type, macro_sel);
src += glsl_h_code; src += glsl_h_code;
return src; return src;
} }
std::string GSDeviceOGL::GenGlslHeader(const std::string_view& entry, GLenum type, const std::string_view& macro) std::string GSDeviceOGL::GenGlslHeader(const std::string_view entry, GLenum type, const std::string_view macro)
{ {
std::string header; std::string header;

View File

@ -353,9 +353,9 @@ public:
void SetScissor(const GSVector4i& scissor); void SetScissor(const GSVector4i& scissor);
bool CreateTextureFX(); bool CreateTextureFX();
std::string GetShaderSource(const std::string_view& entry, GLenum type, const std::string_view& glsl_h_code, std::string GetShaderSource(const std::string_view entry, GLenum type, const std::string_view glsl_h_code,
const std::string_view& macro_sel = std::string_view()); const std::string_view macro_sel = std::string_view());
std::string GenGlslHeader(const std::string_view& entry, GLenum type, const std::string_view& macro); std::string GenGlslHeader(const std::string_view entry, GLenum type, const std::string_view macro);
std::string GetVSSource(VSSelector sel); std::string GetVSSource(VSSelector sel);
std::string GetPSSource(const PSSelector& sel); std::string GetPSSource(const PSSelector& sel);
GLuint CreateSampler(PSSamplerSelector sel); GLuint CreateSampler(PSSamplerSelector sel);

View File

@ -476,7 +476,7 @@ std::string VKShaderCache::GetPipelineCacheBaseFileName(bool debug)
return Path::Combine(EmuFolders::Cache, base_filename); return Path::Combine(EmuFolders::Cache, base_filename);
} }
VKShaderCache::CacheIndexKey VKShaderCache::GetCacheKey(u32 type, const std::string_view& shader_code) VKShaderCache::CacheIndexKey VKShaderCache::GetCacheKey(u32 type, const std::string_view shader_code)
{ {
union HashParts union HashParts
{ {

View File

@ -71,7 +71,7 @@ private:
static std::string GetShaderCacheBaseFileName(bool debug); static std::string GetShaderCacheBaseFileName(bool debug);
static std::string GetPipelineCacheBaseFileName(bool debug); static std::string GetPipelineCacheBaseFileName(bool debug);
static CacheIndexKey GetCacheKey(u32 type, const std::string_view& shader_code); static CacheIndexKey GetCacheKey(u32 type, const std::string_view shader_code);
static std::optional<VKShaderCache::SPIRVCodeVector> CompileShaderToSPV( static std::optional<VKShaderCache::SPIRVCodeVector> CompileShaderToSPV(
u32 stage, std::string_view source, bool debug); u32 stage, std::string_view source, bool debug);

View File

@ -27,13 +27,13 @@
namespace GameDatabaseSchema namespace GameDatabaseSchema
{ {
static const char* getHWFixName(GSHWFixId id); static const char* getHWFixName(GSHWFixId id);
static std::optional<GSHWFixId> parseHWFixName(const std::string_view& name); static std::optional<GSHWFixId> parseHWFixName(const std::string_view name);
static bool isUserHackHWFix(GSHWFixId id); static bool isUserHackHWFix(GSHWFixId id);
} // namespace GameDatabaseSchema } // namespace GameDatabaseSchema
namespace GameDatabase namespace GameDatabase
{ {
static void parseAndInsert(const std::string_view& serial, const c4::yml::NodeRef& node); static void parseAndInsert(const std::string_view serial, const c4::yml::NodeRef& node);
static void initDatabase(); static void initDatabase();
} // namespace GameDatabase } // namespace GameDatabase
@ -84,7 +84,7 @@ const char* GameDatabaseSchema::GameEntry::compatAsString() const
} }
} }
void GameDatabase::parseAndInsert(const std::string_view& serial, const c4::yml::NodeRef& node) void GameDatabase::parseAndInsert(const std::string_view serial, const c4::yml::NodeRef& node)
{ {
GameDatabaseSchema::GameEntry gameEntry; GameDatabaseSchema::GameEntry gameEntry;
if (node.has_child("name")) if (node.has_child("name"))
@ -404,7 +404,7 @@ const char* GameDatabaseSchema::getHWFixName(GSHWFixId id)
return s_gs_hw_fix_names[static_cast<u32>(id)]; return s_gs_hw_fix_names[static_cast<u32>(id)];
} }
static std::optional<GameDatabaseSchema::GSHWFixId> GameDatabaseSchema::parseHWFixName(const std::string_view& name) static std::optional<GameDatabaseSchema::GSHWFixId> GameDatabaseSchema::parseHWFixName(const std::string_view name)
{ {
for (u32 i = 0; i < std::size(s_gs_hw_fix_names); i++) for (u32 i = 0; i < std::size(s_gs_hw_fix_names); i++)
{ {
@ -993,7 +993,7 @@ void GameDatabase::ensureLoaded()
}); });
} }
const GameDatabaseSchema::GameEntry* GameDatabase::findGame(const std::string_view& serial) const GameDatabaseSchema::GameEntry* GameDatabase::findGame(const std::string_view serial)
{ {
GameDatabase::ensureLoaded(); GameDatabase::ensureLoaded();
@ -1001,7 +1001,7 @@ const GameDatabaseSchema::GameEntry* GameDatabase::findGame(const std::string_vi
return (iter != s_game_db.end()) ? &iter->second : nullptr; return (iter != s_game_db.end()) ? &iter->second : nullptr;
} }
bool GameDatabase::TrackHash::parseHash(const std::string_view& str) bool GameDatabase::TrackHash::parseHash(const std::string_view str)
{ {
constexpr u32 expected_length = SIZE * 2; constexpr u32 expected_length = SIZE * 2;
if (str.length() != expected_length) if (str.length() != expected_length)

View File

@ -125,13 +125,13 @@ namespace GameDatabaseSchema
namespace GameDatabase namespace GameDatabase
{ {
void ensureLoaded(); void ensureLoaded();
const GameDatabaseSchema::GameEntry* findGame(const std::string_view& serial); const GameDatabaseSchema::GameEntry* findGame(const std::string_view serial);
struct TrackHash struct TrackHash
{ {
static constexpr u32 SIZE = 16; static constexpr u32 SIZE = 16;
bool parseHash(const std::string_view& str); bool parseHash(const std::string_view str);
std::string toString() const; std::string toString() const;
#define MAKE_OPERATOR(op) \ #define MAKE_OPERATOR(op) \

View File

@ -54,10 +54,10 @@ namespace GameList
using CacheMap = UnorderedStringMap<Entry>; using CacheMap = UnorderedStringMap<Entry>;
using PlayedTimeMap = UnorderedStringMap<PlayedTimeEntry>; using PlayedTimeMap = UnorderedStringMap<PlayedTimeEntry>;
static bool IsScannableFilename(const std::string_view& path); static bool IsScannableFilename(const std::string_view path);
static bool GetIsoSerialAndCRC(const std::string& path, s32* disc_type, std::string* serial, u32* crc); static bool GetIsoSerialAndCRC(const std::string& path, s32* disc_type, std::string* serial, u32* crc);
static Region ParseDatabaseRegion(const std::string_view& db_region); static Region ParseDatabaseRegion(const std::string_view db_region);
static bool GetElfListEntry(const std::string& path, GameList::Entry* entry); static bool GetElfListEntry(const std::string& path, GameList::Entry* entry);
static bool GetIsoListEntry(const std::string& path, GameList::Entry* entry); static bool GetIsoListEntry(const std::string& path, GameList::Entry* entry);
@ -129,7 +129,7 @@ const char* GameList::EntryCompatibilityRatingToString(CompatibilityRating ratin
// clang-format on // clang-format on
} }
bool GameList::IsScannableFilename(const std::string_view& path) bool GameList::IsScannableFilename(const std::string_view path)
{ {
return VMManager::IsDiscFileName(path) || VMManager::IsElfFileName(path); return VMManager::IsDiscFileName(path) || VMManager::IsElfFileName(path);
} }
@ -212,7 +212,7 @@ bool GameList::GetElfListEntry(const std::string& path, GameList::Entry* entry)
return true; return true;
} }
GameList::Region GameList::ParseDatabaseRegion(const std::string_view& db_region) GameList::Region GameList::ParseDatabaseRegion(const std::string_view db_region)
{ {
// clang-format off // clang-format off
////// NTSC ////// ////// NTSC //////
@ -747,7 +747,7 @@ const GameList::Entry* GameList::GetEntryByCRC(u32 crc)
return nullptr; return nullptr;
} }
const GameList::Entry* GameList::GetEntryBySerialAndCRC(const std::string_view& serial, u32 crc) const GameList::Entry* GameList::GetEntryBySerialAndCRC(const std::string_view serial, u32 crc)
{ {
for (const Entry& entry : s_entries) for (const Entry& entry : s_entries)
{ {

View File

@ -121,7 +121,7 @@ namespace GameList
const Entry* GetEntryByIndex(u32 index); const Entry* GetEntryByIndex(u32 index);
const Entry* GetEntryForPath(const char* path); const Entry* GetEntryForPath(const char* path);
const Entry* GetEntryByCRC(u32 crc); const Entry* GetEntryByCRC(u32 crc);
const Entry* GetEntryBySerialAndCRC(const std::string_view& serial, u32 crc); const Entry* GetEntryBySerialAndCRC(const std::string_view serial, u32 crc);
u32 GetEntryCount(); u32 GetEntryCount();
/// Populates the game list with files in the configured directories. /// Populates the game list with files in the configured directories.

View File

@ -23,7 +23,7 @@
namespace Host namespace Host
{ {
static std::pair<const char*, u32> LookupTranslationString( static std::pair<const char*, u32> LookupTranslationString(
const std::string_view& context, const std::string_view& msg); const std::string_view context, const std::string_view msg);
static std::mutex s_settings_mutex; static std::mutex s_settings_mutex;
static LayeredSettingsInterface s_layered_settings_interface; static LayeredSettingsInterface s_layered_settings_interface;
@ -37,7 +37,7 @@ namespace Host
static u32 s_translation_string_cache_pos; static u32 s_translation_string_cache_pos;
} // namespace Host } // namespace Host
std::pair<const char*, u32> Host::LookupTranslationString(const std::string_view& context, const std::string_view& msg) std::pair<const char*, u32> Host::LookupTranslationString(const std::string_view context, const std::string_view msg)
{ {
// TODO: TranslatableString, compile-time hashing. // TODO: TranslatableString, compile-time hashing.
@ -114,18 +114,18 @@ add_string:
return ret; return ret;
} }
const char* Host::TranslateToCString(const std::string_view& context, const std::string_view& msg) const char* Host::TranslateToCString(const std::string_view context, const std::string_view msg)
{ {
return LookupTranslationString(context, msg).first; return LookupTranslationString(context, msg).first;
} }
std::string_view Host::TranslateToStringView(const std::string_view& context, const std::string_view& msg) std::string_view Host::TranslateToStringView(const std::string_view context, const std::string_view msg)
{ {
const auto mp = LookupTranslationString(context, msg); const auto mp = LookupTranslationString(context, msg);
return std::string_view(mp.first, mp.second); return std::string_view(mp.first, mp.second);
} }
std::string Host::TranslateToString(const std::string_view& context, const std::string_view& msg) std::string Host::TranslateToString(const std::string_view context, const std::string_view msg)
{ {
return std::string(TranslateToStringView(context, msg)); return std::string(TranslateToStringView(context, msg));
} }
@ -138,7 +138,7 @@ void Host::ClearTranslationCache()
s_translation_string_mutex.unlock(); s_translation_string_mutex.unlock();
} }
void Host::ReportFormattedErrorAsync(const std::string_view& title, const char* format, ...) void Host::ReportFormattedErrorAsync(const std::string_view title, const char* format, ...)
{ {
std::va_list ap; std::va_list ap;
va_start(ap, format); va_start(ap, format);
@ -147,7 +147,7 @@ void Host::ReportFormattedErrorAsync(const std::string_view& title, const char*
ReportErrorAsync(title, message); ReportErrorAsync(title, message);
} }
bool Host::ConfirmFormattedMessage(const std::string_view& title, const char* format, ...) bool Host::ConfirmFormattedMessage(const std::string_view title, const char* format, ...)
{ {
std::va_list ap; std::va_list ap;
va_start(ap, format); va_start(ap, format);

View File

@ -29,16 +29,16 @@ namespace Host
/// Returns a localized version of the specified string within the specified context. /// Returns a localized version of the specified string within the specified context.
/// The pointer is guaranteed to be valid until the next language change. /// The pointer is guaranteed to be valid until the next language change.
const char* TranslateToCString(const std::string_view& context, const std::string_view& msg); const char* TranslateToCString(const std::string_view context, const std::string_view msg);
/// Returns a localized version of the specified string within the specified context. /// Returns a localized version of the specified string within the specified context.
/// The view is guaranteed to be valid until the next language change. /// The view is guaranteed to be valid until the next language change.
/// NOTE: When passing this to fmt, positional arguments should be used in the base string, as /// NOTE: When passing this to fmt, positional arguments should be used in the base string, as
/// not all locales follow the same word ordering. /// not all locales follow the same word ordering.
std::string_view TranslateToStringView(const std::string_view& context, const std::string_view& msg); std::string_view TranslateToStringView(const std::string_view context, const std::string_view msg);
/// Returns a localized version of the specified string within the specified context. /// Returns a localized version of the specified string within the specified context.
std::string TranslateToString(const std::string_view& context, const std::string_view& msg); std::string TranslateToString(const std::string_view context, const std::string_view msg);
/// Returns a localized version of the specified string within the specified context, adjusting for plurals using %n. /// Returns a localized version of the specified string within the specified context, adjusting for plurals using %n.
std::string TranslatePluralToString(const char* context, const char* msg, const char* disambiguation, int count); std::string TranslatePluralToString(const char* context, const char* msg, const char* disambiguation, int count);
@ -49,23 +49,23 @@ namespace Host
/// Adds OSD messages, duration is in seconds. /// Adds OSD messages, duration is in seconds.
void AddOSDMessage(std::string message, float duration = 2.0f); void AddOSDMessage(std::string message, float duration = 2.0f);
void AddKeyedOSDMessage(std::string key, std::string message, float duration = 2.0f); void AddKeyedOSDMessage(std::string key, std::string message, float duration = 2.0f);
void AddIconOSDMessage(std::string key, const char* icon, const std::string_view& message, float duration = 2.0f); void AddIconOSDMessage(std::string key, const char* icon, const std::string_view message, float duration = 2.0f);
void RemoveKeyedOSDMessage(std::string key); void RemoveKeyedOSDMessage(std::string key);
void ClearOSDMessages(); void ClearOSDMessages();
/// Displays an asynchronous error on the UI thread, i.e. doesn't block the caller. /// Displays an asynchronous error on the UI thread, i.e. doesn't block the caller.
void ReportErrorAsync(const std::string_view& title, const std::string_view& message); void ReportErrorAsync(const std::string_view title, const std::string_view message);
void ReportFormattedErrorAsync(const std::string_view& title, const char* format, ...); void ReportFormattedErrorAsync(const std::string_view title, const char* format, ...);
/// Displays a synchronous confirmation on the UI thread, i.e. blocks the caller. /// Displays a synchronous confirmation on the UI thread, i.e. blocks the caller.
bool ConfirmMessage(const std::string_view& title, const std::string_view& message); bool ConfirmMessage(const std::string_view title, const std::string_view message);
bool ConfirmFormattedMessage(const std::string_view& title, const char* format, ...); bool ConfirmFormattedMessage(const std::string_view title, const char* format, ...);
/// Opens a URL, using the default application. /// Opens a URL, using the default application.
void OpenURL(const std::string_view& url); void OpenURL(const std::string_view url);
/// Copies the provided text to the host's clipboard, if present. /// Copies the provided text to the host's clipboard, if present.
bool CopyTextToClipboard(const std::string_view& text); bool CopyTextToClipboard(const std::string_view text);
/// Requests settings reset. Can be called from any thread, will call back and apply on the CPU thread. /// Requests settings reset. Can be called from any thread, will call back and apply on the CPU thread.
bool RequestResetSettings(bool folders, bool core, bool controllers, bool hotkeys, bool ui); bool RequestResetSettings(bool folders, bool core, bool controllers, bool hotkeys, bool ui);
@ -156,7 +156,7 @@ namespace Host
void SetInputSettingsLayer(SettingsInterface* sif); void SetInputSettingsLayer(SettingsInterface* sif);
/// Implementation to retrieve a translated string. /// Implementation to retrieve a translated string.
s32 GetTranslatedStringImpl(const std::string_view& context, const std::string_view& msg, char* tbuf, size_t tbuf_space); s32 GetTranslatedStringImpl(const std::string_view context, const std::string_view msg, char* tbuf, size_t tbuf_space);
} // namespace Internal } // namespace Internal
} // namespace Host } // namespace Host

View File

@ -229,8 +229,8 @@ namespace FullscreenUI
static void DrawStartGameWindow(); static void DrawStartGameWindow();
static void DrawExitWindow(); static void DrawExitWindow();
static void DrawPauseMenu(MainWindowType type); static void DrawPauseMenu(MainWindowType type);
static void ExitFullscreenAndOpenURL(const std::string_view& url); static void ExitFullscreenAndOpenURL(const std::string_view url);
static void CopyTextToClipboard(std::string title, const std::string_view& text); static void CopyTextToClipboard(std::string title, const std::string_view text);
static void DrawAboutWindow(); static void DrawAboutWindow();
static void OpenAboutWindow(); static void OpenAboutWindow();
static void GetStandardSelectionFooterText(SmallStringBase& dest, bool back_instead_of_cancel); static void GetStandardSelectionFooterText(SmallStringBase& dest, bool back_instead_of_cancel);
@ -299,7 +299,7 @@ namespace FullscreenUI
static void SwitchToGameSettings(); static void SwitchToGameSettings();
static void SwitchToGameSettings(const std::string& path); static void SwitchToGameSettings(const std::string& path);
static void SwitchToGameSettings(const GameList::Entry* entry); static void SwitchToGameSettings(const GameList::Entry* entry);
static void SwitchToGameSettings(const std::string_view& serial, u32 crc); static void SwitchToGameSettings(const std::string_view serial, u32 crc);
static void DrawSettingsWindow(); static void DrawSettingsWindow();
static void DrawSummarySettingsPage(); static void DrawSummarySettingsPage();
static void DrawInterfaceSettingsPage(); static void DrawInterfaceSettingsPage();
@ -389,9 +389,9 @@ namespace FullscreenUI
static void DrawClampingModeSetting(SettingsInterface* bsi, const char* title, const char* summary, int vunum); static void DrawClampingModeSetting(SettingsInterface* bsi, const char* title, const char* summary, int vunum);
static void PopulateGraphicsAdapterList(); static void PopulateGraphicsAdapterList();
static void PopulateGameListDirectoryCache(SettingsInterface* si); static void PopulateGameListDirectoryCache(SettingsInterface* si);
static void PopulatePatchesAndCheatsList(const std::string_view& serial, u32 crc); static void PopulatePatchesAndCheatsList(const std::string_view serial, u32 crc);
static void BeginInputBinding(SettingsInterface* bsi, InputBindingInfo::Type type, const std::string_view& section, static void BeginInputBinding(SettingsInterface* bsi, InputBindingInfo::Type type, const std::string_view section,
const std::string_view& key, const std::string_view& display_name); const std::string_view key, const std::string_view display_name);
static void DrawInputBindingWindow(); static void DrawInputBindingWindow();
static void DrawInputBindingButton(SettingsInterface* bsi, InputBindingInfo::Type type, const char* section, const char* name, const char* display_name, const char* icon_name, bool show_type = true); static void DrawInputBindingButton(SettingsInterface* bsi, InputBindingInfo::Type type, const char* section, const char* name, const char* display_name, const char* icon_name, bool show_type = true);
static void ClearInputBindingVariables(); static void ClearInputBindingVariables();
@ -1589,8 +1589,8 @@ void FullscreenUI::ClearInputBindingVariables()
s_input_binding_value_ranges = {}; s_input_binding_value_ranges = {};
} }
void FullscreenUI::BeginInputBinding(SettingsInterface* bsi, InputBindingInfo::Type type, const std::string_view& section, void FullscreenUI::BeginInputBinding(SettingsInterface* bsi, InputBindingInfo::Type type, const std::string_view section,
const std::string_view& key, const std::string_view& display_name) const std::string_view key, const std::string_view display_name)
{ {
if (s_input_binding_type != InputBindingInfo::Type::Unknown) if (s_input_binding_type != InputBindingInfo::Type::Unknown)
{ {
@ -2708,7 +2708,7 @@ void FullscreenUI::SwitchToSettings()
s_settings_page = SettingsPage::Interface; s_settings_page = SettingsPage::Interface;
} }
void FullscreenUI::SwitchToGameSettings(const std::string_view& serial, u32 crc) void FullscreenUI::SwitchToGameSettings(const std::string_view serial, u32 crc)
{ {
s_game_settings_entry.reset(); s_game_settings_entry.reset();
s_game_settings_interface = std::make_unique<INISettingsInterface>(VMManager::GetGameSettingsPath(serial, crc)); s_game_settings_interface = std::make_unique<INISettingsInterface>(VMManager::GetGameSettingsPath(serial, crc));
@ -2761,7 +2761,7 @@ void FullscreenUI::PopulateGameListDirectoryCache(SettingsInterface* si)
s_game_list_directories_cache.emplace_back(std::move(dir), true); s_game_list_directories_cache.emplace_back(std::move(dir), true);
} }
void FullscreenUI::PopulatePatchesAndCheatsList(const std::string_view& serial, u32 crc) void FullscreenUI::PopulatePatchesAndCheatsList(const std::string_view serial, u32 crc)
{ {
constexpr auto sort_patches = [](Patch::PatchInfoList& list) { constexpr auto sort_patches = [](Patch::PatchInfoList& list) {
std::sort(list.begin(), list.end(), [](const Patch::PatchInfo& lhs, const Patch::PatchInfo& rhs) { return lhs.name < rhs.name; }); std::sort(list.begin(), list.end(), [](const Patch::PatchInfo& lhs, const Patch::PatchInfo& rhs) { return lhs.name < rhs.name; });
@ -6519,7 +6519,7 @@ GSTexture* FullscreenUI::GetCoverForCurrentGame()
// Overlays // Overlays
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void FullscreenUI::ExitFullscreenAndOpenURL(const std::string_view& url) void FullscreenUI::ExitFullscreenAndOpenURL(const std::string_view url)
{ {
Host::RunOnCPUThread([url = std::string(url)]() { Host::RunOnCPUThread([url = std::string(url)]() {
if (Host::IsFullscreen()) if (Host::IsFullscreen())
@ -6529,7 +6529,7 @@ void FullscreenUI::ExitFullscreenAndOpenURL(const std::string_view& url)
}); });
} }
void FullscreenUI::CopyTextToClipboard(std::string title, const std::string_view& text) void FullscreenUI::CopyTextToClipboard(std::string title, const std::string_view text)
{ {
if (Host::CopyTextToClipboard(text)) if (Host::CopyTextToClipboard(text))
ShowToast(std::string(), std::move(title)); ShowToast(std::string(), std::move(title));

View File

@ -78,7 +78,7 @@ namespace ImGuiFullscreen
static __fi ImVec4 ModAlpha(const ImVec4& v, float a) { return ImVec4(v.x, v.y, v.z, a); } static __fi ImVec4 ModAlpha(const ImVec4& v, float a) { return ImVec4(v.x, v.y, v.z, a); }
static __fi ImVec4 MulAlpha(const ImVec4& v, float a) { return ImVec4(v.x, v.y, v.z, v.w * a); } static __fi ImVec4 MulAlpha(const ImVec4& v, float a) { return ImVec4(v.x, v.y, v.z, v.w * a); }
static __fi std::string_view RemoveHash(const std::string_view& s) static __fi std::string_view RemoveHash(const std::string_view s)
{ {
const std::string_view::size_type pos = s.find('#'); const std::string_view::size_type pos = s.find('#');
return (pos != std::string_view::npos) ? s.substr(0, pos) : s; return (pos != std::string_view::npos) ? s.substr(0, pos) : s;

View File

@ -631,7 +631,7 @@ void Host::AddKeyedOSDMessage(std::string key, std::string message, float durati
s_osd_posted_messages.push_back(std::move(msg)); s_osd_posted_messages.push_back(std::move(msg));
} }
void Host::AddIconOSDMessage(std::string key, const char* icon, const std::string_view& message, float duration /* = 2.0f */) void Host::AddIconOSDMessage(std::string key, const char* icon, const std::string_view message, float duration /* = 2.0f */)
{ {
if (!key.empty()) if (!key.empty())
Console.WriteLn(Color_StrongGreen, fmt::format("OSD [{}]: {}", key, message)); Console.WriteLn(Color_StrongGreen, fmt::format("OSD [{}]: {}", key, message));

View File

@ -290,7 +290,7 @@ std::vector<InputBindingKey> DInputSource::EnumerateMotors()
return {}; return {};
} }
bool DInputSource::GetGenericBindingMapping(const std::string_view& device, InputManager::GenericInputBindingMapping* mapping) bool DInputSource::GetGenericBindingMapping(const std::string_view device, InputManager::GenericInputBindingMapping* mapping)
{ {
return {}; return {};
} }
@ -305,7 +305,7 @@ void DInputSource::UpdateMotorState(InputBindingKey large_key, InputBindingKey s
// not supported // not supported
} }
std::optional<InputBindingKey> DInputSource::ParseKeyString(const std::string_view& device, const std::string_view& binding) std::optional<InputBindingKey> DInputSource::ParseKeyString(const std::string_view device, const std::string_view binding)
{ {
if (!device.starts_with("DInput-") || binding.empty()) if (!device.starts_with("DInput-") || binding.empty())
return std::nullopt; return std::nullopt;

View File

@ -42,11 +42,11 @@ public:
void PollEvents() override; void PollEvents() override;
std::vector<std::pair<std::string, std::string>> EnumerateDevices() override; std::vector<std::pair<std::string, std::string>> EnumerateDevices() override;
std::vector<InputBindingKey> EnumerateMotors() override; std::vector<InputBindingKey> EnumerateMotors() override;
bool GetGenericBindingMapping(const std::string_view& device, InputManager::GenericInputBindingMapping* mapping) override; bool GetGenericBindingMapping(const std::string_view device, InputManager::GenericInputBindingMapping* mapping) override;
void UpdateMotorState(InputBindingKey key, float intensity) override; void UpdateMotorState(InputBindingKey key, float intensity) override;
void UpdateMotorState(InputBindingKey large_key, InputBindingKey small_key, float large_intensity, float small_intensity) override; void UpdateMotorState(InputBindingKey large_key, InputBindingKey small_key, float large_intensity, float small_intensity) override;
std::optional<InputBindingKey> ParseKeyString(const std::string_view& device, const std::string_view& binding) override; std::optional<InputBindingKey> ParseKeyString(const std::string_view device, const std::string_view binding) override;
TinyString ConvertKeyToString(InputBindingKey key) override; TinyString ConvertKeyToString(InputBindingKey key) override;
TinyString ConvertKeyToIcon(InputBindingKey key) override; TinyString ConvertKeyToIcon(InputBindingKey key) override;

View File

@ -89,15 +89,15 @@ struct PadVibrationBinding
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
namespace InputManager namespace InputManager
{ {
static std::optional<InputBindingKey> ParseHostKeyboardKey(const std::string_view& source, const std::string_view& sub_binding); static std::optional<InputBindingKey> ParseHostKeyboardKey(const std::string_view source, const std::string_view sub_binding);
static std::optional<InputBindingKey> ParsePointerKey(const std::string_view& source, const std::string_view& sub_binding); static std::optional<InputBindingKey> ParsePointerKey(const std::string_view source, const std::string_view sub_binding);
static std::vector<std::string_view> SplitChord(const std::string_view& binding); static std::vector<std::string_view> SplitChord(const std::string_view binding);
static bool SplitBinding(const std::string_view& binding, std::string_view* source, std::string_view* sub_binding); static bool SplitBinding(const std::string_view binding, std::string_view* source, std::string_view* sub_binding);
static void PrettifyInputBindingPart(const std::string_view binding, SmallString& ret, bool& changed); static void PrettifyInputBindingPart(const std::string_view binding, SmallString& ret, bool& changed);
static void AddBinding(const std::string_view& binding, const InputEventHandler& handler); static void AddBinding(const std::string_view binding, const InputEventHandler& handler);
static void AddBindings(const std::vector<std::string>& bindings, const InputEventHandler& handler); static void AddBindings(const std::vector<std::string>& bindings, const InputEventHandler& handler);
static bool ParseBindingAndGetSource(const std::string_view& binding, InputBindingKey* key, InputSource** source); static bool ParseBindingAndGetSource(const std::string_view binding, InputBindingKey* key, InputSource** source);
static bool IsAxisHandler(const InputEventHandler& handler); static bool IsAxisHandler(const InputEventHandler& handler);
static float ApplySingleBindingScale(float sensitivity, float deadzone, float value); static float ApplySingleBindingScale(float sensitivity, float deadzone, float value);
@ -170,7 +170,7 @@ static std::vector<std::pair<u32, PointerMoveCallback>> s_pointer_move_callbacks
// Binding Parsing // Binding Parsing
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
std::vector<std::string_view> InputManager::SplitChord(const std::string_view& binding) std::vector<std::string_view> InputManager::SplitChord(const std::string_view binding)
{ {
std::vector<std::string_view> parts; std::vector<std::string_view> parts;
@ -200,7 +200,7 @@ std::vector<std::string_view> InputManager::SplitChord(const std::string_view& b
return parts; return parts;
} }
bool InputManager::SplitBinding(const std::string_view& binding, std::string_view* source, std::string_view* sub_binding) bool InputManager::SplitBinding(const std::string_view binding, std::string_view* source, std::string_view* sub_binding)
{ {
const std::string_view::size_type slash_pos = binding.find('/'); const std::string_view::size_type slash_pos = binding.find('/');
if (slash_pos == std::string_view::npos) if (slash_pos == std::string_view::npos)
@ -214,7 +214,7 @@ bool InputManager::SplitBinding(const std::string_view& binding, std::string_vie
return true; return true;
} }
std::optional<InputBindingKey> InputManager::ParseInputBindingKey(const std::string_view& binding) std::optional<InputBindingKey> InputManager::ParseInputBindingKey(const std::string_view binding)
{ {
std::string_view source, sub_binding; std::string_view source, sub_binding;
if (!SplitBinding(binding, &source, &sub_binding)) if (!SplitBinding(binding, &source, &sub_binding))
@ -245,7 +245,7 @@ std::optional<InputBindingKey> InputManager::ParseInputBindingKey(const std::str
return std::nullopt; return std::nullopt;
} }
bool InputManager::ParseBindingAndGetSource(const std::string_view& binding, InputBindingKey* key, InputSource** source) bool InputManager::ParseBindingAndGetSource(const std::string_view binding, InputBindingKey* key, InputSource** source)
{ {
std::string_view source_string, sub_binding; std::string_view source_string, sub_binding;
if (!SplitBinding(binding, &source_string, &sub_binding)) if (!SplitBinding(binding, &source_string, &sub_binding))
@ -460,7 +460,7 @@ void InputManager::PrettifyInputBindingPart(const std::string_view binding, Smal
} }
void InputManager::AddBinding(const std::string_view& binding, const InputEventHandler& handler) void InputManager::AddBinding(const std::string_view binding, const InputEventHandler& handler)
{ {
std::shared_ptr<InputBinding> ibinding; std::shared_ptr<InputBinding> ibinding;
const std::vector<std::string_view> chord_bindings(SplitChord(binding)); const std::vector<std::string_view> chord_bindings(SplitChord(binding));
@ -585,7 +585,7 @@ bool InputManager::GetInputSourceDefaultEnabled(InputSourceType type)
} }
} }
std::optional<InputSourceType> InputManager::ParseInputSourceString(const std::string_view& str) std::optional<InputSourceType> InputManager::ParseInputSourceString(const std::string_view str)
{ {
for (u32 i = 0; i < static_cast<u32>(InputSourceType::Count); i++) for (u32 i = 0; i < static_cast<u32>(InputSourceType::Count); i++)
{ {
@ -596,7 +596,7 @@ std::optional<InputSourceType> InputManager::ParseInputSourceString(const std::s
return std::nullopt; return std::nullopt;
} }
std::optional<InputBindingKey> InputManager::ParseHostKeyboardKey(const std::string_view& source, const std::string_view& sub_binding) std::optional<InputBindingKey> InputManager::ParseHostKeyboardKey(const std::string_view source, const std::string_view sub_binding)
{ {
if (source != "Keyboard") if (source != "Keyboard")
return std::nullopt; return std::nullopt;
@ -611,7 +611,7 @@ std::optional<InputBindingKey> InputManager::ParseHostKeyboardKey(const std::str
return key; return key;
} }
std::optional<InputBindingKey> InputManager::ParsePointerKey(const std::string_view& source, const std::string_view& sub_binding) std::optional<InputBindingKey> InputManager::ParsePointerKey(const std::string_view source, const std::string_view sub_binding)
{ {
const std::optional<s32> pointer_index = StringUtil::FromChars<s32>(source.substr(8)); const std::optional<s32> pointer_index = StringUtil::FromChars<s32>(source.substr(8));
if (!pointer_index.has_value() || pointer_index.value() < 0) if (!pointer_index.has_value() || pointer_index.value() < 0)
@ -664,7 +664,7 @@ std::optional<InputBindingKey> InputManager::ParsePointerKey(const std::string_v
return std::nullopt; return std::nullopt;
} }
std::optional<u32> InputManager::GetIndexFromPointerBinding(const std::string_view& source) std::optional<u32> InputManager::GetIndexFromPointerBinding(const std::string_view source)
{ {
if (!source.starts_with("Pointer-")) if (!source.starts_with("Pointer-"))
return std::nullopt; return std::nullopt;
@ -1548,7 +1548,7 @@ static void GetKeyboardGenericBindingMapping(std::vector<std::pair<GenericInputB
mapping->emplace_back(GenericInputBinding::R3, "Keyboard/4"); mapping->emplace_back(GenericInputBinding::R3, "Keyboard/4");
} }
static bool GetInternalGenericBindingMapping(const std::string_view& device, InputManager::GenericInputBindingMapping* mapping) static bool GetInternalGenericBindingMapping(const std::string_view device, InputManager::GenericInputBindingMapping* mapping)
{ {
if (device == "Keyboard") if (device == "Keyboard")
{ {
@ -1559,7 +1559,7 @@ static bool GetInternalGenericBindingMapping(const std::string_view& device, Inp
return false; return false;
} }
InputManager::GenericInputBindingMapping InputManager::GetGenericBindingMapping(const std::string_view& device) InputManager::GenericInputBindingMapping InputManager::GetGenericBindingMapping(const std::string_view device)
{ {
GenericInputBindingMapping mapping; GenericInputBindingMapping mapping;

View File

@ -172,16 +172,16 @@ namespace InputManager
bool GetInputSourceDefaultEnabled(InputSourceType type); bool GetInputSourceDefaultEnabled(InputSourceType type);
/// Parses an input class string. /// Parses an input class string.
std::optional<InputSourceType> ParseInputSourceString(const std::string_view& str); std::optional<InputSourceType> ParseInputSourceString(const std::string_view str);
/// Parses a pointer device string, i.e. tells you which pointer is specified. /// Parses a pointer device string, i.e. tells you which pointer is specified.
std::optional<u32> GetIndexFromPointerBinding(const std::string_view& str); std::optional<u32> GetIndexFromPointerBinding(const std::string_view str);
/// Returns the device name for a pointer index (e.g. Pointer-0). /// Returns the device name for a pointer index (e.g. Pointer-0).
std::string GetPointerDeviceName(u32 pointer_index); std::string GetPointerDeviceName(u32 pointer_index);
/// Converts a key code from a human-readable string to an identifier. /// Converts a key code from a human-readable string to an identifier.
std::optional<u32> ConvertHostKeyboardStringToCode(const std::string_view& str); std::optional<u32> ConvertHostKeyboardStringToCode(const std::string_view str);
/// Converts a key code from an identifier to a human-readable string. /// Converts a key code from an identifier to a human-readable string.
std::optional<std::string> ConvertHostKeyboardCodeToString(u32 code); std::optional<std::string> ConvertHostKeyboardCodeToString(u32 code);
@ -200,7 +200,7 @@ namespace InputManager
InputBindingKey MakePointerAxisKey(u32 index, InputPointerAxis axis); InputBindingKey MakePointerAxisKey(u32 index, InputPointerAxis axis);
/// Parses an input binding key string. /// Parses an input binding key string.
std::optional<InputBindingKey> ParseInputBindingKey(const std::string_view& binding); std::optional<InputBindingKey> ParseInputBindingKey(const std::string_view binding);
/// Converts a input key to a string. /// Converts a input key to a string.
std::string ConvertInputBindingKeyToString(InputBindingInfo::Type binding_type, InputBindingKey key); std::string ConvertInputBindingKeyToString(InputBindingInfo::Type binding_type, InputBindingKey key);
@ -222,7 +222,7 @@ namespace InputManager
/// Retrieves bindings that match the generic bindings for the specified device. /// Retrieves bindings that match the generic bindings for the specified device.
using GenericInputBindingMapping = std::vector<std::pair<GenericInputBinding, std::string>>; using GenericInputBindingMapping = std::vector<std::pair<GenericInputBinding, std::string>>;
GenericInputBindingMapping GetGenericBindingMapping(const std::string_view& device); GenericInputBindingMapping GetGenericBindingMapping(const std::string_view device);
/// Returns whether a given input source is enabled. /// Returns whether a given input source is enabled.
bool IsInputSourceEnabled(SettingsInterface& si, InputSourceType type); bool IsInputSourceEnabled(SettingsInterface& si, InputSourceType type);

View File

@ -60,7 +60,7 @@ InputBindingKey InputSource::MakeGenericControllerMotorKey(InputSourceType clazz
} }
std::optional<InputBindingKey> InputSource::ParseGenericControllerKey( std::optional<InputBindingKey> InputSource::ParseGenericControllerKey(
InputSourceType clazz, const std::string_view& source, const std::string_view& sub_binding) InputSourceType clazz, const std::string_view source, const std::string_view sub_binding)
{ {
// try to find the number, this function doesn't care about whether it's xinput or sdl or whatever // try to find the number, this function doesn't care about whether it's xinput or sdl or whatever
std::string_view::size_type pos = 0; std::string_view::size_type pos = 0;

View File

@ -27,7 +27,7 @@ public:
virtual void PollEvents() = 0; virtual void PollEvents() = 0;
virtual std::optional<InputBindingKey> ParseKeyString(const std::string_view& device, const std::string_view& binding) = 0; virtual std::optional<InputBindingKey> ParseKeyString(const std::string_view device, const std::string_view binding) = 0;
virtual TinyString ConvertKeyToString(InputBindingKey key) = 0; virtual TinyString ConvertKeyToString(InputBindingKey key) = 0;
virtual TinyString ConvertKeyToIcon(InputBindingKey key) = 0; virtual TinyString ConvertKeyToIcon(InputBindingKey key) = 0;
@ -39,7 +39,7 @@ public:
/// Retrieves bindings that match the generic bindings for the specified device. /// Retrieves bindings that match the generic bindings for the specified device.
/// Returns false if it's not one of our devices. /// Returns false if it's not one of our devices.
virtual bool GetGenericBindingMapping(const std::string_view& device, InputManager::GenericInputBindingMapping* mapping) = 0; virtual bool GetGenericBindingMapping(const std::string_view device, InputManager::GenericInputBindingMapping* mapping) = 0;
/// Informs the source of a new vibration motor state. Changes may not take effect until the next PollEvents() call. /// Informs the source of a new vibration motor state. Changes may not take effect until the next PollEvents() call.
virtual void UpdateMotorState(InputBindingKey key, float intensity) = 0; virtual void UpdateMotorState(InputBindingKey key, float intensity) = 0;
@ -62,7 +62,7 @@ public:
/// Parses a generic controller key string. /// Parses a generic controller key string.
static std::optional<InputBindingKey> ParseGenericControllerKey( static std::optional<InputBindingKey> ParseGenericControllerKey(
InputSourceType clazz, const std::string_view& source, const std::string_view& sub_binding); InputSourceType clazz, const std::string_view source, const std::string_view sub_binding);
/// Converts a generic controller key to a string. /// Converts a generic controller key to a string.
static std::string ConvertGenericControllerKeyToString(InputBindingKey key); static std::string ConvertGenericControllerKeyToString(InputBindingKey key);

View File

@ -236,7 +236,7 @@ u32 SDLInputSource::GetRGBForPlayerId(SettingsInterface& si, u32 player_id)
player_id); player_id);
} }
u32 SDLInputSource::ParseRGBForPlayerId(const std::string_view& str, u32 player_id) u32 SDLInputSource::ParseRGBForPlayerId(const std::string_view str, u32 player_id)
{ {
if (player_id >= MAX_LED_COLORS) if (player_id >= MAX_LED_COLORS)
return 0; return 0;
@ -349,7 +349,7 @@ std::vector<std::pair<std::string, std::string>> SDLInputSource::EnumerateDevice
return ret; return ret;
} }
std::optional<InputBindingKey> SDLInputSource::ParseKeyString(const std::string_view& device, const std::string_view& binding) std::optional<InputBindingKey> SDLInputSource::ParseKeyString(const std::string_view device, const std::string_view binding)
{ {
if (!device.starts_with("SDL-") || binding.empty()) if (!device.starts_with("SDL-") || binding.empty())
return std::nullopt; return std::nullopt;
@ -596,7 +596,7 @@ bool SDLInputSource::ProcessSDLEvent(const SDL_Event* event)
} }
} }
SDL_Joystick* SDLInputSource::GetJoystickForDevice(const std::string_view& device) SDL_Joystick* SDLInputSource::GetJoystickForDevice(const std::string_view device)
{ {
if (!device.starts_with("SDL-")) if (!device.starts_with("SDL-"))
return nullptr; return nullptr;
@ -917,7 +917,7 @@ std::vector<InputBindingKey> SDLInputSource::EnumerateMotors()
return ret; return ret;
} }
bool SDLInputSource::GetGenericBindingMapping(const std::string_view& device, InputManager::GenericInputBindingMapping* mapping) bool SDLInputSource::GetGenericBindingMapping(const std::string_view device, InputManager::GenericInputBindingMapping* mapping)
{ {
if (!device.starts_with("SDL-")) if (!device.starts_with("SDL-"))
return false; return false;
@ -939,27 +939,27 @@ bool SDLInputSource::GetGenericBindingMapping(const std::string_view& device, In
const GenericInputBinding negative = s_sdl_generic_binding_axis_mapping[i][0]; const GenericInputBinding negative = s_sdl_generic_binding_axis_mapping[i][0];
const GenericInputBinding positive = s_sdl_generic_binding_axis_mapping[i][1]; const GenericInputBinding positive = s_sdl_generic_binding_axis_mapping[i][1];
if (negative != GenericInputBinding::Unknown) if (negative != GenericInputBinding::Unknown)
mapping->emplace_back(negative, StringUtil::StdStringFromFormat("SDL-%d/-%s", pid, s_sdl_axis_names[i])); mapping->emplace_back(negative, fmt::format("SDL-{}/-{}", pid, s_sdl_axis_names[i]));
if (positive != GenericInputBinding::Unknown) if (positive != GenericInputBinding::Unknown)
mapping->emplace_back(positive, StringUtil::StdStringFromFormat("SDL-%d/+%s", pid, s_sdl_axis_names[i])); mapping->emplace_back(positive, fmt::format("SDL-{}/+{}", pid, s_sdl_axis_names[i]));
} }
for (u32 i = 0; i < std::size(s_sdl_generic_binding_button_mapping); i++) for (u32 i = 0; i < std::size(s_sdl_generic_binding_button_mapping); i++)
{ {
const GenericInputBinding binding = s_sdl_generic_binding_button_mapping[i]; const GenericInputBinding binding = s_sdl_generic_binding_button_mapping[i];
if (binding != GenericInputBinding::Unknown) if (binding != GenericInputBinding::Unknown)
mapping->emplace_back(binding, StringUtil::StdStringFromFormat("SDL-%d/%s", pid, s_sdl_button_names[i])); mapping->emplace_back(binding, fmt::format("SDL-{}/{}", pid, s_sdl_button_names[i]));
} }
if (it->use_game_controller_rumble || it->haptic_left_right_effect) if (it->use_game_controller_rumble || it->haptic_left_right_effect)
{ {
mapping->emplace_back(GenericInputBinding::SmallMotor, StringUtil::StdStringFromFormat("SDL-%d/SmallMotor", pid)); mapping->emplace_back(GenericInputBinding::SmallMotor, fmt::format("SDL-{}/SmallMotor", pid));
mapping->emplace_back(GenericInputBinding::LargeMotor, StringUtil::StdStringFromFormat("SDL-%d/LargeMotor", pid)); mapping->emplace_back(GenericInputBinding::LargeMotor, fmt::format("SDL-{}/LargeMotor", pid));
} }
else else
{ {
mapping->emplace_back(GenericInputBinding::SmallMotor, StringUtil::StdStringFromFormat("SDL-%d/Haptic", pid)); mapping->emplace_back(GenericInputBinding::SmallMotor, fmt::format("SDL-{}/Haptic", pid));
mapping->emplace_back(GenericInputBinding::LargeMotor, StringUtil::StdStringFromFormat("SDL-%d/Haptic", pid)); mapping->emplace_back(GenericInputBinding::LargeMotor, fmt::format("SDL-{}/Haptic", pid));
} }
return true; return true;

View File

@ -30,20 +30,20 @@ public:
void PollEvents() override; void PollEvents() override;
std::vector<std::pair<std::string, std::string>> EnumerateDevices() override; std::vector<std::pair<std::string, std::string>> EnumerateDevices() override;
std::vector<InputBindingKey> EnumerateMotors() override; std::vector<InputBindingKey> EnumerateMotors() override;
bool GetGenericBindingMapping(const std::string_view& device, InputManager::GenericInputBindingMapping* mapping) override; bool GetGenericBindingMapping(const std::string_view device, InputManager::GenericInputBindingMapping* mapping) override;
void UpdateMotorState(InputBindingKey key, float intensity) override; void UpdateMotorState(InputBindingKey key, float intensity) override;
void UpdateMotorState(InputBindingKey large_key, InputBindingKey small_key, float large_intensity, float small_intensity) override; void UpdateMotorState(InputBindingKey large_key, InputBindingKey small_key, float large_intensity, float small_intensity) override;
std::optional<InputBindingKey> ParseKeyString(const std::string_view& device, const std::string_view& binding) override; std::optional<InputBindingKey> ParseKeyString(const std::string_view device, const std::string_view binding) override;
TinyString ConvertKeyToString(InputBindingKey key) override; TinyString ConvertKeyToString(InputBindingKey key) override;
TinyString ConvertKeyToIcon(InputBindingKey key) override; TinyString ConvertKeyToIcon(InputBindingKey key) override;
bool ProcessSDLEvent(const SDL_Event* event); bool ProcessSDLEvent(const SDL_Event* event);
SDL_Joystick* GetJoystickForDevice(const std::string_view& device); SDL_Joystick* GetJoystickForDevice(const std::string_view device);
static u32 GetRGBForPlayerId(SettingsInterface& si, u32 player_id); static u32 GetRGBForPlayerId(SettingsInterface& si, u32 player_id);
static u32 ParseRGBForPlayerId(const std::string_view& str, u32 player_id); static u32 ParseRGBForPlayerId(const std::string_view str, u32 player_id);
private: private:
struct ControllerData struct ControllerData

View File

@ -250,7 +250,7 @@ std::vector<std::pair<std::string, std::string>> XInputSource::EnumerateDevices(
return ret; return ret;
} }
std::optional<InputBindingKey> XInputSource::ParseKeyString(const std::string_view& device, const std::string_view& binding) std::optional<InputBindingKey> XInputSource::ParseKeyString(const std::string_view device, const std::string_view binding)
{ {
if (!device.starts_with("XInput-") || binding.empty()) if (!device.starts_with("XInput-") || binding.empty())
return std::nullopt; return std::nullopt;
@ -383,7 +383,7 @@ std::vector<InputBindingKey> XInputSource::EnumerateMotors()
return ret; return ret;
} }
bool XInputSource::GetGenericBindingMapping(const std::string_view& device, InputManager::GenericInputBindingMapping* mapping) bool XInputSource::GetGenericBindingMapping(const std::string_view device, InputManager::GenericInputBindingMapping* mapping)
{ {
if (!device.starts_with("XInput-")) if (!device.starts_with("XInput-"))
return false; return false;
@ -402,22 +402,22 @@ bool XInputSource::GetGenericBindingMapping(const std::string_view& device, Inpu
const GenericInputBinding negative = s_xinput_generic_binding_axis_mapping[i][0]; const GenericInputBinding negative = s_xinput_generic_binding_axis_mapping[i][0];
const GenericInputBinding positive = s_xinput_generic_binding_axis_mapping[i][1]; const GenericInputBinding positive = s_xinput_generic_binding_axis_mapping[i][1];
if (negative != GenericInputBinding::Unknown) if (negative != GenericInputBinding::Unknown)
mapping->emplace_back(negative, StringUtil::StdStringFromFormat("XInput-%d/-%s", pid, s_axis_names[i])); mapping->emplace_back(negative, fmt::format("XInput-{}/-{}", pid, s_axis_names[i]));
if (positive != GenericInputBinding::Unknown) if (positive != GenericInputBinding::Unknown)
mapping->emplace_back(positive, StringUtil::StdStringFromFormat("XInput-%d/+%s", pid, s_axis_names[i])); mapping->emplace_back(positive, fmt::format("XInput-{}/+{}", pid, s_axis_names[i]));
} }
for (u32 i = 0; i < std::size(s_xinput_generic_binding_button_mapping); i++) for (u32 i = 0; i < std::size(s_xinput_generic_binding_button_mapping); i++)
{ {
const GenericInputBinding binding = s_xinput_generic_binding_button_mapping[i]; const GenericInputBinding binding = s_xinput_generic_binding_button_mapping[i];
if (binding != GenericInputBinding::Unknown) if (binding != GenericInputBinding::Unknown)
mapping->emplace_back(binding, StringUtil::StdStringFromFormat("XInput-%d/%s", pid, s_button_names[i])); mapping->emplace_back(binding, fmt::format("XInput-{}/{}", pid, s_button_names[i]));
} }
if (m_controllers[pid].has_small_motor) if (m_controllers[pid].has_small_motor)
mapping->emplace_back(GenericInputBinding::SmallMotor, StringUtil::StdStringFromFormat("XInput-%d/SmallMotor", pid)); mapping->emplace_back(GenericInputBinding::SmallMotor, fmt::format("XInput-{}/SmallMotor", pid));
if (m_controllers[pid].has_large_motor) if (m_controllers[pid].has_large_motor)
mapping->emplace_back(GenericInputBinding::LargeMotor, StringUtil::StdStringFromFormat("XInput-%d/LargeMotor", pid)); mapping->emplace_back(GenericInputBinding::LargeMotor, fmt::format("XInput-{}/LargeMotor", pid));
return true; return true;
} }

View File

@ -79,11 +79,11 @@ public:
void PollEvents() override; void PollEvents() override;
std::vector<std::pair<std::string, std::string>> EnumerateDevices() override; std::vector<std::pair<std::string, std::string>> EnumerateDevices() override;
std::vector<InputBindingKey> EnumerateMotors() override; std::vector<InputBindingKey> EnumerateMotors() override;
bool GetGenericBindingMapping(const std::string_view& device, InputManager::GenericInputBindingMapping* mapping) override; bool GetGenericBindingMapping(const std::string_view device, InputManager::GenericInputBindingMapping* mapping) override;
void UpdateMotorState(InputBindingKey key, float intensity) override; void UpdateMotorState(InputBindingKey key, float intensity) override;
void UpdateMotorState(InputBindingKey large_key, InputBindingKey small_key, float large_intensity, float small_intensity) override; void UpdateMotorState(InputBindingKey large_key, InputBindingKey small_key, float large_intensity, float small_intensity) override;
std::optional<InputBindingKey> ParseKeyString(const std::string_view& device, const std::string_view& binding) override; std::optional<InputBindingKey> ParseKeyString(const std::string_view device, const std::string_view binding) override;
TinyString ConvertKeyToString(InputBindingKey key) override; TinyString ConvertKeyToString(InputBindingKey key) override;
TinyString ConvertKeyToIcon(InputBindingKey key) override; TinyString ConvertKeyToIcon(InputBindingKey key) override;

View File

@ -56,7 +56,7 @@ namespace Patch
{"byte", "short", "word", "double", "extended", "beshort", "beword", "bedouble", "bytes"}}; {"byte", "short", "word", "double", "extended", "beshort", "beword", "bedouble", "bytes"}};
template <typename EnumType, class ArrayType> template <typename EnumType, class ArrayType>
static inline std::optional<EnumType> LookupEnumName(const std::string_view& val, const ArrayType& arr) static inline std::optional<EnumType> LookupEnumName(const std::string_view val, const ArrayType& arr)
{ {
for (size_t i = 0; i < arr.size(); i++) for (size_t i = 0; i < arr.size(); i++)
{ {
@ -120,7 +120,7 @@ namespace Patch
{ {
int code; int code;
const char* text; const char* text;
void (*func)(PatchGroup* group, const std::string_view& cmd, const std::string_view& param); void (*func)(PatchGroup* group, const std::string_view cmd, const std::string_view param);
}; };
using PatchList = std::vector<PatchGroup>; using PatchList = std::vector<PatchGroup>;
@ -129,27 +129,27 @@ namespace Patch
namespace PatchFunc namespace PatchFunc
{ {
static void patch(PatchGroup* group, const std::string_view& cmd, const std::string_view& param); static void patch(PatchGroup* group, const std::string_view cmd, const std::string_view param);
static void gsaspectratio(PatchGroup* group, const std::string_view& cmd, const std::string_view& param); static void gsaspectratio(PatchGroup* group, const std::string_view cmd, const std::string_view param);
static void gsinterlacemode(PatchGroup* group, const std::string_view& cmd, const std::string_view& param); static void gsinterlacemode(PatchGroup* group, const std::string_view cmd, const std::string_view param);
} // namespace PatchFunc } // namespace PatchFunc
static void TrimPatchLine(std::string& buffer); static void TrimPatchLine(std::string& buffer);
static int PatchTableExecute(PatchGroup* group, const std::string_view& lhs, const std::string_view& rhs, static int PatchTableExecute(PatchGroup* group, const std::string_view lhs, const std::string_view rhs,
const std::span<const PatchTextTable>& Table); const std::span<const PatchTextTable>& Table);
static void LoadPatchLine(PatchGroup* group, const std::string_view& line); static void LoadPatchLine(PatchGroup* group, const std::string_view line);
static u32 LoadPatchesFromString(PatchList* patch_list, const std::string& patch_file); static u32 LoadPatchesFromString(PatchList* patch_list, const std::string& patch_file);
static bool OpenPatchesZip(); static bool OpenPatchesZip();
static std::string GetPnachTemplate( static std::string GetPnachTemplate(
const std::string_view& serial, u32 crc, bool include_serial, bool add_wildcard, bool all_crcs); const std::string_view serial, u32 crc, bool include_serial, bool add_wildcard, bool all_crcs);
static std::vector<std::string> FindPatchFilesOnDisk( static std::vector<std::string> FindPatchFilesOnDisk(
const std::string_view& serial, u32 crc, bool cheats, bool all_crcs); const std::string_view serial, u32 crc, bool cheats, bool all_crcs);
static bool ContainsPatchName(const PatchInfoList& patches, const std::string_view patchName); static bool ContainsPatchName(const PatchInfoList& patches, const std::string_view patchName);
static bool ContainsPatchName(const PatchList& patches, const std::string_view patchName); static bool ContainsPatchName(const PatchList& patches, const std::string_view patchName);
template <typename F> template <typename F>
static void EnumeratePnachFiles(const std::string_view& serial, u32 crc, bool cheats, bool for_ui, const F& f); static void EnumeratePnachFiles(const std::string_view serial, u32 crc, bool cheats, bool for_ui, const F& f);
static bool PatchStringHasUnlabelledPatch(const std::string& pnach_data); static bool PatchStringHasUnlabelledPatch(const std::string& pnach_data);
static void ExtractPatchInfo(PatchInfoList* dst, const std::string& pnach_data, u32* num_unlabelled_patches); static void ExtractPatchInfo(PatchInfoList* dst, const std::string& pnach_data, u32* num_unlabelled_patches);
@ -213,7 +213,7 @@ bool Patch::ContainsPatchName(const PatchList& patch_list, const std::string_vie
}) != patch_list.end(); }) != patch_list.end();
} }
int Patch::PatchTableExecute(PatchGroup* group, const std::string_view& lhs, const std::string_view& rhs, int Patch::PatchTableExecute(PatchGroup* group, const std::string_view lhs, const std::string_view rhs,
const std::span<const PatchTextTable>& Table) const std::span<const PatchTextTable>& Table)
{ {
int i = 0; int i = 0;
@ -233,7 +233,7 @@ int Patch::PatchTableExecute(PatchGroup* group, const std::string_view& lhs, con
} }
// This routine is for executing the commands of the ini file. // This routine is for executing the commands of the ini file.
void Patch::LoadPatchLine(PatchGroup* group, const std::string_view& line) void Patch::LoadPatchLine(PatchGroup* group, const std::string_view line)
{ {
std::string_view key, value; std::string_view key, value;
StringUtil::ParseAssignmentString(line, &key, &value); StringUtil::ParseAssignmentString(line, &key, &value);
@ -355,7 +355,7 @@ bool Patch::OpenPatchesZip()
return true; return true;
} }
std::string Patch::GetPnachTemplate(const std::string_view& serial, u32 crc, bool include_serial, bool add_wildcard, bool all_crcs) std::string Patch::GetPnachTemplate(const std::string_view serial, u32 crc, bool include_serial, bool add_wildcard, bool all_crcs)
{ {
pxAssert(!all_crcs || (include_serial && add_wildcard)); pxAssert(!all_crcs || (include_serial && add_wildcard));
if (all_crcs) if (all_crcs)
@ -366,7 +366,7 @@ std::string Patch::GetPnachTemplate(const std::string_view& serial, u32 crc, boo
return fmt::format("{:08X}{}.pnach", crc, add_wildcard ? "*" : ""); return fmt::format("{:08X}{}.pnach", crc, add_wildcard ? "*" : "");
} }
std::vector<std::string> Patch::FindPatchFilesOnDisk(const std::string_view& serial, u32 crc, bool cheats, bool all_crcs) std::vector<std::string> Patch::FindPatchFilesOnDisk(const std::string_view serial, u32 crc, bool cheats, bool all_crcs)
{ {
FileSystem::FindResultsArray files; FileSystem::FindResultsArray files;
FileSystem::FindFiles(cheats ? EmuFolders::Cheats.c_str() : EmuFolders::Patches.c_str(), FileSystem::FindFiles(cheats ? EmuFolders::Cheats.c_str() : EmuFolders::Patches.c_str(),
@ -398,7 +398,7 @@ bool Patch::ContainsPatchName(const PatchInfoList& patches, const std::string_vi
} }
template <typename F> template <typename F>
void Patch::EnumeratePnachFiles(const std::string_view& serial, u32 crc, bool cheats, bool for_ui, const F& f) void Patch::EnumeratePnachFiles(const std::string_view serial, u32 crc, bool cheats, bool for_ui, const F& f)
{ {
// Prefer files on disk over the zip. // Prefer files on disk over the zip.
std::vector<std::string> disk_patch_files; std::vector<std::string> disk_patch_files;
@ -553,7 +553,7 @@ std::string_view Patch::PatchInfo::GetNameParentPart() const
return ret; return ret;
} }
Patch::PatchInfoList Patch::GetPatchInfo(const std::string_view& serial, u32 crc, bool cheats, bool showAllCRCS, u32* num_unlabelled_patches) Patch::PatchInfoList Patch::GetPatchInfo(const std::string_view serial, u32 crc, bool cheats, bool showAllCRCS, u32* num_unlabelled_patches)
{ {
PatchInfoList ret; PatchInfoList ret;
@ -568,7 +568,7 @@ Patch::PatchInfoList Patch::GetPatchInfo(const std::string_view& serial, u32 crc
return ret; return ret;
} }
std::string Patch::GetPnachFilename(const std::string_view& serial, u32 crc, bool cheats) std::string Patch::GetPnachFilename(const std::string_view serial, u32 crc, bool cheats)
{ {
return Path::Combine(cheats ? EmuFolders::Cheats : EmuFolders::Patches, GetPnachTemplate(serial, crc, true, false, false)); return Path::Combine(cheats ? EmuFolders::Cheats : EmuFolders::Patches, GetPnachTemplate(serial, crc, true, false, false));
} }
@ -798,7 +798,7 @@ void Patch::UnloadPatches()
} }
// PatchFunc Functions. // PatchFunc Functions.
void Patch::PatchFunc::patch(PatchGroup* group, const std::string_view& cmd, const std::string_view& param) void Patch::PatchFunc::patch(PatchGroup* group, const std::string_view cmd, const std::string_view param)
{ {
#define PATCH_ERROR(fstring, ...) \ #define PATCH_ERROR(fstring, ...) \
Console.Error(fmt::format("(Patch) Error Parsing: {}={}: " fstring, cmd, param, __VA_ARGS__)) Console.Error(fmt::format("(Patch) Error Parsing: {}={}: " fstring, cmd, param, __VA_ARGS__))
@ -874,7 +874,7 @@ void Patch::PatchFunc::patch(PatchGroup* group, const std::string_view& cmd, con
#undef PATCH_ERROR #undef PATCH_ERROR
} }
void Patch::PatchFunc::gsaspectratio(PatchGroup* group, const std::string_view& cmd, const std::string_view& param) void Patch::PatchFunc::gsaspectratio(PatchGroup* group, const std::string_view cmd, const std::string_view param)
{ {
for (u32 i = 0; i < static_cast<u32>(AspectRatioType::MaxCount); i++) for (u32 i = 0; i < static_cast<u32>(AspectRatioType::MaxCount); i++)
{ {
@ -888,7 +888,7 @@ void Patch::PatchFunc::gsaspectratio(PatchGroup* group, const std::string_view&
Console.Error(fmt::format("Patch error: {} is an unknown aspect ratio.", param)); Console.Error(fmt::format("Patch error: {} is an unknown aspect ratio.", param));
} }
void Patch::PatchFunc::gsinterlacemode(PatchGroup* group, const std::string_view& cmd, const std::string_view& param) void Patch::PatchFunc::gsinterlacemode(PatchGroup* group, const std::string_view cmd, const std::string_view param)
{ {
const std::optional<int> interlace_mode = StringUtil::FromChars<int>(param); const std::optional<int> interlace_mode = StringUtil::FromChars<int>(param);
if (!interlace_mode.has_value() || interlace_mode.value() < 0 || if (!interlace_mode.has_value() || interlace_mode.value() < 0 ||

View File

@ -81,10 +81,10 @@ namespace Patch
extern const char* CHEATS_CONFIG_SECTION; extern const char* CHEATS_CONFIG_SECTION;
extern const char* PATCH_ENABLE_CONFIG_KEY; extern const char* PATCH_ENABLE_CONFIG_KEY;
extern PatchInfoList GetPatchInfo(const std::string_view& serial, u32 crc, bool cheats, bool showAllCRCS, u32* num_unlabelled_patches); extern PatchInfoList GetPatchInfo(const std::string_view serial, u32 crc, bool cheats, bool showAllCRCS, u32* num_unlabelled_patches);
/// Returns the path to a new cheat/patch pnach for the specified serial and CRC. /// Returns the path to a new cheat/patch pnach for the specified serial and CRC.
extern std::string GetPnachFilename(const std::string_view& serial, u32 crc, bool cheats); extern std::string GetPnachFilename(const std::string_view serial, u32 crc, bool cheats);
/// Reloads cheats/patches. If verbose is set, the number of patches loaded will be shown in the OSD. /// Reloads cheats/patches. If verbose is set, the number of patches loaded will be shown in the OSD.
extern void ReloadPatches(const std::string& serial, u32 crc, bool reload_files, bool reload_enabled_list, bool verbose, bool verbose_if_changed); extern void ReloadPatches(const std::string& serial, u32 crc, bool reload_files, bool reload_enabled_list, bool verbose, bool verbose_if_changed);

View File

@ -242,7 +242,7 @@ const char* Pcsx2Config::SpeedhackOptions::GetSpeedHackName(SpeedHack id)
return s_speed_hack_names[static_cast<u32>(id)]; return s_speed_hack_names[static_cast<u32>(id)];
} }
std::optional<SpeedHack> Pcsx2Config::SpeedhackOptions::ParseSpeedHackName(const std::string_view& name) std::optional<SpeedHack> Pcsx2Config::SpeedhackOptions::ParseSpeedHackName(const std::string_view name)
{ {
for (u32 i = 0; i < std::size(s_speed_hack_names); i++) for (u32 i = 0; i < std::size(s_speed_hack_names); i++)
{ {

View File

@ -890,7 +890,7 @@ std::vector<AvailableMcdInfo> FileMcd_GetAvailableCards(bool include_in_use_card
return mcds; return mcds;
} }
std::optional<AvailableMcdInfo> FileMcd_GetCardInfo(const std::string_view& name) std::optional<AvailableMcdInfo> FileMcd_GetCardInfo(const std::string_view name)
{ {
std::optional<AvailableMcdInfo> ret; std::optional<AvailableMcdInfo> ret;
@ -923,7 +923,7 @@ std::optional<AvailableMcdInfo> FileMcd_GetCardInfo(const std::string_view& name
return ret; return ret;
} }
bool FileMcd_CreateNewCard(const std::string_view& name, MemoryCardType type, MemoryCardFileType file_type) bool FileMcd_CreateNewCard(const std::string_view name, MemoryCardType type, MemoryCardFileType file_type)
{ {
const std::string full_path(Path::Combine(EmuFolders::MemoryCards, name)); const std::string full_path(Path::Combine(EmuFolders::MemoryCards, name));
@ -1018,7 +1018,7 @@ bool FileMcd_CreateNewCard(const std::string_view& name, MemoryCardType type, Me
return false; return false;
} }
bool FileMcd_RenameCard(const std::string_view& name, const std::string_view& new_name) bool FileMcd_RenameCard(const std::string_view name, const std::string_view new_name)
{ {
const std::string name_path(Path::Combine(EmuFolders::MemoryCards, name)); const std::string name_path(Path::Combine(EmuFolders::MemoryCards, name));
const std::string new_name_path(Path::Combine(EmuFolders::MemoryCards, new_name)); const std::string new_name_path(Path::Combine(EmuFolders::MemoryCards, new_name));
@ -1043,7 +1043,7 @@ bool FileMcd_RenameCard(const std::string_view& name, const std::string_view& ne
return true; return true;
} }
bool FileMcd_DeleteCard(const std::string_view& name) bool FileMcd_DeleteCard(const std::string_view name)
{ {
const std::string name_path(Path::Combine(EmuFolders::MemoryCards, name)); const std::string name_path(Path::Combine(EmuFolders::MemoryCards, name));

View File

@ -9,6 +9,7 @@
#include <ctime> #include <ctime>
#include <optional> #include <optional>
#include <string> #include <string>
#include <string_view>
#include <vector> #include <vector>
struct McdSizeInfo struct McdSizeInfo
@ -52,9 +53,9 @@ void FileMcd_NextFrame(uint port, uint slot);
int FileMcd_ReIndex(uint port, uint slot, const std::string& filter); int FileMcd_ReIndex(uint port, uint slot, const std::string& filter);
std::vector<AvailableMcdInfo> FileMcd_GetAvailableCards(bool include_in_use_cards); std::vector<AvailableMcdInfo> FileMcd_GetAvailableCards(bool include_in_use_cards);
std::optional<AvailableMcdInfo> FileMcd_GetCardInfo(const std::string_view& name); std::optional<AvailableMcdInfo> FileMcd_GetCardInfo(const std::string_view name);
bool FileMcd_IsMemoryCardFormatted(const std::string& path); bool FileMcd_IsMemoryCardFormatted(const std::string& path);
bool FileMcd_IsMemoryCardFormatted(std::FILE* fp); bool FileMcd_IsMemoryCardFormatted(std::FILE* fp);
bool FileMcd_CreateNewCard(const std::string_view& name, MemoryCardType type, MemoryCardFileType file_type); bool FileMcd_CreateNewCard(const std::string_view name, MemoryCardType type, MemoryCardFileType file_type);
bool FileMcd_RenameCard(const std::string_view& name, const std::string_view& new_name); bool FileMcd_RenameCard(const std::string_view name, const std::string_view new_name);
bool FileMcd_DeleteCard(const std::string_view& name); bool FileMcd_DeleteCard(const std::string_view name);

View File

@ -428,7 +428,7 @@ MemoryCardFileEntry* FolderMemoryCard::AppendFileEntryToDir(const MemoryCardFile
return newFileEntry; return newFileEntry;
} }
static bool FilterMatches(const std::string_view& fileName, const std::string_view& filter) static bool FilterMatches(const std::string_view fileName, const std::string_view filter)
{ {
std::string_view::size_type start = 0; std::string_view::size_type start = 0;
std::string_view::size_type len = filter.length(); std::string_view::size_type len = filter.length();
@ -452,7 +452,7 @@ static bool FilterMatches(const std::string_view& fileName, const std::string_vi
return false; return false;
} }
bool FolderMemoryCard::AddFolder(MemoryCardFileEntry* const dirEntry, const std::string& dirPath, MemoryCardFileMetadataReference* parent /* = nullptr */, const bool enableFiltering /* = false */, const std::string_view& filter /* = "" */) bool FolderMemoryCard::AddFolder(MemoryCardFileEntry* const dirEntry, const std::string& dirPath, MemoryCardFileMetadataReference* parent /* = nullptr */, const bool enableFiltering /* = false */, const std::string_view filter /* = "" */)
{ {
if (FileSystem::DirectoryExists(dirPath.c_str())) if (FileSystem::DirectoryExists(dirPath.c_str()))
{ {
@ -1895,7 +1895,7 @@ std::vector<FolderMemoryCard::EnumeratedFileEntry> FolderMemoryCard::GetOrderedF
return result; return result;
} }
void FolderMemoryCard::DeleteFromIndex(const std::string& filePath, const std::string_view& entry) const void FolderMemoryCard::DeleteFromIndex(const std::string& filePath, const std::string_view entry) const
{ {
const std::string indexName(Path::Combine(filePath, "_pcsx2_index")); const std::string indexName(Path::Combine(filePath, "_pcsx2_index"));
@ -1988,7 +1988,7 @@ FileAccessHelper::~FileAccessHelper()
this->CloseAll(); this->CloseAll();
} }
std::FILE* FileAccessHelper::Open(const std::string_view& folderName, MemoryCardFileMetadataReference* fileRef, bool writeMetadata /* = false */) std::FILE* FileAccessHelper::Open(const std::string_view folderName, MemoryCardFileMetadataReference* fileRef, bool writeMetadata /* = false */)
{ {
std::string filename(folderName); std::string filename(folderName);
fileRef->GetPath(&filename); fileRef->GetPath(&filename);
@ -2020,7 +2020,7 @@ std::FILE* FileAccessHelper::Open(const std::string_view& folderName, MemoryCard
return file; return file;
} }
void FileAccessHelper::WriteMetadata(const std::string_view& folderName, const MemoryCardFileMetadataReference* fileRef) void FileAccessHelper::WriteMetadata(const std::string_view folderName, const MemoryCardFileMetadataReference* fileRef)
{ {
std::string fileName(folderName); std::string fileName(folderName);
const bool cleanedFilename = fileRef->GetPath(&fileName); const bool cleanedFilename = fileRef->GetPath(&fileName);
@ -2112,7 +2112,7 @@ void FileAccessHelper::WriteIndex(const std::string& baseFolderName, MemoryCardF
} }
} }
std::FILE* FileAccessHelper::ReOpen(const std::string_view& folderName, MemoryCardFileMetadataReference* fileRef, bool writeMetadata /* = false */) std::FILE* FileAccessHelper::ReOpen(const std::string_view folderName, MemoryCardFileMetadataReference* fileRef, bool writeMetadata /* = false */)
{ {
std::string internalPath; std::string internalPath;
fileRef->GetInternalPath(&internalPath); fileRef->GetInternalPath(&internalPath);
@ -2158,7 +2158,7 @@ void FileAccessHelper::CloseFileHandle(std::FILE*& file, const MemoryCardFileEnt
} }
} }
void FileAccessHelper::CloseMatching(const std::string_view& path) void FileAccessHelper::CloseMatching(const std::string_view path)
{ {
for (auto it = m_files.begin(); it != m_files.end();) for (auto it = m_files.begin(); it != m_files.end();)
{ {

View File

@ -191,9 +191,9 @@ public:
~FileAccessHelper(); ~FileAccessHelper();
// Get an already opened file if possible, or open a new one and remember it // Get an already opened file if possible, or open a new one and remember it
std::FILE* ReOpen(const std::string_view& folderName, MemoryCardFileMetadataReference* fileRef, bool writeMetadata = false); std::FILE* ReOpen(const std::string_view folderName, MemoryCardFileMetadataReference* fileRef, bool writeMetadata = false);
// Close all open files that start with the given path, so either a file if a filename is given or all files in a directory and its subdirectories when a directory is given // Close all open files that start with the given path, so either a file if a filename is given or all files in a directory and its subdirectories when a directory is given
void CloseMatching(const std::string_view& path); void CloseMatching(const std::string_view path);
// Close all open files // Close all open files
void CloseAll(); void CloseAll();
// Flush the written data of all open files to the file system // Flush the written data of all open files to the file system
@ -213,12 +213,12 @@ private:
static bool CleanMemcardFilenameEndDotOrSpace(char* name, size_t length); static bool CleanMemcardFilenameEndDotOrSpace(char* name, size_t length);
// Open a new file and remember it for later // Open a new file and remember it for later
std::FILE* Open(const std::string_view& folderName, MemoryCardFileMetadataReference* fileRef, bool writeMetadata = false); std::FILE* Open(const std::string_view folderName, MemoryCardFileMetadataReference* fileRef, bool writeMetadata = false);
// Close a file and delete its handle // Close a file and delete its handle
// If entry is given, it also attempts to set the created and modified timestamps of the file according to the entry // If entry is given, it also attempts to set the created and modified timestamps of the file according to the entry
void CloseFileHandle(std::FILE*& file, const MemoryCardFileEntry* entry = nullptr); void CloseFileHandle(std::FILE*& file, const MemoryCardFileEntry* entry = nullptr);
void WriteMetadata(const std::string_view& folderName, const MemoryCardFileMetadataReference* fileRef); void WriteMetadata(const std::string_view folderName, const MemoryCardFileMetadataReference* fileRef);
}; };
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
@ -438,7 +438,7 @@ protected:
// - dirPath: the full path to the directory in the host file system // - dirPath: the full path to the directory in the host file system
// - parent: pointer to the parent dir's quick-access reference element // - parent: pointer to the parent dir's quick-access reference element
// - enableFiltering and filter: filter loaded contents, see LoadMemoryCardData() // - enableFiltering and filter: filter loaded contents, see LoadMemoryCardData()
bool AddFolder(MemoryCardFileEntry* const dirEntry, const std::string& dirPath, MemoryCardFileMetadataReference* parent = nullptr, const bool enableFiltering = false, const std::string_view& filter = ""); bool AddFolder(MemoryCardFileEntry* const dirEntry, const std::string& dirPath, MemoryCardFileMetadataReference* parent = nullptr, const bool enableFiltering = false, const std::string_view filter = "");
// adds a file in the host file sytem to the memory card // adds a file in the host file sytem to the memory card
// - dirEntry: the entry of the directory in the parent directory, or the root "." entry // - dirEntry: the entry of the directory in the parent directory, or the root "." entry
@ -524,7 +524,7 @@ protected:
// for legacy entries without an entry in the index file, order is unspecified and should not be relied on // for legacy entries without an entry in the index file, order is unspecified and should not be relied on
std::vector<EnumeratedFileEntry> GetOrderedFiles(const std::string& dirPath) const; std::vector<EnumeratedFileEntry> GetOrderedFiles(const std::string& dirPath) const;
void DeleteFromIndex(const std::string& filePath, const std::string_view& entry) const; void DeleteFromIndex(const std::string& filePath, const std::string_view entry) const;
}; };
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------

View File

@ -67,7 +67,7 @@ const char* Pad::ControllerInfo::GetLocalizedName() const
return Host::TranslateToCString("Pad", display_name); return Host::TranslateToCString("Pad", display_name);
} }
std::optional<u32> Pad::ControllerInfo::GetBindIndex(const std::string_view& name) const std::optional<u32> Pad::ControllerInfo::GetBindIndex(const std::string_view name) const
{ {
for (u32 i = 0; i < static_cast<u32>(bindings.size()); i++) for (u32 i = 0; i < static_cast<u32>(bindings.size()); i++)
{ {
@ -268,7 +268,7 @@ const Pad::ControllerInfo* Pad::GetControllerInfo(Pad::ControllerType type)
return nullptr; return nullptr;
} }
const Pad::ControllerInfo* Pad::GetControllerInfoByName(const std::string_view& name) const Pad::ControllerInfo* Pad::GetControllerInfoByName(const std::string_view name)
{ {
for (const ControllerInfo* info : s_controller_info) for (const ControllerInfo* info : s_controller_info)
{ {

View File

@ -43,7 +43,7 @@ namespace Pad
// Returns general information for the specified controller type. // Returns general information for the specified controller type.
const ControllerInfo* GetControllerInfo(Pad::ControllerType type); const ControllerInfo* GetControllerInfo(Pad::ControllerType type);
const ControllerInfo* GetControllerInfoByName(const std::string_view& name); const ControllerInfo* GetControllerInfoByName(const std::string_view name);
// Returns controller info based on the type in the config. // Returns controller info based on the type in the config.
// Needed because we can't just read EmuConfig when altering input profiles. // Needed because we can't just read EmuConfig when altering input profiles.

View File

@ -90,7 +90,7 @@ namespace Pad
const char* GetLocalizedName() const; const char* GetLocalizedName() const;
/// Returns the index of the specified binding point, by name. /// Returns the index of the specified binding point, by name.
std::optional<u32> GetBindIndex(const std::string_view& name) const; std::optional<u32> GetBindIndex(const std::string_view name) const;
}; };
// Total number of pad ports, across both multitaps. // Total number of pad ports, across both multitaps.

View File

@ -531,7 +531,7 @@ s64 usb_get_clock()
return s_usb_clocks; return s_usb_clocks;
} }
s32 USB::DeviceTypeNameToIndex(const std::string_view& device) s32 USB::DeviceTypeNameToIndex(const std::string_view device)
{ {
RegisterDevice& rd = RegisterDevice::instance(); RegisterDevice& rd = RegisterDevice::instance();
return rd.Index(device); return rd.Index(device);
@ -555,13 +555,13 @@ std::vector<std::pair<const char*, const char*>> USB::GetDeviceTypes()
return ret; return ret;
} }
const char* USB::GetDeviceName(const std::string_view& device) const char* USB::GetDeviceName(const std::string_view device)
{ {
const DeviceProxy* dev = RegisterDevice::instance().Device(device); const DeviceProxy* dev = RegisterDevice::instance().Device(device);
return dev ? dev->Name() : TRANSLATE_NOOP("USB", "Not Connected"); return dev ? dev->Name() : TRANSLATE_NOOP("USB", "Not Connected");
} }
const char* USB::GetDeviceSubtypeName(const std::string_view& device, u32 subtype) const char* USB::GetDeviceSubtypeName(const std::string_view device, u32 subtype)
{ {
const DeviceProxy* dev = RegisterDevice::instance().Device(device); const DeviceProxy* dev = RegisterDevice::instance().Device(device);
if (!dev) if (!dev)
@ -574,19 +574,19 @@ const char* USB::GetDeviceSubtypeName(const std::string_view& device, u32 subtyp
return subtypes[subtype]; return subtypes[subtype];
} }
std::span<const char*> USB::GetDeviceSubtypes(const std::string_view& device) std::span<const char*> USB::GetDeviceSubtypes(const std::string_view device)
{ {
const DeviceProxy* dev = RegisterDevice::instance().Device(device); const DeviceProxy* dev = RegisterDevice::instance().Device(device);
return dev ? dev->SubTypes() : std::span<const char*>(); return dev ? dev->SubTypes() : std::span<const char*>();
} }
std::span<const InputBindingInfo> USB::GetDeviceBindings(const std::string_view& device, u32 subtype) std::span<const InputBindingInfo> USB::GetDeviceBindings(const std::string_view device, u32 subtype)
{ {
const DeviceProxy* dev = RegisterDevice::instance().Device(device); const DeviceProxy* dev = RegisterDevice::instance().Device(device);
return dev ? dev->Bindings(subtype) : std::span<const InputBindingInfo>(); return dev ? dev->Bindings(subtype) : std::span<const InputBindingInfo>();
} }
std::span<const SettingInfo> USB::GetDeviceSettings(const std::string_view& device, u32 subtype) std::span<const SettingInfo> USB::GetDeviceSettings(const std::string_view device, u32 subtype)
{ {
const DeviceProxy* dev = RegisterDevice::instance().Device(device); const DeviceProxy* dev = RegisterDevice::instance().Device(device);
return dev ? dev->Settings(subtype) : std::span<const SettingInfo>(); return dev ? dev->Settings(subtype) : std::span<const SettingInfo>();
@ -619,7 +619,7 @@ void USB::SetDeviceBindValue(u32 port, u32 bind_index, float value)
s_usb_device_proxy[port]->SetBindingValue(s_usb_device[port], bind_index, value); s_usb_device_proxy[port]->SetBindingValue(s_usb_device[port], bind_index, value);
} }
void USB::InputDeviceConnected(const std::string_view& identifier) void USB::InputDeviceConnected(const std::string_view identifier)
{ {
for (u32 i = 0; i < NUM_PORTS; i++) for (u32 i = 0; i < NUM_PORTS; i++)
{ {
@ -628,7 +628,7 @@ void USB::InputDeviceConnected(const std::string_view& identifier)
} }
} }
void USB::InputDeviceDisconnected(const std::string_view& identifier) void USB::InputDeviceDisconnected(const std::string_view identifier)
{ {
for (u32 i = 0; i < NUM_PORTS; i++) for (u32 i = 0; i < NUM_PORTS; i++)
{ {
@ -647,17 +647,17 @@ void USB::SetConfigDevice(SettingsInterface& si, u32 port, const char* devname)
si.SetStringValue(GetConfigSection(port).c_str(), "Type", devname); si.SetStringValue(GetConfigSection(port).c_str(), "Type", devname);
} }
u32 USB::GetConfigSubType(const SettingsInterface& si, u32 port, const std::string_view& devname) u32 USB::GetConfigSubType(const SettingsInterface& si, u32 port, const std::string_view devname)
{ {
return si.GetUIntValue(GetConfigSection(port).c_str(), fmt::format("{}_subtype", devname).c_str(), 0u); return si.GetUIntValue(GetConfigSection(port).c_str(), fmt::format("{}_subtype", devname).c_str(), 0u);
} }
void USB::SetConfigSubType(SettingsInterface& si, u32 port, const std::string_view& devname, u32 subtype) void USB::SetConfigSubType(SettingsInterface& si, u32 port, const std::string_view devname, u32 subtype)
{ {
si.SetUIntValue(GetConfigSection(port).c_str(), fmt::format("{}_subtype", devname).c_str(), subtype); si.SetUIntValue(GetConfigSection(port).c_str(), fmt::format("{}_subtype", devname).c_str(), subtype);
} }
std::string USB::GetConfigSubKey(const std::string_view& device, const std::string_view& bind_name) std::string USB::GetConfigSubKey(const std::string_view device, const std::string_view bind_name)
{ {
return fmt::format("{}_{}", device, bind_name); return fmt::format("{}_{}", device, bind_name);
} }

View File

@ -22,34 +22,34 @@ namespace USB
NUM_PORTS = 2, NUM_PORTS = 2,
}; };
s32 DeviceTypeNameToIndex(const std::string_view& device); s32 DeviceTypeNameToIndex(const std::string_view device);
const char* DeviceTypeIndexToName(s32 device); const char* DeviceTypeIndexToName(s32 device);
std::vector<std::pair<const char*, const char*>> GetDeviceTypes(); std::vector<std::pair<const char*, const char*>> GetDeviceTypes();
const char* GetDeviceName(const std::string_view& device); const char* GetDeviceName(const std::string_view device);
const char* GetDeviceSubtypeName(const std::string_view& device, u32 subtype); const char* GetDeviceSubtypeName(const std::string_view device, u32 subtype);
std::span<const char*> GetDeviceSubtypes(const std::string_view& device); std::span<const char*> GetDeviceSubtypes(const std::string_view device);
std::span<const InputBindingInfo> GetDeviceBindings(const std::string_view& device, u32 subtype); std::span<const InputBindingInfo> GetDeviceBindings(const std::string_view device, u32 subtype);
std::span<const SettingInfo> GetDeviceSettings(const std::string_view& device, u32 subtype); std::span<const SettingInfo> GetDeviceSettings(const std::string_view device, u32 subtype);
std::span<const InputBindingInfo> GetDeviceBindings(u32 port); std::span<const InputBindingInfo> GetDeviceBindings(u32 port);
float GetDeviceBindValue(u32 port, u32 bind_index); float GetDeviceBindValue(u32 port, u32 bind_index);
void SetDeviceBindValue(u32 port, u32 bind_index, float value); void SetDeviceBindValue(u32 port, u32 bind_index, float value);
/// Called when a new input device is connected. /// Called when a new input device is connected.
void InputDeviceConnected(const std::string_view& identifier); void InputDeviceConnected(const std::string_view identifier);
/// Called when an input device is disconnected. /// Called when an input device is disconnected.
void InputDeviceDisconnected(const std::string_view& identifier); void InputDeviceDisconnected(const std::string_view identifier);
std::string GetConfigSection(int port); std::string GetConfigSection(int port);
std::string GetConfigDevice(const SettingsInterface& si, u32 port); std::string GetConfigDevice(const SettingsInterface& si, u32 port);
void SetConfigDevice(SettingsInterface& si, u32 port, const char* devname); void SetConfigDevice(SettingsInterface& si, u32 port, const char* devname);
u32 GetConfigSubType(const SettingsInterface& si, u32 port, const std::string_view& devname); u32 GetConfigSubType(const SettingsInterface& si, u32 port, const std::string_view devname);
void SetConfigSubType(SettingsInterface& si, u32 port, const std::string_view& devname, u32 subtype); void SetConfigSubType(SettingsInterface& si, u32 port, const std::string_view devname, u32 subtype);
/// Returns the configuration key for the specified bind and device type. /// Returns the configuration key for the specified bind and device type.
std::string GetConfigSubKey(const std::string_view& device, const std::string_view& bind_name); std::string GetConfigSubKey(const std::string_view device, const std::string_view bind_name);
/// Performs automatic controller mapping with the provided list of generic mappings. /// Performs automatic controller mapping with the provided list of generic mappings.
bool MapDevice(SettingsInterface& si, u32 port, const std::vector<std::pair<GenericInputBinding, std::string>>& mapping); bool MapDevice(SettingsInterface& si, u32 port, const std::vector<std::pair<GenericInputBinding, std::string>>& mapping);

View File

@ -49,11 +49,11 @@ void DeviceProxy::UpdateSettings(USBDevice* dev, SettingsInterface& si) const
{ {
} }
void DeviceProxy::InputDeviceConnected(USBDevice* dev, const std::string_view& identifier) const void DeviceProxy::InputDeviceConnected(USBDevice* dev, const std::string_view identifier) const
{ {
} }
void DeviceProxy::InputDeviceDisconnected(USBDevice* dev, const std::string_view& identifier) const void DeviceProxy::InputDeviceDisconnected(USBDevice* dev, const std::string_view identifier) const
{ {
} }

View File

@ -61,8 +61,8 @@ public:
virtual bool Freeze(USBDevice* dev, StateWrapper& sw) const; virtual bool Freeze(USBDevice* dev, StateWrapper& sw) const;
virtual void UpdateSettings(USBDevice* dev, SettingsInterface& si) const; virtual void UpdateSettings(USBDevice* dev, SettingsInterface& si) const;
virtual void InputDeviceConnected(USBDevice* dev, const std::string_view& identifier) const; virtual void InputDeviceConnected(USBDevice* dev, const std::string_view identifier) const;
virtual void InputDeviceDisconnected(USBDevice* dev, const std::string_view& identifier) const; virtual void InputDeviceDisconnected(USBDevice* dev, const std::string_view identifier) const;
}; };
class RegisterDevice class RegisterDevice
@ -90,7 +90,7 @@ public:
registerDeviceMap[key] = std::unique_ptr<DeviceProxy>(creator); registerDeviceMap[key] = std::unique_ptr<DeviceProxy>(creator);
} }
DeviceProxy* Device(const std::string_view& name) DeviceProxy* Device(const std::string_view name)
{ {
auto proxy = std::find_if(registerDeviceMap.begin(), auto proxy = std::find_if(registerDeviceMap.begin(),
registerDeviceMap.end(), registerDeviceMap.end(),
@ -108,7 +108,7 @@ public:
return (it != registerDeviceMap.end()) ? it->second.get() : nullptr; return (it != registerDeviceMap.end()) ? it->second.get() : nullptr;
} }
DeviceType Index(const std::string_view& name) DeviceType Index(const std::string_view name)
{ {
auto proxy = std::find_if(registerDeviceMap.begin(), auto proxy = std::find_if(registerDeviceMap.begin(),
registerDeviceMap.end(), registerDeviceMap.end(),

View File

@ -32,7 +32,7 @@ namespace usb_pad
} }
} }
std::unique_ptr<SDLFFDevice> SDLFFDevice::Create(const std::string_view& device) std::unique_ptr<SDLFFDevice> SDLFFDevice::Create(const std::string_view device)
{ {
SDLInputSource* source = static_cast<SDLInputSource*>(InputManager::GetInputSourceInterface(InputSourceType::SDL)); SDLInputSource* source = static_cast<SDLInputSource*>(InputManager::GetInputSourceInterface(InputSourceType::SDL));
if (!source) if (!source)
@ -57,7 +57,7 @@ namespace usb_pad
return ret; return ret;
} }
void SDLFFDevice::CreateEffects(const std::string_view& device) void SDLFFDevice::CreateEffects(const std::string_view device)
{ {
constexpr u32 length = 10000; // 10 seconds since NFS games seem to not issue new commands while rotating. constexpr u32 length = 10000; // 10 seconds since NFS games seem to not issue new commands while rotating.

View File

@ -13,7 +13,7 @@ namespace usb_pad
public: public:
~SDLFFDevice() override; ~SDLFFDevice() override;
static std::unique_ptr<SDLFFDevice> Create(const std::string_view& device); static std::unique_ptr<SDLFFDevice> Create(const std::string_view device);
void SetConstantForce(int level) override; void SetConstantForce(int level) override;
void SetSpringForce(const parsed_ff_data& ff) override; void SetSpringForce(const parsed_ff_data& ff) override;
@ -25,7 +25,7 @@ namespace usb_pad
private: private:
SDLFFDevice(SDL_Haptic* haptic); SDLFFDevice(SDL_Haptic* haptic);
void CreateEffects(const std::string_view& device); void CreateEffects(const std::string_view device);
void DestroyEffects(); void DestroyEffects();
SDL_Haptic* m_haptic = nullptr; SDL_Haptic* m_haptic = nullptr;

View File

@ -875,14 +875,14 @@ namespace usb_pad
return GetWheelSettings(static_cast<PS2WheelTypes>(subtype)); return GetWheelSettings(static_cast<PS2WheelTypes>(subtype));
} }
void PadDevice::InputDeviceConnected(USBDevice* dev, const std::string_view& identifier) const void PadDevice::InputDeviceConnected(USBDevice* dev, const std::string_view identifier) const
{ {
PadState* s = USB_CONTAINER_OF(dev, PadState, dev); PadState* s = USB_CONTAINER_OF(dev, PadState, dev);
if (s->mFFdevName == identifier && s->HasFF()) if (s->mFFdevName == identifier && s->HasFF())
s->OpenFFDevice(); s->OpenFFDevice();
} }
void PadDevice::InputDeviceDisconnected(USBDevice* dev, const std::string_view& identifier) const void PadDevice::InputDeviceDisconnected(USBDevice* dev, const std::string_view identifier) const
{ {
PadState* s = USB_CONTAINER_OF(dev, PadState, dev); PadState* s = USB_CONTAINER_OF(dev, PadState, dev);
if (s->mFFdevName == identifier) if (s->mFFdevName == identifier)

View File

@ -77,8 +77,8 @@ namespace usb_pad
void UpdateSettings(USBDevice* dev, SettingsInterface& si) const override; void UpdateSettings(USBDevice* dev, SettingsInterface& si) const override;
float GetBindingValue(const USBDevice* dev, u32 bind_index) const override; float GetBindingValue(const USBDevice* dev, u32 bind_index) const override;
void SetBindingValue(USBDevice* dev, u32 bind_index, float value) const override; void SetBindingValue(USBDevice* dev, u32 bind_index, float value) const override;
void InputDeviceConnected(USBDevice* dev, const std::string_view& identifier) const override; void InputDeviceConnected(USBDevice* dev, const std::string_view identifier) const override;
void InputDeviceDisconnected(USBDevice* dev, const std::string_view& identifier) const override; void InputDeviceDisconnected(USBDevice* dev, const std::string_view identifier) const override;
std::span<const char*> SubTypes() const override; std::span<const char*> SubTypes() const override;
std::span<const InputBindingInfo> Bindings(u32 subtype) const override; std::span<const InputBindingInfo> Bindings(u32 subtype) const override;
std::span<const SettingInfo> Settings(u32 subtype) const override; std::span<const SettingInfo> Settings(u32 subtype) const override;

View File

@ -697,7 +697,7 @@ bool VMManager::ReloadGameSettings()
return true; return true;
} }
std::string VMManager::GetGameSettingsPath(const std::string_view& game_serial, u32 game_crc) std::string VMManager::GetGameSettingsPath(const std::string_view game_serial, u32 game_crc)
{ {
std::string sanitized_serial(Path::SanitizeFileName(game_serial)); std::string sanitized_serial(Path::SanitizeFileName(game_serial));
@ -728,12 +728,12 @@ std::string VMManager::GetDiscOverrideFromGameSettings(const std::string& elf_pa
return iso_path; return iso_path;
} }
std::string VMManager::GetInputProfilePath(const std::string_view& name) std::string VMManager::GetInputProfilePath(const std::string_view name)
{ {
return Path::Combine(EmuFolders::InputProfiles, fmt::format("{}.ini", name)); return Path::Combine(EmuFolders::InputProfiles, fmt::format("{}.ini", name));
} }
std::string VMManager::GetDebuggerSettingsFilePath(const std::string_view& game_serial, u32 game_crc) std::string VMManager::GetDebuggerSettingsFilePath(const std::string_view game_serial, u32 game_crc)
{ {
std::string path; std::string path;
if (!game_serial.empty() && game_crc != 0) if (!game_serial.empty() && game_crc != 0)
@ -2219,28 +2219,28 @@ bool VMManager::ChangeGSDump(const std::string& path)
return true; return true;
} }
bool VMManager::IsElfFileName(const std::string_view& path) bool VMManager::IsElfFileName(const std::string_view path)
{ {
return StringUtil::EndsWithNoCase(path, ".elf"); return StringUtil::EndsWithNoCase(path, ".elf");
} }
bool VMManager::IsBlockDumpFileName(const std::string_view& path) bool VMManager::IsBlockDumpFileName(const std::string_view path)
{ {
return StringUtil::EndsWithNoCase(path, ".dump"); return StringUtil::EndsWithNoCase(path, ".dump");
} }
bool VMManager::IsGSDumpFileName(const std::string_view& path) bool VMManager::IsGSDumpFileName(const std::string_view path)
{ {
return (StringUtil::EndsWithNoCase(path, ".gs") || StringUtil::EndsWithNoCase(path, ".gs.xz") || return (StringUtil::EndsWithNoCase(path, ".gs") || StringUtil::EndsWithNoCase(path, ".gs.xz") ||
StringUtil::EndsWithNoCase(path, ".gs.zst")); StringUtil::EndsWithNoCase(path, ".gs.zst"));
} }
bool VMManager::IsSaveStateFileName(const std::string_view& path) bool VMManager::IsSaveStateFileName(const std::string_view path)
{ {
return StringUtil::EndsWithNoCase(path, ".p2s"); return StringUtil::EndsWithNoCase(path, ".p2s");
} }
bool VMManager::IsDiscFileName(const std::string_view& path) bool VMManager::IsDiscFileName(const std::string_view path)
{ {
static const char* extensions[] = {".iso", ".bin", ".img", ".mdf", ".gz", ".cso", ".zso", ".chd"}; static const char* extensions[] = {".iso", ".bin", ".img", ".mdf", ".gz", ".cso", ".zso", ".chd"};
@ -2253,7 +2253,7 @@ bool VMManager::IsDiscFileName(const std::string_view& path)
return false; return false;
} }
bool VMManager::IsLoadableFileName(const std::string_view& path) bool VMManager::IsLoadableFileName(const std::string_view path)
{ {
return IsDiscFileName(path) || IsElfFileName(path) || IsGSDumpFileName(path) || IsBlockDumpFileName(path); return IsDiscFileName(path) || IsElfFileName(path) || IsGSDumpFileName(path) || IsBlockDumpFileName(path);
} }
@ -2956,7 +2956,7 @@ void VMManager::WarnAboutUnsafeSettings()
return; return;
std::string messages; std::string messages;
auto append = [&messages](const char* icon, const std::string_view& msg) { auto append = [&messages](const char* icon, const std::string_view msg) {
messages += icon; messages += icon;
messages += ' '; messages += ' ';
messages += msg; messages += msg;

View File

@ -170,37 +170,37 @@ namespace VMManager
bool ChangeGSDump(const std::string& path); bool ChangeGSDump(const std::string& path);
/// Returns true if the specified path is an ELF. /// Returns true if the specified path is an ELF.
bool IsElfFileName(const std::string_view& path); bool IsElfFileName(const std::string_view path);
/// Returns true if the specified path is a blockdump. /// Returns true if the specified path is a blockdump.
bool IsBlockDumpFileName(const std::string_view& path); bool IsBlockDumpFileName(const std::string_view path);
/// Returns true if the specified path is a GS Dump. /// Returns true if the specified path is a GS Dump.
bool IsGSDumpFileName(const std::string_view& path); bool IsGSDumpFileName(const std::string_view path);
/// Returns true if the specified path is a save state. /// Returns true if the specified path is a save state.
bool IsSaveStateFileName(const std::string_view& path); bool IsSaveStateFileName(const std::string_view path);
/// Returns true if the specified path is a disc image. /// Returns true if the specified path is a disc image.
bool IsDiscFileName(const std::string_view& path); bool IsDiscFileName(const std::string_view path);
/// Returns true if the specified path is a disc/elf/etc. /// Returns true if the specified path is a disc/elf/etc.
bool IsLoadableFileName(const std::string_view& path); bool IsLoadableFileName(const std::string_view path);
/// Returns the serial to use when computing the game settings path for the current game. /// Returns the serial to use when computing the game settings path for the current game.
std::string GetSerialForGameSettings(); std::string GetSerialForGameSettings();
/// Returns the path for the game settings ini file for the specified CRC. /// Returns the path for the game settings ini file for the specified CRC.
std::string GetGameSettingsPath(const std::string_view& game_serial, u32 game_crc); std::string GetGameSettingsPath(const std::string_view game_serial, u32 game_crc);
/// Returns the ISO override for an ELF via gamesettings. /// Returns the ISO override for an ELF via gamesettings.
std::string GetDiscOverrideFromGameSettings(const std::string& elf_path); std::string GetDiscOverrideFromGameSettings(const std::string& elf_path);
/// Returns the path for the input profile ini file with the specified name (may not exist). /// Returns the path for the input profile ini file with the specified name (may not exist).
std::string GetInputProfilePath(const std::string_view& name); std::string GetInputProfilePath(const std::string_view name);
/// Returns the path for the debugger settings json file for the specified game serial and CRC. /// Returns the path for the debugger settings json file for the specified game serial and CRC.
std::string GetDebuggerSettingsFilePath(const std::string_view& game_serial, u32 game_crc); std::string GetDebuggerSettingsFilePath(const std::string_view game_serial, u32 game_crc);
/// Returns the path for the debugger settings json file for the current game. /// Returns the path for the debugger settings json file for the current game.
std::string GetDebuggerSettingsFilePathForCurrentGame(); std::string GetDebuggerSettingsFilePathForCurrentGame();
@ -307,14 +307,14 @@ namespace Host
void OnPerformanceMetricsUpdated(); void OnPerformanceMetricsUpdated();
/// Called when a save state is loading, before the file is processed. /// Called when a save state is loading, before the file is processed.
void OnSaveStateLoading(const std::string_view& filename); void OnSaveStateLoading(const std::string_view filename);
/// Called after a save state is successfully loaded. If the save state was invalid, was_successful will be false. /// Called after a save state is successfully loaded. If the save state was invalid, was_successful will be false.
void OnSaveStateLoaded(const std::string_view& filename, bool was_successful); void OnSaveStateLoaded(const std::string_view filename, bool was_successful);
/// Called when a save state is being created/saved. The compression/write to disk is asynchronous, so this callback /// Called when a save state is being created/saved. The compression/write to disk is asynchronous, so this callback
/// just signifies that the save has started, not necessarily completed. /// just signifies that the save has started, not necessarily completed.
void OnSaveStateSaved(const std::string_view& filename); void OnSaveStateSaved(const std::string_view filename);
/// Provided by the host; called when the running executable changes. /// Provided by the host; called when the running executable changes.
void OnGameChanged(const std::string& title, const std::string& elf_override, const std::string& disc_path, void OnGameChanged(const std::string& title, const std::string& elf_override, const std::string& disc_path,

View File

@ -33,20 +33,20 @@ void Host::SetDefaultUISettings(SettingsInterface& si)
{ {
} }
void Host::ReportErrorAsync(const std::string_view& title, const std::string_view& message) void Host::ReportErrorAsync(const std::string_view title, const std::string_view message)
{ {
} }
bool Host::ConfirmMessage(const std::string_view& title, const std::string_view& message) bool Host::ConfirmMessage(const std::string_view title, const std::string_view message)
{ {
return true; return true;
} }
void Host::OpenURL(const std::string_view& url) void Host::OpenURL(const std::string_view url)
{ {
} }
bool Host::CopyTextToClipboard(const std::string_view& text) bool Host::CopyTextToClipboard(const std::string_view text)
{ {
return false; return false;
} }
@ -122,15 +122,15 @@ void Host::OnPerformanceMetricsUpdated()
{ {
} }
void Host::OnSaveStateLoading(const std::string_view& filename) void Host::OnSaveStateLoading(const std::string_view filename)
{ {
} }
void Host::OnSaveStateLoaded(const std::string_view& filename, bool was_successful) void Host::OnSaveStateLoaded(const std::string_view filename, bool was_successful)
{ {
} }
void Host::OnSaveStateSaved(const std::string_view& filename) void Host::OnSaveStateSaved(const std::string_view filename)
{ {
} }
@ -180,7 +180,7 @@ void Host::PumpMessagesOnCPUThread()
} }
s32 Host::Internal::GetTranslatedStringImpl( s32 Host::Internal::GetTranslatedStringImpl(
const std::string_view& context, const std::string_view& msg, char* tbuf, size_t tbuf_space) const std::string_view context, const std::string_view msg, char* tbuf, size_t tbuf_space)
{ {
if (msg.size() > tbuf_space) if (msg.size() > tbuf_space)
return -1; return -1;
@ -243,7 +243,7 @@ void Host::OpenHostFileSelectorAsync(std::string_view title, bool select_directo
callback(std::string()); callback(std::string());
} }
std::optional<u32> InputManager::ConvertHostKeyboardStringToCode(const std::string_view& str) std::optional<u32> InputManager::ConvertHostKeyboardStringToCode(const std::string_view str)
{ {
return std::nullopt; return std::nullopt;
} }