mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 08:55:32 +01:00
Core/Common: Move old-style pointer+size HexStr methods to Trinity::Impl where they can't hurt anyone
(cherry picked from commit 7b8b999516)
This commit is contained in:
@@ -794,7 +794,7 @@ bool Utf8ToUpperOnlyLatin(std::string& utf8String)
|
||||
return WStrToUtf8(wstr, utf8String);
|
||||
}
|
||||
|
||||
std::string ByteArrayToHexStr(uint8 const* bytes, size_t arrayLen, bool reverse /* = false */)
|
||||
std::string Trinity::Impl::ByteArrayToHexStr(uint8 const* bytes, size_t arrayLen, bool reverse /* = false */)
|
||||
{
|
||||
int32 init = 0;
|
||||
int32 end = arrayLen;
|
||||
@@ -818,11 +818,9 @@ std::string ByteArrayToHexStr(uint8 const* bytes, size_t arrayLen, bool reverse
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
void HexStrToByteArray(std::string const& str, uint8* out, bool reverse /*= false*/)
|
||||
void Trinity::Impl::HexStrToByteArray(std::string const& str, uint8* out, size_t outlen, bool reverse /*= false*/)
|
||||
{
|
||||
// string must have even number of characters
|
||||
if (str.length() & 1)
|
||||
return;
|
||||
ASSERT(str.size() == (2 * outlen));
|
||||
|
||||
int32 init = 0;
|
||||
int32 end = int32(str.length());
|
||||
|
||||
@@ -340,15 +340,22 @@ TC_COMMON_API bool IsIPAddress(char const* ipaddress);
|
||||
TC_COMMON_API uint32 CreatePIDFile(std::string const& filename);
|
||||
TC_COMMON_API uint32 GetPID();
|
||||
|
||||
TC_COMMON_API std::string ByteArrayToHexStr(uint8 const* bytes, size_t length, bool reverse = false);
|
||||
namespace Trinity::Impl
|
||||
{
|
||||
TC_COMMON_API std::string ByteArrayToHexStr(uint8 const* bytes, size_t length, bool reverse = false);
|
||||
TC_COMMON_API void HexStrToByteArray(std::string const& str, uint8* out, size_t outlen, bool reverse = false);
|
||||
}
|
||||
|
||||
template <typename Container>
|
||||
std::string ByteArrayToHexStr(Container const& c, bool reverse = false) { return ByteArrayToHexStr(std::data(c), std::size(c), reverse); }
|
||||
TC_COMMON_API void HexStrToByteArray(std::string const& str, uint8* out, bool reverse = false);
|
||||
std::string ByteArrayToHexStr(Container const& c, bool reverse = false)
|
||||
{
|
||||
return Trinity::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)
|
||||
{
|
||||
ASSERT(str.size() == (2 * Size));
|
||||
HexStrToByteArray(str, buf.data(), reverse);
|
||||
Trinity::Impl::HexStrToByteArray(str, buf.data(), Size, reverse);
|
||||
}
|
||||
template <size_t Size>
|
||||
std::array<uint8, Size> HexStrToByteArray(std::string const& str, bool reverse = false)
|
||||
|
||||
@@ -3192,7 +3192,7 @@ bool ConditionMgr::IsPlayerMeetingCondition(Player const* player, PlayerConditio
|
||||
ByteBuffer HexToBytes(const std::string& hex)
|
||||
{
|
||||
ByteBuffer buffer(hex.length() / 2, ByteBuffer::Resize{});
|
||||
HexStrToByteArray(hex, buffer.contents());
|
||||
Trinity::Impl::HexStrToByteArray(hex, buffer.contents(), buffer.size());
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
@@ -82,11 +82,11 @@ void RealmList::LoadBuildInfo()
|
||||
build.Build = fields[4].GetUInt32();
|
||||
std::string win64AuthSeedHexStr = fields[5].GetString();
|
||||
if (win64AuthSeedHexStr.length() == build.Win64AuthSeed.size() * 2)
|
||||
HexStrToByteArray(win64AuthSeedHexStr, build.Win64AuthSeed.data());
|
||||
HexStrToByteArray(win64AuthSeedHexStr, build.Win64AuthSeed);
|
||||
|
||||
std::string mac64AuthSeedHexStr = fields[6].GetString();
|
||||
if (mac64AuthSeedHexStr.length() == build.Mac64AuthSeed.size() * 2)
|
||||
HexStrToByteArray(mac64AuthSeedHexStr, build.Mac64AuthSeed.data());
|
||||
HexStrToByteArray(mac64AuthSeedHexStr, build.Mac64AuthSeed);
|
||||
|
||||
} while (result->NextRow());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user