TrinityCore
Loading...
Searching...
No Matches
ByteBuffer Class Reference

#include <ByteBuffer.h>

+ Inheritance diagram for ByteBuffer:

Public Member Functions

 ByteBuffer ()
 
 ByteBuffer (size_t reserve)
 
 ByteBuffer (ByteBuffer &&buf) noexcept
 
 ByteBuffer (ByteBuffer const &right)=default
 
 ByteBuffer (MessageBuffer &&buffer)
 
std::vector< uint8 > && Move ()
 
ByteBuffer & operator= (ByteBuffer const &right)
 
ByteBuffer & operator= (ByteBuffer &&right) noexcept
 
virtual ~ByteBuffer ()=default
 
void clear ()
 
template<typename T >
void append (T value)
 
template<typename T >
void put (std::size_t pos, T value)
 
ByteBuffer & operator<< (bool value)
 
ByteBuffer & operator<< (uint8 value)
 
ByteBuffer & operator<< (uint16 value)
 
ByteBuffer & operator<< (uint32 value)
 
ByteBuffer & operator<< (uint64 value)
 
ByteBuffer & operator<< (int8 value)
 
ByteBuffer & operator<< (int16 value)
 
ByteBuffer & operator<< (int32 value)
 
ByteBuffer & operator<< (int64 value)
 
ByteBuffer & operator<< (float value)
 
ByteBuffer & operator<< (double value)
 
ByteBuffer & operator<< (std::string_view value)
 
ByteBuffer & operator<< (std::string const &str)
 
ByteBuffer & operator<< (char const *str)
 
ByteBuffer & operator>> (bool &value)
 
ByteBuffer & operator>> (uint8 &value)
 
ByteBuffer & operator>> (uint16 &value)
 
ByteBuffer & operator>> (uint32 &value)
 
ByteBuffer & operator>> (uint64 &value)
 
ByteBuffer & operator>> (int8 &value)
 
ByteBuffer & operator>> (int16 &value)
 
ByteBuffer & operator>> (int32 &value)
 
ByteBuffer & operator>> (int64 &value)
 
ByteBuffer & operator>> (float &value)
 
ByteBuffer & operator>> (double &value)
 
ByteBuffer & operator>> (std::string &value)
 
uint8 & operator[] (size_t const pos)
 
uint8 const & operator[] (size_t const pos) const
 
size_t rpos () const
 
size_t rpos (size_t rpos_)
 
void rfinish ()
 
size_t wpos () const
 
size_t wpos (size_t wpos_)
 
template<typename T >
void read_skip ()
 
void read_skip (size_t skip)
 
template<typename T >
T read ()
 
template<typename T >
T read (size_t pos) const
 
void read (uint8 *dest, size_t len)
 
template<size_t Size>
void read (std::array< uint8, Size > &arr)
 
void readPackGUID (uint64 &guid)
 
std::string ReadCString (bool requireValidUtf8=true)
 
uint8 * contents ()
 
uint8 const * contents () const
 
size_t size () const
 
bool empty () const
 
void resize (size_t newsize)
 
void reserve (size_t ressize)
 
void shrink_to_fit ()
 
void append (const char *src, size_t cnt)
 
template<class T >
void append (const T *src, size_t cnt)
 
void append (uint8 const *src, size_t cnt)
 
void append (ByteBuffer const &buffer)
 
template<size_t Size>
void append (std::array< uint8, Size > const &arr)
 
void appendPackXYZ (float x, float y, float z)
 
void appendPackGUID (uint64 guid)
 
void put (size_t pos, const uint8 *src, size_t cnt)
 
void print_storage () const
 
void textlike () const
 
void hexlike () const
 
template<>
void read_skip ()
 
template<>
void read_skip ()
 

Static Public Attributes

static constexpr size_t DEFAULT_SIZE = 0x1000
 

Protected Attributes

size_t _rpos
 
