Add unity build support
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace
|
||||
namespace NAZARA_ANONYMOUS_NAMESPACE
|
||||
{
|
||||
const char* errorType[] = {
|
||||
"Assert failed: ", // ErrorType::AssertFailed
|
||||
@@ -41,6 +41,8 @@ namespace Nz
|
||||
*/
|
||||
void AbstractLogger::WriteError(ErrorType type, const std::string_view& error, unsigned int line, const char* file, const char* function)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
std::ostringstream ss;
|
||||
ss << errorType[UnderlyingCast(type)] << error;
|
||||
|
||||
|
||||
9
src/Nazara/Core/AntiWindows.hpp
Normal file
9
src/Nazara/Core/AntiWindows.hpp
Normal file
@@ -0,0 +1,9 @@
|
||||
// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#ifndef _WINDOWS_
|
||||
#error This header should only be included after including windows.h directly or indirectly in a .cpp
|
||||
#endif
|
||||
|
||||
#undef RemoveDirectory
|
||||
10
src/Nazara/Core/AntiX11.hpp
Normal file
10
src/Nazara/Core/AntiX11.hpp
Normal file
@@ -0,0 +1,10 @@
|
||||
// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#ifndef _X11_XLIB_H_
|
||||
#error This header should only be included after including X11/Xlib.h directly or indirectly in a .cpp
|
||||
#endif
|
||||
|
||||
#undef Bool
|
||||
#undef None
|
||||
@@ -99,3 +99,8 @@ namespace Nz
|
||||
|
||||
DynLib& DynLib::operator=(DynLib&&) noexcept = default;
|
||||
}
|
||||
|
||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||
#include <Nazara/Core/AntiWindows.hpp>
|
||||
#endif
|
||||
|
||||
|
||||
@@ -203,3 +203,7 @@ namespace Nz
|
||||
const char* Error::s_lastErrorFile = "";
|
||||
unsigned int Error::s_lastErrorLine = 0;
|
||||
}
|
||||
|
||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||
#include <Nazara/Core/AntiWindows.hpp>
|
||||
#endif
|
||||
|
||||
@@ -452,3 +452,8 @@ namespace Nz
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||
#include <Nazara/Core/AntiWindows.hpp>
|
||||
#endif
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Nz
|
||||
* \brief Core class that represents the "Guillotine problem", combination of the "Bin packing problem" and the "cutting stock"
|
||||
*/
|
||||
|
||||
namespace
|
||||
namespace NAZARA_ANONYMOUS_NAMESPACE
|
||||
{
|
||||
/*!
|
||||
* \brief Gets the score for fitting the area
|
||||
@@ -635,6 +635,8 @@ namespace Nz
|
||||
|
||||
int GuillotineBinPack::ScoreByHeuristic(int width, int height, const Rectui& freeRect, FreeRectChoiceHeuristic rectChoice)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
switch (rectChoice)
|
||||
{
|
||||
case RectBestAreaFit:
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace
|
||||
namespace NAZARA_ANONYMOUS_NAMESPACE
|
||||
{
|
||||
struct VendorString
|
||||
{
|
||||
@@ -108,6 +108,8 @@ namespace Nz
|
||||
|
||||
std::string_view HardwareInfo::GetProcessorBrandString()
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
if (!Initialize())
|
||||
NazaraError("Failed to initialize HardwareInfo");
|
||||
|
||||
@@ -136,6 +138,8 @@ namespace Nz
|
||||
|
||||
ProcessorVendor HardwareInfo::GetProcessorVendor()
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
if (!Initialize())
|
||||
NazaraError("Failed to initialize HardwareInfo");
|
||||
|
||||
@@ -151,6 +155,8 @@ namespace Nz
|
||||
|
||||
std::string_view HardwareInfo::GetProcessorVendorName()
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
if (!Initialize())
|
||||
NazaraError("Failed to initialize HardwareInfo");
|
||||
|
||||
@@ -179,6 +185,8 @@ namespace Nz
|
||||
|
||||
bool HardwareInfo::HasCapability(ProcessorCap capability)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
return s_capabilities[UnderlyingCast(capability)];
|
||||
}
|
||||
|
||||
@@ -191,6 +199,8 @@ namespace Nz
|
||||
|
||||
bool HardwareInfo::Initialize()
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
if (IsInitialized())
|
||||
return true;
|
||||
|
||||
@@ -294,6 +304,8 @@ namespace Nz
|
||||
|
||||
bool HardwareInfo::IsInitialized()
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
return s_initialized;
|
||||
}
|
||||
|
||||
@@ -303,6 +315,8 @@ namespace Nz
|
||||
|
||||
void HardwareInfo::Uninitialize()
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
// Nothing to do
|
||||
s_initialized = false;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace
|
||||
namespace NAZARA_ANONYMOUS_NAMESPACE
|
||||
{
|
||||
UInt32 crc32_reflect(UInt32 ref, unsigned int j)
|
||||
{
|
||||
@@ -63,6 +63,8 @@ namespace Nz
|
||||
|
||||
CRC32Hash::CRC32Hash(UInt32 polynomial)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
if (polynomial == DefaultPolynomial)
|
||||
m_table = crc32_table;
|
||||
else
|
||||
@@ -84,6 +86,8 @@ namespace Nz
|
||||
|
||||
CRC32Hash::~CRC32Hash()
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
if (m_table != crc32_table)
|
||||
delete[] m_table;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace
|
||||
namespace NAZARA_ANONYMOUS_NAMESPACE
|
||||
{
|
||||
static const UInt64 crc64_table[] = {
|
||||
0x0000000000000000ULL, 0x42F0E1EBA9EA3693ULL, 0x85E1C3D753D46D26ULL, 0xC711223CFA3E5BB5ULL,
|
||||
@@ -80,6 +80,8 @@ namespace Nz
|
||||
|
||||
void CRC64Hash::Append(const UInt8* data, std::size_t len)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
while (len--)
|
||||
m_crc = (m_crc << 8) ^ crc64_table[((m_crc >> 56) ^ *data++) & 0xFF];
|
||||
}
|
||||
|
||||
@@ -254,6 +254,7 @@ namespace Nz
|
||||
SET(c, d, a, b, 14, 17, T15);
|
||||
SET(b, c, d, a, 15, 22, T16);
|
||||
#undef SET
|
||||
#undef F
|
||||
|
||||
/* Round 2. */
|
||||
/* Let [abcd k s i] denote the operation
|
||||
@@ -280,6 +281,7 @@ namespace Nz
|
||||
SET(c, d, a, b, 7, 14, T31);
|
||||
SET(b, c, d, a, 12, 20, T32);
|
||||
#undef SET
|
||||
#undef G
|
||||
|
||||
/* Round 3. */
|
||||
/* Let [abcd k s t] denote the operation
|
||||
@@ -306,6 +308,7 @@ namespace Nz
|
||||
SET(c, d, a, b, 15, 16, T47);
|
||||
SET(b, c, d, a, 2, 23, T48);
|
||||
#undef SET
|
||||
#undef H
|
||||
|
||||
/* Round 4. */
|
||||
/* Let [abcd k s t] denote the operation
|
||||
@@ -332,6 +335,9 @@ namespace Nz
|
||||
SET(c, d, a, b, 2, 15, T63);
|
||||
SET(b, c, d, a, 9, 21, T64);
|
||||
#undef SET
|
||||
#undef I
|
||||
|
||||
#undef ROTATE_LEFT
|
||||
|
||||
/* Then perform the following additions. (That is increment each
|
||||
of the four registers by the value it had before this block
|
||||
@@ -342,3 +348,69 @@ namespace Nz
|
||||
m_abcd[3] += d;
|
||||
}
|
||||
}
|
||||
|
||||
#undef T_MASK
|
||||
#undef T1
|
||||
#undef T2
|
||||
#undef T3
|
||||
#undef T4
|
||||
#undef T5
|
||||
#undef T6
|
||||
#undef T7
|
||||
#undef T8
|
||||
#undef T9
|
||||
#undef T10
|
||||
#undef T11
|
||||
#undef T12
|
||||
#undef T13
|
||||
#undef T14
|
||||
#undef T15
|
||||
#undef T16
|
||||
#undef T17
|
||||
#undef T18
|
||||
#undef T19
|
||||
#undef T20
|
||||
#undef T21
|
||||
#undef T22
|
||||
#undef T23
|
||||
#undef T24
|
||||
#undef T25
|
||||
#undef T26
|
||||
#undef T27
|
||||
#undef T28
|
||||
#undef T29
|
||||
#undef T30
|
||||
#undef T31
|
||||
#undef T32
|
||||
#undef T33
|
||||
#undef T34
|
||||
#undef T35
|
||||
#undef T36
|
||||
#undef T37
|
||||
#undef T38
|
||||
#undef T39
|
||||
#undef T40
|
||||
#undef T41
|
||||
#undef T42
|
||||
#undef T43
|
||||
#undef T44
|
||||
#undef T45
|
||||
#undef T46
|
||||
#undef T47
|
||||
#undef T48
|
||||
#undef T49
|
||||
#undef T50
|
||||
#undef T51
|
||||
#undef T52
|
||||
#undef T53
|
||||
#undef T54
|
||||
#undef T55
|
||||
#undef T56
|
||||
#undef T57
|
||||
#undef T58
|
||||
#undef T59
|
||||
#undef T60
|
||||
#undef T61
|
||||
#undef T62
|
||||
#undef T63
|
||||
#undef T64
|
||||
|
||||
@@ -1062,3 +1062,35 @@ namespace Nz
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#undef ADDINC128
|
||||
#undef K1_0_TO_19
|
||||
#undef K1_20_TO_39
|
||||
#undef K1_40_TO_59
|
||||
#undef K1_60_TO_79
|
||||
#undef REVERSE32
|
||||
#undef REVERSE64
|
||||
#undef ROUND1_0_TO_15
|
||||
#undef ROUND1_16_TO_19
|
||||
#undef ROUND1_20_TO_39
|
||||
#undef ROUND1_40_TO_59
|
||||
#undef ROUND1_60_TO_79
|
||||
#undef ROUND256
|
||||
#undef ROUND256_0_TO_15
|
||||
#undef ROUND512
|
||||
#undef ROUND512_0_TO_15
|
||||
#undef SHR
|
||||
#undef ROTL32
|
||||
#undef ROTR32
|
||||
#undef ROTR64
|
||||
#undef Ch
|
||||
#undef Maj
|
||||
#undef Parity
|
||||
#undef Sigma0_256
|
||||
#undef Sigma1_256
|
||||
#undef sigma0_256
|
||||
#undef sigma1_256
|
||||
#undef Sigma0_512
|
||||
#undef Sigma1_512
|
||||
#undef sigma0_512
|
||||
#undef sigma1_512
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace
|
||||
namespace NAZARA_ANONYMOUS_NAMESPACE
|
||||
{
|
||||
const UInt64 C0[256] = {
|
||||
0X18186018C07830D8ULL, 0X23238C2305AF4626ULL, 0XC6C63FC67EF991B8ULL, 0XE8E887E8136FCDFBULL,
|
||||
@@ -788,6 +788,8 @@ namespace Nz
|
||||
|
||||
void WhirlpoolHash::ProcessBuffer()
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
int i, r;
|
||||
UInt64 K[8]; // the round key
|
||||
UInt64 block[8]; // mu(buffer)
|
||||
@@ -1020,3 +1022,8 @@ namespace Nz
|
||||
m_hash[7] ^= state[7] ^ block[7];
|
||||
}
|
||||
}
|
||||
|
||||
#undef ONE64
|
||||
#undef ROTR64
|
||||
#undef R
|
||||
#undef T64
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace
|
||||
namespace NAZARA_ANONYMOUS_NAMESPACE
|
||||
{
|
||||
StdLogger s_stdLogger;
|
||||
}
|
||||
@@ -60,6 +60,8 @@ namespace Nz
|
||||
|
||||
void Log::SetLogger(AbstractLogger* logger)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
if (s_logger != &s_stdLogger)
|
||||
delete s_logger;
|
||||
|
||||
@@ -111,6 +113,8 @@ namespace Nz
|
||||
|
||||
bool Log::Initialize()
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
if (s_logger == &s_stdLogger)
|
||||
SetLogger(new FileLogger());
|
||||
|
||||
@@ -129,6 +133,6 @@ namespace Nz
|
||||
NazaraStaticSignalImpl(Log, OnLogWrite);
|
||||
NazaraStaticSignalImpl(Log, OnLogWriteError);
|
||||
|
||||
AbstractLogger* Log::s_logger = &s_stdLogger;
|
||||
AbstractLogger* Log::s_logger = &NAZARA_ANONYMOUS_NAMESPACE_PREFIX(s_stdLogger);
|
||||
bool Log::s_enabled = true;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace
|
||||
namespace NAZARA_ANONYMOUS_NAMESPACE
|
||||
{
|
||||
constexpr unsigned int s_allocatedId = 0xDEADB33FUL;
|
||||
constexpr unsigned int s_freedId = 0x4B1DUL;
|
||||
@@ -102,6 +102,8 @@ namespace Nz
|
||||
|
||||
void* MemoryManager::Allocate(std::size_t size, bool multi, const char* file, unsigned int line)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
if (!s_initialized)
|
||||
Initialize();
|
||||
|
||||
@@ -182,6 +184,8 @@ namespace Nz
|
||||
|
||||
void MemoryManager::EnableAllocationFilling(bool allocationFilling)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
s_allocationFilling = allocationFilling;
|
||||
}
|
||||
|
||||
@@ -193,6 +197,8 @@ namespace Nz
|
||||
|
||||
void MemoryManager::EnableAllocationLogging(bool logAllocations)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
s_allocationLogging = logAllocations;
|
||||
}
|
||||
|
||||
@@ -207,6 +213,8 @@ namespace Nz
|
||||
|
||||
void MemoryManager::Free(void* pointer, bool multi)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
if (!pointer)
|
||||
return;
|
||||
|
||||
@@ -282,6 +290,8 @@ namespace Nz
|
||||
|
||||
unsigned int MemoryManager::GetAllocatedBlockCount()
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
return s_allocatedBlock;
|
||||
}
|
||||
|
||||
@@ -292,6 +302,8 @@ namespace Nz
|
||||
|
||||
std::size_t MemoryManager::GetAllocatedSize()
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
return s_allocatedSize;
|
||||
}
|
||||
|
||||
@@ -302,6 +314,8 @@ namespace Nz
|
||||
|
||||
unsigned int MemoryManager::GetAllocationCount()
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
return s_allocationCount;
|
||||
}
|
||||
|
||||
@@ -312,6 +326,8 @@ namespace Nz
|
||||
|
||||
bool MemoryManager::IsAllocationFillingEnabled()
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
return s_allocationFilling;
|
||||
}
|
||||
|
||||
@@ -322,6 +338,8 @@ namespace Nz
|
||||
|
||||
bool MemoryManager::IsAllocationLoggingEnabled()
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
return s_allocationLogging;
|
||||
}
|
||||
|
||||
@@ -334,6 +352,8 @@ namespace Nz
|
||||
|
||||
void MemoryManager::NextFree(const char* file, unsigned int line)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
s_nextFreeFile = file;
|
||||
s_nextFreeLine = line;
|
||||
}
|
||||
@@ -344,6 +364,8 @@ namespace Nz
|
||||
|
||||
void MemoryManager::Initialize()
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
char timeStr[23];
|
||||
TimeInfo(timeStr);
|
||||
|
||||
@@ -384,6 +406,8 @@ namespace Nz
|
||||
|
||||
void MemoryManager::Uninitialize()
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
#ifdef NAZARA_PLATFORM_WINDOWS
|
||||
DeleteCriticalSection(&s_mutex);
|
||||
#elif defined(NAZARA_PLATFORM_POSIX)
|
||||
@@ -430,3 +454,7 @@ namespace Nz
|
||||
std::fclose(log);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||
#include <Nazara/Core/AntiWindows.hpp>
|
||||
#endif
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace
|
||||
namespace NAZARA_ANONYMOUS_NAMESPACE
|
||||
{
|
||||
using PluginLoad = int (*)();
|
||||
using PluginUnload = void (*)();
|
||||
@@ -78,6 +78,8 @@ namespace Nz
|
||||
|
||||
bool PluginManager::Mount(Plugin plugin)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
std::filesystem::path pluginName = s_pluginFiles[UnderlyingCast(plugin)];
|
||||
|
||||
#ifdef NAZARA_DEBUG
|
||||
@@ -107,6 +109,8 @@ namespace Nz
|
||||
|
||||
bool PluginManager::Mount(const std::filesystem::path& pluginPath, bool appendExtension)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
if (!Initialize())
|
||||
{
|
||||
NazaraError("Failed to initialize PluginManager");
|
||||
@@ -176,6 +180,8 @@ namespace Nz
|
||||
|
||||
void PluginManager::RemoveDirectory(const std::filesystem::path& directoryPath)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
if (!Initialize())
|
||||
{
|
||||
NazaraError("Failed to initialize PluginManager");
|
||||
@@ -196,6 +202,8 @@ namespace Nz
|
||||
|
||||
void PluginManager::Unmount(Plugin plugin)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
Unmount(s_pluginFiles[UnderlyingCast(plugin)]);
|
||||
}
|
||||
|
||||
@@ -210,6 +218,8 @@ namespace Nz
|
||||
|
||||
void PluginManager::Unmount(const std::filesystem::path& pluginPath)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
if (!Initialize())
|
||||
{
|
||||
NazaraError("Failed to initialize PluginManager");
|
||||
@@ -237,6 +247,8 @@ namespace Nz
|
||||
|
||||
void PluginManager::Uninitialize()
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
if (!s_initialized)
|
||||
return;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace
|
||||
namespace NAZARA_ANONYMOUS_NAMESPACE
|
||||
{
|
||||
const char* errorType[] = {
|
||||
"Assert failed", // ErrorType::AssertFailed
|
||||
@@ -81,6 +81,8 @@ namespace Nz
|
||||
|
||||
void StdLogger::WriteError(ErrorType type, const std::string_view& error, unsigned int line, const char* file, const char* function)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
fprintf(stderr, "%s: ", errorType[UnderlyingCast(type)]);
|
||||
fwrite(error.data(), sizeof(char), error.size(), stdout);
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace
|
||||
namespace NAZARA_ANONYMOUS_NAMESPACE
|
||||
{
|
||||
bool IsSpace(char32_t character)
|
||||
{
|
||||
@@ -115,6 +115,8 @@ namespace Nz
|
||||
|
||||
std::string FromWideString(const std::wstring_view& wstr)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
return WideConverter<sizeof(wchar_t)>::From(wstr.data(), wstr.size());
|
||||
}
|
||||
|
||||
@@ -163,6 +165,8 @@ namespace Nz
|
||||
|
||||
std::string_view GetWord(const std::string_view& str, std::size_t wordIndex, UnicodeAware)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
utf8::unchecked::iterator<const char*> it(str.data());
|
||||
utf8::unchecked::iterator<const char*> end(str.data() + str.size());
|
||||
|
||||
@@ -254,6 +258,8 @@ namespace Nz
|
||||
|
||||
bool StartsWith(const std::string_view& lhs, const std::string_view& rhs, CaseIndependent)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
if (rhs.size() > lhs.size())
|
||||
return false;
|
||||
|
||||
@@ -343,6 +349,8 @@ namespace Nz
|
||||
|
||||
std::string ToLower(const std::string_view& str)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
std::string result;
|
||||
result.reserve(str.size());
|
||||
std::transform(str.begin(), str.end(), std::back_inserter(result), Overload<char>(ToLower));
|
||||
@@ -368,6 +376,8 @@ namespace Nz
|
||||
|
||||
std::string ToUpper(const std::string_view& str)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
std::string result;
|
||||
result.reserve(str.size());
|
||||
std::transform(str.begin(), str.end(), std::back_inserter(result), Overload<char>(ToUpper));
|
||||
@@ -409,11 +419,15 @@ namespace Nz
|
||||
|
||||
std::wstring ToWideString(const std::string_view& str)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
return WideConverter<sizeof(wchar_t)>::To(str);
|
||||
}
|
||||
|
||||
std::string_view TrimLeft(std::string_view str)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
while (!str.empty() && IsSpace(str.front()))
|
||||
str.remove_prefix(1);
|
||||
|
||||
@@ -422,6 +436,8 @@ namespace Nz
|
||||
|
||||
std::string_view TrimLeft(std::string_view str, UnicodeAware)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
utf8::unchecked::iterator<const char*> it(str.data());
|
||||
utf8::unchecked::iterator<const char*> end(str.data() + str.size());
|
||||
while (it != end && IsSpace(*it))
|
||||
@@ -465,6 +481,8 @@ namespace Nz
|
||||
|
||||
std::string_view TrimRight(std::string_view str)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
while (!str.empty() && IsSpace(str.back()))
|
||||
str.remove_suffix(1);
|
||||
|
||||
@@ -473,6 +491,8 @@ namespace Nz
|
||||
|
||||
std::string_view TrimRight(std::string_view str, UnicodeAware)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
if (str.empty())
|
||||
return str;
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Nz
|
||||
|
||||
#include <Nazara/Core/UnicodeData.hpp>
|
||||
|
||||
namespace
|
||||
namespace NAZARA_ANONYMOUS_NAMESPACE
|
||||
{
|
||||
const UnicodeCharacter* GetCharacter(Nz::UInt32 codepoint)
|
||||
{
|
||||
@@ -74,6 +74,8 @@ namespace Nz
|
||||
*/
|
||||
Unicode::Category Unicode::GetCategory(char32_t character)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
if (const UnicodeCharacter* characterData = GetCharacter(character))
|
||||
return characterData->category;
|
||||
else
|
||||
@@ -89,6 +91,8 @@ namespace Nz
|
||||
|
||||
Unicode::Direction Unicode::GetDirection(char32_t character)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
if (const UnicodeCharacter* characterData = GetCharacter(character))
|
||||
return characterData->direction;
|
||||
else
|
||||
@@ -104,6 +108,8 @@ namespace Nz
|
||||
|
||||
char32_t Unicode::GetLowercase(char32_t character)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
if (const UnicodeCharacterSimpleMapping* characterMapping = GetCharacterMapping(character, unicodeLower))
|
||||
return characterMapping->character;
|
||||
else
|
||||
@@ -118,6 +124,8 @@ namespace Nz
|
||||
*/
|
||||
char32_t Unicode::GetTitlecase(char32_t character)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
if (const UnicodeCharacterSimpleMapping* characterMapping = GetCharacterMapping(character, unicodeTitle))
|
||||
return characterMapping->character;
|
||||
else
|
||||
@@ -132,6 +140,8 @@ namespace Nz
|
||||
*/
|
||||
char32_t Unicode::GetUppercase(char32_t character)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
if (const UnicodeCharacterSimpleMapping* characterMapping = GetCharacterMapping(character, unicodeUpper))
|
||||
return characterMapping->character;
|
||||
else
|
||||
|
||||
@@ -10,18 +10,22 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace
|
||||
namespace NAZARA_ANONYMOUS_NAMESPACE
|
||||
{
|
||||
LARGE_INTEGER s_frequency; // La fréquence ne varie pas pas au cours de l'exécution
|
||||
}
|
||||
|
||||
bool ClockImplInitializeHighPrecision()
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
return QueryPerformanceFrequency(&s_frequency) != 0;
|
||||
}
|
||||
|
||||
UInt64 ClockImplGetElapsedMicroseconds()
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/windows/desktop/ms644904(v=vs.85).aspx
|
||||
//HANDLE thread = GetCurrentThread();
|
||||
//DWORD oldMask = SetThreadAffinityMask(thread, 1);
|
||||
@@ -43,3 +47,5 @@ namespace Nz
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Core/AntiWindows.hpp>
|
||||
|
||||
@@ -47,3 +47,5 @@ namespace Nz
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Core/AntiWindows.hpp>
|
||||
|
||||
@@ -45,3 +45,5 @@ namespace Nz
|
||||
}
|
||||
|
||||
#endif // NAZARA_CORE_WIN32_FILEIMPL_HPP
|
||||
|
||||
#include <Nazara/Core/AntiWindows.hpp>
|
||||
|
||||
@@ -110,3 +110,5 @@ namespace Nz
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Core/AntiWindows.hpp>
|
||||
|
||||
@@ -246,3 +246,5 @@ namespace Nz
|
||||
std::unique_ptr<HANDLE[]> TaskSchedulerImpl::s_workerThreads; // Doivent être contigus
|
||||
DWORD TaskSchedulerImpl::s_workerCount;
|
||||
}
|
||||
|
||||
#include <Nazara/Core/AntiWindows.hpp>
|
||||
|
||||
@@ -26,3 +26,5 @@ namespace Nz
|
||||
return std::mktime(&timeinfo);
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Core/AntiWindows.hpp>
|
||||
|
||||
Reference in New Issue
Block a user