refactor(Core/Misc): acore to Acore (#6043)

This commit is contained in:
Kitzunu
2021-05-31 14:21:54 +02:00
committed by GitHub
parent 7eeae6866e
commit 897a02bb75
224 changed files with 942 additions and 942 deletions

View File

@@ -33,7 +33,7 @@ namespace boost::asio::ip
typedef basic_endpoint<tcp> tcp_endpoint;
}
namespace acore::Asio
namespace Acore::Asio
{
class DeadlineTimer;
class IoContext;

View File

@@ -18,7 +18,7 @@
#define DeadlineTimerBase boost::asio::basic_deadline_timer<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime> BasicDeadlineTimerThirdTemplateArg>
namespace acore::Asio
namespace Acore::Asio
{
class DeadlineTimer : public DeadlineTimerBase
{

View File

@@ -19,7 +19,7 @@
#define IoContextBase io_service
#endif
namespace acore::Asio
namespace Acore::Asio
{
class IoContext
{

View File

@@ -9,7 +9,7 @@
#include "Define.h"
#include <boost/asio/ip/address.hpp>
namespace acore::Net
namespace Acore::Net
{
#if BOOST_VERSION >= 106600
using boost::asio::ip::make_address;

View File

@@ -15,7 +15,7 @@
#include <boost/asio/ip/network_v6.hpp>
#endif
namespace acore::Net
namespace Acore::Net
{
inline bool IsInNetwork(boost::asio::ip::address_v4 const& networkAddress, boost::asio::ip::address_v4 const& mask, boost::asio::ip::address_v4 const& clientAddress)
{

View File

@@ -11,7 +11,7 @@
#include <boost/asio/ip/tcp.hpp>
#include <string>
namespace acore::Asio
namespace Acore::Asio
{
/**
Hack to make it possible to forward declare resolver (one of its template arguments is a typedef to something super long and using nested classes)

View File

@@ -13,7 +13,7 @@
#include <boost/asio/bind_executor.hpp>
#endif
namespace acore::Asio
namespace Acore::Asio
{
/**
Hack to make it possible to forward declare strand (which is a inner class)

View File

@@ -6,9 +6,9 @@
#include "GitRevision.h"
#include "StringFormat.h"
void acore::Banner::Show(char const* applicationName, void(*log)(char const* text), void(*logExtraInfo)())
void Acore::Banner::Show(char const* applicationName, void(*log)(char const* text), void(*logExtraInfo)())
{
log(acore::StringFormat("%s (%s)", GitRevision::GetFullVersion(), applicationName).c_str());
log(Acore::StringFormat("%s (%s)", GitRevision::GetFullVersion(), applicationName).c_str());
log("<Ctrl-C> to stop.\n");
log(" █████╗ ███████╗███████╗██████╗ ██████╗ ████████╗██╗ ██╗");
log(" ██╔══██╗╚══███╔╝██╔════╝██╔══██╗██╔═══██╗╚══██╔══╝██║ ██║");

View File

@@ -7,7 +7,7 @@
#include "Define.h"
namespace acore
namespace Acore
{
namespace Banner
{

View File

@@ -63,7 +63,7 @@ namespace MMAP
}
// load and init dtNavMesh - read parameters from file
std::string fileName = acore::StringFormat(MAP_FILE_NAME_FORMAT, sConfigMgr->GetOption<std::string>("DataDir", ".").c_str(), mapId);
std::string fileName = Acore::StringFormat(MAP_FILE_NAME_FORMAT, sConfigMgr->GetOption<std::string>("DataDir", ".").c_str(), mapId);
FILE* file = fopen(fileName.c_str(), "rb");
if (!file)
@@ -122,7 +122,7 @@ namespace MMAP
}
// load this tile :: mmaps/MMMXXYY.mmtile
std::string fileName = acore::StringFormat(TILE_FILE_NAME_FORMAT, sConfigMgr->GetOption<std::string>("DataDir", ".").c_str(), mapId, x, y);
std::string fileName = Acore::StringFormat(TILE_FILE_NAME_FORMAT, sConfigMgr->GetOption<std::string>("DataDir", ".").c_str(), mapId, x, y);
FILE* file = fopen(fileName.c_str(), "rb");
if (!file)
{

View File

@@ -98,7 +98,7 @@ AC_COMMON_API void CleanStringForMysqlQuery(std::string& str);
#define MAX_QUERY_LEN 32*1024
namespace acore
namespace Acore
{
template<class ArgumentType, class ResultType>
struct unary_function

View File

@@ -41,7 +41,7 @@ namespace
template<typename Format, typename... Args>
inline void PrintError(std::string_view filename, Format&& fmt, Args&& ... args)
{
std::string message = acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...);
std::string message = Acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...);
if (IsAppConfig(filename))
{
@@ -76,7 +76,7 @@ namespace
if (in.fail())
{
throw ConfigException(acore::StringFormat("Config::LoadFile: Failed open file '%s'", file.c_str()));
throw ConfigException(Acore::StringFormat("Config::LoadFile: Failed open file '%s'", file.c_str()));
}
uint32 count = 0;
@@ -104,11 +104,11 @@ namespace
// read line error
if (!in.good() && !in.eof())
{
throw ConfigException(acore::StringFormat("> Config::LoadFile: Failure to read line number %u in file '%s'", lineNumber, file.c_str()));
throw ConfigException(Acore::StringFormat("> Config::LoadFile: Failure to read line number %u in file '%s'", lineNumber, file.c_str()));
}
// remove whitespace in line
line = acore::String::Trim(line, in.getloc());
line = Acore::String::Trim(line, in.getloc());
if (line.empty())
{
@@ -135,8 +135,8 @@ namespace
continue;
}
auto entry = acore::String::Trim(line.substr(0, equal_pos), in.getloc());
auto value = acore::String::Trim(line.substr(equal_pos + 1, std::string::npos), in.getloc());
auto entry = Acore::String::Trim(line.substr(0, equal_pos), in.getloc());
auto value = Acore::String::Trim(line.substr(equal_pos + 1, std::string::npos), in.getloc());
value.erase(std::remove(value.begin(), value.end(), '"'), value.end());
@@ -153,7 +153,7 @@ namespace
// No lines read
if (!count)
throw ConfigException(acore::StringFormat("Config::LoadFile: Empty file '%s'", file.c_str()));
throw ConfigException(Acore::StringFormat("Config::LoadFile: Empty file '%s'", file.c_str()));
// Add correct keys if file load without errors
for (auto const& [entry, key] : fileConfigs)
@@ -214,19 +214,19 @@ T ConfigMgr::GetValueDefault(std::string const& name, T const& def, bool showLog
if (showLogs)
{
LOG_ERROR("server", "> Config: Missing name %s in config, add \"%s = %s\"",
name.c_str(), name.c_str(), acore::ToString(def).c_str());
name.c_str(), name.c_str(), Acore::ToString(def).c_str());
}
return def;
}
auto value = acore::StringTo<T>(itr->second);
auto value = Acore::StringTo<T>(itr->second);
if (!value)
{
if (showLogs)
{
LOG_ERROR("server", "> Config: Bad value defined for name '%s', going to use '%s' instead",
name.c_str(), acore::ToString(def).c_str());
name.c_str(), Acore::ToString(def).c_str());
}
return def;
@@ -264,7 +264,7 @@ bool ConfigMgr::GetOption<bool>(std::string const& name, bool const& def, bool s
{
std::string val = GetValueDefault(name, std::string(def ? "1" : "0"), showLogs);
auto boolVal = acore::StringTo<bool>(val);
auto boolVal = Acore::StringTo<bool>(val);
if (!boolVal)
{
if (showLogs)

View File

@@ -7,25 +7,25 @@
#include "Errors.h"
#include <limits>
acore::Crypto::AES::AES(bool encrypting) : _ctx(EVP_CIPHER_CTX_new()), _encrypting(encrypting)
Acore::Crypto::AES::AES(bool encrypting) : _ctx(EVP_CIPHER_CTX_new()), _encrypting(encrypting)
{
EVP_CIPHER_CTX_init(_ctx);
int status = EVP_CipherInit_ex(_ctx, EVP_aes_128_gcm(), nullptr, nullptr, nullptr, _encrypting ? 1 : 0);
ASSERT(status);
}
acore::Crypto::AES::~AES()
Acore::Crypto::AES::~AES()
{
EVP_CIPHER_CTX_free(_ctx);
}
void acore::Crypto::AES::Init(Key const& key)
void Acore::Crypto::AES::Init(Key const& key)
{
int status = EVP_CipherInit_ex(_ctx, nullptr, nullptr, key.data(), nullptr, -1);
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, size_t length, Tag& tag)
{
ASSERT(length <= static_cast<size_t>(std::numeric_limits<int>::max()));
int len = static_cast<int>(length);

View File

@@ -10,7 +10,7 @@
#include <array>
#include <openssl/evp.h>
namespace acore::Crypto
namespace Acore::Crypto
{
class AC_COMMON_API AES
{

View File

@@ -7,7 +7,7 @@
#include "ARC4.h"
#include "Errors.h"
acore::Crypto::ARC4::ARC4()
Acore::Crypto::ARC4::ARC4()
: _ctx(EVP_CIPHER_CTX_new())
{
EVP_CIPHER_CTX_init(_ctx);
@@ -15,12 +15,12 @@ acore::Crypto::ARC4::ARC4()
ASSERT(result == 1);
}
acore::Crypto::ARC4::~ARC4()
Acore::Crypto::ARC4::~ARC4()
{
EVP_CIPHER_CTX_free(_ctx);
}
void acore::Crypto::ARC4::Init(uint8 const* seed, size_t len)
void Acore::Crypto::ARC4::Init(uint8 const* seed, size_t len)
{
int result1 = EVP_CIPHER_CTX_set_key_length(_ctx, len);
ASSERT(result1 == 1);
@@ -28,7 +28,7 @@ void acore::Crypto::ARC4::Init(uint8 const* seed, size_t len)
ASSERT(result2 == 1);
}
void acore::Crypto::ARC4::UpdateData(uint8* data, size_t len)
void Acore::Crypto::ARC4::UpdateData(uint8* data, size_t len)
{
int outlen = 0;
int result1 = EVP_EncryptUpdate(_ctx, data, &outlen, data, len);

View File

@@ -11,7 +11,7 @@
#include <array>
#include <openssl/evp.h>
namespace acore::Crypto
namespace Acore::Crypto
{
class ARC4
{

View File

@@ -6,7 +6,7 @@
#include "Argon2.h"
#include <argon2/argon2.h>
/*static*/ Optional<std::string> acore::Crypto::Argon2::Hash(std::string const& password, BigNumber const& salt, uint32 nIterations, uint32 kibMemoryCost)
/*static*/ Optional<std::string> Acore::Crypto::Argon2::Hash(std::string const& password, BigNumber const& salt, uint32 nIterations, uint32 kibMemoryCost)
{
char buf[ENCODED_HASH_LEN];
std::vector<uint8> saltBytes = salt.ToByteVector();
@@ -25,7 +25,7 @@
return {};
}
/*static*/ bool acore::Crypto::Argon2::Verify(std::string const& password, std::string const& hash)
/*static*/ bool Acore::Crypto::Argon2::Verify(std::string const& password, std::string const& hash)
{
int status = argon2id_verify(hash.c_str(), password.c_str(), password.length());
return (status == ARGON2_OK);

View File

@@ -11,7 +11,7 @@
#include "Optional.h"
#include <string>
namespace acore::Crypto
namespace Acore::Crypto
{
struct AC_COMMON_API Argon2
{

View File

@@ -16,9 +16,9 @@ AuthCrypt::AuthCrypt() : _initialized(false)
void AuthCrypt::Init(SessionKey const& K)
{
uint8 ServerEncryptionKey[] = { 0xCC, 0x98, 0xAE, 0x04, 0xE8, 0x97, 0xEA, 0xCA, 0x12, 0xDD, 0xC0, 0x93, 0x42, 0x91, 0x53, 0x57 };
_serverEncrypt.Init(acore::Crypto::HMAC_SHA1::GetDigestOf(ServerEncryptionKey, K));
_serverEncrypt.Init(Acore::Crypto::HMAC_SHA1::GetDigestOf(ServerEncryptionKey, K));
uint8 ServerDecryptionKey[] = { 0xC2, 0xB3, 0x72, 0x3C, 0xC6, 0xAE, 0xD9, 0xB5, 0x34, 0x3C, 0x53, 0xEE, 0x2F, 0x43, 0x67, 0xCE };
_clientDecrypt.Init(acore::Crypto::HMAC_SHA1::GetDigestOf(ServerDecryptionKey, K));
_clientDecrypt.Init(Acore::Crypto::HMAC_SHA1::GetDigestOf(ServerDecryptionKey, K));
// Drop first 1024 bytes, as WoW uses ARC4-drop1024.
std::array<uint8, 1024> syncBuf;

View File

@@ -23,8 +23,8 @@ public:
bool IsInitialized() const { return _initialized; }
private:
acore::Crypto::ARC4 _clientDecrypt;
acore::Crypto::ARC4 _serverEncrypt;
Acore::Crypto::ARC4 _clientDecrypt;
Acore::Crypto::ARC4 _serverEncrypt;
bool _initialized;
};
#endif

View File

@@ -9,8 +9,8 @@
#include <algorithm>
#include <functional>
using SHA1 = acore::Crypto::SHA1;
using SRP6 = acore::Crypto::SRP6;
using SHA1 = Acore::Crypto::SHA1;
using SRP6 = Acore::Crypto::SRP6;
/*static*/ std::array<uint8, 1> const SRP6::g = { 7 };
/*static*/ std::array<uint8, 32> const SRP6::N = HexStrToByteArray<32>("894B645E89E1535BBDAD5B8B290650530801B18EBFBF5E8FAB3C82872A3E9BB7", true);

View File

@@ -14,7 +14,7 @@
#include <array>
#include <optional>
namespace acore::Crypto
namespace Acore::Crypto
{
class SRP6
{

View File

@@ -8,7 +8,7 @@
#include "Define.h"
namespace acore::Crypto
namespace Acore::Crypto
{
struct Constants
{

View File

@@ -13,7 +13,7 @@
#include <iterator>
#include <vector>
namespace acore::Impl
namespace Acore::Impl
{
struct CryptoGenericsImpl
{
@@ -21,7 +21,7 @@ namespace acore::Impl
static typename Cipher::IV GenerateRandomIV()
{
typename Cipher::IV iv;
acore::Crypto::GetRandomBytes(iv);
Acore::Crypto::GetRandomBytes(iv);
return iv;
}
@@ -44,7 +44,7 @@ namespace acore::Impl
};
}
namespace acore::Crypto
namespace Acore::Crypto
{
template <typename Cipher>
void AEEncryptWithRandomIV(std::vector<uint8>& data, typename Cipher::Key const& key)
@@ -52,7 +52,7 @@ namespace acore::Crypto
using IV = typename Cipher::IV;
using Tag = typename Cipher::Tag;
// select random IV
IV iv = acore::Impl::CryptoGenericsImpl::GenerateRandomIV<Cipher>();
IV iv = Acore::Impl::CryptoGenericsImpl::GenerateRandomIV<Cipher>();
Tag tag;
// encrypt data
@@ -62,8 +62,8 @@ namespace acore::Crypto
ASSERT(success);
// append trailing IV and tag
acore::Impl::CryptoGenericsImpl::AppendToBack(data, iv);
acore::Impl::CryptoGenericsImpl::AppendToBack(data, tag);
Acore::Impl::CryptoGenericsImpl::AppendToBack(data, iv);
Acore::Impl::CryptoGenericsImpl::AppendToBack(data, tag);
}
template <typename Cipher>
@@ -80,8 +80,8 @@ namespace acore::Crypto
// extract trailing IV and tag
IV iv;
Tag tag;
acore::Impl::CryptoGenericsImpl::SplitFromBack(data, tag);
acore::Impl::CryptoGenericsImpl::SplitFromBack(data, iv);
Acore::Impl::CryptoGenericsImpl::SplitFromBack(data, tag);
Acore::Impl::CryptoGenericsImpl::SplitFromBack(data, iv);
// decrypt data
Cipher cipher(false);

View File

@@ -16,7 +16,7 @@
class BigNumber;
namespace acore::Impl
namespace Acore::Impl
{
struct GenericHashImpl
{
@@ -98,10 +98,10 @@ namespace acore::Impl
};
}
namespace acore::Crypto
namespace Acore::Crypto
{
using SHA1 = acore::Impl::GenericHash<EVP_sha1, Constants::SHA1_DIGEST_LENGTH_BYTES>;
using SHA256 = acore::Impl::GenericHash<EVP_sha256, Constants::SHA256_DIGEST_LENGTH_BYTES>;
using SHA1 = Acore::Impl::GenericHash<EVP_sha1, Constants::SHA1_DIGEST_LENGTH_BYTES>;
using SHA256 = Acore::Impl::GenericHash<EVP_sha256, Constants::SHA256_DIGEST_LENGTH_BYTES>;
}
#endif

View File

@@ -7,7 +7,7 @@
#include "Errors.h"
#include <openssl/rand.h>
void acore::Crypto::GetRandomBytes(uint8* buf, size_t len)
void Acore::Crypto::GetRandomBytes(uint8* buf, size_t len)
{
int result = RAND_bytes(buf, len);
ASSERT(result == 1);

View File

@@ -9,7 +9,7 @@
#include "Define.h"
#include <array>
namespace acore::Crypto
namespace Acore::Crypto
{
void GetRandomBytes(uint8* buf, size_t len);

View File

@@ -16,7 +16,7 @@
class BigNumber;
namespace acore::Impl
namespace Acore::Impl
{
struct HMACImpl
{
@@ -110,9 +110,9 @@ namespace acore::Impl
};
}
namespace acore::Crypto
namespace Acore::Crypto
{
using HMAC_SHA1 = acore::Impl::GenericHMAC<EVP_sha1, Constants::SHA1_DIGEST_LENGTH_BYTES>;
using HMAC_SHA256 = acore::Impl::GenericHMAC<EVP_sha256, Constants::SHA256_DIGEST_LENGTH_BYTES>;
using HMAC_SHA1 = Acore::Impl::GenericHMAC<EVP_sha1, Constants::SHA1_DIGEST_LENGTH_BYTES>;
using HMAC_SHA256 = Acore::Impl::GenericHMAC<EVP_sha256, Constants::SHA256_DIGEST_LENGTH_BYTES>;
}
#endif

View File

@@ -8,11 +8,11 @@
#include <openssl/evp.h>
#include <openssl/hmac.h>
constexpr std::size_t acore::Crypto::TOTP::RECOMMENDED_SECRET_LENGTH;
constexpr std::size_t Acore::Crypto::TOTP::RECOMMENDED_SECRET_LENGTH;
static constexpr uint32 TOTP_INTERVAL = 30;
static constexpr uint32 HMAC_RESULT_SIZE = 20;
/*static*/ uint32 acore::Crypto::TOTP::GenerateToken(Secret const& secret, time_t timestamp)
/*static*/ uint32 Acore::Crypto::TOTP::GenerateToken(Secret const& secret, time_t timestamp)
{
timestamp /= TOTP_INTERVAL;
unsigned char challenge[8];
@@ -31,7 +31,7 @@ static constexpr uint32 HMAC_RESULT_SIZE = 20;
return (truncated % 1000000);
}
/*static*/ bool acore::Crypto::TOTP::ValidateToken(Secret const& secret, uint32 token)
/*static*/ bool Acore::Crypto::TOTP::ValidateToken(Secret const& secret, uint32 token)
{
time_t now = time(nullptr);
return (

View File

@@ -10,7 +10,7 @@
#include <ctime>
#include <vector>
namespace acore::Crypto
namespace Acore::Crypto
{
struct AC_COMMON_API TOTP
{

View File

@@ -54,11 +54,11 @@ namespace
}
}
namespace acore
namespace Acore
{
void Assert(char const* file, int line, char const* function, std::string const& debugInfo, char const* message)
{
std::string formattedMessage = acore::StringFormat("\n%s:%i in %s ASSERTION FAILED:\n %s\n", file, line, function, message) + debugInfo + '\n';
std::string formattedMessage = Acore::StringFormat("\n%s:%i in %s ASSERTION FAILED:\n %s\n", file, line, function, message) + debugInfo + '\n';
fprintf(stderr, "%s", formattedMessage.c_str());
fflush(stderr);
Crash(formattedMessage.c_str());
@@ -69,7 +69,7 @@ namespace acore
va_list args;
va_start(args, format);
std::string formattedMessage = acore::StringFormat("\n%s:%i in %s ASSERTION FAILED:\n %s\n", file, line, function, message) + FormatAssertionMessage(format, args) + '\n' + debugInfo + '\n';
std::string formattedMessage = Acore::StringFormat("\n%s:%i in %s ASSERTION FAILED:\n %s\n", file, line, function, message) + FormatAssertionMessage(format, args) + '\n' + debugInfo + '\n';
va_end(args);
fprintf(stderr, "%s", formattedMessage.c_str());
@@ -83,7 +83,7 @@ namespace acore
va_list args;
va_start(args, message);
std::string formattedMessage = acore::StringFormat("\n%s:%i in %s FATAL ERROR:\n", file, line, function) + FormatAssertionMessage(message, args) + '\n';
std::string formattedMessage = Acore::StringFormat("\n%s:%i in %s FATAL ERROR:\n", file, line, function) + FormatAssertionMessage(message, args) + '\n';
va_end(args);
fprintf(stderr, "%s", formattedMessage.c_str());
@@ -95,7 +95,7 @@ namespace acore
void Error(char const* file, int line, char const* function, char const* message)
{
std::string formattedMessage = acore::StringFormat("\n%s:%i in %s ERROR:\n %s\n", file, line, function, message);
std::string formattedMessage = Acore::StringFormat("\n%s:%i in %s ERROR:\n %s\n", file, line, function, message);
fprintf(stderr, "%s", formattedMessage.c_str());
fflush(stderr);
Crash(formattedMessage.c_str());
@@ -109,7 +109,7 @@ namespace acore
void Abort(char const* file, int line, char const* function)
{
std::string formattedMessage = acore::StringFormat("\n%s:%i in %s ABORTED.\n", file, line, function);
std::string formattedMessage = Acore::StringFormat("\n%s:%i in %s ABORTED.\n", file, line, function);
fprintf(stderr, "%s", formattedMessage.c_str());
fflush(stderr);
Crash(formattedMessage.c_str());
@@ -132,13 +132,13 @@ namespace acore
void AbortHandler(int sigval)
{
// nothing useful to log here, no way to pass args
std::string formattedMessage = acore::StringFormat("Caught signal %i\n", sigval);
std::string formattedMessage = Acore::StringFormat("Caught signal %i\n", sigval);
fprintf(stderr, "%s", formattedMessage.c_str());
fflush(stderr);
Crash(formattedMessage.c_str());
}
} // namespace acore
} // namespace Acore
std::string GetDebugInfo()
{

View File

@@ -10,7 +10,7 @@
#include "Define.h"
#include <string>
namespace acore
namespace Acore
{
DECLSPEC_NORETURN void Assert(char const* file, int line, char const* function, std::string const& debugInfo, char const* message) ATTR_NORETURN;
DECLSPEC_NORETURN void Assert(char const* file, int line, char const* function, std::string const& debugInfo, char const* message, char const* format, ...) ATTR_NORETURN ATTR_PRINTF(6, 7);
@@ -27,7 +27,7 @@ namespace acore
DECLSPEC_NORETURN void AbortHandler(int sigval) ATTR_NORETURN;
} // namespace acore
} // namespace Acore
std::string GetDebugInfo();
@@ -43,13 +43,13 @@ std::string GetDebugInfo();
#define EXCEPTION_ASSERTION_FAILURE 0xC0000420L
#endif
#define WPAssert(cond, ...) ASSERT_BEGIN do { if (!(cond)) acore::Assert(__FILE__, __LINE__, __FUNCTION__, GetDebugInfo(), #cond, ##__VA_ARGS__); } while(0) ASSERT_END
#define WPAssert_NODEBUGINFO(cond, ...) ASSERT_BEGIN do { if (!(cond)) acore::Assert(__FILE__, __LINE__, __FUNCTION__, "", #cond, ##__VA_ARGS__); } while(0) ASSERT_END
#define WPFatal(cond, ...) ASSERT_BEGIN do { if (!(cond)) acore::Fatal(__FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); } while(0) ASSERT_END
#define WPError(cond, msg) ASSERT_BEGIN do { if (!(cond)) acore::Error(__FILE__, __LINE__, __FUNCTION__, (msg)); } while(0) ASSERT_END
#define WPWarning(cond, msg) ASSERT_BEGIN do { if (!(cond)) acore::Warning(__FILE__, __LINE__, __FUNCTION__, (msg)); } while(0) ASSERT_END
#define WPAbort() ASSERT_BEGIN do { acore::Abort(__FILE__, __LINE__, __FUNCTION__); } while(0) ASSERT_END
#define WPAbort_MSG(msg, ...) ASSERT_BEGIN do { acore::Abort(__FILE__, __LINE__, __FUNCTION__, (msg), ##__VA_ARGS__); } while(0) ASSERT_END
#define WPAssert(cond, ...) ASSERT_BEGIN do { if (!(cond)) Acore::Assert(__FILE__, __LINE__, __FUNCTION__, GetDebugInfo(), #cond, ##__VA_ARGS__); } while(0) ASSERT_END
#define WPAssert_NODEBUGINFO(cond, ...) ASSERT_BEGIN do { if (!(cond)) Acore::Assert(__FILE__, __LINE__, __FUNCTION__, "", #cond, ##__VA_ARGS__); } while(0) ASSERT_END
#define WPFatal(cond, ...) ASSERT_BEGIN do { if (!(cond)) Acore::Fatal(__FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); } while(0) ASSERT_END
#define WPError(cond, msg) ASSERT_BEGIN do { if (!(cond)) Acore::Error(__FILE__, __LINE__, __FUNCTION__, (msg)); } while(0) ASSERT_END
#define WPWarning(cond, msg) ASSERT_BEGIN do { if (!(cond)) Acore::Warning(__FILE__, __LINE__, __FUNCTION__, (msg)); } while(0) ASSERT_END
#define WPAbort() ASSERT_BEGIN do { Acore::Abort(__FILE__, __LINE__, __FUNCTION__); } while(0) ASSERT_END
#define WPAbort_MSG(msg, ...) ASSERT_BEGIN do { Acore::Abort(__FILE__, __LINE__, __FUNCTION__, (msg), ##__VA_ARGS__); } while(0) ASSERT_END
#ifdef PERFORMANCE_PROFILING
#define ASSERT(cond, ...) ((void)0)

View File

@@ -91,13 +91,13 @@ template<class OBJECT_TYPES>
class TypeMapContainer
{
public:
template<class SPECIFIC_TYPE> [[nodiscard]] size_t Count() const { return acore::Count(i_elements, (SPECIFIC_TYPE*)nullptr); }
template<class SPECIFIC_TYPE> [[nodiscard]] size_t Count() const { return Acore::Count(i_elements, (SPECIFIC_TYPE*)nullptr); }
/// inserts a specific object into the container
template<class SPECIFIC_TYPE>
bool insert(SPECIFIC_TYPE* obj)
{
SPECIFIC_TYPE* t = acore::Insert(i_elements, obj);
SPECIFIC_TYPE* t = Acore::Insert(i_elements, obj);
return (t != nullptr);
}
@@ -105,7 +105,7 @@ public:
//template<class SPECIFIC_TYPE>
// bool remove(SPECIFIC_TYPE* obj)
//{
// SPECIFIC_TYPE* t = acore::Remove(i_elements, obj);
// SPECIFIC_TYPE* t = Acore::Remove(i_elements, obj);
// return (t != nullptr);
//}
@@ -123,19 +123,19 @@ public:
template<class SPECIFIC_TYPE>
bool Insert(KEY_TYPE const& handle, SPECIFIC_TYPE* obj)
{
return acore::Insert(_elements, handle, obj);
return Acore::Insert(_elements, handle, obj);
}
template<class SPECIFIC_TYPE>
bool Remove(KEY_TYPE const& handle)
{
return acore::Remove(_elements, handle, (SPECIFIC_TYPE*)nullptr);
return Acore::Remove(_elements, handle, (SPECIFIC_TYPE*)nullptr);
}
template<class SPECIFIC_TYPE>
SPECIFIC_TYPE* Find(KEY_TYPE const& handle)
{
return acore::Find(_elements, handle, (SPECIFIC_TYPE*)nullptr);
return Acore::Find(_elements, handle, (SPECIFIC_TYPE*)nullptr);
}
ContainerUnorderedMap<OBJECT_TYPES, KEY_TYPE>& GetElements() { return _elements; }

View File

@@ -18,7 +18,7 @@
#include <map>
#include <unordered_map>
namespace acore
namespace Acore
{
// Helpers
// Insert helpers

View File

@@ -17,7 +17,7 @@
#include "Utilities/TypeList.h"
#include <map>
namespace acore
namespace Acore
{
/* ContainerMapList Helpers */
// count functions

View File

@@ -32,12 +32,12 @@ struct B32Impl
}
};
/*static*/ std::string acore::Encoding::Base32::Encode(std::vector<uint8> const& data)
/*static*/ std::string Acore::Encoding::Base32::Encode(std::vector<uint8> const& data)
{
return acore::Impl::GenericBaseEncoding<B32Impl>::Encode(data);
return Acore::Impl::GenericBaseEncoding<B32Impl>::Encode(data);
}
/*static*/ Optional<std::vector<uint8>> acore::Encoding::Base32::Decode(std::string const& data)
/*static*/ Optional<std::vector<uint8>> Acore::Encoding::Base32::Decode(std::string const& data)
{
return acore::Impl::GenericBaseEncoding<B32Impl>::Decode(data);
return Acore::Impl::GenericBaseEncoding<B32Impl>::Decode(data);
}

View File

@@ -11,7 +11,7 @@
#include <string>
#include <vector>
namespace acore::Encoding
namespace Acore::Encoding
{
struct AC_COMMON_API Base32
{

View File

@@ -34,12 +34,12 @@ struct B64Impl
}
};
/*static*/ std::string acore::Encoding::Base64::Encode(std::vector<uint8> const& data)
/*static*/ std::string Acore::Encoding::Base64::Encode(std::vector<uint8> const& data)
{
return acore::Impl::GenericBaseEncoding<B64Impl>::Encode(data);
return Acore::Impl::GenericBaseEncoding<B64Impl>::Encode(data);
}
/*static*/ Optional<std::vector<uint8>> acore::Encoding::Base64::Decode(std::string const& data)
/*static*/ Optional<std::vector<uint8>> Acore::Encoding::Base64::Decode(std::string const& data)
{
return acore::Impl::GenericBaseEncoding<B64Impl>::Decode(data);
return Acore::Impl::GenericBaseEncoding<B64Impl>::Decode(data);
}

View File

@@ -11,7 +11,7 @@
#include <string>
#include <vector>
namespace acore::Encoding
namespace Acore::Encoding
{
struct AC_COMMON_API Base64
{

View File

@@ -12,7 +12,7 @@
#include <string>
#include <vector>
namespace acore::Impl
namespace Acore::Impl
{
template <typename Encoding>
struct GenericBaseEncoding

View File

@@ -49,7 +49,7 @@ void Appender::write(LogMessage* message)
ss << message->getTimeStr() << ' ';
if (flags & APPENDER_FLAGS_PREFIX_LOGLEVEL)
ss << acore::StringFormat("%-5s ", Appender::getLogLevelString(message->level));
ss << Acore::StringFormat("%-5s ", Appender::getLogLevelString(message->level));
if (flags & APPENDER_FLAGS_PREFIX_LOGFILTERTYPE)
ss << '[' << message->type << "] ";

View File

@@ -34,20 +34,20 @@ void AppenderConsole::InitColors(std::string const& name, std::string_view str)
return;
}
std::vector<std::string_view> colorStrs = acore::Tokenize(str, ' ', false);
std::vector<std::string_view> colorStrs = Acore::Tokenize(str, ' ', false);
if (colorStrs.size() != NUM_ENABLED_LOG_LEVELS)
{
throw InvalidAppenderArgsException(acore::StringFormat("Log::CreateAppenderFromConfig: Invalid color data '%s' for console appender %s (expected %u entries, got %zu)",
throw InvalidAppenderArgsException(Acore::StringFormat("Log::CreateAppenderFromConfig: Invalid color data '%s' for console appender %s (expected %u entries, got %zu)",
std::string(str).c_str(), name.c_str(), NUM_ENABLED_LOG_LEVELS, colorStrs.size()));
}
for (uint8 i = 0; i < NUM_ENABLED_LOG_LEVELS; ++i)
{
if (Optional<uint8> color = acore::StringTo<uint8>(colorStrs[i]); color && EnumUtils::IsValid<ColorTypes>(*color))
if (Optional<uint8> color = Acore::StringTo<uint8>(colorStrs[i]); color && EnumUtils::IsValid<ColorTypes>(*color))
_colors[i] = static_cast<ColorTypes>(*color);
else
{
throw InvalidAppenderArgsException(acore::StringFormat("Log::CreateAppenderFromConfig: Invalid color '%s' for log level %s on console appender %s",
throw InvalidAppenderArgsException(Acore::StringFormat("Log::CreateAppenderFromConfig: Invalid color '%s' for log level %s on console appender %s",
std::string(colorStrs[i]).c_str(), EnumUtils::ToTitle(static_cast<LogLevel>(i)), name.c_str()));
}
}

View File

@@ -18,7 +18,7 @@ AppenderFile::AppenderFile(uint8 id, std::string const& name, LogLevel level, Ap
_fileSize(0)
{
if (args.size() < 4)
throw InvalidAppenderArgsException(acore::StringFormat("Log::CreateAppenderFromConfig: Missing file name for appender %s", name.c_str()));
throw InvalidAppenderArgsException(Acore::StringFormat("Log::CreateAppenderFromConfig: Missing file name for appender %s", name.c_str()));
_fileName.assign(args[3]);
@@ -37,10 +37,10 @@ AppenderFile::AppenderFile(uint8 id, std::string const& name, LogLevel level, Ap
if (5 < args.size())
{
if (Optional<uint32> size = acore::StringTo<uint32>(args[5]))
if (Optional<uint32> size = Acore::StringTo<uint32>(args[5]))
_maxFileSize = *size;
else
throw InvalidAppenderArgsException(acore::StringFormat("Log::CreateAppenderFromConfig: Invalid size '%s' for appender %s", std::string(args[5]).c_str(), name.c_str()));
throw InvalidAppenderArgsException(Acore::StringFormat("Log::CreateAppenderFromConfig: Invalid size '%s' for appender %s", std::string(args[5]).c_str(), name.c_str()));
}
_dynamicName = std::string::npos != _fileName.find("%s");

View File

@@ -54,7 +54,7 @@ void Log::CreateAppenderFromConfig(std::string const& appenderName)
// if type = Console. optional1 = Color
std::string options = sConfigMgr->GetStringDefault(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::string name = appenderName.substr(9);
@@ -66,8 +66,8 @@ void Log::CreateAppenderFromConfig(std::string const& appenderName)
}
AppenderFlags flags = APPENDER_FLAGS_NONE;
AppenderType type = AppenderType(acore::StringTo<uint8>(tokens[0]).value_or(APPENDER_INVALID));
LogLevel level = LogLevel(acore::StringTo<uint8>(tokens[1]).value_or(LOG_LEVEL_INVALID));
AppenderType type = AppenderType(Acore::StringTo<uint8>(tokens[0]).value_or(APPENDER_INVALID));
LogLevel level = LogLevel(Acore::StringTo<uint8>(tokens[1]).value_or(LOG_LEVEL_INVALID));
auto factoryFunction = appenderFactory.find(type);
if (factoryFunction == appenderFactory.end())
@@ -84,7 +84,7 @@ void Log::CreateAppenderFromConfig(std::string const& appenderName)
if (size > 2)
{
if (Optional<uint8> flagsVal = acore::StringTo<uint8>(tokens[2]))
if (Optional<uint8> flagsVal = Acore::StringTo<uint8>(tokens[2]))
flags = AppenderFlags(*flagsVal);
else
{
@@ -120,7 +120,7 @@ void Log::CreateLoggerFromConfig(std::string const& appenderName)
return;
}
std::vector<std::string_view> tokens = acore::Tokenize(options, ',', true);
std::vector<std::string_view> tokens = Acore::Tokenize(options, ',', true);
if (tokens.size() != 2)
{
@@ -135,7 +135,7 @@ void Log::CreateLoggerFromConfig(std::string const& appenderName)
return;
}
level = LogLevel(acore::StringTo<uint8>(tokens[0]).value_or(LOG_LEVEL_INVALID));
level = LogLevel(Acore::StringTo<uint8>(tokens[0]).value_or(LOG_LEVEL_INVALID));
if (level > NUM_ENABLED_LOG_LEVELS)
{
fprintf(stderr, "Log::CreateLoggerFromConfig: Wrong Log Level '%s' for logger %s\n", std::string(tokens[0]).c_str(), name.c_str());
@@ -148,7 +148,7 @@ void Log::CreateLoggerFromConfig(std::string const& appenderName)
logger = std::make_unique<Logger>(name, level);
//fprintf(stdout, "Log::CreateLoggerFromConfig: Created Logger %s, Level %u\n", name.c_str(), level);
for (std::string_view appenderName : acore::Tokenize(tokens[1], ' ', false))
for (std::string_view appenderName : Acore::Tokenize(tokens[1], ' ', false))
{
if (Appender* appender = GetAppenderByName(appenderName))
{
@@ -248,7 +248,7 @@ std::string Log::GetTimestampStr()
// HH hour (2 digits 00-23)
// MM minutes (2 digits 00-59)
// SS seconds (2 digits 00-59)
return acore::StringFormat("%04d-%02d-%02d_%02d-%02d-%02d",
return Acore::StringFormat("%04d-%02d-%02d_%02d-%02d-%02d",
aTm.tm_year + 1900, aTm.tm_mon + 1, aTm.tm_mday, aTm.tm_hour, aTm.tm_min, aTm.tm_sec);
}

View File

@@ -52,7 +52,7 @@ public:
template<typename Format, typename... Args>
inline void outMessage(std::string const& filter, LogLevel const level, Format&& fmt, Args&&... args)
{
outMessage(filter, level, acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...));
outMessage(filter, level, Acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...));
}
template<typename Format, typename... Args>
@@ -61,7 +61,7 @@ public:
if (!ShouldLog("commands.gm", LOG_LEVEL_INFO))
return;
outCommand(acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...), std::to_string(account));
outCommand(Acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...), std::to_string(account));
}
void outCharDump(char const* str, uint32 account_id, uint64 guid, char const* name);
@@ -81,7 +81,7 @@ public:
template<typename Format, typename... Args>
inline void outString(Format&& fmt, Args&& ... args)
{
outMessage("server", LOG_LEVEL_INFO, acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...));
outMessage("server", LOG_LEVEL_INFO, Acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...));
}
inline void outString()
@@ -92,7 +92,7 @@ public:
template<typename Format, typename... Args>
inline void outError(Format&& fmt, Args&& ... args)
{
outMessage("server", LOG_LEVEL_ERROR, acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...));
outMessage("server", LOG_LEVEL_ERROR, Acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...));
}
template<typename Format, typename... Args>
@@ -101,19 +101,19 @@ public:
if (!ShouldLog("sql.sql", LOG_LEVEL_ERROR))
return;
outMessage("sql.sql", LOG_LEVEL_ERROR, acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...));
outMessage("sql.sql", LOG_LEVEL_ERROR, Acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...));
}
template<typename Format, typename... Args>
inline void outBasic(Format&& fmt, Args&& ... args)
{
outMessage("server", LOG_LEVEL_INFO, acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...));
outMessage("server", LOG_LEVEL_INFO, Acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...));
}
template<typename Format, typename... Args>
inline void outDetail(Format&& fmt, Args&& ... args)
{
outMessage("server", LOG_LEVEL_INFO, acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...));
outMessage("server", LOG_LEVEL_INFO, Acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...));
}
template<typename Format, typename... Args>
@@ -122,7 +122,7 @@ public:
if (!ShouldLog("sql.dev", LOG_LEVEL_INFO))
return;
outMessage("sql.dev", LOG_LEVEL_INFO, acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...));
outMessage("sql.dev", LOG_LEVEL_INFO, Acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...));
}
template<typename Format, typename... Args>
@@ -131,13 +131,13 @@ public:
if (!ShouldLog("sql.driver", LOG_LEVEL_INFO))
return;
outMessage("sql.driver", LOG_LEVEL_INFO, acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...));
outMessage("sql.driver", LOG_LEVEL_INFO, Acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...));
}
template<typename Format, typename... Args>
inline void outMisc(Format&& fmt, Args&& ... args)
{
outMessage("server", LOG_LEVEL_INFO, acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...));
outMessage("server", LOG_LEVEL_INFO, Acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...));
}
template<typename Format, typename... Args>
@@ -149,7 +149,7 @@ public:
if (!ShouldLog("server", LOG_LEVEL_DEBUG))
return;
outMessage("server", LOG_LEVEL_DEBUG, acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...));
outMessage("server", LOG_LEVEL_DEBUG, Acore::StringFormat(std::forward<Format>(fmt), std::forward<Args>(args)...));
}
private:

View File

@@ -21,7 +21,7 @@ std::string LogMessage::getTimeStr(time_t time)
{
tm aTm;
localtime_r(&time, &aTm);
return acore::StringFormat("%04d-%02d-%02d_%02d:%02d:%02d", aTm.tm_year + 1900, aTm.tm_mon + 1, aTm.tm_mday, aTm.tm_hour, aTm.tm_min, aTm.tm_sec);
return Acore::StringFormat("%04d-%02d-%02d_%02d:%02d:%02d", aTm.tm_year + 1900, aTm.tm_mon + 1, aTm.tm_mday, aTm.tm_hour, aTm.tm_min, aTm.tm_sec);
}
std::string LogMessage::getTimeStr() const

View File

@@ -9,7 +9,7 @@
#include "SmartEnum.h"
#include <stdexcept>
namespace acore::Impl::EnumUtilsImpl
namespace Acore::Impl::EnumUtilsImpl
{
/********************************************************************\

View File

@@ -9,7 +9,7 @@
#include "SmartEnum.h"
#include <stdexcept>
namespace acore::Impl::EnumUtilsImpl
namespace Acore::Impl::EnumUtilsImpl
{
/************************************************************\

View File

@@ -13,7 +13,7 @@
#ifdef WIN32
#include <windows.h>
#endif // WIN32
using namespace acore;
using namespace Acore;
Thread::Thread() : m_task(nullptr), m_iThreadId(), m_ThreadImp()
{

View File

@@ -10,7 +10,7 @@
#include <thread>
#include <atomic>
namespace acore
namespace Acore
{
class Runnable
{

View File

@@ -14,7 +14,7 @@
#include "Define.h"
namespace acore
namespace Acore
{
template<typename MUTEX>
class GeneralLock
@@ -126,9 +126,9 @@ namespace acore
};
}
template<class T, class MUTEX> MUTEX acore::ClassLevelLockable<T, MUTEX>::si_mtx;
template<class T, class MUTEX> MUTEX Acore::ClassLevelLockable<T, MUTEX>::si_mtx;
#define INSTANTIATE_CLASS_MUTEX(CTYPE, MUTEX) \
template class acore::ClassLevelLockable<CTYPE, MUTEX>
template class Acore::ClassLevelLockable<CTYPE, MUTEX>
#endif

View File

@@ -16,7 +16,7 @@
#include <utility>
#include <vector>
namespace acore
namespace Acore
{
template<class T>
constexpr inline T* AddressOrSelf(T* ptr)
@@ -60,14 +60,14 @@ namespace acore
};
}
namespace acore::Containers
namespace Acore::Containers
{
// resizes <container> to have at most <requestedSize> elements
// if it has more than <requestedSize> elements, the elements to keep are selected randomly
template<class C>
void RandomResize(C& container, std::size_t requestedSize)
{
static_assert(std::is_base_of<std::forward_iterator_tag, typename std::iterator_traits<typename C::iterator>::iterator_category>::value, "Invalid container passed to acore::Containers::RandomResize");
static_assert(std::is_base_of<std::forward_iterator_tag, typename std::iterator_traits<typename C::iterator>::iterator_category>::value, "Invalid container passed to Acore::Containers::RandomResize");
if (std::size(container) <= requestedSize)
return;
@@ -176,7 +176,7 @@ namespace acore::Containers
}
/*
* @fn void acore::Containers::RandomShuffle(C& container)
* @fn void Acore::Containers::RandomShuffle(C& container)
*
* @brief Reorder the elements of the container randomly.
*

View File

@@ -9,7 +9,7 @@
#include "Define.h"
#include <utility>
namespace acore
namespace Acore
{
/**
* @class IteratorPair
@@ -41,6 +41,6 @@ namespace acore
}
//! namespace Containers
}
//! namespace acore
//! namespace Acore
#endif // IteratorPair_h__

View File

@@ -11,7 +11,7 @@
#include <unordered_set>
#include <mutex>
namespace acore
namespace Acore
{
/// Handle termination signals
class SignalHandler

View File

@@ -20,7 +20,7 @@ struct EnumText
char const* const Description;
};
namespace acore::Impl::EnumUtilsImpl
namespace Acore::Impl::EnumUtilsImpl
{
template <typename Enum>
struct EnumUtils
@@ -36,20 +36,20 @@ class EnumUtils
{
public:
template <typename Enum>
static size_t Count() { return acore::Impl::EnumUtilsImpl::EnumUtils<Enum>::Count(); }
static size_t Count() { return Acore::Impl::EnumUtilsImpl::EnumUtils<Enum>::Count(); }
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>
static Enum FromIndex(size_t index) { return acore::Impl::EnumUtilsImpl::EnumUtils<Enum>::FromIndex(index); }
static Enum FromIndex(size_t index) { return Acore::Impl::EnumUtilsImpl::EnumUtils<Enum>::FromIndex(index); }
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);}
template<typename Enum>
static bool IsValid(Enum value)
{
try
{
acore::Impl::EnumUtilsImpl::EnumUtils<Enum>::ToIndex(value);
Acore::Impl::EnumUtilsImpl::EnumUtils<Enum>::ToIndex(value);
return true;
} catch (...)
{
@@ -105,7 +105,7 @@ class EnumUtils
static Iterator<Enum> End() { return Iterator<Enum>(); }
template <typename Enum>
static acore::IteratorPair<Iterator<Enum>> Iterate() { return { Begin<Enum>(), End<Enum>() }; }
static Acore::IteratorPair<Iterator<Enum>> Iterate() { return { Begin<Enum>(), End<Enum>() }; }
template <typename Enum>
static char const* ToConstant(Enum value) { return ToString(value).Constant; }

View File

@@ -16,11 +16,11 @@
#include <string_view>
#include <type_traits>
namespace acore::Impl::StringConvertImpl
namespace Acore::Impl::StringConvertImpl
{
template <typename T, typename = void> struct For
{
static_assert(acore::dependant_false_v<T>, "Unsupported type used for ToString or StringTo");
static_assert(Acore::dependant_false_v<T>, "Unsupported type used for ToString or StringTo");
};
template <typename T>
@@ -241,18 +241,18 @@ namespace acore::Impl::StringConvertImpl
#endif
}
namespace acore
namespace Acore
{
template <typename Result, typename... Params>
Optional<Result> StringTo(std::string_view str, Params&&... params)
{
return acore::Impl::StringConvertImpl::For<Result>::FromString(str, std::forward<Params>(params)...);
return Acore::Impl::StringConvertImpl::For<Result>::FromString(str, std::forward<Params>(params)...);
}
template <typename Type, typename... Params>
std::string ToString(Type&& val, Params&&... params)
{
return acore::Impl::StringConvertImpl::For<std::decay_t<Type>>::ToString(std::forward<Type>(val), std::forward<Params>(params)...);
return Acore::Impl::StringConvertImpl::For<std::decay_t<Type>>::ToString(std::forward<Type>(val), std::forward<Params>(params)...);
}
}

View File

@@ -7,7 +7,7 @@
#include <locale>
template<class Str>
Str acore::String::Trim(const Str& s, const std::locale& loc /*= std::locale()*/)
Str Acore::String::Trim(const Str& s, const std::locale& loc /*= std::locale()*/)
{
typename Str::const_iterator first = s.begin();
typename Str::const_iterator end = s.end();
@@ -31,4 +31,4 @@ Str acore::String::Trim(const Str& s, const std::locale& loc /*= std::locale()*/
}
// Template Trim
template std::string acore::String::Trim<std::string>(const std::string& s, const std::locale& loc /*= std::locale()*/);
template std::string Acore::String::Trim<std::string>(const std::string& s, const std::locale& loc /*= std::locale()*/);

View File

@@ -10,7 +10,7 @@
#include <fmt/printf.h>
namespace acore
namespace Acore
{
/// Default AC string format function.
template<typename Format, typename... Args>
@@ -40,7 +40,7 @@ namespace acore
}
}
namespace acore::String
namespace Acore::String
{
template<class Str>
Str Trim(const Str& s, const std::locale& loc = std::locale());

View File

@@ -5,7 +5,7 @@
#include "Tokenize.h"
std::vector<std::string_view> acore::Tokenize(std::string_view str, char sep, bool keepEmpty)
std::vector<std::string_view> Acore::Tokenize(std::string_view str, char sep, bool keepEmpty)
{
std::vector<std::string_view> tokens;

View File

@@ -10,7 +10,7 @@
#include <string_view>
#include <vector>
namespace acore
namespace Acore
{
std::vector<std::string_view> Tokenize(std::string_view str, char sep, bool keepEmpty);

View File

@@ -8,7 +8,7 @@
#include <tuple>
namespace acore
namespace Acore
{
template <typename T, typename Tuple>
struct has_type;

View File

@@ -8,7 +8,7 @@
#include "advstd.h"
namespace acore
namespace Acore
{
// end "iterator" tag for find_type_if
struct find_type_end;
@@ -35,11 +35,11 @@ namespace acore
template<typename... Ts>
struct Example
{
using TupleArg = acore::find_type_if_t<acore::is_tuple, Ts...>;
using TupleArg = Acore::find_type_if_t<Acore::is_tuple, Ts...>;
bool HasTuple()
{
return !std::is_same_v<TupleArg, acore::find_type_end>;
return !std::is_same_v<TupleArg, Acore::find_type_end>;
}
};
@@ -47,7 +47,7 @@ namespace acore
example.HasTuple() == true; // TupleArg is std::tuple<int, int, int>
Example<int, std::string, char> example2;
example2.HasTuple() == false; // TupleArg is acore::find_type_end
example2.HasTuple() == false; // TupleArg is Acore::find_type_end
*/
template<template<typename...> typename Check, typename... Ts>

View File

@@ -343,7 +343,7 @@ bool Utf8toWStr(char const* utf8str, size_t csize, wchar_t* wstr, size_t& wsize)
{
try
{
acore::CheckedBufferOutputIterator<wchar_t> out(wstr, wsize);
Acore::CheckedBufferOutputIterator<wchar_t> out(wstr, wsize);
out = utf8::utf8to16(utf8str, utf8str + csize, out);
wsize -= out.remaining(); // remaining unused space
wstr[wsize] = L'\0';
@@ -585,7 +585,7 @@ bool Utf8ToUpperOnlyLatin(std::string& 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, size_t arrayLen, bool reverse /* = false */)
{
int32 init = 0;
int32 end = arrayLen;
@@ -609,7 +609,7 @@ std::string acore::Impl::ByteArrayToHexStr(uint8 const* bytes, size_t arrayLen,
return ss.str();
}
void acore::Impl::HexStrToByteArray(std::string const& str, uint8* out, size_t outlen, bool reverse /*= false*/)
void Acore::Impl::HexStrToByteArray(std::string const& str, uint8* out, size_t outlen, bool reverse /*= false*/)
{
ASSERT(str.size() == (2 * outlen));

View File

@@ -314,7 +314,7 @@ uint32 GetPID();
bool StringEqualI(std::string_view str1, std::string_view str2);
namespace acore::Impl
namespace Acore::Impl
{
std::string ByteArrayToHexStr(uint8 const* bytes, size_t length, bool reverse = false);
void HexStrToByteArray(std::string const& str, uint8* out, size_t outlen, bool reverse = false);
@@ -323,13 +323,13 @@ namespace acore::Impl
template<typename Container>
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>
void HexStrToByteArray(std::string const& 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>
std::array<uint8, Size> HexStrToByteArray(std::string const& str, bool reverse = false)