size_t _wpos
 
std::vector< uint8 > _storage
 

Detailed Description

Definition at line 69 of file ByteBuffer.h.

Constructor & Destructor Documentation

◆ ByteBuffer() [1/5]

ByteBuffer::ByteBuffer ( )
inline

Definition at line 75 of file ByteBuffer.h.

◆ ByteBuffer() [2/5]

ByteBuffer::ByteBuffer ( size_t  reserve)
inline

Definition at line 80 of file ByteBuffer.h.

◆ ByteBuffer() [3/5]

ByteBuffer::ByteBuffer ( ByteBuffer &&  buf)
inlinenoexcept

Definition at line 85 of file ByteBuffer.h.

◆ ByteBuffer() [4/5]

ByteBuffer::ByteBuffer ( ByteBuffer const &  right)
default

◆ ByteBuffer() [5/5]

ByteBuffer::ByteBuffer ( MessageBuffer &&  buffer)

Definition at line 28 of file ByteBuffer.cpp.

◆ ~ByteBuffer()

virtual ByteBuffer::~ByteBuffer ( )
virtualdefault

Member Function Documentation

◆ append() [1/6]

void ByteBuffer::append ( ByteBuffer const &  buffer)
inline

Definition at line 446 of file ByteBuffer.h.

References contents(), and wpos().

◆ append() [2/6]

void ByteBuffer::append ( const char *  src,
size_t  cnt 
)
inline

Definition at line 434 of file ByteBuffer.h.

◆ append() [3/6]

template<class T >
void ByteBuffer::append ( const T *  src,
size_t  cnt 
)
inline

Definition at line 439 of file ByteBuffer.h.

◆ append() [4/6]

template<size_t Size>
void ByteBuffer::append ( std::array< uint8, Size > const &  arr)
inline

Definition at line 453 of file ByteBuffer.h.

◆ append() [5/6]

◆ append() [6/6]

void ByteBuffer::append ( uint8 const *  src,
size_t  cnt 
)

Definition at line 90 of file ByteBuffer.cpp.

References _storage, _wpos, ASSERT, size(), and SZFMTD.

◆ appendPackGUID()

◆ appendPackXYZ()

void ByteBuffer::appendPackXYZ ( float  x,
float  y,
float  z 
)
inline

Definition at line 459 of file ByteBuffer.h.

Referenced by operator<<().

◆ clear()

◆ contents() [1/2]

◆ contents() [2/2]

uint8 const * ByteBuffer::contents ( ) const
inline

Definition at line 406 of file ByteBuffer.h.

◆ empty()

◆ hexlike()

◆ Move()

std::vector< uint8 > && ByteBuffer::Move ( )
inline

Definition at line 93 of file ByteBuffer.h.

◆ operator<<() [1/14]

ByteBuffer & ByteBuffer::operator<< ( bool  value)
inline

Definition at line 148 of file ByteBuffer.h.

◆ operator<<() [2/14]

ByteBuffer & ByteBuffer::operator<< ( char const *  str)
inline

Definition at line 229 of file ByteBuffer.h.

References operator<<().

◆ operator<<() [3/14]

ByteBuffer & ByteBuffer::operator<< ( double  value)
inline

Definition at line 210 of file ByteBuffer.h.

◆ operator<<() [4/14]

ByteBuffer & ByteBuffer::operator<< ( float  value)
inline

Definition at line 204 of file ByteBuffer.h.

◆ operator<<() [5/14]

ByteBuffer & ByteBuffer::operator<< ( int16  value)
inline

Definition at line 185 of file ByteBuffer.h.

◆ operator<<() [6/14]

ByteBuffer & ByteBuffer::operator<< ( int32  value)
inline

Definition at line 191 of file ByteBuffer.h.

◆ operator<<() [7/14]

ByteBuffer & ByteBuffer::operator<< ( int64  value)
inline

Definition at line 197 of file ByteBuffer.h.

