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_ABI_NAMESPACE_START(...)' = '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
#if TOML_WINDOWS_COMPAT
#ifndef _WINDOWS_
extern "C"
{
int __stdcall WideCharToMultiByte(
unsigned int CodePage,
unsigned long dwFlags,
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
{
namespace winapi
{
extern "C"
{
int __stdcall WideCharToMultiByte(unsigned int CodePage, unsigned long dwFlags, 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);
}
}
TOML_API
TOML_EXTERNAL_LINKAGE
std::string narrow(std::wstring_view str) noexcept
@ -225,13 +238,13 @@ TOML_IMPL_NAMESPACE_START
return {};
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
);
if (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;
}
@ -244,11 +257,11 @@ TOML_IMPL_NAMESPACE_START
return {};
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)
{
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;
}

View File

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

View File

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

View File

@ -12021,19 +12021,32 @@ TOML_NAMESPACE_END;
// implementations of windows wide string nonsense
#if TOML_WINDOWS_COMPAT
#ifndef _WINDOWS_
extern "C"
{
int __stdcall WideCharToMultiByte(
unsigned int CodePage,
unsigned long dwFlags,
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
{
namespace winapi
{
extern "C"
{
int __stdcall WideCharToMultiByte(unsigned int CodePage, unsigned long dwFlags, 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);
}
}
TOML_API
TOML_EXTERNAL_LINKAGE
std::string narrow(std::wstring_view str) noexcept
@ -12042,13 +12055,13 @@ TOML_IMPL_NAMESPACE_START
return {};
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
);
if (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;
}
@ -12061,11 +12074,11 @@ TOML_IMPL_NAMESPACE_START
return {};
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)
{
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;
}

View File

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