fix conflict with Windows.h (closes #99)

This commit is contained in:
Mark Gillard 2021-05-14 15:47:35 +03:00
parent dca69453f6
commit c4e00f9a56
6 changed files with 58 additions and 36 deletions

View File

@ -39,7 +39,7 @@ paths = [ 'images' ]
[defines] [macros]
'TOML_ASYMMETRICAL_EQUALITY_OPS(...)' = 'static_assert(true)' 'TOML_ASYMMETRICAL_EQUALITY_OPS(...)' = 'static_assert(true)'
'TOML_ABI_NAMESPACE_START(...)' = 'static_assert(true)' 'TOML_ABI_NAMESPACE_START(...)' = 'static_assert(true)'
'TOML_ABI_NAMESPACE_BOOL(...)' = 'static_assert(true)' 'TOML_ABI_NAMESPACE_BOOL(...)' = 'static_assert(true)'

View File

@ -204,19 +204,32 @@ TOML_NAMESPACE_END;
// implementations of windows wide string nonsense // implementations of windows wide string nonsense
#if TOML_WINDOWS_COMPAT #if TOML_WINDOWS_COMPAT
TOML_IMPL_NAMESPACE_START #ifndef _WINDOWS_
{
namespace winapi
{
extern "C" extern "C"
{ {
int __stdcall WideCharToMultiByte(unsigned int CodePage, unsigned long dwFlags, const wchar_t* lpWideCharStr, int cchWideChar, int __stdcall WideCharToMultiByte(
char* lpMultiByteStr, int cbMultiByte, const char* lpDefaultChar, int* lpUsedDefaultChar); unsigned int CodePage,
int __stdcall MultiByteToWideChar(unsigned int CodePage, unsigned long dwFlags, const char* lpMultiByteStr, int cbMultiByte, unsigned long dwFlags,
wchar_t* lpWideCharStr, int cchWideChar); const wchar_t* lpWideCharStr,
} int cchWideChar,
char* lpMultiByteStr,
int cbMultiByte,
const char* lpDefaultChar,
int* lpUsedDefaultChar
);
int __stdcall MultiByteToWideChar(
unsigned int CodePage,
unsigned long dwFlags,
const char* lpMultiByteStr,
int cbMultiByte,
wchar_t* lpWideCharStr,
int cchWideChar
);
} }
#endif // _WINDOWS_
TOML_IMPL_NAMESPACE_START
{
TOML_API TOML_API
TOML_EXTERNAL_LINKAGE TOML_EXTERNAL_LINKAGE
std::string narrow(std::wstring_view str) noexcept std::string narrow(std::wstring_view str) noexcept
@ -225,13 +238,13 @@ TOML_IMPL_NAMESPACE_START
return {}; return {};
std::string s; std::string s;
const auto len = winapi::WideCharToMultiByte( const auto len = WideCharToMultiByte(
65001, 0, str.data(), static_cast<int>(str.length()), nullptr, 0, nullptr, nullptr 65001, 0, str.data(), static_cast<int>(str.length()), nullptr, 0, nullptr, nullptr
); );
if (len) if (len)
{ {
s.resize(static_cast<size_t>(len)); s.resize(static_cast<size_t>(len));
winapi::WideCharToMultiByte(65001, 0, str.data(), static_cast<int>(str.length()), s.data(), len, nullptr, nullptr); WideCharToMultiByte(65001, 0, str.data(), static_cast<int>(str.length()), s.data(), len, nullptr, nullptr);
} }
return s; return s;
} }
@ -244,11 +257,11 @@ TOML_IMPL_NAMESPACE_START
return {}; return {};
std::wstring s; std::wstring s;
const auto len = winapi::MultiByteToWideChar(65001, 0, str.data(), static_cast<int>(str.length()), nullptr, 0); const auto len = MultiByteToWideChar(65001, 0, str.data(), static_cast<int>(str.length()), nullptr, 0);
if (len) if (len)
{ {
s.resize(static_cast<size_t>(len)); s.resize(static_cast<size_t>(len));
winapi::MultiByteToWideChar(65001, 0, str.data(), static_cast<int>(str.length()), s.data(), len); MultiByteToWideChar(65001, 0, str.data(), static_cast<int>(str.length()), s.data(), len);
} }
return s; return s;
} }

View File