◆ operator<<() [8/14]

ByteBuffer & ByteBuffer::operator<< ( int8  value)
inline

Definition at line 179 of file ByteBuffer.h.

◆ operator<<() [9/14]

ByteBuffer & ByteBuffer::operator<< ( std::string const &  str)
inline

Definition at line 224 of file ByteBuffer.h.

References operator<<().

◆ operator<<() [10/14]

ByteBuffer & ByteBuffer::operator<< ( std::string_view  value)
inline

Definition at line 216 of file ByteBuffer.h.

◆ operator<<() [11/14]

ByteBuffer & ByteBuffer::operator<< ( uint16  value)
inline

Definition at line 160 of file ByteBuffer.h.

◆ operator<<() [12/14]

ByteBuffer & ByteBuffer::operator<< ( uint32  value)
inline

Definition at line 166 of file ByteBuffer.h.

◆ operator<<() [13/14]

ByteBuffer & ByteBuffer::operator<< ( uint64  value)
inline

Definition at line 172 of file ByteBuffer.h.

◆ operator<<() [14/14]

ByteBuffer & ByteBuffer::operator<< ( uint8  value)
inline

Definition at line 154 of file ByteBuffer.h.

◆ operator=() [1/2]

ByteBuffer & ByteBuffer::operator= ( ByteBuffer &&  right)
inlinenoexcept

Definition at line 112 of file ByteBuffer.h.

References _rpos.

◆ operator=() [2/2]

ByteBuffer & ByteBuffer::operator= ( ByteBuffer const &  right)
inline

Definition at line 100 of file ByteBuffer.h.

References _rpos, _storage, and _wpos.

◆ operator>>() [1/12]

ByteBuffer & ByteBuffer::operator>> ( bool &  value)
inline

Definition at line 234 of file ByteBuffer.h.

◆ operator>>() [2/12]

ByteBuffer & ByteBuffer::operator>> ( double &  value)

Definition at line 67 of file ByteBuffer.cpp.

◆ operator>>() [3/12]

ByteBuffer & ByteBuffer::operator>> ( float &  value)

Definition at line 59 of file ByteBuffer.cpp.

◆ operator>>() [4/12]

ByteBuffer & ByteBuffer::operator>> ( int16 &  value)
inline

Definition at line 271 of file ByteBuffer.h.

◆ operator>>() [5/12]

ByteBuffer & ByteBuffer::operator>> ( int32 &  value)
inline

Definition at line 277 of file ByteBuffer.h.

◆ operator>>() [6/12]

ByteBuffer & ByteBuffer::operator>> ( int64 &  value)
inline

Definition at line 283 of file ByteBuffer.h.

◆ operator>>() [7/12]

ByteBuffer & ByteBuffer::operator>> ( int8 &  value)
inline

Definition at line 265 of file ByteBuffer.h.

◆ operator>>() [8/12]

ByteBuffer & ByteBuffer::operator>> ( std::string &  value)
inline

Definition at line 292 of file ByteBuffer.h.

◆ operator>>() [9/12]

ByteBuffer & ByteBuffer::operator>> ( uint16 &  value)
inline

Definition at line 246 of file ByteBuffer.h.

◆ operator>>() [10/12]

ByteBuffer & ByteBuffer::operator>> ( uint32 &  value)
inline

Definition at line 252 of file ByteBuffer.h.

◆ operator>>() [11/12]

ByteBuffer & ByteBuffer::operator>> ( uint64 &  value)
inline

Definition at line 258 of file ByteBuffer.h.

◆ operator>>() [12/12]

ByteBuffer & ByteBuffer::operator>> ( uint8 &  value)
inline

Definition at line 240 of file ByteBuffer.h.

◆ operator[]() [1/2]

uint8 & ByteBuffer::operator[] ( size_t const  pos)
inline

Definition at line 298 of file ByteBuffer.h.

