refactor: move Platform

This commit is contained in:
Horror Proton
2022-10-13 11:12:25 +08:00
parent 8c43b77abc
commit ac7bd7fbb0
4 changed files with 37 additions and 27 deletions

View File

@@ -125,6 +125,7 @@
<ClInclude Include="Utils\AsstRanges.hpp" />
<ClInclude Include="Utils\AsstTypes.h" />
<ClInclude Include="Utils\AsstUtils.hpp" />
<ClInclude Include="Utils\Platform.hpp" />
<ClInclude Include="Utils\Locale.hpp" />
<ClInclude Include="Utils\Demangle.hpp" />
<ClInclude Include="Utils\Meta.hpp" />

View File

@@ -617,6 +617,9 @@
<ClInclude Include="Utils\AsstHttp.hpp">
<Filter>源文件\Utils</Filter>
</ClInclude>
<ClInclude Include="Utils\Platform.hpp">
<Filter>源文件\Utils</Filter>
</ClInclude>
<ClInclude Include="Utils\AsstImageIo.hpp">
<Filter>源文件\Utils</Filter>
</ClInclude>

View File

@@ -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<os_string, std::wstring>);
#else
static_assert(std::same_as<os_string, std::string>);
#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

View File

@@ -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<os_string, std::wstring>);
#else
static_assert(std::same_as<os_string, std::string>);
#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