mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-23 05:36:23 +00:00
refactor(Core/Misc): acore to Acore (#6043)
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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__
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <unordered_set>
|
||||
#include <mutex>
|
||||
|
||||
namespace acore
|
||||
namespace Acore
|
||||
{
|
||||
/// Handle termination signals
|
||||
class SignalHandler
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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)...);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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()*/);
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <tuple>
|
||||
|
||||
namespace acore
|
||||
namespace Acore
|
||||
{
|
||||
template <typename T, typename Tuple>
|
||||
struct has_type;
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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));
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user