◆ operator[]() [2/2]

uint8 const & ByteBuffer::operator[] ( size_t const  pos) const
inline

Definition at line 305 of file ByteBuffer.h.

◆ print_storage()

void ByteBuffer::print_storage ( ) const

Definition at line 124 of file ByteBuffer.cpp.

References LOG_LEVEL_TRACE, size(), sLog, and TC_LOG_TRACE.

Referenced by WorldSession::LogUnprocessedTail().

◆ put() [1/2]

void ByteBuffer::put ( size_t  pos,
const uint8 *  src,
size_t  cnt 
)

Definition at line 115 of file ByteBuffer.cpp.

References _storage, ASSERT, size(), and SZFMTD.

◆ put() [2/2]

◆ read() [1/4]

◆ read() [2/4]

template<typename T >
T ByteBuffer::read ( size_t  pos) const
inline

Definition at line 350 of file ByteBuffer.h.

References EndianConvert().

◆ read() [3/4]

template<size_t Size>
void ByteBuffer::read ( std::array< uint8, Size > &  arr)
inline

Definition at line 368 of file ByteBuffer.h.

◆ read() [4/4]

void ByteBuffer::read ( uint8 *  dest,
size_t  len 
)
inline

Definition at line 359 of file ByteBuffer.h.

◆ read_skip() [1/4]

◆ read_skip() [2/4]

template<>
void ByteBuffer::read_skip ( )
inline

Definition at line 509 of file ByteBuffer.h.

◆ read_skip() [3/4]

template<>
void ByteBuffer::read_skip ( )
inline

Definition at line 516 of file ByteBuffer.h.

◆ read_skip() [4/4]

void ByteBuffer::read_skip ( size_t  skip)
inline

Definition at line 336 of file ByteBuffer.h.

◆ ReadCString()

std::string ByteBuffer::ReadCString ( bool  requireValidUtf8 = true)

Definition at line 75 of file ByteBuffer.cpp.

References rpos(), and size().

Referenced by WorldPackets::Chat::ChatMessage::Read().

◆ readPackGUID()

void ByteBuffer::readPackGUID ( uint64 &  guid)
inline

Definition at line 373 of file ByteBuffer.h.

Referenced by WorldSession::HandleEquipmentSetDelete(), and operator>>().

◆ reserve()

◆ resize()

◆ rfinish()

◆ rpos() [1/2]

◆ rpos() [2/2]

size_t ByteBuffer::rpos ( size_t  rpos_)
inline

Definition at line 314 of file ByteBuffer.h.

◆ shrink_to_fit()

void ByteBuffer::shrink_to_fit ( )
inline

Definition at line 429 of file ByteBuffer.h.

◆ size()

◆ textlike()

void ByteBuffer::textlike ( ) const

Definition at line 138 of file ByteBuffer.cpp.

References LOG_LEVEL_TRACE, size(), sLog, and TC_LOG_TRACE.

◆ wpos() [1/2]

◆ wpos() [2/2]

size_t ByteBuffer::wpos ( size_t  wpos_)
inline

Definition at line 327 of file ByteBuffer.h.

Member Data Documentation

◆ _rpos

size_t ByteBuffer::_rpos
protected

Definition at line 496 of file ByteBuffer.h.

Referenced by operator=(), and operator=().

◆ _storage

std::vector<uint8> ByteBuffer::_storage
protected

Definition at line 497 of file ByteBuffer.h.

Referenced by append(), WorldPacket::Initialize(), operator=(), and put().

◆ _wpos

size_t ByteBuffer::_wpos
protected

Definition at line 496 of file ByteBuffer.h.

Referenced by append(), and operator=().

◆ DEFAULT_SIZE

constexpr size_t ByteBuffer::DEFAULT_SIZE = 0x1000
staticconstexpr

Definition at line 72 of file ByteBuffer.h.


The documentation for this class was generated from the following files: