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)
 
ByteBufferoperator= (ByteBuffer const &right)
 
ByteBufferoperator= (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)
 
ByteBufferoperator<< (bool value)
 
ByteBufferoperator<< (uint8 value)
 
ByteBufferoperator<< (uint16 value)
 
ByteBufferoperator<< (uint32 value)
 
ByteBufferoperator<< (uint64 value)
 
ByteBufferoperator<< (int8 value)
 
ByteBufferoperator<< (int16 value)
 
ByteBufferoperator<< (int32 value)
 
ByteBufferoperator<< (int64 value)
 
ByteBufferoperator<< (float value)
 
ByteBufferoperator<< (double value)
 
ByteBufferoperator<< (std::string_view value)
 
ByteBufferoperator<< (std::string const &str)
 
ByteBufferoperator<< (char const *str)
 
ByteBufferoperator>> (bool &value)
 
ByteBufferoperator>> (uint8 &value)
 
ByteBufferoperator>> (uint16 &value)
 
ByteBufferoperator>> (uint32 &value)
 
ByteBufferoperator>> (uint64 &value)
 
ByteBufferoperator>> (int8 &value)
 
ByteBufferoperator>> (int16 &value)
 
ByteBufferoperator>> (int32 &value)
 
ByteBufferoperator>> (int64 &value)
 
ByteBufferoperator>> (float &value)
 
ByteBufferoperator>> (double &value)
 
ByteBufferoperator>> (std::string &value)
 
uint8operator[] (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 >
read ()
 
template<typename 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)
 
uint8contents ()
 
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 442 of file ByteBuffer.h.

+ Here is the call graph for this function:

◆ append() [2/6]

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

Definition at line 430 of file ByteBuffer.h.

◆ append() [3/6]

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

Definition at line 435 of file ByteBuffer.h.

◆ append() [4/6]

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

Definition at line 449 of file ByteBuffer.h.

◆ append() [5/6]

template<typename T >
void ByteBuffer::append ( value)
inline

Definition at line 129 of file ByteBuffer.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ append() [6/6]

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

Definition at line 92 of file ByteBuffer.cpp.

+ Here is the call graph for this function:

◆ appendPackGUID()

void ByteBuffer::appendPackGUID ( uint64  guid)
inline

Definition at line 464 of file ByteBuffer.h.

+ Here is the caller graph for this function:

◆ appendPackXYZ()

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

Definition at line 455 of file ByteBuffer.h.

+ Here is the caller graph for this function:

◆ clear()

void ByteBuffer::clear ( )
inline

Definition at line 123 of file ByteBuffer.h.

+ Here is the caller graph for this function:

◆ contents() [1/2]

uint8 * ByteBuffer::contents ( )
inline

Definition at line 395 of file ByteBuffer.h.

+ Here is the caller graph for this function:

◆ contents() [2/2]

uint8 const * ByteBuffer::contents ( ) const
inline

Definition at line 402 of file ByteBuffer.h.

◆ empty()

bool ByteBuffer::empty ( ) const
inline

Definition at line 410 of file ByteBuffer.h.

+ Here is the caller graph for this function:

◆ hexlike()

void ByteBuffer::hexlike ( ) const

Definition at line 157 of file ByteBuffer.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator<<() [1/14]

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

Definition at line 144 of file ByteBuffer.h.

◆ operator<<() [2/14]

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

Definition at line 225 of file ByteBuffer.h.

+ Here is the call graph for this function:

◆ operator<<() [3/14]

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

Definition at line 206 of file ByteBuffer.h.

◆ operator<<() [4/14]

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

Definition at line 200 of file ByteBuffer.h.

◆ operator<<() [5/14]

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

Definition at line 181 of file ByteBuffer.h.

◆ operator<<() [6/14]

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

Definition at line 187 of file ByteBuffer.h.

◆ operator<<() [7/14]

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

Definition at line 193 of file ByteBuffer.h.

◆ operator<<() [8/14]

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

Definition at line 175 of file ByteBuffer.h.

◆ operator<<() [9/14]

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

Definition at line 220 of file ByteBuffer.h.

+ Here is the call graph for this function:

◆ operator<<() [10/14]

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

Definition at line 212 of file ByteBuffer.h.

◆ operator<<() [11/14]

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

Definition at line 156 of file ByteBuffer.h.

◆ operator<<() [12/14]

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

Definition at line 162 of file ByteBuffer.h.

◆ operator<<() [13/14]

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

Definition at line 168 of file ByteBuffer.h.

◆ operator<<() [14/14]

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

Definition at line 150 of file ByteBuffer.h.

◆ operator=() [1/2]

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

Definition at line 107 of file ByteBuffer.h.

◆ operator=() [2/2]

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

Definition at line 95 of file ByteBuffer.h.

+ Here is the caller graph for this function:

◆ operator>>() [1/12]

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

Definition at line 230 of file ByteBuffer.h.

◆ operator>>() [2/12]

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

