2
0
mirror of https://github.com/boostorg/log.git synced 2026-02-01 08:32:15 +00:00

Updated Boost.WinAPI usage to the new location and namespace.

This commit is contained in:
Andrey Semashev
2017-10-24 22:55:48 +03:00
parent 4241a27775
commit 19973d0488
16 changed files with 231 additions and 232 deletions

View File

@@ -24,8 +24,8 @@
#if defined(BOOST_WINDOWS)
#include <cstring>
#include <limits>
#include <boost/detail/winapi/get_last_error.hpp>
#include <boost/detail/winapi/character_code_conversion.hpp>
#include <boost/winapi/get_last_error.hpp>
#include <boost/winapi/character_code_conversion.hpp>
#endif
#include <boost/log/detail/header.hpp>
@@ -236,20 +236,20 @@ std::wstring utf8_to_utf16(const char* str)
else if (BOOST_UNLIKELY(utf8_len > static_cast< std::size_t >((std::numeric_limits< int >::max)())))
BOOST_LOG_THROW_DESCR(bad_alloc, "UTF-8 string too long");
int len = boost::detail::winapi::MultiByteToWideChar(boost::detail::winapi::CP_UTF8_, boost::detail::winapi::MB_ERR_INVALID_CHARS_, str, static_cast< int >(utf8_len), NULL, 0);
int len = boost::winapi::MultiByteToWideChar(boost::winapi::CP_UTF8_, boost::winapi::MB_ERR_INVALID_CHARS_, str, static_cast< int >(utf8_len), NULL, 0);
if (BOOST_LIKELY(len > 0))
{
std::wstring wstr;
wstr.resize(len);
len = boost::detail::winapi::MultiByteToWideChar(boost::detail::winapi::CP_UTF8_, boost::detail::winapi::MB_ERR_INVALID_CHARS_, str, static_cast< int >(utf8_len), &wstr[0], len);
len = boost::winapi::MultiByteToWideChar(boost::winapi::CP_UTF8_, boost::winapi::MB_ERR_INVALID_CHARS_, str, static_cast< int >(utf8_len), &wstr[0], len);
if (BOOST_LIKELY(len > 0))
{
return wstr;
}
}
const boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError();
const boost::winapi::DWORD_ err = boost::winapi::GetLastError();
BOOST_LOG_THROW_DESCR_PARAMS(system_error, "Failed to convert UTF-8 to UTF-16", (err));
BOOST_LOG_UNREACHABLE_RETURN(std::wstring());
}
@@ -263,26 +263,26 @@ std::string utf16_to_utf8(const wchar_t* wstr)
else if (BOOST_UNLIKELY(utf16_len > static_cast< std::size_t >((std::numeric_limits< int >::max)())))
BOOST_LOG_THROW_DESCR(bad_alloc, "UTF-16 string too long");
const boost::detail::winapi::DWORD_ flags =
const boost::winapi::DWORD_ flags =
#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
boost::detail::winapi::WC_ERR_INVALID_CHARS_;
boost::winapi::WC_ERR_INVALID_CHARS_;
#else
0u;
#endif
int len = boost::detail::winapi::WideCharToMultiByte(boost::detail::winapi::CP_UTF8_, flags, wstr, static_cast< int >(utf16_len), NULL, 0, NULL, NULL);
int len = boost::winapi::WideCharToMultiByte(boost::winapi::CP_UTF8_, flags, wstr, static_cast< int >(utf16_len), NULL, 0, NULL, NULL);
if (BOOST_LIKELY(len > 0))
{
std::string str;
str.resize(len);
len = boost::detail::winapi::WideCharToMultiByte(boost::detail::winapi::CP_UTF8_, flags, wstr, static_cast< int >(utf16_len), &str[0], len, NULL, NULL);
len = boost::winapi::WideCharToMultiByte(boost::winapi::CP_UTF8_, flags, wstr, static_cast< int >(utf16_len), &str[0], len, NULL, NULL);
if (BOOST_LIKELY(len > 0))
{
return str;
}
}
const boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError();
const boost::winapi::DWORD_ err = boost::winapi::GetLastError();
BOOST_LOG_THROW_DESCR_PARAMS(system_error, "Failed to convert UTF-16 to UTF-8", (err));
BOOST_LOG_UNREACHABLE_RETURN(std::string());
}