@ -71,7 +71,6 @@
<None Include="CODE_OF_CONDUCT.md" /> <None Include="CODE_OF_CONDUCT.md" />
<None Include="CONTRIBUTING.md" /> <None Include="CONTRIBUTING.md" />
<None Include="cpp.hint" /> <None Include="cpp.hint" />
<None Include="docs\Doxyfile" />
<None Include="docs\pages\main_page.dox" /> <None Include="docs\pages\main_page.dox" />
<None Include="docs\poxy.toml" /> <None Include="docs\poxy.toml" />
<None Include="LICENSE" /> <None Include="LICENSE" />

View File

@ -96,9 +96,6 @@
<None Include=".circleci\config.yml"> <None Include=".circleci\config.yml">
<Filter>.circleci</Filter> <Filter>.circleci</Filter>
</None> </None>
<None Include="docs\Doxyfile">
<Filter>docs</Filter>
</None>
<None Include="tools\ci_single_header_check.py"> <None Include="tools\ci_single_header_check.py">
<Filter>tools</Filter> <Filter>tools</Filter>
</None> </None>

View File

@ -12021,19 +12021,32 @@ TOML_NAMESPACE_END;
// implementations of windows wide string nonsense // implementations of windows wide string nonsense
#if TOML_WINDOWS_COMPAT #if TOML_WINDOWS_COMPAT
TOML_IMPL_NAMESPACE_START #ifndef _WINDOWS_
{
namespace winapi
{
extern "C" extern "C"
{ {
int __stdcall WideCharToMultiByte(unsigned int CodePage, unsigned long dwFlags, const wchar_t* lpWideCharStr, int cchWideChar, int __stdcall WideCharToMultiByte(
char* lpMultiByteStr, int cbMultiByte, const char* lpDefaultChar, int* lpUsedDefaultChar); unsigned int CodePage,
int __stdcall MultiByteToWideChar(unsigned int CodePage, unsigned long dwFlags, const char* lpMultiByteStr, int cbMultiByte, unsigned long dwFlags,
wchar_t* lpWideCharStr, int cchWideChar); const wchar_t* lpWideCharStr,
} int cchWideChar,
char* lpMultiByteStr,
int cbMultiByte,
const char* lpDefaultChar,
int* lpUsedDefaultChar
);
int __stdcall MultiByteToWideChar(
unsigned int CodePage,
unsigned long dwFlags,
const char* lpMultiByteStr,
int cbMultiByte,
wchar_t* lpWideCharStr,
int cchWideChar
);
} }
#endif // _WINDOWS_
TOML_IMPL_NAMESPACE_START
{
TOML_API TOML_API
TOML_EXTERNAL_LINKAGE TOML_EXTERNAL_LINKAGE
std::string narrow(std::wstring_view str) noexcept std::string narrow(std::wstring_view str) noexcept
@ -12042,13 +12055,13 @@ TOML_IMPL_NAMESPACE_START
return {}; return {};
std::string s; std::string s;
const auto len = winapi::WideCharToMultiByte( const auto len = WideCharToMultiByte(
65001, 0, str.data(), static_cast<int>(str.length()), nullptr, 0, nullptr, nullptr 65001, 0, str.data(), static_cast<int>(str.length()), nullptr, 0, nullptr, nullptr
); );
if (len) if (len)
{ {
s.resize(static_cast<size_t>(len)); s.resize(static_cast<size_t>(len));
winapi::WideCharToMultiByte(65001, 0, str.data(), static_cast<int>(str.length()), s.data(), len, nullptr, nullptr); WideCharToMultiByte(65001, 0, str.data(), static_cast<int>(str.length()), s.data(), len, nullptr, nullptr);
} }
return s; return s;
} }
@ -12061,11 +12074,11 @@ TOML_IMPL_NAMESPACE_START
return {}; return {};
std::wstring s; std::wstring s;
const auto len = winapi::MultiByteToWideChar(65001, 0, str.data(), static_cast<int>(str.length()), nullptr, 0); const auto len = MultiByteToWideChar(65001, 0, str.data(), static_cast<int>(str.length()), nullptr, 0);
if (len) if (len)
{ {
s.resize(static_cast<size_t>(len)); s.resize(static_cast<size_t>(len));
winapi::MultiByteToWideChar(65001, 0, str.data(), static_cast<int>(str.length()), s.data(), len); MultiByteToWideChar(65001, 0, str.data(), static_cast<int>(str.length()), s.data(), len);
} }
return s; return s;
} }

View File

@ -1,4 +1,4 @@
misk>=0.4.0 misk>=0.4.0
poxy>=0.3.0 poxy>=0.3.1
pyyaml pyyaml
python-dateutil python-dateutil