mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-19 03:33:56 +00:00
Add basic_string_view overload for utils::string::copy
This commit is contained in:
@@ -30,6 +30,21 @@ namespace utils::string
|
||||
array[std::min(Size - 1, size)] = {};
|
||||
}
|
||||
|
||||
template <typename T, size_t Size, class Traits = std::char_traits<T>>
|
||||
requires(std::is_trivially_copyable_v<T>)
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
|
||||
void copy(T (&array)[Size], const std::basic_string_view<T, Traits> str)
|
||||
{
|
||||
if constexpr (Size == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const auto size = std::min(Size - 1, str.size());
|
||||
memcpy(array, str.data(), size * sizeof(T));
|
||||
array[size] = {};
|
||||
}
|
||||
|
||||
inline char char_to_lower(const char val)
|
||||
{
|
||||
return static_cast<char>(std::tolower(static_cast<unsigned char>(val)));
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "std_include.hpp"
|
||||
#include "kusd_mmio.hpp"
|
||||
#include <utils/time.hpp>
|
||||
#include <utils/string.hpp>
|
||||
#include "windows_emulator.hpp"
|
||||
#include "version/windows_version_manager.hpp"
|
||||
|
||||
@@ -83,9 +84,7 @@ namespace
|
||||
kusd.ProcessorFeatures.arr[PF_RDPID_INSTRUCTION_AVAILABLE] = 0;
|
||||
|
||||
const auto& system_root = version.get_system_root();
|
||||
const auto& root_str = system_root.u16string();
|
||||
const auto copy_size = std::min(root_str.size() * sizeof(char16_t), sizeof(kusd.NtSystemRoot.arr) - sizeof(char16_t));
|
||||
memcpy(&kusd.NtSystemRoot.arr[0], root_str.data(), copy_size);
|
||||
utils::string::copy(kusd.NtSystemRoot.arr, std::u16string_view{system_root.u16string()});
|
||||
|
||||
kusd.ImageNumberLow = IMAGE_FILE_MACHINE_AMD64;
|
||||
kusd.ImageNumberHigh = IMAGE_FILE_MACHINE_AMD64;
|
||||
|
||||
Reference in New Issue
Block a user