AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Acore::Impl Namespace Reference

Namespaces

namespace  ChatCommands
 
namespace  EnumUtilsImpl
 
namespace  StringConvertImpl
 

Classes

struct  CastToVisitor
 
struct  CryptoGenericsImpl
 
struct  CurrentServerProcessHolder
 
struct  GenericBaseEncoding
 
class  GenericHash
 
struct  GenericHashImpl
 
class  GenericHMAC
 
class  MPSCQueueIntrusive
 
class  MPSCQueueNonIntrusive
 

Functions

template<class T , class Tuple , size_t... I>
T * new_from_tuple (Tuple &&args, std::index_sequence< I... >)
 
AC_COMMON_API std::string ByteArrayToHexStr (uint8 const *bytes, size_t length, bool reverse=false)
 
AC_COMMON_API void HexStrToByteArray (std::string_view str, uint8 *out, size_t outlen, bool reverse=false)
 

Function Documentation

◆ ByteArrayToHexStr()

std::string Acore::Impl::ByteArrayToHexStr ( uint8 const *  bytes,
size_t  length,
bool  reverse = false 
)
541{
542 int32 init = 0;
543 int32 end = arrayLen;
544 int8 op = 1;
545
546 if (reverse)
547 {
548 init = arrayLen - 1;
549 end = -1;
550 op = -1;
551 }
552
553 std::ostringstream ss;
554 for (int32 i = init; i != end; i += op)
555 {
556 char buffer[4];
557 snprintf(buffer, sizeof(buffer), "%02X", bytes[i]);
558 ss << buffer;
559 }
560
561 return ss.str();
562}
std::int32_t int32
Definition: Define.h:104
std::int8_t int8
Definition: Define.h:106

Referenced by ByteArrayToHexStr(), Guild::HandleMemberDepositMoney(), Guild::HandleMemberWithdrawMoney(), WardenMac::Init(), and WardenWin::Init().

◆ HexStrToByteArray()

void Acore::Impl::HexStrToByteArray ( std::string_view  str,
uint8 out,
size_t  outlen,
bool  reverse = false 
)
565{
566 ASSERT(str.size() == (2 * outlen));
567
568 int32 init = 0;
569 int32 end = int32(str.length());
570 int8 op = 1;
571
572 if (reverse)
573 {
574 init = int32(str.length() - 2);
575 end = -2;
576 op = -1;
577 }
578
579 uint32 j = 0;
580 for (int32 i = init; i != end; i += 2 * op)
581 {
582 char buffer[3] = { str[i], str[i + 1], '\0' };
583 out[j++] = uint8(strtoul(buffer, nullptr, 16));
584 }
585}
#define ASSERT
Definition: Errors.h:68
std::uint8_t uint8
Definition: Define.h:110
std::uint32_t uint32
Definition: Define.h:108

References ASSERT.

Referenced by HexStrToByteArray().

◆ new_from_tuple()

template<class T , class Tuple , size_t... I>
T * Acore::Impl::new_from_tuple ( Tuple &&  args,
std::index_sequence< I... >   
)
53 {
54 return new T(std::get<I>(std::forward<Tuple>(args))...);
55 }