Definition at line 69 of file ByteBuffer.cpp.

◆ operator>>() [3/12]

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

Definition at line 61 of file ByteBuffer.cpp.

◆ operator>>() [4/12]

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

Definition at line 267 of file ByteBuffer.h.

◆ operator>>() [5/12]

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

Definition at line 273 of file ByteBuffer.h.

◆ operator>>() [6/12]

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

Definition at line 279 of file ByteBuffer.h.

◆ operator>>() [7/12]

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

Definition at line 261 of file ByteBuffer.h.

◆ operator>>() [8/12]

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

Definition at line 288 of file ByteBuffer.h.

◆ operator>>() [9/12]

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

Definition at line 242 of file ByteBuffer.h.

◆ operator>>() [10/12]

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

Definition at line 248 of file ByteBuffer.h.

◆ operator>>() [11/12]

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

Definition at line 254 of file ByteBuffer.h.

◆ operator>>() [12/12]

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

Definition at line 236 of file ByteBuffer.h.

◆ operator[]() [1/2]

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

Definition at line 294 of file ByteBuffer.h.

◆ operator[]() [2/2]

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

Definition at line 301 of file ByteBuffer.h.

◆ print_storage()

void ByteBuffer::print_storage ( ) const

Definition at line 126 of file ByteBuffer.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ put() [1/2]

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

Definition at line 117 of file ByteBuffer.cpp.

+ Here is the call graph for this function:

◆ put() [2/2]

template<typename T >
void ByteBuffer::put ( std::size_t  pos,
value 
)
inline

Definition at line 137 of file ByteBuffer.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read() [1/4]

template<typename T >
T ByteBuffer::read ( )
inline

Definition at line 339 of file ByteBuffer.h.

+ Here is the caller graph for this function:

◆ read() [2/4]

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

Definition at line 346 of file ByteBuffer.h.

+ Here is the call graph for this function:

◆ read() [3/4]

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

Definition at line 364 of file ByteBuffer.h.

◆ read() [4/4]

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

Definition at line 355 of file ByteBuffer.h.

◆ read_skip() [1/4]

template<typename T >
void ByteBuffer::read_skip ( )
inline

Definition at line 330 of file ByteBuffer.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read_skip() [2/4]

template<>
void ByteBuffer::read_skip ( )
inline

Definition at line 505 of file ByteBuffer.h.

◆ read_skip() [3/4]

template<>
void ByteBuffer::read_skip ( )
inline

Definition at line 512 of file ByteBuffer.h.

◆ read_skip() [4/4]

void ByteBuffer::read_skip ( size_t  skip)
inline

Definition at line 332 of file ByteBuffer.h.

◆ ReadCString()

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

Definition at line 77 of file ByteBuffer.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readPackGUID()

void ByteBuffer::readPackGUID ( uint64 guid)
inline

Definition at line 369 of file ByteBuffer.h.

+ Here is the caller graph for this function:

◆ reserve()

void ByteBuffer::reserve ( size_t  ressize)
inline

Definition at line 419 of file ByteBuffer.h.

+ Here is the caller graph for this function:

◆ resize()

void ByteBuffer::resize ( size_t  newsize)
inline

Definition at line 412 of file ByteBuffer.h.

+ Here is the caller graph for this function:

◆ rfinish()

void ByteBuffer::rfinish ( )
inline

Definition at line 316 of file ByteBuffer.h.

+ Here is the caller graph for this function:

◆ rpos() [1/2]

size_t ByteBuffer::rpos ( ) const
inline

Definition at line 308 of file ByteBuffer.h.

+ Here is the caller graph for this function:

◆ rpos() [2/2]

size_t ByteBuffer::rpos ( size_t  rpos_)
inline

Definition at line 310 of file ByteBuffer.h.

◆ shrink_to_fit()

void ByteBuffer::shrink_to_fit ( )
inline

Definition at line 425 of file ByteBuffer.h.

◆ size()

size_t ByteBuffer::size ( ) const
inline

Definition at line 409 of file ByteBuffer.h.

+ Here is the caller graph for this function:

◆ textlike()

void ByteBuffer::textlike ( ) const

Definition at line 140 of file ByteBuffer.cpp.

+ Here is the call graph for this function:

◆ wpos() [1/2]

size_t ByteBuffer::wpos ( ) const
inline

Definition at line 321 of file ByteBuffer.h.

+ Here is the caller graph for this function:

◆ wpos() [2/2]

size_t ByteBuffer::wpos ( size_t  wpos_)
inline

Definition at line 323 of file ByteBuffer.h.

Member Data Documentation

◆ _rpos

size_t ByteBuffer::_rpos
protected

Definition at line 492 of file ByteBuffer.h.

◆ _storage

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

Definition at line 493 of file ByteBuffer.h.

◆ _wpos

size_t ByteBuffer::_wpos
protected

Definition at line 492 of file ByteBuffer.h.

◆ 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: