mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-11 14:44:36 +00:00
update openal
This commit is contained in:
parent
62f3b93ff9
commit
6721a6b021
287 changed files with 33851 additions and 27325 deletions
|
|
@ -5,36 +5,37 @@
|
|||
|
||||
#include <cstdlib>
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
std::string wstr_to_utf8(const WCHAR *wstr)
|
||||
#include "alstring.h"
|
||||
|
||||
std::string wstr_to_utf8(std::wstring_view wstr)
|
||||
{
|
||||
std::string ret;
|
||||
|
||||
int len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, nullptr, 0, nullptr, nullptr);
|
||||
const int len{WideCharToMultiByte(CP_UTF8, 0, wstr.data(), al::sizei(wstr), nullptr, 0,
|
||||
nullptr, nullptr)};
|
||||
if(len > 0)
|
||||
{
|
||||
ret.resize(len);
|
||||
WideCharToMultiByte(CP_UTF8, 0, wstr, -1, &ret[0], len, nullptr, nullptr);
|
||||
ret.pop_back();
|
||||
ret.resize(static_cast<size_t>(len));
|
||||
WideCharToMultiByte(CP_UTF8, 0, wstr.data(), al::sizei(wstr), ret.data(), len,
|
||||
nullptr, nullptr);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::wstring utf8_to_wstr(const char *str)
|
||||
std::wstring utf8_to_wstr(std::string_view str)
|
||||
{
|
||||
std::wstring ret;
|
||||
|
||||
int len = MultiByteToWideChar(CP_UTF8, 0, str, -1, nullptr, 0);
|
||||
const int len{MultiByteToWideChar(CP_UTF8, 0, str.data(), al::sizei(str), nullptr, 0)};
|
||||
if(len > 0)
|
||||
{
|
||||
ret.resize(len);
|
||||
MultiByteToWideChar(CP_UTF8, 0, str, -1, &ret[0], len);
|
||||
ret.pop_back();
|
||||
ret.resize(static_cast<size_t>(len));
|
||||
MultiByteToWideChar(CP_UTF8, 0, str.data(), al::sizei(str), ret.data(), len);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
@ -43,21 +44,25 @@ std::wstring utf8_to_wstr(const char *str)
|
|||
|
||||
namespace al {
|
||||
|
||||
al::optional<std::string> getenv(const char *envname)
|
||||
std::optional<std::string> getenv(const char *envname)
|
||||
{
|
||||
#ifdef _GAMING_XBOX
|
||||
const char *str{::getenv(envname)};
|
||||
#else
|
||||
const char *str{std::getenv(envname)};
|
||||
if(str && str[0] != '\0')
|
||||
#endif
|
||||
if(str && *str != '\0')
|
||||
return str;
|
||||
return al::nullopt;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
al::optional<std::wstring> getenv(const WCHAR *envname)
|
||||
std::optional<std::wstring> getenv(const WCHAR *envname)
|
||||
{
|
||||
const WCHAR *str{_wgetenv(envname)};
|
||||
if(str && str[0] != L'\0')
|
||||
if(str && *str != L'\0')
|
||||
return str;
|
||||
return al::nullopt;
|
||||
return std::nullopt;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue