mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2025-11-29 17:38:24 +08:00
refactor(src/common): remove unused imports (#19506)
* refactor(src/common): remove unused imports * fix: build * chore: fix build * chore: size_t -> std::size_t * chore: fix fuckup from previous commit * chore: fix build * chore: fix build * chore: fix build * chore: fix build with std::size_t * chore: fix build * chore: fix build * chore: fix build * chore: fix build * chore: fix build * chore: fix build * chore: fix build * chore: fix build * chore: fix build * chore: fix build * chore: fix build * chore: fix build
This commit is contained in:
@@ -18,8 +18,6 @@
|
|||||||
#ifndef AsioHacksFwd_h__
|
#ifndef AsioHacksFwd_h__
|
||||||
#define AsioHacksFwd_h__
|
#define AsioHacksFwd_h__
|
||||||
|
|
||||||
#include <boost/version.hpp>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Collection of forward declarations to improve compile time
|
Collection of forward declarations to improve compile time
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
#ifndef Resolver_h__
|
#ifndef Resolver_h__
|
||||||
#define Resolver_h__
|
#define Resolver_h__
|
||||||
|
|
||||||
#include "IoContext.h"
|
|
||||||
#include "Optional.h"
|
#include "Optional.h"
|
||||||
#include <boost/asio/ip/tcp.hpp>
|
#include <boost/asio/ip/tcp.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ namespace
|
|||||||
|
|
||||||
template<> struct HashTrait< GameObjectModel>
|
template<> struct HashTrait< GameObjectModel>
|
||||||
{
|
{
|
||||||
static size_t hashCode(const GameObjectModel& g) { return (size_t)(void*)&g; }
|
static std::size_t hashCode(const GameObjectModel& g) { return (size_t)(void*)&g; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<> struct PositionTrait< GameObjectModel>
|
template<> struct PositionTrait< GameObjectModel>
|
||||||
|
|||||||
@@ -18,9 +18,6 @@
|
|||||||
#ifndef _IMMAPMANAGER_H
|
#ifndef _IMMAPMANAGER_H
|
||||||
#define _IMMAPMANAGER_H
|
#define _IMMAPMANAGER_H
|
||||||
|
|
||||||
#include "Define.h"
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
// Interface for IMMapManger
|
// Interface for IMMapManger
|
||||||
namespace MMAP
|
namespace MMAP
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,8 +17,6 @@
|
|||||||
|
|
||||||
#include "MMapFactory.h"
|
#include "MMapFactory.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <set>
|
|
||||||
|
|
||||||
namespace MMAP
|
namespace MMAP
|
||||||
{
|
{
|
||||||
// ######################## MMapFactory ########################
|
// ######################## MMapFactory ########################
|
||||||
|
|||||||
@@ -18,11 +18,7 @@
|
|||||||
#ifndef _MMAP_FACTORY_H
|
#ifndef _MMAP_FACTORY_H
|
||||||
#define _MMAP_FACTORY_H
|
#define _MMAP_FACTORY_H
|
||||||
|
|
||||||
#include "DetourAlloc.h"
|
|
||||||
#include "DetourExtended.h"
|
|
||||||
#include "DetourNavMesh.h"
|
|
||||||
#include "MMapMgr.h"
|
#include "MMapMgr.h"
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
namespace MMAP
|
namespace MMAP
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ namespace MMAP
|
|||||||
unsigned char* data = (unsigned char*)dtAlloc(fileHeader.size, DT_ALLOC_PERM);
|
unsigned char* data = (unsigned char*)dtAlloc(fileHeader.size, DT_ALLOC_PERM);
|
||||||
ASSERT(data);
|
ASSERT(data);
|
||||||
|
|
||||||
size_t result = fread(data, fileHeader.size, 1, file);
|
std::size_t result = fread(data, fileHeader.size, 1, file);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
LOG_ERROR("maps", "MMAP:loadMap: Bad header or data in mmap {:03}{:02}{:02}.mmtile", mapId, x, y);
|
LOG_ERROR("maps", "MMAP:loadMap: Bad header or data in mmap {:03}{:02}{:02}.mmtile", mapId, x, y);
|
||||||
|
|||||||
@@ -22,12 +22,11 @@
|
|||||||
#include "DetourAlloc.h"
|
#include "DetourAlloc.h"
|
||||||
#include "DetourExtended.h"
|
#include "DetourExtended.h"
|
||||||
#include "DetourNavMesh.h"
|
#include "DetourNavMesh.h"
|
||||||
#include <shared_mutex>
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
// memory management
|
// memory management
|
||||||
inline void* dtCustomAlloc(size_t size, dtAllocHint /*hint*/)
|
inline void* dtCustomAlloc(std::size_t size, dtAllocHint /*hint*/)
|
||||||
{
|
{
|
||||||
return (void*)new unsigned char[size];
|
return (void*)new unsigned char[size];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,6 @@
|
|||||||
#ifndef _VMAPFACTORY_H
|
#ifndef _VMAPFACTORY_H
|
||||||
#define _VMAPFACTORY_H
|
#define _VMAPFACTORY_H
|
||||||
|
|
||||||
#include "IVMapMgr.h"
|
|
||||||
|
|
||||||
// This is the access point to the VMapMgr.
|
// This is the access point to the VMapMgr.
|
||||||
namespace VMAP
|
namespace VMAP
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
#ifndef _VMAPMANAGER2_H
|
#ifndef _VMAPMANAGER2_H
|
||||||
#define _VMAPMANAGER2_H
|
#define _VMAPMANAGER2_H
|
||||||
|
|
||||||
#include "Common.h"
|
|
||||||
#include "IVMapMgr.h"
|
#include "IVMapMgr.h"
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
#include "BoundingIntervalHierarchy.h"
|
#include "BoundingIntervalHierarchy.h"
|
||||||
#include "Define.h"
|
#include "Define.h"
|
||||||
#include <G3D/AABox.h>
|
#include <G3D/AABox.h>
|
||||||
#include <G3D/HashTrait.h>
|
|
||||||
#include <G3D/Ray.h>
|
#include <G3D/Ray.h>
|
||||||
#include <G3D/Vector3.h>
|
#include <G3D/Vector3.h>
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#ifndef _REGULAR_GRID_H
|
#ifndef _REGULAR_GRID_H
|
||||||
#define _REGULAR_GRID_H
|
#define _REGULAR_GRID_H
|
||||||
|
|
||||||
#include <G3D/BoundsTrait.h>
|
|
||||||
#include <G3D/PositionTrait.h>
|
#include <G3D/PositionTrait.h>
|
||||||
#include <G3D/Ray.h>
|
#include <G3D/Ray.h>
|
||||||
#include <G3D/Table.h>
|
#include <G3D/Table.h>
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
#ifndef _VMAPDEFINITIONS_H
|
#ifndef _VMAPDEFINITIONS_H
|
||||||
#define _VMAPDEFINITIONS_H
|
#define _VMAPDEFINITIONS_H
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
#define LIQUID_TILE_SIZE (533.333f / 128.f)
|
#define LIQUID_TILE_SIZE (533.333f / 128.f)
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
#ifndef _VMAPTOOLS_H
|
#ifndef _VMAPTOOLS_H
|
||||||
#define _VMAPTOOLS_H
|
#define _VMAPTOOLS_H
|
||||||
|
|
||||||
#include "Define.h"
|
|
||||||
#include <G3D/AABox.h>
|
#include <G3D/AABox.h>
|
||||||
#include <G3D/CollisionDetection.h>
|
#include <G3D/CollisionDetection.h>
|
||||||
|
|
||||||
|
|||||||
@@ -19,10 +19,7 @@
|
|||||||
#define AZEROTHCORE_COMMON_H
|
#define AZEROTHCORE_COMMON_H
|
||||||
|
|
||||||
#include "Define.h"
|
#include "Define.h"
|
||||||
#include <array>
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
#if AC_PLATFORM == AC_PLATFORM_WINDOWS
|
#if AC_PLATFORM == AC_PLATFORM_WINDOWS
|
||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
|
|||||||
@@ -46,9 +46,9 @@ namespace
|
|||||||
// Check system configs like *server.conf*
|
// Check system configs like *server.conf*
|
||||||
bool IsAppConfig(std::string_view fileName)
|
bool IsAppConfig(std::string_view fileName)
|
||||||
{
|
{
|
||||||
size_t foundAuth = fileName.find("authserver.conf");
|
std::size_t foundAuth = fileName.find("authserver.conf");
|
||||||
size_t foundWorld = fileName.find("worldserver.conf");
|
std::size_t foundWorld = fileName.find("worldserver.conf");
|
||||||
size_t foundImport = fileName.find("dbimport.conf");
|
std::size_t foundImport = fileName.find("dbimport.conf");
|
||||||
|
|
||||||
return foundAuth != std::string_view::npos || foundWorld != std::string_view::npos || foundImport != std::string_view::npos;
|
return foundAuth != std::string_view::npos || foundWorld != std::string_view::npos || foundImport != std::string_view::npos;
|
||||||
}
|
}
|
||||||
@@ -56,8 +56,8 @@ namespace
|
|||||||
// Check logging system configs like Appender.* and Logger.*
|
// Check logging system configs like Appender.* and Logger.*
|
||||||
bool IsLoggingSystemOptions(std::string_view optionName)
|
bool IsLoggingSystemOptions(std::string_view optionName)
|
||||||
{
|
{
|
||||||
size_t foundAppender = optionName.find("Appender.");
|
std::size_t foundAppender = optionName.find("Appender.");
|
||||||
size_t foundLogger = optionName.find("Logger.");
|
std::size_t foundLogger = optionName.find("Logger.");
|
||||||
|
|
||||||
return foundAppender != std::string_view::npos || foundLogger != std::string_view::npos;
|
return foundAppender != std::string_view::npos || foundLogger != std::string_view::npos;
|
||||||
}
|
}
|
||||||
@@ -223,7 +223,7 @@ namespace
|
|||||||
std::string result;
|
std::string result;
|
||||||
|
|
||||||
const char* str = key.c_str();
|
const char* str = key.c_str();
|
||||||
size_t n = key.length();
|
std::size_t n = key.length();
|
||||||
|
|
||||||
char curr;
|
char curr;
|
||||||
bool isEnd;
|
bool isEnd;
|
||||||
@@ -231,7 +231,7 @@ namespace
|
|||||||
bool currIsNumeric;
|
bool currIsNumeric;
|
||||||
bool nextIsNumeric;
|
bool nextIsNumeric;
|
||||||
|
|
||||||
for (size_t i = 0; i < n; ++i)
|
for (std::size_t i = 0; i < n; ++i)
|
||||||
{
|
{
|
||||||
curr = str[i];
|
curr = str[i];
|
||||||
if (curr == ' ' || curr == '.' || curr == '-')
|
if (curr == ' ' || curr == '.' || curr == '-')
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
#ifndef CONFIG_H
|
#ifndef CONFIG_H
|
||||||
#define CONFIG_H
|
#define CONFIG_H
|
||||||
|
|
||||||
#include "Define.h"
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ void Acore::Crypto::AES::Init(Key const& key)
|
|||||||
ASSERT(status);
|
ASSERT(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Acore::Crypto::AES::Process(IV const& iv, uint8* data, size_t length, Tag& tag)
|
bool Acore::Crypto::AES::Process(IV const& iv, uint8* data, std::size_t length, Tag& tag)
|
||||||
{
|
{
|
||||||
ASSERT(length <= static_cast<size_t>(std::numeric_limits<int>::max()));
|
ASSERT(length <= static_cast<size_t>(std::numeric_limits<int>::max()));
|
||||||
int len = static_cast<int>(length);
|
int len = static_cast<int>(length);
|
||||||
|
|||||||
@@ -27,9 +27,9 @@ namespace Acore::Crypto
|
|||||||
class AC_COMMON_API AES
|
class AC_COMMON_API AES
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static constexpr size_t IV_SIZE_BYTES = 12;
|
static constexpr std::size_t IV_SIZE_BYTES = 12;
|
||||||
static constexpr size_t KEY_SIZE_BYTES = 16;
|
static constexpr std::size_t KEY_SIZE_BYTES = 16;
|
||||||
static constexpr size_t TAG_SIZE_BYTES = 12;
|
static constexpr std::size_t TAG_SIZE_BYTES = 12;
|
||||||
|
|
||||||
using IV = std::array<uint8, IV_SIZE_BYTES>;
|
using IV = std::array<uint8, IV_SIZE_BYTES>;
|
||||||
using Key = std::array<uint8, KEY_SIZE_BYTES>;
|
using Key = std::array<uint8, KEY_SIZE_BYTES>;
|
||||||
@@ -40,7 +40,7 @@ namespace Acore::Crypto
|
|||||||
|
|
||||||
void Init(Key const& key);
|
void Init(Key const& key);
|
||||||
|
|
||||||
bool Process(IV const& iv, uint8* data, size_t length, Tag& tag);
|
bool Process(IV const& iv, uint8* data, std::size_t length, Tag& tag);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EVP_CIPHER_CTX* _ctx;
|
EVP_CIPHER_CTX* _ctx;
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ Acore::Crypto::ARC4::~ARC4()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Acore::Crypto::ARC4::Init(uint8 const* seed, size_t len)
|
void Acore::Crypto::ARC4::Init(uint8 const* seed, std::size_t len)
|
||||||
{
|
{
|
||||||
int result1 = EVP_CIPHER_CTX_set_key_length(_ctx, len);
|
int result1 = EVP_CIPHER_CTX_set_key_length(_ctx, len);
|
||||||
ASSERT(result1 == 1);
|
ASSERT(result1 == 1);
|
||||||
@@ -48,7 +48,7 @@ void Acore::Crypto::ARC4::Init(uint8 const* seed, size_t len)
|
|||||||
ASSERT(result2 == 1);
|
ASSERT(result2 == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Acore::Crypto::ARC4::UpdateData(uint8* data, size_t len)
|
void Acore::Crypto::ARC4::UpdateData(uint8* data, std::size_t len)
|
||||||
{
|
{
|
||||||
int outlen = 0;
|
int outlen = 0;
|
||||||
int result1 = EVP_EncryptUpdate(_ctx, data, &outlen, data, len);
|
int result1 = EVP_EncryptUpdate(_ctx, data, &outlen, data, len);
|
||||||
|
|||||||
@@ -30,12 +30,12 @@ namespace Acore::Crypto
|
|||||||
ARC4();
|
ARC4();
|
||||||
~ARC4();
|
~ARC4();
|
||||||
|
|
||||||
void Init(uint8 const* seed, size_t len);
|
void Init(uint8 const* seed, std::size_t len);
|
||||||
|
|
||||||
template <typename Container>
|
template <typename Container>
|
||||||
void Init(Container const& c) { Init(std::data(c), std::size(c)); }
|
void Init(Container const& c) { Init(std::data(c), std::size(c)); }
|
||||||
|
|
||||||
void UpdateData(uint8* data, size_t len);
|
void UpdateData(uint8* data, std::size_t len);
|
||||||
|
|
||||||
template <typename Container>
|
template <typename Container>
|
||||||
void UpdateData(Container& c) { UpdateData(std::data(c), std::size(c)); }
|
void UpdateData(Container& c) { UpdateData(std::data(c), std::size(c)); }
|
||||||
|
|||||||
@@ -35,13 +35,13 @@ void AuthCrypt::Init(SessionKey const& K)
|
|||||||
_initialized = true;
|
_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AuthCrypt::DecryptRecv(uint8* data, size_t len)
|
void AuthCrypt::DecryptRecv(uint8* data, std::size_t len)
|
||||||
{
|
{
|
||||||
ASSERT(_initialized);
|
ASSERT(_initialized);
|
||||||
_clientDecrypt.UpdateData(data, len);
|
_clientDecrypt.UpdateData(data, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AuthCrypt::EncryptSend(uint8* data, size_t len)
|
void AuthCrypt::EncryptSend(uint8* data, std::size_t len)
|
||||||
{
|
{
|
||||||
ASSERT(_initialized);
|
ASSERT(_initialized);
|
||||||
_serverEncrypt.UpdateData(data, len);
|
_serverEncrypt.UpdateData(data, len);
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ public:
|
|||||||
AuthCrypt() = default;
|
AuthCrypt() = default;
|
||||||
|
|
||||||
void Init(SessionKey const& K);
|
void Init(SessionKey const& K);
|
||||||
void DecryptRecv(uint8* data, size_t len);
|
void DecryptRecv(uint8* data, std::size_t len);
|
||||||
void EncryptSend(uint8* data, size_t len);
|
void EncryptSend(uint8* data, std::size_t len);
|
||||||
|
|
||||||
bool IsInitialized() const { return _initialized; }
|
bool IsInitialized() const { return _initialized; }
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
#include "Define.h"
|
#include "Define.h"
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
constexpr size_t SESSION_KEY_LENGTH = 40;
|
constexpr std::size_t SESSION_KEY_LENGTH = 40;
|
||||||
using SessionKey = std::array<uint8, SESSION_KEY_LENGTH>;
|
using SessionKey = std::array<uint8, SESSION_KEY_LENGTH>;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -51,14 +51,14 @@ using SRP6 = Acore::Crypto::SRP6;
|
|||||||
{
|
{
|
||||||
// split S into two buffers
|
// split S into two buffers
|
||||||
std::array<uint8, EPHEMERAL_KEY_LENGTH / 2> buf0{}, buf1{};
|
std::array<uint8, EPHEMERAL_KEY_LENGTH / 2> buf0{}, buf1{};
|
||||||
for (size_t i = 0; i < EPHEMERAL_KEY_LENGTH / 2; ++i)
|
for (std::size_t i = 0; i < EPHEMERAL_KEY_LENGTH / 2; ++i)
|
||||||
{
|
{
|
||||||
buf0[i] = S[2 * i + 0];
|
buf0[i] = S[2 * i + 0];
|
||||||
buf1[i] = S[2 * i + 1];
|
buf1[i] = S[2 * i + 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// find position of first nonzero byte
|
// find position of first nonzero byte
|
||||||
size_t p = 0;
|
std::size_t p = 0;
|
||||||
while (p < EPHEMERAL_KEY_LENGTH && !S[p])
|
while (p < EPHEMERAL_KEY_LENGTH && !S[p])
|
||||||
++p;
|
++p;
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ using SRP6 = Acore::Crypto::SRP6;
|
|||||||
|
|
||||||
// stick the two hashes back together
|
// stick the two hashes back together
|
||||||
SessionKey K;
|
SessionKey K;
|
||||||
for (size_t i = 0; i < SHA1::DIGEST_LENGTH; ++i)
|
for (std::size_t i = 0; i < SHA1::DIGEST_LENGTH; ++i)
|
||||||
{
|
{
|
||||||
K[2 * i + 0] = hash0[i];
|
K[2 * i + 0] = hash0[i];
|
||||||
K[2 * i + 1] = hash1[i];
|
K[2 * i + 1] = hash1[i];
|
||||||
|
|||||||
@@ -28,13 +28,13 @@ namespace Acore::Crypto
|
|||||||
class AC_COMMON_API SRP6
|
class AC_COMMON_API SRP6
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static constexpr size_t SALT_LENGTH = 32;
|
static constexpr std::size_t SALT_LENGTH = 32;
|
||||||
using Salt = std::array<uint8, SALT_LENGTH>;
|
using Salt = std::array<uint8, SALT_LENGTH>;
|
||||||
|
|
||||||
static constexpr size_t VERIFIER_LENGTH = 32;
|
static constexpr std::size_t VERIFIER_LENGTH = 32;
|
||||||
using Verifier = std::array<uint8, VERIFIER_LENGTH>;
|
using Verifier = std::array<uint8, VERIFIER_LENGTH>;
|
||||||
|
|
||||||
static constexpr size_t EPHEMERAL_KEY_LENGTH = 32;
|
static constexpr std::size_t EPHEMERAL_KEY_LENGTH = 32;
|
||||||
using EphemeralKey = std::array<uint8, EPHEMERAL_KEY_LENGTH>;
|
using EphemeralKey = std::array<uint8, EPHEMERAL_KEY_LENGTH>;
|
||||||
|
|
||||||
static std::array<uint8, 1> const g;
|
static std::array<uint8, 1> const g;
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ bool BigNumber::IsNegative() const
|
|||||||
return BN_is_negative(_bn);
|
return BN_is_negative(_bn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BigNumber::GetBytes(uint8* buf, size_t bufsize, bool littleEndian) const
|
void BigNumber::GetBytes(uint8* buf, std::size_t bufsize, bool littleEndian) const
|
||||||
{
|
{
|
||||||
#if defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER < 0x10100000L
|
#if defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||||
int nBytes = GetNumBytes();
|
int nBytes = GetNumBytes();
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public:
|
|||||||
BigNumber(int32 v) : BigNumber() { SetDword(v); }
|
BigNumber(int32 v) : BigNumber() { SetDword(v); }
|
||||||
BigNumber(std::string const& v) : BigNumber() { SetHexStr(v); }
|
BigNumber(std::string const& v) : BigNumber() { SetHexStr(v); }
|
||||||
|
|
||||||
template <size_t Size>
|
template <std::size_t Size>
|
||||||
BigNumber(std::array<uint8, Size> const& v, bool littleEndian = true) : BigNumber() { SetBinary(v.data(), Size, littleEndian); }
|
BigNumber(std::array<uint8, Size> const& v, bool littleEndian = true) : BigNumber() { SetBinary(v.data(), Size, littleEndian); }
|
||||||
|
|
||||||
~BigNumber();
|
~BigNumber();
|
||||||
@@ -116,7 +116,7 @@ public:
|
|||||||
|
|
||||||
[[nodiscard]] uint32 AsDword() const;
|
[[nodiscard]] uint32 AsDword() const;
|
||||||
|
|
||||||
void GetBytes(uint8* buf, size_t bufsize, bool littleEndian = true) const;
|
void GetBytes(uint8* buf, std::size_t bufsize, bool littleEndian = true) const;
|
||||||
[[nodiscard]] std::vector<uint8> ToByteVector(int32 minSize = 0, bool littleEndian = true) const;
|
[[nodiscard]] std::vector<uint8> ToByteVector(int32 minSize = 0, bool littleEndian = true) const;
|
||||||
|
|
||||||
template <std::size_t Size>
|
template <std::size_t Size>
|
||||||
|
|||||||
@@ -18,15 +18,13 @@
|
|||||||
#ifndef AZEROTHCORE_CRYPTO_CONSTANTS_H
|
#ifndef AZEROTHCORE_CRYPTO_CONSTANTS_H
|
||||||
#define AZEROTHCORE_CRYPTO_CONSTANTS_H
|
#define AZEROTHCORE_CRYPTO_CONSTANTS_H
|
||||||
|
|
||||||
#include "Define.h"
|
|
||||||
|
|
||||||
namespace Acore::Crypto
|
namespace Acore::Crypto
|
||||||
{
|
{
|
||||||
struct Constants
|
struct Constants
|
||||||
{
|
{
|
||||||
static constexpr size_t MD5_DIGEST_LENGTH_BYTES = 16;
|
static constexpr std::size_t MD5_DIGEST_LENGTH_BYTES = 16;
|
||||||
static constexpr size_t SHA1_DIGEST_LENGTH_BYTES = 20;
|
static constexpr std::size_t SHA1_DIGEST_LENGTH_BYTES = 20;
|
||||||
static constexpr size_t SHA256_DIGEST_LENGTH_BYTES = 32;
|
static constexpr std::size_t SHA256_DIGEST_LENGTH_BYTES = 32;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace Acore::Impl
|
|||||||
static void SplitFromBack(std::vector<uint8>& data, Container& tail)
|
static void SplitFromBack(std::vector<uint8>& data, Container& tail)
|
||||||
{
|
{
|
||||||
ASSERT(data.size() >= std::size(tail));
|
ASSERT(data.size() >= std::size(tail));
|
||||||
for (size_t i = 1, N = std::size(tail); i <= N; ++i)
|
for (std::size_t i = 1, N = std::size(tail); i <= N; ++i)
|
||||||
{
|
{
|
||||||
tail[N - i] = data.back();
|
tail[N - i] = data.back();
|
||||||
data.pop_back();
|
data.pop_back();
|
||||||
|
|||||||
@@ -43,14 +43,14 @@ namespace Acore::Impl
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
template <GenericHashImpl::HashCreator HashCreator, size_t DigestLength>
|
template <GenericHashImpl::HashCreator HashCreator, std::size_t DigestLength>
|
||||||
class GenericHash
|
class GenericHash
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static constexpr size_t DIGEST_LENGTH = DigestLength;
|
static constexpr std::size_t DIGEST_LENGTH = DigestLength;
|
||||||
using Digest = std::array<uint8, DIGEST_LENGTH>;
|
using Digest = std::array<uint8, DIGEST_LENGTH>;
|
||||||
|
|
||||||
static Digest GetDigestOf(uint8 const* data, size_t len)
|
static Digest GetDigestOf(uint8 const* data, std::size_t len)
|
||||||
{
|
{
|
||||||
GenericHash hash;
|
GenericHash hash;
|
||||||
hash.UpdateData(data, len);
|
hash.UpdateData(data, len);
|
||||||
@@ -112,7 +112,7 @@ namespace Acore::Impl
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateData(uint8 const* data, size_t len)
|
void UpdateData(uint8 const* data, std::size_t len)
|
||||||
{
|
{
|
||||||
int result = EVP_DigestUpdate(_ctx, data, len);
|
int result = EVP_DigestUpdate(_ctx, data, len);
|
||||||
ASSERT(result == 1);
|
ASSERT(result == 1);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
#include "Errors.h"
|
#include "Errors.h"
|
||||||
#include <openssl/rand.h>
|
#include <openssl/rand.h>
|
||||||
|
|
||||||
void Acore::Crypto::GetRandomBytes(uint8* buf, size_t len)
|
void Acore::Crypto::GetRandomBytes(uint8* buf, std::size_t len)
|
||||||
{
|
{
|
||||||
int result = RAND_bytes(buf, len);
|
int result = RAND_bytes(buf, len);
|
||||||
ASSERT(result == 1, "Not enough randomness in OpenSSL's entropy pool. What in the world are you running on?");
|
ASSERT(result == 1, "Not enough randomness in OpenSSL's entropy pool. What in the world are you running on?");
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
namespace Acore::Crypto
|
namespace Acore::Crypto
|
||||||
{
|
{
|
||||||
AC_COMMON_API void GetRandomBytes(uint8* buf, size_t len);
|
AC_COMMON_API void GetRandomBytes(uint8* buf, std::size_t len);
|
||||||
|
|
||||||
template <typename Container>
|
template <typename Container>
|
||||||
void GetRandomBytes(Container& c)
|
void GetRandomBytes(Container& c)
|
||||||
@@ -31,7 +31,7 @@ namespace Acore::Crypto
|
|||||||
GetRandomBytes(std::data(c), std::size(c));
|
GetRandomBytes(std::data(c), std::size(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <size_t S>
|
template <std::size_t S>
|
||||||
std::array<uint8, S> GetRandomBytes()
|
std::array<uint8, S> GetRandomBytes()
|
||||||
{
|
{
|
||||||
std::array<uint8, S> arr;
|
std::array<uint8, S> arr;
|
||||||
|
|||||||
@@ -29,15 +29,15 @@ class BigNumber;
|
|||||||
|
|
||||||
namespace Acore::Impl
|
namespace Acore::Impl
|
||||||
{
|
{
|
||||||
template <GenericHashImpl::HashCreator HashCreator, size_t DigestLength>
|
template <GenericHashImpl::HashCreator HashCreator, std::size_t DigestLength>
|
||||||
class GenericHMAC
|
class GenericHMAC
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static constexpr size_t DIGEST_LENGTH = DigestLength;
|
static constexpr std::size_t DIGEST_LENGTH = DigestLength;
|
||||||
using Digest = std::array<uint8, DIGEST_LENGTH>;
|
using Digest = std::array<uint8, DIGEST_LENGTH>;
|
||||||
|
|
||||||
template <typename Container>
|
template <typename Container>
|
||||||
static Digest GetDigestOf(Container const& seed, uint8 const* data, size_t len)
|
static Digest GetDigestOf(Container const& seed, uint8 const* data, std::size_t len)
|
||||||
{
|
{
|
||||||
GenericHMAC hash(seed);
|
GenericHMAC hash(seed);
|
||||||
hash.UpdateData(data, len);
|
hash.UpdateData(data, len);
|
||||||
@@ -54,7 +54,7 @@ namespace Acore::Impl
|
|||||||
return hash.GetDigest();
|
return hash.GetDigest();
|
||||||
}
|
}
|
||||||
|
|
||||||
GenericHMAC(uint8 const* seed, size_t len) : _ctx(GenericHashImpl::MakeCTX()), _key(EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, nullptr, seed, len))
|
GenericHMAC(uint8 const* seed, std::size_t len) : _ctx(GenericHashImpl::MakeCTX()), _key(EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, nullptr, seed, len))
|
||||||
{
|
{
|
||||||
int result = EVP_DigestSignInit(_ctx, nullptr, HashCreator(), nullptr, _key);
|
int result = EVP_DigestSignInit(_ctx, nullptr, HashCreator(), nullptr, _key);
|
||||||
ASSERT(result == 1);
|
ASSERT(result == 1);
|
||||||
@@ -105,7 +105,7 @@ namespace Acore::Impl
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateData(uint8 const* data, size_t len)
|
void UpdateData(uint8 const* data, std::size_t len)
|
||||||
{
|
{
|
||||||
int result = EVP_DigestSignUpdate(_ctx, data, len);
|
int result = EVP_DigestSignUpdate(_ctx, data, len);
|
||||||
ASSERT(result == 1);
|
ASSERT(result == 1);
|
||||||
@@ -120,7 +120,7 @@ namespace Acore::Impl
|
|||||||
|
|
||||||
void Finalize()
|
void Finalize()
|
||||||
{
|
{
|
||||||
size_t length = DIGEST_LENGTH;
|
std::size_t length = DIGEST_LENGTH;
|
||||||
int result = EVP_DigestSignFinal(_ctx, _digest.data(), &length);
|
int result = EVP_DigestSignFinal(_ctx, _digest.data(), &length);
|
||||||
ASSERT(result == 1);
|
ASSERT(result == 1);
|
||||||
ASSERT(length == DIGEST_LENGTH);
|
ASSERT(length == DIGEST_LENGTH);
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "OpenSSLCrypto.h"
|
#include "OpenSSLCrypto.h"
|
||||||
#include "Errors.h"
|
|
||||||
#include <openssl/crypto.h> // NOTE: this import is NEEDED (even though some IDEs report it as unused)
|
#include <openssl/crypto.h> // NOTE: this import is NEEDED (even though some IDEs report it as unused)
|
||||||
|
|
||||||
#if defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER < 0x1010000fL
|
#if defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER < 0x1010000fL
|
||||||
|
|||||||
@@ -18,9 +18,6 @@
|
|||||||
#ifndef AZEROTHCORE_SESSIONKEYGENERATOR_HPP
|
#ifndef AZEROTHCORE_SESSIONKEYGENERATOR_HPP
|
||||||
#define AZEROTHCORE_SESSIONKEYGENERATOR_HPP
|
#define AZEROTHCORE_SESSIONKEYGENERATOR_HPP
|
||||||
|
|
||||||
#include "CryptoHash.h"
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
template <typename Hash>
|
template <typename Hash>
|
||||||
class SessionKeyGenerator
|
class SessionKeyGenerator
|
||||||
{
|
{
|
||||||
@@ -30,8 +27,8 @@ public:
|
|||||||
o0it(o0.begin())
|
o0it(o0.begin())
|
||||||
{
|
{
|
||||||
uint8 const* data = std::data(buf);
|
uint8 const* data = std::data(buf);
|
||||||
size_t const len = std::size(buf);
|
std::size_t const len = std::size(buf);
|
||||||
size_t const halflen = (len / 2);
|
std::size_t const halflen = (len / 2);
|
||||||
|
|
||||||
o1 = Hash::GetDigestOf(data, halflen);
|
o1 = Hash::GetDigestOf(data, halflen);
|
||||||
o2 = Hash::GetDigestOf(data + halflen, len - halflen);
|
o2 = Hash::GetDigestOf(data + halflen, len - halflen);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace Acore::Crypto
|
|||||||
{
|
{
|
||||||
struct AC_COMMON_API TOTP
|
struct AC_COMMON_API TOTP
|
||||||
{
|
{
|
||||||
static constexpr size_t RECOMMENDED_SECRET_LENGTH = 20;
|
static constexpr std::size_t RECOMMENDED_SECRET_LENGTH = 20;
|
||||||
using Secret = std::vector<uint8>;
|
using Secret = std::vector<uint8>;
|
||||||
|
|
||||||
static uint32 GenerateToken(Secret const& key, time_t timestamp);
|
static uint32 GenerateToken(Secret const& key, time_t timestamp);
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ DBCFileLoader::~DBCFileLoader()
|
|||||||
delete[] fieldsOffset;
|
delete[] fieldsOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBCFileLoader::Record DBCFileLoader::getRecord(size_t id)
|
DBCFileLoader::Record DBCFileLoader::getRecord(std::size_t id)
|
||||||
{
|
{
|
||||||
ASSERT(data);
|
ASSERT(data);
|
||||||
return Record(*this, data + id * recordSize);
|
return Record(*this, data + id * recordSize);
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public:
|
|||||||
class Record
|
class Record
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
[[nodiscard]] float getFloat(size_t field) const
|
[[nodiscard]] float getFloat(std::size_t field) const
|
||||||
{
|
{
|
||||||
ASSERT(field < file.fieldCount);
|
ASSERT(field < file.fieldCount);
|
||||||
float val = *reinterpret_cast<float*>(offset + file.GetOffset(field));
|
float val = *reinterpret_cast<float*>(offset + file.GetOffset(field));
|
||||||
@@ -54,7 +54,7 @@ public:
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] uint32 getUInt(size_t field) const
|
[[nodiscard]] uint32 getUInt(std::size_t field) const
|
||||||
{
|
{
|
||||||
ASSERT(field < file.fieldCount);
|
ASSERT(field < file.fieldCount);
|
||||||
uint32 val = *reinterpret_cast<uint32*>(offset + file.GetOffset(field));
|
uint32 val = *reinterpret_cast<uint32*>(offset + file.GetOffset(field));
|
||||||
@@ -62,16 +62,16 @@ public:
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] uint8 getUInt8(size_t field) const
|
[[nodiscard]] uint8 getUInt8(std::size_t field) const
|
||||||
{
|
{
|
||||||
ASSERT(field < file.fieldCount);
|
ASSERT(field < file.fieldCount);
|
||||||
return *reinterpret_cast<uint8*>(offset + file.GetOffset(field));
|
return *reinterpret_cast<uint8*>(offset + file.GetOffset(field));
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] const char* getString(size_t field) const
|
[[nodiscard]] const char* getString(std::size_t field) const
|
||||||
{
|
{
|
||||||
ASSERT(field < file.fieldCount);
|
ASSERT(field < file.fieldCount);
|
||||||
size_t stringOffset = getUInt(field);
|
std::size_t stringOffset = getUInt(field);
|
||||||
ASSERT(stringOffset < file.stringSize);
|
ASSERT(stringOffset < file.stringSize);
|
||||||
return reinterpret_cast<char*>(file.stringTable + stringOffset);
|
return reinterpret_cast<char*>(file.stringTable + stringOffset);
|
||||||
}
|
}
|
||||||
@@ -85,12 +85,12 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Get record by id
|
// Get record by id
|
||||||
Record getRecord(size_t id);
|
Record getRecord(std::size_t id);
|
||||||
|
|
||||||
[[nodiscard]] uint32 GetNumRows() const { return recordCount; }
|
[[nodiscard]] uint32 GetNumRows() const { return recordCount; }
|
||||||
[[nodiscard]] uint32 GetRowSize() const { return recordSize; }
|
[[nodiscard]] uint32 GetRowSize() const { return recordSize; }
|
||||||
[[nodiscard]] uint32 GetCols() const { return fieldCount; }
|
[[nodiscard]] uint32 GetCols() const { return fieldCount; }
|
||||||
[[nodiscard]] uint32 GetOffset(size_t id) const { return (fieldsOffset != nullptr && id < fieldCount) ? fieldsOffset[id] : 0; }
|
[[nodiscard]] uint32 GetOffset(std::size_t id) const { return (fieldsOffset != nullptr && id < fieldCount) ? fieldsOffset[id] : 0; }
|
||||||
[[nodiscard]] bool IsLoaded() const { return data != nullptr; }
|
[[nodiscard]] bool IsLoaded() const { return data != nullptr; }
|
||||||
char* AutoProduceData(char const* fmt, uint32& count, char**& indexTable);
|
char* AutoProduceData(char const* fmt, uint32& count, char**& indexTable);
|
||||||
char* AutoProduceStrings(char const* fmt, char* dataTable);
|
char* AutoProduceStrings(char const* fmt, char* dataTable);
|
||||||
|
|||||||
@@ -260,13 +260,13 @@ BOOL WheatyExceptionReport::_GetProcessorName(TCHAR* sProcessorName, DWORD maxco
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<size_t size>
|
template<std::size_t size>
|
||||||
void ToTchar(wchar_t const* src, TCHAR (&dst)[size], std::true_type)
|
void ToTchar(wchar_t const* src, TCHAR (&dst)[size], std::true_type)
|
||||||
{
|
{
|
||||||
wcstombs_s(nullptr, dst, src, size);
|
wcstombs_s(nullptr, dst, src, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<size_t size>
|
template<std::size_t size>
|
||||||
void ToTchar(wchar_t const* src, TCHAR (&dst)[size], std::false_type)
|
void ToTchar(wchar_t const* src, TCHAR (&dst)[size], std::false_type)
|
||||||
{
|
{
|
||||||
wcscpy_s(dst, src);
|
wcscpy_s(dst, src);
|
||||||
@@ -1455,8 +1455,8 @@ void WheatyExceptionReport::FormatOutputValue(char* pszCurrBuffer,
|
|||||||
BasicType basicType,
|
BasicType basicType,
|
||||||
DWORD64 length,
|
DWORD64 length,
|
||||||
PVOID pAddress,
|
PVOID pAddress,
|
||||||
size_t bufferSize,
|
std::size_t bufferSize,
|
||||||
size_t countOverride)
|
std::size_t countOverride)
|
||||||
{
|
{
|
||||||
__try
|
__try
|
||||||
{
|
{
|
||||||
@@ -1677,7 +1677,7 @@ void WheatyExceptionReport::PrintSymbolDetail()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add appropriate indentation level (since this routine is recursive)
|
// Add appropriate indentation level (since this routine is recursive)
|
||||||
for (size_t i = 0; i < symbolDetails.size(); i++)
|
for (std::size_t i = 0; i < symbolDetails.size(); i++)
|
||||||
{
|
{
|
||||||
Log(_T("\t"));
|
Log(_T("\t"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ private:
|
|||||||
|
|
||||||
static void DumpTypeIndex(DWORD64, DWORD, DWORD_PTR, bool&, char const*, char*, bool, bool);
|
static void DumpTypeIndex(DWORD64, DWORD, DWORD_PTR, bool&, char const*, char*, bool, bool);
|
||||||
|
|
||||||
static void FormatOutputValue(char* pszCurrBuffer, BasicType basicType, DWORD64 length, PVOID pAddress, size_t bufferSize, size_t countOverride = 0);
|
static void FormatOutputValue(char* pszCurrBuffer, BasicType basicType, DWORD64 length, PVOID pAddress, std::size_t bufferSize, std::size_t countOverride = 0);
|
||||||
|
|
||||||
static BasicType GetBasicType(DWORD typeIndex, DWORD64 modBase);
|
static BasicType GetBasicType(DWORD typeIndex, DWORD64 modBase);
|
||||||
static DWORD_PTR DereferenceUnsafePointer(DWORD_PTR address);
|
static DWORD_PTR DereferenceUnsafePointer(DWORD_PTR address);
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
#include "CompilerDefs.h"
|
#include "CompilerDefs.h"
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
#include <climits>
|
#include <climits>
|
||||||
#include <cstddef>
|
|
||||||
|
|
||||||
#define ACORE_LITTLEENDIAN 0
|
#define ACORE_LITTLEENDIAN 0
|
||||||
#define ACORE_BIGENDIAN 1
|
#define ACORE_BIGENDIAN 1
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#include "Define.h"
|
#include "Define.h"
|
||||||
#include "ObjectRegistry.h"
|
#include "ObjectRegistry.h"
|
||||||
#include "TypeList.h"
|
|
||||||
|
|
||||||
/** FactoryHolder holds a factory object of a specific type
|
/** FactoryHolder holds a factory object of a specific type
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -18,12 +18,9 @@
|
|||||||
#ifndef ACORE_OBJECTREGISTRY_H
|
#ifndef ACORE_OBJECTREGISTRY_H
|
||||||
#define ACORE_OBJECTREGISTRY_H
|
#define ACORE_OBJECTREGISTRY_H
|
||||||
|
|
||||||
#include "Define.h"
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
/** ObjectRegistry holds all registry item of the same type
|
/** ObjectRegistry holds all registry item of the same type
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -23,12 +23,10 @@
|
|||||||
* types of object at the same time.
|
* types of object at the same time.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Define.h"
|
|
||||||
#include "Dynamic/TypeList.h"
|
#include "Dynamic/TypeList.h"
|
||||||
#include "GridRefMgr.h"
|
#include "GridRefMgr.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @class ContainerMapList is a mulit-type container for map elements
|
* @class ContainerMapList is a mulit-type container for map elements
|
||||||
@@ -102,7 +100,7 @@ template<class OBJECT_TYPES>
|
|||||||
class TypeMapContainer
|
class TypeMapContainer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
template<class SPECIFIC_TYPE> [[nodiscard]] size_t Count() const { return Acore::Count(i_elements, (SPECIFIC_TYPE*)nullptr); }
|
template<class SPECIFIC_TYPE> [[nodiscard]] std::size_t Count() const { return Acore::Count(i_elements, (SPECIFIC_TYPE*)nullptr); }
|
||||||
|
|
||||||
/// inserts a specific object into the container
|
/// inserts a specific object into the container
|
||||||
template<class SPECIFIC_TYPE>
|
template<class SPECIFIC_TYPE>
|
||||||
|
|||||||
@@ -24,10 +24,7 @@
|
|||||||
* to access or mutate the container.
|
* to access or mutate the container.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Define.h"
|
|
||||||
#include "Dynamic/TypeList.h"
|
#include "Dynamic/TypeList.h"
|
||||||
#include <map>
|
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
namespace Acore
|
namespace Acore
|
||||||
{
|
{
|
||||||
@@ -159,31 +156,31 @@ namespace Acore
|
|||||||
/* ContainerMapList Helpers */
|
/* ContainerMapList Helpers */
|
||||||
// count functions
|
// count functions
|
||||||
template<class SPECIFIC_TYPE>
|
template<class SPECIFIC_TYPE>
|
||||||
size_t Count(const ContainerMapList<SPECIFIC_TYPE>& elements, SPECIFIC_TYPE* /*fake*/)
|
std::size_t Count(const ContainerMapList<SPECIFIC_TYPE>& elements, SPECIFIC_TYPE* /*fake*/)
|
||||||
{
|
{
|
||||||
return elements._element.getSize();
|
return elements._element.getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class SPECIFIC_TYPE>
|
template<class SPECIFIC_TYPE>
|
||||||
size_t Count(const ContainerMapList<TypeNull>& /*elements*/, SPECIFIC_TYPE* /*fake*/)
|
std::size_t Count(const ContainerMapList<TypeNull>& /*elements*/, SPECIFIC_TYPE* /*fake*/)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class SPECIFIC_TYPE, class T>
|
template<class SPECIFIC_TYPE, class T>
|
||||||
size_t Count(const ContainerMapList<T>& /*elements*/, SPECIFIC_TYPE* /*fake*/)
|
std::size_t Count(const ContainerMapList<T>& /*elements*/, SPECIFIC_TYPE* /*fake*/)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class SPECIFIC_TYPE, class T>
|
template<class SPECIFIC_TYPE, class T>
|
||||||
size_t Count(const ContainerMapList<TypeList<SPECIFIC_TYPE, T>>& elements, SPECIFIC_TYPE* fake)
|
std::size_t Count(const ContainerMapList<TypeList<SPECIFIC_TYPE, T>>& elements, SPECIFIC_TYPE* fake)
|
||||||
{
|
{
|
||||||
return Count(elements._elements, fake);
|
return Count(elements._elements, fake);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class SPECIFIC_TYPE, class H, class T>
|
template<class SPECIFIC_TYPE, class H, class T>
|
||||||
size_t Count(const ContainerMapList<TypeList<H, T>>& elements, SPECIFIC_TYPE* fake)
|
std::size_t Count(const ContainerMapList<TypeList<H, T>>& elements, SPECIFIC_TYPE* fake)
|
||||||
{
|
{
|
||||||
return Count(elements._TailElements, fake);
|
return Count(elements._TailElements, fake);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,27 +32,27 @@ namespace Acore
|
|||||||
{
|
{
|
||||||
/* ContainerMapList Helpers */
|
/* ContainerMapList Helpers */
|
||||||
// count functions
|
// count functions
|
||||||
// template<class SPECIFIC_TYPE> size_t Count(const ContainerMapList<SPECIFIC_TYPE> &elements, CountedPtr<SPECIFIC_TYPE>* /*fake*/)
|
// template<class SPECIFIC_TYPE> std::size_t Count(const ContainerMapList<SPECIFIC_TYPE> &elements, CountedPtr<SPECIFIC_TYPE>* /*fake*/)
|
||||||
// {
|
// {
|
||||||
// return elements._element.size();
|
// return elements._element.size();
|
||||||
// };
|
// };
|
||||||
//
|
//
|
||||||
// template<class SPECIFIC_TYPE> size_t Count(const ContainerMapList<TypeNull> &elements, CountedPtr<SPECIFIC_TYPE>* /*fake*/)
|
// template<class SPECIFIC_TYPE> std::size_t Count(const ContainerMapList<TypeNull> &elements, CountedPtr<SPECIFIC_TYPE>* /*fake*/)
|
||||||
// {
|
// {
|
||||||
// return 0;
|
// return 0;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// template<class SPECIFIC_TYPE, class T> size_t Count(const ContainerMapList<T> &elements, CountedPtr<SPECIFIC_TYPE>* /*fake*/)
|
// template<class SPECIFIC_TYPE, class T> std::size_t Count(const ContainerMapList<T> &elements, CountedPtr<SPECIFIC_TYPE>* /*fake*/)
|
||||||
// {
|
// {
|
||||||
// return 0;
|
// return 0;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// template<class SPECIFIC_TYPE, class T> size_t Count(const ContainerMapList<TypeList<SPECIFIC_TYPE, T> >&elements, SPECIFIC_TYPE* fake)
|
// template<class SPECIFIC_TYPE, class T> std::size_t Count(const ContainerMapList<TypeList<SPECIFIC_TYPE, T> >&elements, SPECIFIC_TYPE* fake)
|
||||||
// {
|
// {
|
||||||
// return Count(elements._elements, fake);
|
// return Count(elements._elements, fake);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// template<class SPECIFIC_TYPE, class H, class T> size_t Count(const ContainerMapList<TypeList<H, T> >&elements, SPECIFIC_TYPE* fake)
|
// template<class SPECIFIC_TYPE, class H, class T> std::size_t Count(const ContainerMapList<TypeList<H, T> >&elements, SPECIFIC_TYPE* fake)
|
||||||
// {
|
// {
|
||||||
// return Count(elements._TailElements, fake);
|
// return Count(elements._TailElements, fake);
|
||||||
// }
|
// }
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
* to overload its types as a visit method is called.
|
* to overload its types as a visit method is called.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Define.h"
|
|
||||||
#include "Dynamic/TypeContainer.h"
|
#include "Dynamic/TypeContainer.h"
|
||||||
|
|
||||||
// forward declaration
|
// forward declaration
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
#include "LogCommon.h"
|
#include "LogCommon.h"
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
struct LogMessage;
|
struct LogMessage;
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#define APPENDERCONSOLE_H
|
#define APPENDERCONSOLE_H
|
||||||
|
|
||||||
#include "Appender.h"
|
#include "Appender.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
// EnumUtils: DESCRIBE THIS
|
// EnumUtils: DESCRIBE THIS
|
||||||
enum ColorTypes
|
enum ColorTypes
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ AppenderFile::AppenderFile(uint8 id, std::string const& name, LogLevel level, Ap
|
|||||||
|
|
||||||
if (flags & APPENDER_FLAGS_USE_TIMESTAMP)
|
if (flags & APPENDER_FLAGS_USE_TIMESTAMP)
|
||||||
{
|
{
|
||||||
size_t dot_pos = _fileName.find_last_of('.');
|
std::size_t dot_pos = _fileName.find_last_of('.');
|
||||||
if (dot_pos != std::string::npos)
|
if (dot_pos != std::string::npos)
|
||||||
{
|
{
|
||||||
_fileName.insert(dot_pos, sLog->GetLogsTimestamp());
|
_fileName.insert(dot_pos, sLog->GetLogsTimestamp());
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "Appender.h"
|
#include "Appender.h"
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
class AppenderFile : public Appender
|
class AppenderFile : public Appender
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ void Log::CreateAppenderFromConfig(std::string const& appenderName)
|
|||||||
|
|
||||||
std::vector<std::string_view> tokens = Acore::Tokenize(options, ',', true);
|
std::vector<std::string_view> tokens = Acore::Tokenize(options, ',', true);
|
||||||
|
|
||||||
size_t const size = tokens.size();
|
std::size_t const size = tokens.size();
|
||||||
std::string name = appenderName.substr(9);
|
std::string name = appenderName.substr(9);
|
||||||
|
|
||||||
if (size < 2)
|
if (size < 2)
|
||||||
@@ -265,7 +265,7 @@ Logger const* Log::GetLoggerByType(std::string const& type) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string parentLogger = LOGGER_ROOT;
|
std::string parentLogger = LOGGER_ROOT;
|
||||||
size_t found = type.find_last_of('.');
|
std::size_t found = type.find_last_of('.');
|
||||||
if (found != std::string::npos)
|
if (found != std::string::npos)
|
||||||
{
|
{
|
||||||
parentLogger = type.substr(0, found);
|
parentLogger = type.substr(0, found);
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
#include "Define.h"
|
#include "Define.h"
|
||||||
#include "LogCommon.h"
|
#include "LogCommon.h"
|
||||||
#include "StringFormat.h"
|
#include "StringFormat.h"
|
||||||
#include <memory>
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
#ifndef LOGOPERATION_H
|
#ifndef LOGOPERATION_H
|
||||||
#define LOGOPERATION_H
|
#define LOGOPERATION_H
|
||||||
|
|
||||||
#include "Define.h"
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
class Logger;
|
class Logger;
|
||||||
|
|||||||
@@ -51,10 +51,10 @@ AC_API_EXPORT EnumText EnumUtils<ColorTypes>::ToString(ColorTypes value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
AC_API_EXPORT size_t EnumUtils<ColorTypes>::Count() { return 15; }
|
AC_API_EXPORT std::size_t EnumUtils<ColorTypes>::Count() { return 15; }
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
AC_API_EXPORT ColorTypes EnumUtils<ColorTypes>::FromIndex(size_t index)
|
AC_API_EXPORT ColorTypes EnumUtils<ColorTypes>::FromIndex(std::size_t index)
|
||||||
{
|
{
|
||||||
switch (index)
|
switch (index)
|
||||||
{
|
{
|
||||||
@@ -78,7 +78,7 @@ AC_API_EXPORT ColorTypes EnumUtils<ColorTypes>::FromIndex(size_t index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
AC_API_EXPORT size_t EnumUtils<ColorTypes>::ToIndex(ColorTypes value)
|
AC_API_EXPORT std::size_t EnumUtils<ColorTypes>::ToIndex(ColorTypes value)
|
||||||
{
|
{
|
||||||
switch (value)
|
switch (value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -43,10 +43,10 @@ AC_API_EXPORT EnumText EnumUtils<LogLevel>::ToString(LogLevel value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
AC_API_EXPORT size_t EnumUtils<LogLevel>::Count() { return 7; }
|
AC_API_EXPORT std::size_t EnumUtils<LogLevel>::Count() { return 7; }
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
AC_API_EXPORT LogLevel EnumUtils<LogLevel>::FromIndex(size_t index)
|
AC_API_EXPORT LogLevel EnumUtils<LogLevel>::FromIndex(std::size_t index)
|
||||||
{
|
{
|
||||||
switch (index)
|
switch (index)
|
||||||
{
|
{
|
||||||
@@ -62,7 +62,7 @@ AC_API_EXPORT LogLevel EnumUtils<LogLevel>::FromIndex(size_t index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
AC_API_EXPORT size_t EnumUtils<LogLevel>::ToIndex(LogLevel value)
|
AC_API_EXPORT std::size_t EnumUtils<LogLevel>::ToIndex(LogLevel value)
|
||||||
{
|
{
|
||||||
switch (value)
|
switch (value)
|
||||||
{
|
{
|
||||||
@@ -94,10 +94,10 @@ AC_API_EXPORT EnumText EnumUtils<AppenderType>::ToString(AppenderType value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
AC_API_EXPORT size_t EnumUtils<AppenderType>::Count() { return 4; }
|
AC_API_EXPORT std::size_t EnumUtils<AppenderType>::Count() { return 4; }
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
AC_API_EXPORT AppenderType EnumUtils<AppenderType>::FromIndex(size_t index)
|
AC_API_EXPORT AppenderType EnumUtils<AppenderType>::FromIndex(std::size_t index)
|
||||||
{
|
{
|
||||||
switch (index)
|
switch (index)
|
||||||
{
|
{
|
||||||
@@ -110,7 +110,7 @@ AC_API_EXPORT AppenderType EnumUtils<AppenderType>::FromIndex(size_t index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
AC_API_EXPORT size_t EnumUtils<AppenderType>::ToIndex(AppenderType value)
|
AC_API_EXPORT std::size_t EnumUtils<AppenderType>::ToIndex(AppenderType value)
|
||||||
{
|
{
|
||||||
switch (value)
|
switch (value)
|
||||||
{
|
{
|
||||||
@@ -141,10 +141,10 @@ AC_API_EXPORT EnumText EnumUtils<AppenderFlags>::ToString(AppenderFlags value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
AC_API_EXPORT size_t EnumUtils<AppenderFlags>::Count() { return 6; }
|
AC_API_EXPORT std::size_t EnumUtils<AppenderFlags>::Count() { return 6; }
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
AC_API_EXPORT AppenderFlags EnumUtils<AppenderFlags>::FromIndex(size_t index)
|
AC_API_EXPORT AppenderFlags EnumUtils<AppenderFlags>::FromIndex(std::size_t index)
|
||||||
{
|
{
|
||||||
switch (index)
|
switch (index)
|
||||||
{
|
{
|
||||||
@@ -159,7 +159,7 @@ AC_API_EXPORT AppenderFlags EnumUtils<AppenderFlags>::FromIndex(size_t index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
AC_API_EXPORT size_t EnumUtils<AppenderFlags>::ToIndex(AppenderFlags value)
|
AC_API_EXPORT std::size_t EnumUtils<AppenderFlags>::ToIndex(AppenderFlags value)
|
||||||
{
|
{
|
||||||
switch (value)
|
switch (value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,11 +22,9 @@
|
|||||||
#include "Duration.h"
|
#include "Duration.h"
|
||||||
#include "MPSCQueue.h"
|
#include "MPSCQueue.h"
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <iosfwd>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <utility>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace Acore::Asio
|
namespace Acore::Asio
|
||||||
|
|||||||
@@ -19,8 +19,6 @@
|
|||||||
#define MPSCQueue_h__
|
#define MPSCQueue_h__
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <memory>
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
namespace Acore::Impl
|
namespace Acore::Impl
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,11 +18,8 @@
|
|||||||
#ifndef _PCQ_H
|
#ifndef _PCQ_H
|
||||||
#define _PCQ_H
|
#define _PCQ_H
|
||||||
|
|
||||||
#include <atomic>
|
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#include <mutex>
|
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <type_traits>
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class ProducerConsumerQueue
|
class ProducerConsumerQueue
|
||||||
@@ -51,7 +48,7 @@ public:
|
|||||||
return _queue.empty();
|
return _queue.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] size_t Size() const
|
[[nodiscard]] std::size_t Size() const
|
||||||
{
|
{
|
||||||
return _queue.size();
|
return _queue.size();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,6 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Define.h"
|
|
||||||
|
|
||||||
namespace Acore
|
namespace Acore
|
||||||
{
|
{
|
||||||
template<typename MUTEX>
|
template<typename MUTEX>
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
#ifndef AsyncCallbackProcessor_h__
|
#ifndef AsyncCallbackProcessor_h__
|
||||||
#define AsyncCallbackProcessor_h__
|
#define AsyncCallbackProcessor_h__
|
||||||
|
|
||||||
#include "Define.h"
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
namespace ByteConverter
|
namespace ByteConverter
|
||||||
{
|
{
|
||||||
template<size_t T>
|
template<std::size_t T>
|
||||||
inline void convert(char* val)
|
inline void convert(char* val)
|
||||||
{
|
{
|
||||||
std::swap(*val, *(val + T - 1));
|
std::swap(*val, *(val + T - 1));
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ template <typename T>
|
|||||||
class CircularBuffer
|
class CircularBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit CircularBuffer(size_t size) :
|
explicit CircularBuffer(std::size_t size) :
|
||||||
buf_(std::unique_ptr<T[]>(new T[size])),
|
buf_(std::unique_ptr<T[]>(new T[size])),
|
||||||
max_size_(size)
|
max_size_(size)
|
||||||
{
|
{
|
||||||
@@ -52,14 +52,14 @@ public:
|
|||||||
return full_;
|
return full_;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] size_t capacity() const
|
[[nodiscard]] std::size_t capacity() const
|
||||||
{
|
{
|
||||||
return max_size_;
|
return max_size_;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] size_t size() const
|
[[nodiscard]] std::size_t size() const
|
||||||
{
|
{
|
||||||
size_t size = max_size_;
|
std::size_t size = max_size_;
|
||||||
|
|
||||||
if (!full_)
|
if (!full_)
|
||||||
{
|
{
|
||||||
@@ -95,9 +95,9 @@ public:
|
|||||||
private:
|
private:
|
||||||
std::mutex mutex_;
|
std::mutex mutex_;
|
||||||
std::unique_ptr<T[]> buf_;
|
std::unique_ptr<T[]> buf_;
|
||||||
size_t head_ = 0;
|
std::size_t head_ = 0;
|
||||||
size_t tail_ = 0;
|
std::size_t tail_ = 0;
|
||||||
const size_t max_size_;
|
const std::size_t max_size_;
|
||||||
bool full_ = false;
|
bool full_ = false;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -23,8 +23,6 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <type_traits>
|
|
||||||
#include <utility>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace Acore
|
namespace Acore
|
||||||
@@ -51,13 +49,13 @@ namespace Acore
|
|||||||
using reference = T&;
|
using reference = T&;
|
||||||
using difference_type = std::ptrdiff_t;
|
using difference_type = std::ptrdiff_t;
|
||||||
|
|
||||||
CheckedBufferOutputIterator(T* buf, size_t n) : _buf(buf), _end(buf + n) {}
|
CheckedBufferOutputIterator(T* buf, std::size_t n) : _buf(buf), _end(buf + n) {}
|
||||||
|
|
||||||
T& operator*() const { check(); return *_buf; }
|
T& operator*() const { check(); return *_buf; }
|
||||||
CheckedBufferOutputIterator& operator++() { check(); ++_buf; return *this; }
|
CheckedBufferOutputIterator& operator++() { check(); ++_buf; return *this; }
|
||||||
CheckedBufferOutputIterator operator++(int) { CheckedBufferOutputIterator v = *this; operator++(); return v; }
|
CheckedBufferOutputIterator operator++(int) { CheckedBufferOutputIterator v = *this; operator++(); return v; }
|
||||||
|
|
||||||
[[nodiscard]] size_t remaining() const { return (_end - _buf); }
|
[[nodiscard]] std::size_t remaining() const { return (_end - _buf); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
T* _buf;
|
T* _buf;
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
#include "Duration.h"
|
#include "Duration.h"
|
||||||
#include "Random.h"
|
#include "Random.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <type_traits>
|
|
||||||
|
|
||||||
class EventProcessor;
|
class EventProcessor;
|
||||||
|
|
||||||
|
|||||||
@@ -24,9 +24,7 @@
|
|||||||
#ifndef _ACORE_GEOMETRY_H
|
#ifndef _ACORE_GEOMETRY_H
|
||||||
#define _ACORE_GEOMETRY_H
|
#define _ACORE_GEOMETRY_H
|
||||||
|
|
||||||
#include "Define.h"
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iostream>
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
[[nodiscard]] inline float getAngle(float startX, float startY, float destX, float destY)
|
[[nodiscard]] inline float getAngle(float startX, float startY, float destX, float destY)
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
#ifndef IteratorPair_h__
|
#ifndef IteratorPair_h__
|
||||||
#define IteratorPair_h__
|
#define IteratorPair_h__
|
||||||
|
|
||||||
#include "Define.h"
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
namespace Acore
|
namespace Acore
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ inline T mean(Container&& c)
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
inline T median(std::vector<T> a)
|
inline T median(std::vector<T> a)
|
||||||
{
|
{
|
||||||
size_t n = a.size();
|
std::size_t n = a.size();
|
||||||
// If size of the arr[] is even
|
// If size of the arr[] is even
|
||||||
if (n % 2 == 0)
|
if (n % 2 == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,9 +25,6 @@
|
|||||||
#define _ACORE_PHYSICS_H
|
#define _ACORE_PHYSICS_H
|
||||||
|
|
||||||
#include "Geometry.h"
|
#include "Geometry.h"
|
||||||
#include <cmath>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ double rand_chance()
|
|||||||
return urd(engine);
|
return urd(engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 urandweighted(size_t count, double const* chances)
|
uint32 urandweighted(std::size_t count, double const* chances)
|
||||||
{
|
{
|
||||||
std::discrete_distribution<uint32> dd(chances, chances + count);
|
std::discrete_distribution<uint32> dd(chances, chances + count);
|
||||||
return dd(engine);
|
return dd(engine);
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ AC_COMMON_API double rand_norm();
|
|||||||
AC_COMMON_API double rand_chance();
|
AC_COMMON_API double rand_chance();
|
||||||
|
|
||||||
/* Return a random number in the range 0..count (exclusive) with each value having a different chance of happening */
|
/* Return a random number in the range 0..count (exclusive) with each value having a different chance of happening */
|
||||||
AC_COMMON_API uint32 urandweighted(size_t count, double const* chances);
|
AC_COMMON_API uint32 urandweighted(std::size_t count, double const* chances);
|
||||||
|
|
||||||
/* Return true if a random roll fits in the specified chance (range 0-100). */
|
/* Return true if a random roll fits in the specified chance (range 0-100). */
|
||||||
inline bool roll_chance_f(float chance)
|
inline bool roll_chance_f(float chance)
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
#include <mm_malloc.h>
|
#include <mm_malloc.h>
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
static __inline__ void *__attribute__((__always_inline__, __nodebug__, __malloc__))
|
static __inline__ void *__attribute__((__always_inline__, __nodebug__, __malloc__))
|
||||||
_mm_malloc(size_t __size, size_t __align)
|
_mm_malloc(std::size_t __size, std::size_t __align)
|
||||||
{
|
{
|
||||||
if (__align == 1)
|
if (__align == 1)
|
||||||
{
|
{
|
||||||
@@ -78,7 +78,7 @@ uint32 SFMTRand::RandomUInt32() // Output random bits
|
|||||||
return sfmt_genrand_uint32(&_state);
|
return sfmt_genrand_uint32(&_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* SFMTRand::operator new(size_t size, std::nothrow_t const&)
|
void* SFMTRand::operator new(std::size_t size, std::nothrow_t const&)
|
||||||
{
|
{
|
||||||
return _mm_malloc(size, 16);
|
return _mm_malloc(size, 16);
|
||||||
}
|
}
|
||||||
@@ -88,7 +88,7 @@ void SFMTRand::operator delete(void* ptr, std::nothrow_t const&)
|
|||||||
_mm_free(ptr);
|
_mm_free(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* SFMTRand::operator new(size_t size)
|
void* SFMTRand::operator new(std::size_t size)
|
||||||
{
|
{
|
||||||
return _mm_malloc(size, 16);
|
return _mm_malloc(size, 16);
|
||||||
}
|
}
|
||||||
@@ -98,7 +98,7 @@ void SFMTRand::operator delete(void* ptr)
|
|||||||
_mm_free(ptr);
|
_mm_free(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* SFMTRand::operator new[](size_t size, std::nothrow_t const&)
|
void* SFMTRand::operator new[](std::size_t size, std::nothrow_t const&)
|
||||||
{
|
{
|
||||||
return _mm_malloc(size, 16);
|
return _mm_malloc(size, 16);
|
||||||
}
|
}
|
||||||
@@ -108,7 +108,7 @@ void SFMTRand::operator delete[](void* ptr, std::nothrow_t const&)
|
|||||||
_mm_free(ptr);
|
_mm_free(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* SFMTRand::operator new[](size_t size)
|
void* SFMTRand::operator new[](std::size_t size)
|
||||||
{
|
{
|
||||||
return _mm_malloc(size, 16);
|
return _mm_malloc(size, 16);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,13 +30,13 @@ class SFMTRand
|
|||||||
public:
|
public:
|
||||||
SFMTRand();
|
SFMTRand();
|
||||||
uint32 RandomUInt32(); // Output random bits
|
uint32 RandomUInt32(); // Output random bits
|
||||||
void* operator new(size_t size, std::nothrow_t const&);
|
void* operator new(std::size_t size, std::nothrow_t const&);
|
||||||
void operator delete(void* ptr, std::nothrow_t const&);
|
void operator delete(void* ptr, std::nothrow_t const&);
|
||||||
void* operator new(size_t size);
|
void* operator new(std::size_t size);
|
||||||
void operator delete(void* ptr);
|
void operator delete(void* ptr);
|
||||||
void* operator new[](size_t size, std::nothrow_t const&);
|
void* operator new[](std::size_t size, std::nothrow_t const&);
|
||||||
void operator delete[](void* ptr, std::nothrow_t const&);
|
void operator delete[](void* ptr, std::nothrow_t const&);
|
||||||
void* operator new[](size_t size);
|
void* operator new[](std::size_t size);
|
||||||
void operator delete[](void* ptr);
|
void operator delete[](void* ptr);
|
||||||
private:
|
private:
|
||||||
sfmt_t _state;
|
sfmt_t _state;
|
||||||
|
|||||||
@@ -37,10 +37,10 @@ namespace Acore::Impl::EnumUtilsImpl
|
|||||||
template <typename Enum>
|
template <typename Enum>
|
||||||
struct EnumUtils
|
struct EnumUtils
|
||||||
{
|
{
|
||||||
static size_t Count();
|
static std::size_t Count();
|
||||||
static EnumText ToString(Enum value);
|
static EnumText ToString(Enum value);
|
||||||
static Enum FromIndex(size_t index);
|
static Enum FromIndex(std::size_t index);
|
||||||
static size_t ToIndex(Enum index);
|
static std::size_t ToIndex(Enum index);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,11 +48,11 @@ class EnumUtils
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
template <typename Enum>
|
template <typename Enum>
|
||||||
static size_t Count() { return Acore::Impl::EnumUtilsImpl::EnumUtils<Enum>::Count(); }
|
static std::size_t Count() { return Acore::Impl::EnumUtilsImpl::EnumUtils<Enum>::Count(); }
|
||||||
template <typename Enum>
|
template <typename Enum>
|
||||||
static EnumText ToString(Enum value) { return Acore::Impl::EnumUtilsImpl::EnumUtils<Enum>::ToString(value); }
|
static EnumText ToString(Enum value) { return Acore::Impl::EnumUtilsImpl::EnumUtils<Enum>::ToString(value); }
|
||||||
template <typename Enum>
|
template <typename Enum>
|
||||||
static Enum FromIndex(size_t index) { return Acore::Impl::EnumUtilsImpl::EnumUtils<Enum>::FromIndex(index); }
|
static Enum FromIndex(std::size_t index) { return Acore::Impl::EnumUtilsImpl::EnumUtils<Enum>::FromIndex(index); }
|
||||||
template <typename Enum>
|
template <typename Enum>
|
||||||
static uint32 ToIndex(Enum value) { return Acore::Impl::EnumUtilsImpl::EnumUtils<Enum>::ToIndex(value);}
|
static uint32 ToIndex(Enum value) { return Acore::Impl::EnumUtilsImpl::EnumUtils<Enum>::ToIndex(value);}
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ public:
|
|||||||
using difference_type = std::ptrdiff_t;
|
using difference_type = std::ptrdiff_t;
|
||||||
|
|
||||||
Iterator() : _index(EnumUtils::Count<Enum>()) {}
|
Iterator() : _index(EnumUtils::Count<Enum>()) {}
|
||||||
explicit Iterator(size_t index) : _index(index) { }
|
explicit Iterator(std::size_t index) : _index(index) { }
|
||||||
|
|
||||||
bool operator==(const Iterator& other) const { return other._index == _index; }
|
bool operator==(const Iterator& other) const { return other._index == _index; }
|
||||||
bool operator!=(const Iterator& other) const { return !operator==(other); }
|
bool operator!=(const Iterator& other) const { return !operator==(other); }
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#include "Define.h"
|
#include "Define.h"
|
||||||
#include <future>
|
#include <future>
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ namespace Acore::Impl::StringConvertImpl
|
|||||||
}
|
}
|
||||||
tmp.append(str);
|
tmp.append(str);
|
||||||
|
|
||||||
size_t n;
|
std::size_t n;
|
||||||
T val = static_cast<T>(std::stold(tmp, &n));
|
T val = static_cast<T>(std::stold(tmp, &n));
|
||||||
if (n != tmp.length())
|
if (n != tmp.length())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ TaskScheduler& TaskScheduler::Update(success_t const& callback)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskScheduler& TaskScheduler::Update(size_t const milliseconds, success_t const& callback)
|
TaskScheduler& TaskScheduler::Update(std::size_t const milliseconds, success_t const& callback)
|
||||||
{
|
{
|
||||||
return Update(std::chrono::milliseconds(milliseconds), callback);
|
return Update(std::chrono::milliseconds(milliseconds), callback);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,14 +19,11 @@
|
|||||||
#define _TASK_SCHEDULER_H_
|
#define _TASK_SCHEDULER_H_
|
||||||
|
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include <algorithm>
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <utility>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class TaskContext;
|
class TaskContext;
|
||||||
@@ -209,7 +206,7 @@ public:
|
|||||||
|
|
||||||
/// Update the scheduler with a difftime in ms.
|
/// Update the scheduler with a difftime in ms.
|
||||||
/// Calls the optional callback on successfully finish.
|
/// Calls the optional callback on successfully finish.
|
||||||
TaskScheduler& Update(size_t const milliseconds, success_t const& callback = EmptyCallback);
|
TaskScheduler& Update(std::size_t const milliseconds, success_t const& callback = EmptyCallback);
|
||||||
|
|
||||||
/// Update the scheduler with a difftime.
|
/// Update the scheduler with a difftime.
|
||||||
/// Calls the optional callback on successfully finish.
|
/// Calls the optional callback on successfully finish.
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ std::vector<std::string_view> Acore::Tokenize(std::string_view str, char sep, bo
|
|||||||
{
|
{
|
||||||
std::vector<std::string_view> tokens;
|
std::vector<std::string_view> tokens;
|
||||||
|
|
||||||
size_t start = 0;
|
std::size_t start = 0;
|
||||||
for (size_t end = str.find(sep); end != std::string_view::npos; end = str.find(sep, start))
|
for (std::size_t end = str.find(sep); end != std::string_view::npos; end = str.find(sep, start))
|
||||||
{
|
{
|
||||||
if (keepEmpty || (start < end))
|
if (keepEmpty || (start < end))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
#ifndef _ACORE_TOKENIZE_H_
|
#ifndef _ACORE_TOKENIZE_H_
|
||||||
#define _ACORE_TOKENIZE_H_
|
#define _ACORE_TOKENIZE_H_
|
||||||
|
|
||||||
#include "Common.h"
|
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ namespace Acore
|
|||||||
|
|
||||||
namespace Impl
|
namespace Impl
|
||||||
{
|
{
|
||||||
template <class T, class Tuple, size_t... I>
|
template <class T, class Tuple, std::size_t... I>
|
||||||
T* new_from_tuple(Tuple&& args, std::index_sequence<I...>)
|
T* new_from_tuple(Tuple&& args, std::index_sequence<I...>)
|
||||||
{
|
{
|
||||||
return new T(std::get<I>(std::forward<Tuple>(args))...);
|
return new T(std::get<I>(std::forward<Tuple>(args))...);
|
||||||
|
|||||||
@@ -33,10 +33,10 @@ void stripLineInvisibleChars(std::string& str)
|
|||||||
{
|
{
|
||||||
static std::string const invChars = " \t\7\n";
|
static std::string const invChars = " \t\7\n";
|
||||||
|
|
||||||
size_t wpos = 0;
|
std::size_t wpos = 0;
|
||||||
|
|
||||||
bool space = false;
|
bool space = false;
|
||||||
for (size_t pos = 0; pos < str.size(); ++pos)
|
for (std::size_t pos = 0; pos < str.size(); ++pos)
|
||||||
{
|
{
|
||||||
if (invChars.find(str[pos]) != std::string::npos)
|
if (invChars.find(str[pos]) != std::string::npos)
|
||||||
{
|
{
|
||||||
@@ -242,7 +242,7 @@ uint32 GetPID()
|
|||||||
return uint32(pid);
|
return uint32(pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t utf8length(std::string& utf8str)
|
std::size_t utf8length(std::string& utf8str)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -255,11 +255,11 @@ size_t utf8length(std::string& utf8str)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void utf8truncate(std::string& utf8str, size_t len)
|
void utf8truncate(std::string& utf8str, std::size_t len)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
size_t wlen = utf8::distance(utf8str.c_str(), utf8str.c_str() + utf8str.size());
|
std::size_t wlen = utf8::distance(utf8str.c_str(), utf8str.c_str() + utf8str.size());
|
||||||
if (wlen <= len)
|
if (wlen <= len)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -278,7 +278,7 @@ void utf8truncate(std::string& utf8str, size_t len)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Utf8toWStr(char const* utf8str, size_t csize, wchar_t* wstr, size_t& wsize)
|
bool Utf8toWStr(char const* utf8str, std::size_t csize, wchar_t* wstr, std::size_t& wsize)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -330,7 +330,7 @@ bool Utf8toWStr(std::string_view utf8str, std::wstring& wstr)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WStrToUtf8(wchar_t const* wstr, size_t size, std::string& utf8str)
|
bool WStrToUtf8(wchar_t const* wstr, std::size_t size, std::string& utf8str)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -512,14 +512,14 @@ void vutf8printf(FILE* out, const char* str, va_list* ap)
|
|||||||
char temp_buf[32 * 1024];
|
char temp_buf[32 * 1024];
|
||||||
wchar_t wtemp_buf[32 * 1024];
|
wchar_t wtemp_buf[32 * 1024];
|
||||||
|
|
||||||
size_t temp_len = vsnprintf(temp_buf, 32 * 1024, str, *ap);
|
std::size_t temp_len = vsnprintf(temp_buf, 32 * 1024, str, *ap);
|
||||||
//vsnprintf returns -1 if the buffer is too small
|
//vsnprintf returns -1 if the buffer is too small
|
||||||
if (temp_len == size_t(-1))
|
if (temp_len == std::size_t(-1))
|
||||||
{
|
{
|
||||||
temp_len = 32 * 1024 - 1;
|
temp_len = 32 * 1024 - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t wtemp_len = 32 * 1024 - 1;
|
std::size_t wtemp_len = 32 * 1024 - 1;
|
||||||
Utf8toWStr(temp_buf, temp_len, wtemp_buf, wtemp_len);
|
Utf8toWStr(temp_buf, temp_len, wtemp_buf, wtemp_len);
|
||||||
|
|
||||||
CharToOemBuffW(&wtemp_buf[0], &temp_buf[0], uint32(wtemp_len + 1));
|
CharToOemBuffW(&wtemp_buf[0], &temp_buf[0], uint32(wtemp_len + 1));
|
||||||
@@ -542,7 +542,7 @@ bool Utf8ToUpperOnlyLatin(std::string& utf8String)
|
|||||||
return WStrToUtf8(wstr, utf8String);
|
return WStrToUtf8(wstr, utf8String);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Acore::Impl::ByteArrayToHexStr(uint8 const* bytes, size_t arrayLen, bool reverse /* = false */)
|
std::string Acore::Impl::ByteArrayToHexStr(uint8 const* bytes, std::size_t arrayLen, bool reverse /* = false */)
|
||||||
{
|
{
|
||||||
int32 init = 0;
|
int32 init = 0;
|
||||||
int32 end = arrayLen;
|
int32 end = arrayLen;
|
||||||
@@ -566,7 +566,7 @@ std::string Acore::Impl::ByteArrayToHexStr(uint8 const* bytes, size_t arrayLen,
|
|||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Acore::Impl::HexStrToByteArray(std::string_view str, uint8* out, size_t outlen, bool reverse /*= false*/)
|
void Acore::Impl::HexStrToByteArray(std::string_view str, uint8* out, std::size_t outlen, bool reverse /*= false*/)
|
||||||
{
|
{
|
||||||
ASSERT(str.size() == (2 * outlen));
|
ASSERT(str.size() == (2 * outlen));
|
||||||
|
|
||||||
|
|||||||
@@ -85,9 +85,9 @@ inline T RoundToInterval(T& num, T floor, T ceil)
|
|||||||
AC_COMMON_API bool Utf8toWStr(std::string_view utf8str, std::wstring& wstr);
|
AC_COMMON_API bool Utf8toWStr(std::string_view utf8str, std::wstring& wstr);
|
||||||
|
|
||||||
// in wsize==max size of buffer, out wsize==real string size
|
// in wsize==max size of buffer, out wsize==real string size
|
||||||
AC_COMMON_API bool Utf8toWStr(char const* utf8str, size_t csize, wchar_t* wstr, size_t& wsize);
|
AC_COMMON_API bool Utf8toWStr(char const* utf8str, std::size_t csize, wchar_t* wstr, std::size_t& wsize);
|
||||||
|
|
||||||
inline bool Utf8toWStr(std::string_view utf8str, wchar_t* wstr, size_t& wsize)
|
inline bool Utf8toWStr(std::string_view utf8str, wchar_t* wstr, std::size_t& wsize)
|
||||||
{
|
{
|
||||||
return Utf8toWStr(utf8str.data(), utf8str.size(), wstr, wsize);
|
return Utf8toWStr(utf8str.data(), utf8str.size(), wstr, wsize);
|
||||||
}
|
}
|
||||||
@@ -95,11 +95,11 @@ inline bool Utf8toWStr(std::string_view utf8str, wchar_t* wstr, size_t& wsize)
|
|||||||
AC_COMMON_API bool WStrToUtf8(std::wstring_view wstr, std::string& utf8str);
|
AC_COMMON_API bool WStrToUtf8(std::wstring_view wstr, std::string& utf8str);
|
||||||
|
|
||||||
// size==real string size
|
// size==real string size
|
||||||
AC_COMMON_API bool WStrToUtf8(wchar_t const* wstr, size_t size, std::string& utf8str);
|
AC_COMMON_API bool WStrToUtf8(wchar_t const* wstr, std::size_t size, std::string& utf8str);
|
||||||
|
|
||||||
// set string to "" if invalid utf8 sequence
|
// set string to "" if invalid utf8 sequence
|
||||||
size_t utf8length(std::string& utf8str);
|
std::size_t utf8length(std::string& utf8str);
|
||||||
void utf8truncate(std::string& utf8str, size_t len);
|
void utf8truncate(std::string& utf8str, std::size_t len);
|
||||||
|
|
||||||
inline bool isBasicLatinCharacter(wchar_t wchar)
|
inline bool isBasicLatinCharacter(wchar_t wchar)
|
||||||
{
|
{
|
||||||
@@ -373,8 +373,8 @@ uint32 GetPID();
|
|||||||
|
|
||||||
namespace Acore::Impl
|
namespace Acore::Impl
|
||||||
{
|
{
|
||||||
AC_COMMON_API std::string ByteArrayToHexStr(uint8 const* bytes, size_t length, bool reverse = false);
|
AC_COMMON_API std::string ByteArrayToHexStr(uint8 const* bytes, std::size_t length, bool reverse = false);
|
||||||
AC_COMMON_API void HexStrToByteArray(std::string_view str, uint8* out, size_t outlen, bool reverse = false);
|
AC_COMMON_API void HexStrToByteArray(std::string_view str, uint8* out, std::size_t outlen, bool reverse = false);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Container>
|
template<typename Container>
|
||||||
@@ -383,13 +383,13 @@ std::string ByteArrayToHexStr(Container const& c, bool reverse = false)
|
|||||||
return Acore::Impl::ByteArrayToHexStr(std::data(c), std::size(c), reverse);
|
return Acore::Impl::ByteArrayToHexStr(std::data(c), std::size(c), reverse);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<size_t Size>
|
template<std::size_t Size>
|
||||||
void HexStrToByteArray(std::string_view str, std::array<uint8, Size>& buf, bool reverse = false)
|
void HexStrToByteArray(std::string_view str, std::array<uint8, Size>& buf, bool reverse = false)
|
||||||
{
|
{
|
||||||
Acore::Impl::HexStrToByteArray(str, buf.data(), Size, reverse);
|
Acore::Impl::HexStrToByteArray(str, buf.data(), Size, reverse);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<size_t Size>
|
template<std::size_t Size>
|
||||||
std::array<uint8, Size> HexStrToByteArray(std::string_view str, bool reverse = false)
|
std::array<uint8, Size> HexStrToByteArray(std::string_view str, bool reverse = false)
|
||||||
{
|
{
|
||||||
std::array<uint8, Size> arr;
|
std::array<uint8, Size> arr;
|
||||||
@@ -433,7 +433,7 @@ public:
|
|||||||
m_list.remove(t);
|
m_list.remove(t);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
size_t size()
|
std::size_t size()
|
||||||
{
|
{
|
||||||
return m_list.size();
|
return m_list.size();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -751,7 +751,7 @@ void AuthSession::RealmListCallback(PreparedQueryResult result)
|
|||||||
// Circle through realms in the RealmList and construct the return packet (including # of user characters in each realm)
|
// Circle through realms in the RealmList and construct the return packet (including # of user characters in each realm)
|
||||||
ByteBuffer pkt;
|
ByteBuffer pkt;
|
||||||
|
|
||||||
size_t RealmListSize = 0;
|
std::size_t RealmListSize = 0;
|
||||||
for (auto const& [realmHandle, realm] : sRealmList->GetRealms())
|
for (auto const& [realmHandle, realm] : sRealmList->GetRealms())
|
||||||
{
|
{
|
||||||
// don't work with realms which not compatible with the client
|
// don't work with realms which not compatible with the client
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ private:
|
|||||||
struct AuthHandler
|
struct AuthHandler
|
||||||
{
|
{
|
||||||
AuthStatus status;
|
AuthStatus status;
|
||||||
size_t packetSize;
|
std::size_t packetSize;
|
||||||
bool (AuthSession::* handler)();
|
bool (AuthSession::* handler)();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ namespace Acore::Impl::Readline
|
|||||||
static std::vector<std::string> vec;
|
static std::vector<std::string> vec;
|
||||||
char* cli_unpack_vector(char const*, int state)
|
char* cli_unpack_vector(char const*, int state)
|
||||||
{
|
{
|
||||||
static size_t i=0;
|
static std::size_t i=0;
|
||||||
if (!state)
|
if (!state)
|
||||||
i = 0;
|
i = 0;
|
||||||
if (i < vec.size())
|
if (i < vec.size())
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ int RASession::Send(std::string_view data)
|
|||||||
{
|
{
|
||||||
std::ostream os(&_writeBuffer);
|
std::ostream os(&_writeBuffer);
|
||||||
os << data;
|
os << data;
|
||||||
size_t written = _socket.send(_writeBuffer.data());
|
std::size_t written = _socket.send(_writeBuffer.data());
|
||||||
_writeBuffer.consume(written);
|
_writeBuffer.consume(written);
|
||||||
return written;
|
return written;
|
||||||
}
|
}
|
||||||
@@ -102,7 +102,7 @@ int RASession::Send(std::string_view data)
|
|||||||
std::string RASession::ReadString()
|
std::string RASession::ReadString()
|
||||||
{
|
{
|
||||||
boost::system::error_code error;
|
boost::system::error_code error;
|
||||||
size_t read = boost::asio::read_until(_socket, _readBuffer, "\r\n", error);
|
std::size_t read = boost::asio::read_until(_socket, _readBuffer, "\r\n", error);
|
||||||
if (!read)
|
if (!read)
|
||||||
{
|
{
|
||||||
_socket.close();
|
_socket.close();
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
using boost::asio::ip::tcp;
|
using boost::asio::ip::tcp;
|
||||||
|
|
||||||
const size_t bufferSize = 4096;
|
const std::size_t bufferSize = 4096;
|
||||||
|
|
||||||
class RASession : public std::enable_shared_from_this<RASession>
|
class RASession : public std::enable_shared_from_this<RASession>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -151,11 +151,11 @@ bool DatabaseWorkerPool<T>::PrepareStatements()
|
|||||||
else
|
else
|
||||||
connection->Unlock();
|
connection->Unlock();
|
||||||
|
|
||||||
size_t const preparedSize = connection->m_stmts.size();
|
std::size_t const preparedSize = connection->m_stmts.size();
|
||||||
if (_preparedStatementSize.size() < preparedSize)
|
if (_preparedStatementSize.size() < preparedSize)
|
||||||
_preparedStatementSize.resize(preparedSize);
|
_preparedStatementSize.resize(preparedSize);
|
||||||
|
|
||||||
for (size_t i = 0; i < preparedSize; ++i)
|
for (std::size_t i = 0; i < preparedSize; ++i)
|
||||||
{
|
{
|
||||||
// already set by another connection
|
// already set by another connection
|
||||||
// (each connection only has prepared statements of it's own type sync/async)
|
// (each connection only has prepared statements of it's own type sync/async)
|
||||||
@@ -485,7 +485,7 @@ void DatabaseWorkerPool<T>::Enqueue(SQLOperation* op)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
size_t DatabaseWorkerPool<T>::QueueSize() const
|
std::size_t DatabaseWorkerPool<T>::QueueSize() const
|
||||||
{
|
{
|
||||||
return _queue->Size();
|
return _queue->Size();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] size_t QueueSize() const;
|
[[nodiscard]] std::size_t QueueSize() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32 OpenConnections(InternalIndex type, uint8 numConnections);
|
uint32 OpenConnections(InternalIndex type, uint8 numConnections);
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Field::GetBinarySizeChecked(uint8* buf, size_t length) const
|
void Field::GetBinarySizeChecked(uint8* buf, std::size_t length) const
|
||||||
{
|
{
|
||||||
ASSERT(data.value && (data.length == length), "Expected {}-byte binary blob, got {}data ({} bytes) instead", length, data.value ? "" : "no ", data.length);
|
ASSERT(data.value && (data.length == length), "Expected {}-byte binary blob, got {}data ({} bytes) instead", length, data.value ? "" : "no ", data.length);
|
||||||
memcpy(buf, data.value, length);
|
memcpy(buf, data.value, length);
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ public:
|
|||||||
return GetDataBinary();
|
return GetDataBinary();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, size_t S>
|
template <typename T, std::size_t S>
|
||||||
inline std::enable_if_t<std::is_same_v<Binary, T>, std::array<uint8, S>> Get() const
|
inline std::enable_if_t<std::is_same_v<Binary, T>, std::array<uint8, S>> Get() const
|
||||||
{
|
{
|
||||||
std::array<uint8, S> buf = {};
|
std::array<uint8, S> buf = {};
|
||||||
@@ -173,7 +173,7 @@ private:
|
|||||||
QueryResultFieldMetadata const* meta;
|
QueryResultFieldMetadata const* meta;
|
||||||
void LogWrongType(std::string_view getter, std::string_view typeName) const;
|
void LogWrongType(std::string_view getter, std::string_view typeName) const;
|
||||||
void SetMetadata(QueryResultFieldMetadata const* fieldMeta);
|
void SetMetadata(QueryResultFieldMetadata const* fieldMeta);
|
||||||
void GetBinarySizeChecked(uint8* buf, size_t size) const;
|
void GetBinarySizeChecked(uint8* buf, std::size_t size) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -464,7 +464,7 @@ int MySQLConnection::ExecuteTransaction(std::shared_ptr<TransactionBase> transac
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t MySQLConnection::EscapeString(char* to, const char* from, size_t length)
|
std::size_t MySQLConnection::EscapeString(char* to, const char* from, std::size_t length)
|
||||||
{
|
{
|
||||||
return mysql_real_escape_string(m_Mysql, to, from, length);
|
return mysql_real_escape_string(m_Mysql, to, from, length);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ public:
|
|||||||
void RollbackTransaction();
|
void RollbackTransaction();
|
||||||
void CommitTransaction();
|
void CommitTransaction();
|
||||||
int ExecuteTransaction(std::shared_ptr<TransactionBase> transaction);
|
int ExecuteTransaction(std::shared_ptr<TransactionBase> transaction);
|
||||||
size_t EscapeString(char* to, const char* from, size_t length);
|
std::size_t EscapeString(char* to, const char* from, std::size_t length);
|
||||||
void Ping();
|
void Ping();
|
||||||
|
|
||||||
uint32 GetLastError();
|
uint32 GetLastError();
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ std::string MySQLPreparedStatement::getQueryString() const
|
|||||||
{
|
{
|
||||||
std::string queryString(m_queryString);
|
std::string queryString(m_queryString);
|
||||||
|
|
||||||
size_t pos = 0;
|
std::size_t pos = 0;
|
||||||
|
|
||||||
for (PreparedStatementData const& data : m_stmt->GetParameters())
|
for (PreparedStatementData const& data : m_stmt->GetParameters())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
#include "PreparedStatement.h"
|
#include "PreparedStatement.h"
|
||||||
#include "QueryResult.h"
|
#include "QueryResult.h"
|
||||||
|
|
||||||
bool SQLQueryHolderBase::SetPreparedQueryImpl(size_t index, PreparedStatementBase* stmt)
|
bool SQLQueryHolderBase::SetPreparedQueryImpl(std::size_t index, PreparedStatementBase* stmt)
|
||||||
{
|
{
|
||||||
if (m_queries.size() <= index)
|
if (m_queries.size() <= index)
|
||||||
{
|
{
|
||||||
@@ -34,7 +34,7 @@ bool SQLQueryHolderBase::SetPreparedQueryImpl(size_t index, PreparedStatementBas
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PreparedQueryResult SQLQueryHolderBase::GetPreparedResult(size_t index) const
|
PreparedQueryResult SQLQueryHolderBase::GetPreparedResult(std::size_t index) const
|
||||||
{
|
{
|
||||||
// Don't call to this function if the index is of a prepared statement
|
// Don't call to this function if the index is of a prepared statement
|
||||||
ASSERT(index < m_queries.size(), "Query holder result index out of range, tried to access index {} but there are only {} results",
|
ASSERT(index < m_queries.size(), "Query holder result index out of range, tried to access index {} but there are only {} results",
|
||||||
@@ -43,7 +43,7 @@ PreparedQueryResult SQLQueryHolderBase::GetPreparedResult(size_t index) const
|
|||||||
return m_queries[index].second;
|
return m_queries[index].second;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SQLQueryHolderBase::SetPreparedResult(size_t index, PreparedResultSet* result)
|
void SQLQueryHolderBase::SetPreparedResult(std::size_t index, PreparedResultSet* result)
|
||||||
{
|
{
|
||||||
if (result && !result->GetRowCount())
|
if (result && !result->GetRowCount())
|
||||||
{
|
{
|
||||||
@@ -66,7 +66,7 @@ SQLQueryHolderBase::~SQLQueryHolderBase()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SQLQueryHolderBase::SetSize(size_t size)
|
void SQLQueryHolderBase::SetSize(std::size_t size)
|
||||||
{
|
{
|
||||||
/// to optimize push_back, reserve the number of queries about to be executed
|
/// to optimize push_back, reserve the number of queries about to be executed
|
||||||
m_queries.resize(size);
|
m_queries.resize(size);
|
||||||
@@ -77,7 +77,7 @@ SQLQueryHolderTask::~SQLQueryHolderTask() = default;
|
|||||||
bool SQLQueryHolderTask::Execute()
|
bool SQLQueryHolderTask::Execute()
|
||||||
{
|
{
|
||||||
/// execute all queries in the holder and pass the results
|
/// execute all queries in the holder and pass the results
|
||||||
for (size_t i = 0; i < m_holder->m_queries.size(); ++i)
|
for (std::size_t i = 0; i < m_holder->m_queries.size(); ++i)
|
||||||
if (PreparedStatementBase* stmt = m_holder->m_queries[i].first)
|
if (PreparedStatementBase* stmt = m_holder->m_queries[i].first)
|
||||||
m_holder->SetPreparedResult(i, m_conn->Query(stmt));
|
m_holder->SetPreparedResult(i, m_conn->Query(stmt));
|
||||||
|
|
||||||
|
|||||||
@@ -28,12 +28,12 @@ friend class SQLQueryHolderTask;
|
|||||||
public:
|
public:
|
||||||
SQLQueryHolderBase() = default;
|
SQLQueryHolderBase() = default;
|
||||||
virtual ~SQLQueryHolderBase();
|
virtual ~SQLQueryHolderBase();
|
||||||
void SetSize(size_t size);
|
void SetSize(std::size_t size);
|
||||||
PreparedQueryResult GetPreparedResult(size_t index) const;
|
PreparedQueryResult GetPreparedResult(std::size_t index) const;
|
||||||
void SetPreparedResult(size_t index, PreparedResultSet* result);
|
void SetPreparedResult(std::size_t index, PreparedResultSet* result);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool SetPreparedQueryImpl(size_t index, PreparedStatementBase* stmt);
|
bool SetPreparedQueryImpl(std::size_t index, PreparedStatementBase* stmt);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<std::pair<PreparedStatementBase*, PreparedQueryResult>> m_queries;
|
std::vector<std::pair<PreparedStatementBase*, PreparedQueryResult>> m_queries;
|
||||||
@@ -43,7 +43,7 @@ template<typename T>
|
|||||||
class SQLQueryHolder : public SQLQueryHolderBase
|
class SQLQueryHolder : public SQLQueryHolderBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool SetPreparedQuery(size_t index, PreparedStatement<T>* stmt)
|
bool SetPreparedQuery(std::size_t index, PreparedStatement<T>* stmt)
|
||||||
{
|
{
|
||||||
return SetPreparedQueryImpl(index, stmt);
|
return SetPreparedQueryImpl(index, stmt);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include "DatabaseEnv.h"
|
#include "DatabaseEnv.h"
|
||||||
#include "LogMessage.h"
|
#include "LogMessage.h"
|
||||||
#include "PreparedStatement.h"
|
#include "PreparedStatement.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
AppenderDB::AppenderDB(uint8 id, std::string const& name, LogLevel level, AppenderFlags /*flags*/, std::vector<std::string_view> const& /*args*/)
|
AppenderDB::AppenderDB(uint8 id, std::string const& name, LogLevel level, AppenderFlags /*flags*/, std::vector<std::string_view> const& /*args*/)
|
||||||
: Appender(id, name, level), realmId(0), enabled(false) { }
|
: Appender(id, name, level), realmId(0), enabled(false) { }
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#define APPENDERDB_H
|
#define APPENDERDB_H
|
||||||
|
|
||||||
#include "Appender.h"
|
#include "Appender.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
class AppenderDB : public Appender
|
class AppenderDB : public Appender
|
||||||
{
|
{
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user