From ac7bd7fbb0826da652c478a46600a4bdd873131a Mon Sep 17 00:00:00 2001 From: Horror Proton <107091537+horror-proton@users.noreply.github.com> Date: Thu, 13 Oct 2022 11:12:25 +0800 Subject: [PATCH] refactor: move Platform --- src/MeoAssistant/MeoAssistant.vcxproj | 1 + src/MeoAssistant/MeoAssistant.vcxproj.filters | 3 ++ src/MeoAssistant/Utils/AsstUtils.hpp | 27 --------------- src/MeoAssistant/Utils/Platform.hpp | 33 +++++++++++++++++++ 4 files changed, 37 insertions(+), 27 deletions(-) create mode 100644 src/MeoAssistant/Utils/Platform.hpp diff --git a/src/MeoAssistant/MeoAssistant.vcxproj b/src/MeoAssistant/MeoAssistant.vcxproj index 6a08470636..7592874dbc 100644 --- a/src/MeoAssistant/MeoAssistant.vcxproj +++ b/src/MeoAssistant/MeoAssistant.vcxproj @@ -125,6 +125,7 @@ + diff --git a/src/MeoAssistant/MeoAssistant.vcxproj.filters b/src/MeoAssistant/MeoAssistant.vcxproj.filters index ff344180b6..425b84647d 100644 --- a/src/MeoAssistant/MeoAssistant.vcxproj.filters +++ b/src/MeoAssistant/MeoAssistant.vcxproj.filters @@ -617,6 +617,9 @@ 源文件\Utils + + 源文件\Utils + 源文件\Utils diff --git a/src/MeoAssistant/Utils/AsstUtils.hpp b/src/MeoAssistant/Utils/AsstUtils.hpp index 51f1b21acf..7ec91d9759 100644 --- a/src/MeoAssistant/Utils/AsstUtils.hpp +++ b/src/MeoAssistant/Utils/AsstUtils.hpp @@ -49,31 +49,4 @@ namespace asst::utils #endif // END _WIN32 return buff; } - - using os_string = platform::os_string; - -#ifdef _WIN32 - static_assert(std::same_as); -#else - static_assert(std::same_as); -#endif - - using platform::from_osstring; - using platform::path; - using platform::path_to_ansi_string; - using platform::path_to_crt_string; - using platform::path_to_utf8_string; - using platform::to_osstring; - - using platform::callcmd; - - namespace path_literals - { - inline std::filesystem::path operator"" _p(const char* utf8_str, size_t len) - { - // 日后再优化( - return asst::utils::path(std::string(std::string_view(utf8_str, len))); - } - } - } // namespace asst::utils diff --git a/src/MeoAssistant/Utils/Platform.hpp b/src/MeoAssistant/Utils/Platform.hpp new file mode 100644 index 0000000000..a6af922693 --- /dev/null +++ b/src/MeoAssistant/Utils/Platform.hpp @@ -0,0 +1,33 @@ +#pragma once + +#include "Platform/AsstPlatform.h" + +namespace asst::utils +{ + using os_string = platform::os_string; + +#ifdef _WIN32 + static_assert(std::same_as); +#else + static_assert(std::same_as); +#endif + + using platform::from_osstring; + using platform::path; + using platform::path_to_ansi_string; + using platform::path_to_crt_string; + using platform::path_to_utf8_string; + using platform::to_osstring; + + using platform::callcmd; + + namespace path_literals + { + inline std::filesystem::path operator"" _p(const char* utf8_str, size_t len) + { + // 日后再优化( + return asst::utils::path(std::string(std::string_view(utf8_str, len))); + } + } + +} // namespace asst::utils