AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
WorldPackets::CompactArray< T > Class Template Reference

#include "PacketUtilities.h"

Public Member Functions

 CompactArray ()
 
 CompactArray (CompactArray const &right)
 
 CompactArray (CompactArray &&right)
 
CompactArrayoperator= (CompactArray const &right)
 
CompactArrayoperator= (CompactArray &&right)
 
uint32 GetMask () const
 
T const & operator[] (std::size_t index) const
 
std::size_t GetSize () const
 
void Insert (std::size_t index, T const &value)
 
void Clear ()
 
bool operator== (CompactArray const &r) const
 
bool operator!= (CompactArray const &r) const
 

Private Attributes

uint32 _mask
 
std::vector< T > _contents
 

Detailed Description

template<typename T>
class WorldPackets::CompactArray< T >

Constructor & Destructor Documentation

◆ CompactArray() [1/3]

template<typename T >
WorldPackets::CompactArray< T >::CompactArray ( )
inline
197: _mask(0) { }
uint32 _mask
Definition: PacketUtilities.h:260

◆ CompactArray() [2/3]

template<typename T >
WorldPackets::CompactArray< T >::CompactArray ( CompactArray< T > const &  right)
inline
200 : _mask(right._mask), _contents(right._contents) { }
std::vector< T > _contents
Definition: PacketUtilities.h:261

◆ CompactArray() [3/3]

template<typename T >
WorldPackets::CompactArray< T >::CompactArray ( CompactArray< T > &&  right)
inline
203 : _mask(right._mask), _contents(std::move(right._contents))
204 {
205 right._mask = 0;
206 }

Member Function Documentation

◆ Clear()

template<typename T >
void WorldPackets::CompactArray< T >::Clear ( )
inline

◆ GetMask()

template<typename T >
uint32 WorldPackets::CompactArray< T >::GetMask ( ) const
inline
223{ return _mask; }

References WorldPackets::CompactArray< T >::_mask.

Referenced by WorldPackets::operator<<().

◆ GetSize()

template<typename T >
std::size_t WorldPackets::CompactArray< T >::GetSize ( ) const
inline
225{ return _contents.size(); }

References WorldPackets::CompactArray< T >::_contents.

Referenced by WorldPackets::operator<<().

◆ Insert()

template<typename T >
void WorldPackets::CompactArray< T >::Insert ( std::size_t  index,
T const &  value 
)
inline
228 {
229 CheckCompactArrayMaskOverflow(index, sizeof(_mask) * 8);
230
231 _mask |= 1 << index;
232
233 if (_contents.size() <= index)
234 {
235 _contents.resize(index + 1);
236 }
237
238 _contents[index] = value;
239 }
void CheckCompactArrayMaskOverflow(std::size_t index, std::size_t limit)
Definition: PacketUtilities.cpp:67

References WorldPackets::CompactArray< T >::_contents, WorldPackets::CompactArray< T >::_mask, and WorldPackets::CheckCompactArrayMaskOverflow().

Referenced by WorldPackets::operator>>().

◆ operator!=()

template<typename T >
bool WorldPackets::CompactArray< T >::operator!= ( CompactArray< T > const &  r) const
inline
257{ return !(*this == r); }

◆ operator=() [1/2]

template<typename T >
CompactArray & WorldPackets::CompactArray< T >::operator= ( CompactArray< T > &&  right)
inline
216 {
217 _mask = right._mask;
218 right._mask = 0;
219 _contents = std::move(right._contents);
220 return *this;
221 }

References WorldPackets::CompactArray< T >::_contents, and WorldPackets::CompactArray< T >::_mask.

◆ operator=() [2/2]

template<typename T >
CompactArray & WorldPackets::CompactArray< T >::operator= ( CompactArray< T > const &  right)
inline
209 {
210 _mask = right._mask;
211 _contents = right._contents;
212 return *this;
213 }

References WorldPackets::CompactArray< T >::_contents, and WorldPackets::CompactArray< T >::_mask.

◆ operator==()

template<typename T >
bool WorldPackets::CompactArray< T >::operator== ( CompactArray< T > const &  r) const
inline
248 {
249 if (_mask != r._mask)
250 {
251 return false;
252 }
253
254 return _contents == r._contents;
255 }

References WorldPackets::CompactArray< T >::_contents, and WorldPackets::CompactArray< T >::_mask.

◆ operator[]()

template<typename T >
T const & WorldPackets::CompactArray< T >::operator[] ( std::size_t  index) const
inline
224{ return _contents.at(index); }

References WorldPackets::CompactArray< T >::_contents.

Member Data Documentation

◆ _contents

◆ _mask