Use string_view value names for registry

This commit is contained in:
Sajid 2025-01-28 16:01:12 +06:00
parent 4094690282
commit c5802ae0cb
4 changed files with 10 additions and 9 deletions

View file

@ -298,6 +298,7 @@ endif()
if (UNLEASHED_RECOMP_FLATPAK)
target_compile_definitions(UnleashedRecomp PRIVATE "GAME_INSTALL_DIRECTORY=\"/var/data\"")
target_compile_definitions(UnleashedRecomp PRIVATE "UNLEASHED_RECOMP_FLATPAK")
endif()
if (UNLEASHED_RECOMP_D3D12)

View file

@ -8,14 +8,14 @@ inline bool os::registry::Init()
// TODO: read from file?
template<typename T>
bool os::registry::ReadValue(const std::filesystem::path& path, const std::string& name, T& data)
bool os::registry::ReadValue(const std::string_view& name, T& data)
{
return false;
}
// TODO: write to file?
template<typename T>
bool os::registry::WriteValue(const std::filesystem::path& path, const std::string& name, const T& data)
bool os::registry::WriteValue(const std::string_view& name, const T& data)
{
return false;
}

View file

@ -5,10 +5,10 @@ namespace os::registry
bool Init();
template<typename T>
bool ReadValue(const std::string& name, T& data);
bool ReadValue(const std::string_view& name, T& data);
template<typename T>
bool WriteValue(const std::string& name, const T& data);
bool WriteValue(const std::string_view& name, const T& data);
}
#if _WIN32

View file

@ -9,7 +9,7 @@ inline bool os::registry::Init()
}
template<typename T>
bool os::registry::ReadValue(const std::string& name, T& data)
bool os::registry::ReadValue(const std::string_view& name, T& data)
{
HKEY hKey;
@ -17,7 +17,7 @@ bool os::registry::ReadValue(const std::string& name, T& data)
return false;
wchar_t wideName[128];
int wideNameSize = MultiByteToWideChar(CP_UTF8, 0, name.c_str(), name.size(), wideName, sizeof(wideName));
int wideNameSize = MultiByteToWideChar(CP_UTF8, 0, name.data(), name.size(), wideName, sizeof(wideName));
if (wideNameSize == 0)
{
return false;
@ -90,7 +90,7 @@ bool os::registry::ReadValue(const std::string& name, T& data)
}
template<typename T>
bool os::registry::WriteValue(const std::string& name, const T& data)
bool os::registry::WriteValue(const std::string_view& name, const T& data)
{
HKEY hKey;
@ -136,7 +136,7 @@ bool os::registry::WriteValue(const std::string& name, const T& data)
if (wideString)
{
wchar_t wideName[128];
int wideNameSize = MultiByteToWideChar(CP_UTF8, 0, name.c_str(), name.size(), wideName, sizeof(wideName));
int wideNameSize = MultiByteToWideChar(CP_UTF8, 0, name.data(), name.size(), wideName, sizeof(wideName));
if (wideNameSize == 0)
{
return false;
@ -147,7 +147,7 @@ bool os::registry::WriteValue(const std::string& name, const T& data)
}
else
{
result = RegSetValueExA(hKey, name.c_str(), 0, dataType, pData, dataSize);
result = RegSetValueExA(hKey, name.data(), 0, dataType, pData, dataSize);
}
RegCloseKey(hKey);