EvEmu
0.8.4
11 September 2021
|
Generic class for buffers. More...
#include "Buffer.h"
Classes | |
class | const_iterator |
Buffer's const iterator. More... | |
class | iterator |
Buffer's iterator. More... | |
Public Types | |
typedef size_t | size_type |
Typedef for size type. More... | |
Public Member Functions | |
Buffer (size_type len=0, const uint8 &fill=0) | |
Creates buffer of given length. More... | |
template<typename Iter > | |
Buffer (Iter first, Iter last) | |
Creates buffer with given content. More... | |
Buffer (const Buffer &oth) | |
Copy constructor. More... | |
~Buffer () | |
Destructor; deletes buffer. More... | |
template<typename T > | |
iterator< T > | begin () |
template<typename T > | |
const_iterator< T > | begin () const |
template<typename T > | |
iterator< T > | end () |
template<typename T > | |
const_iterator< T > | end () const |
template<typename T > | |
T & | Get (size_type index) |
Gets element from buffer. More... | |
template<typename T > | |
const T & | Get (size_type index) const |
Gets const element from buffer. More... | |
uint8 & | operator[] (size_type index) |
Overload of access operator[]. More... | |
const uint8 & | operator[] (size_type index) const |
Overload of const access operator[]. More... | |
template<typename T > | |
void | Append (const T &value) |
Appends a single value to buffer. More... | |
template<typename Iter > | |
void | AppendSeq (Iter first, Iter last) |
Appends a sequence of elements to buffer. More... | |
template<typename T > | |
void | Assign (const T &value) |
Assigns a single value to buffer. More... | |
template<typename Iter > | |
void | AssignSeq (Iter first, Iter last) |
Assigns a sequence of elements to buffer. More... | |
template<typename T > | |
void | AssignAt (const_iterator< T > index, const T &value) |
Assigns a single value to buffer at specific point. More... | |
template<typename Iter > | |
void | AssignSeqAt (const_iterator< typename std::iterator_traits< Iter >::value_type > index, Iter first, Iter last) |
Assigns a sequence of elements to buffer at specific point. More... | |
template<typename T > | |
Buffer & | operator<< (const T &value) |
Appends a value to buffer. More... | |
template<typename T > | |
Buffer & | operator= (const T &value) |
Assigns new value to buffer. More... | |
Buffer & | operator= (const Buffer &value) |
Copy operator. More... | |
size_type | size () const |
size_type | capacity () const |
template<typename T > | |
void | Reserve (size_type requiredCount) |
Reserves (pre-allocates) memory for buffer. More... | |
template<typename T > | |
void | ReserveAt (const_iterator< T > index, size_type requiredCount) |
Reserves (pre-allocates) memory for buffer at specific point. More... | |
template<typename T > | |
void | Resize (size_type requiredCount, const uint8 &fill=0) |
Resizes buffer. More... | |
template<typename T > | |
void | ResizeAt (const_iterator< T > index, size_type requiredCount, const uint8 &fill=0) |
Resizes buffer. More... | |
Protected Member Functions | |
template<typename T > | |
void | _Resize (size_type requiredCount) |
Resizes buffer. More... | |
template<typename T > | |
void | _ResizeAt (const_iterator< T > index, size_type requiredCount) |
Resizes buffer. More... | |
void | _Reallocate (size_type requiredSize) |
Reallocates buffer. More... | |
Static Protected Member Functions | |
static size_type | _CalcBufferCapacity (size_type currentCapacity, size_type requiredSize) |
Calculates buffer capacity. More... | |
Protected Attributes | |
uint8 * | mBuffer |
Pointer to start of buffer. More... | |
size_type | mSize |
Current size of buffer, in bytes. More... | |
size_type | mCapacity |
Current capacity of buffer, in bytes. More... | |
Generic class for buffers.
This class incorporates all stuff which may be handy when manipulating with buffers.
typedef size_t Buffer::size_type |
|
inline |
Creates buffer with given content.
Fills buffer with content determined by iterators first and last.
[in] | first | Iterator pointing to first element. |
[in] | last | Iterator pointing to element after the last one. |
Definition at line 352 of file Buffer.h.
References AssignSeq().
|
inline |
|
inline |
Destructor; deletes buffer.
Definition at line 370 of file Buffer.h.
References mBuffer, and SafeFree().
|
inlinestaticprotected |
Calculates buffer capacity.
Based on current capacity and required size of the buffer, this function calculates capacity of buffer to be allocated.
[in] | currentCapacity | Current capacity of buffer, in bytes. |
[in] | requiredSize | Required size of buffer, in bytes. |
Definition at line 791 of file Buffer.h.
References npowof2().
Referenced by _Reallocate().
|
inlineprotected |
Reallocates buffer.
Reallocates buffer so it can efficiently store given amount of data.
[in] | requiredSize | The least required new size of buffer, in bytes. |
Definition at line 763 of file Buffer.h.
References _CalcBufferCapacity(), and capacity().
Referenced by _ResizeAt(), and ReserveAt().
|
inlineprotected |
|
inlineprotected |
Resizes buffer.
Similar to ResizeAt, but does not care about the gaps that may be created.
[in] | index | The point at which the buffer should be resized. |
[in] | requiredCount | The number of elements to hold. |
Definition at line 740 of file Buffer.h.
References _Reallocate().
|
inline |
Appends a single value to buffer.
[in] | value | Value to be appended. |
Definition at line 437 of file Buffer.h.
Referenced by SystemBubble::AddBallExclusive(), SystemManager::AddMarker(), Sentry::EncodeDestiny(), CustomsSE::EncodeDestiny(), Concord::EncodeDestiny(), Missile::EncodeDestiny(), NPC::EncodeDestiny(), DroneSE::EncodeDestiny(), AsteroidSE::EncodeDestiny(), StructureSE::EncodeDestiny(), AnomalySE::EncodeDestiny(), ContainerSE::EncodeDestiny(), WormholeSE::EncodeDestiny(), StationSE::EncodeDestiny(), SystemEntity::EncodeDestiny(), WreckSE::EncodeDestiny(), StaticSystemEntity::EncodeDestiny(), ShipSE::EncodeDestiny(), ItemSystemEntity::EncodeDestiny(), FieldSE::EncodeDestiny(), ObjectSystemEntity::EncodeDestiny(), DynamicSystemEntity::EncodeDestiny(), SystemManager::MakeSetState(), MarshalStream::Put(), PyDecodeEscape(), SystemBubble::SendAddBalls(), SystemBubble::SendAddBalls2(), SystemManager::SendStaticBall(), and MarshalStream::VisitPackedRow().
|
inline |
Appends a sequence of elements to buffer.
[in] | first | Iterator pointing to first element. |
[in] | last | Iterator pointing to element after the last one. |
Definition at line 455 of file Buffer.h.
Referenced by StreamPacketizer::InputData(), MarshalDeflate(), MarshalStream::Put(), and MarshalStream::VisitPackedRow().
|
inline |
|
inline |
|
inline |
Assigns a sequence of elements to buffer.
[in] | first | Iterator pointing to first element. |
[in] | last | Iterator pointing to element after the last one. |
Definition at line 504 of file Buffer.h.
References end().
Referenced by Buffer(), operator=(), StreamPacketizer::Process(), and TCPConnection::SendData().
|
inline |
Assigns a sequence of elements to buffer at specific point.
[in] | index | Point at which the sequence of elements should be assigned. |
[in] | first | Iterator pointing to first element. |
[in] | last | Iterator pointing to element after the last one. |
Definition at line 554 of file Buffer.h.
References end(), and mBuffer.
|
inline |
Definition at line 381 of file Buffer.h.
Referenced by EVETCPConnection::DumpBuffer(), StreamPacketizer::InputData(), UnmarshalStream::Load(), UnmarshalStream::LoadPackedRow(), MarshalDeflate(), operator=(), StreamPacketizer::Process(), TCPConnection::SendData(), MailDB::SendMail(), MarshalStream::VisitPackedRow(), and MarshalStream::VisitSubStream().
|
inline |
|
inline |
Definition at line 612 of file Buffer.h.
References mCapacity.
Referenced by _Reallocate(), and ReserveAt().
|
inline |
Definition at line 387 of file Buffer.h.
References size().
Referenced by AssignSeq(), AssignSeqAt(), DeflateData(), EVETCPConnection::DumpBuffer(), InflateData(), StreamPacketizer::InputData(), MarshalDeflate(), Buffer::const_iterator< uint8 >::operator*(), operator=(), StreamPacketizer::Process(), EVETCPConnection::QueueRep(), TCPConnection::SendData(), MailDB::SendMail(), MarshalStream::VisitPackedRow(), and MarshalStream::VisitSubStream().
|
inline |
Definition at line 390 of file Buffer.h.
References size().
|
inline |
|
inline |
|
inline |
|
inline |
Copy operator.
Definition at line 598 of file Buffer.h.
References AssignSeq(), begin(), and end().
|
inline |
Reserves (pre-allocates) memory for buffer.
Pre-allocates memory for buffer to hold at least requiredCount number of elements.
Should be used in cases where lazy reallocating can negatively affect performance.
[in] | requiredCount | The least reserved number of elements. |
Definition at line 626 of file Buffer.h.
Referenced by MarshalStream::VisitPackedRow().
|
inline |
Reserves (pre-allocates) memory for buffer at specific point.
Pre-allocates memory for buffer to hold at least requiredCount number of elements, counting from index.
Should be used in cases where lazy reallocating can negatively affect performance.
[in] | index | The point at which the memory should be reserved. |
[in] | requiredCount | The least reserved number of elements. |
Definition at line 645 of file Buffer.h.
References _Reallocate(), and capacity().
|
inline |
Resizes buffer.
Changes size of buffer to hold requiredCount number of elements, possibly reallocating it.
[in] | requiredCount | The number of elements to hold. |
[in] | fill | During buffer expansion the gap will be filled by this value. |
Definition at line 670 of file Buffer.h.
Referenced by TCPConnection::RecvData().
|
inline |
Resizes buffer.
Changes size of buffer to hold requiredCount number of elements, counting from index, possibly reallocating it.
[in] | index | The point at which the buffer should be resized. |
[in] | requiredCount | The number of elements to hold. |
[in] | fill | During buffer expansion the gap will be filled by this value. |
Definition at line 688 of file Buffer.h.
References mBuffer, and size().
Referenced by DeflateData(), InflateData(), and EVETCPConnection::QueueRep().
|
inline |
Definition at line 610 of file Buffer.h.
References mSize.
Referenced by PyService::_BuildCachedReturn(), CachedObjectMgr::_UpdateCache(), DeflateData(), DestinyDumpLogText(), end(), CachedObjectMgr::GetCacheFileName(), PyBuffer::hash(), InflateData(), UnmarshalStream::Load(), UnmarshalStream::LoadRLE(), MarshalDeflate(), Buffer::const_iterator< uint8 >::operator+=(), EVETCPConnection::PopRep(), EVETCPConnection::QueueRep(), TCPConnection::RecvData(), ResizeAt(), MarshalStream::SaveRLE(), TCPConnection::SendData(), PyBuffer::size(), PyDumpVisitor::VisitBuffer(), and MarshalStream::VisitSubStream().
|
protected |
Pointer to start of buffer.
Definition at line 711 of file Buffer.h.
Referenced by AssignAt(), AssignSeqAt(), Buffer::const_iterator< uint8 >::operator*(), ResizeAt(), and ~Buffer().
|
protected |
Current capacity of buffer, in bytes.
Definition at line 715 of file Buffer.h.
Referenced by capacity().
|
protected |