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

#include "PacketUtilities.h"

Public Member Functions

 Array ()
 
 Array (size_type limit)
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
size_type size () const
 
bool empty () const
 
reference operator[] (size_type i)
 
const_reference operator[] (size_type i) const
 
void resize (size_type newSize)
 
void reserve (size_type newSize)
 
void push_back (value_type const &value)
 
void push_back (value_type &&value)
 

Private Types

typedef std::vector< T > storage_type
 
typedef storage_type::value_type value_type
 
typedef storage_type::size_type size_type
 
typedef storage_type::reference reference
 
typedef storage_type::const_reference const_reference
 
typedef storage_type::iterator iterator
 
typedef storage_type::const_iterator const_iterator
 

Private Attributes

storage_type _storage
 
size_type _limit
 

Detailed Description

template<typename T, std::size_t N = 1000>
class WorldPackets::Array< T, N >

Utility class for automated prevention of loop counter spoofing in client packets

Member Typedef Documentation

◆ const_iterator

template<typename T , std::size_t N = 1000>
typedef storage_type::const_iterator WorldPackets::Array< T, N >::const_iterator
private

◆ const_reference

template<typename T , std::size_t N = 1000>
typedef storage_type::const_reference WorldPackets::Array< T, N >::const_reference
private

◆ iterator

template<typename T , std::size_t N = 1000>
typedef storage_type::iterator WorldPackets::Array< T, N >::iterator
private

◆ reference

template<typename T , std::size_t N = 1000>
typedef storage_type::reference WorldPackets::Array< T, N >::reference
private

◆ size_type

template<typename T , std::size_t N = 1000>
typedef storage_type::size_type WorldPackets::Array< T, N >::size_type
private

◆ storage_type

template<typename T , std::size_t N = 1000>
typedef std::vector<T> WorldPackets::Array< T, N >::storage_type
private

◆ value_type

template<typename T , std::size_t N = 1000>
typedef storage_type::value_type WorldPackets::Array< T, N >::value_type
private

Constructor & Destructor Documentation

◆ Array() [1/2]

template<typename T , std::size_t N = 1000>
WorldPackets::Array< T, N >::Array ( )
inline
131: _limit(N) { }
size_type _limit
Definition: PacketUtilities.h:188

◆ Array() [2/2]

template<typename T , std::size_t N = 1000>
WorldPackets::Array< T, N >::Array ( size_type  limit)
inline
132: _limit(limit) { }

Member Function Documentation

◆ begin() [1/2]

template<typename T , std::size_t N = 1000>
iterator WorldPackets::Array< T, N >::begin ( )
inline
134{ return _storage.begin(); }
storage_type _storage
Definition: PacketUtilities.h:187

References WorldPackets::Array< T, N >::_storage.

◆ begin() [2/2]

template<typename T , std::size_t N = 1000>
const_iterator WorldPackets::Array< T, N >::begin ( ) const
inline
135{ return _storage.begin(); }

References WorldPackets::Array< T, N >::_storage.

◆ empty()

template<typename T , std::size_t N = 1000>
bool WorldPackets::Array< T, N >::empty ( ) const
inline
141{ return _storage.empty(); }

References WorldPackets::Array< T, N >::_storage.

Referenced by WorldSession::HandleLfgJoinOpcode().

◆ end() [1/2]

template<typename T , std::size_t N = 1000>
iterator WorldPackets::Array< T, N >::end ( )
inline
137{ return _storage.end(); }

References WorldPackets::Array< T, N >::_storage.

◆ end() [2/2]

template<typename T , std::size_t N = 1000>
const_iterator WorldPackets::Array< T, N >::end ( ) const
inline
138{ return _storage.end(); }

References WorldPackets::Array< T, N >::_storage.

◆ operator[]() [1/2]

template<typename T , std::size_t N = 1000>
reference WorldPackets::Array< T, N >::operator[] ( size_type  i)
inline
143{ return _storage[i]; }

References WorldPackets::Array< T, N >::_storage.

◆ operator[]() [2/2]

template<typename T , std::size_t N = 1000>
const_reference WorldPackets::Array< T, N >::operator[] ( size_type  i) const
inline
144{ return _storage[i]; }

References WorldPackets::Array< T, N >::_storage.

◆ push_back() [1/2]

template<typename T , std::size_t N = 1000>
void WorldPackets::Array< T, N >::push_back ( value_type &&  value)
inline
177 {
178 if (_storage.size() >= _limit)
179 {
180 throw PacketArrayMaxCapacityException(_storage.size() + 1, _limit);
181 }
182
183 _storage.push_back(std::forward<value_type>(value));
184 }

References WorldPackets::Array< T, N >::_limit, and WorldPackets::Array< T, N >::_storage.

◆ push_back() [2/2]

template<typename T , std::size_t N = 1000>
void WorldPackets::Array< T, N >::push_back ( value_type const &  value)
inline
167 {
168 if (_storage.size() >= _limit)
169 {
170 throw PacketArrayMaxCapacityException(_storage.size() + 1, _limit);
171 }
172
173 _storage.push_back(value);
174 }

References WorldPackets::Array< T, N >::_limit, and WorldPackets::Array< T, N >::_storage.

◆ reserve()

template<typename T , std::size_t N = 1000>
void WorldPackets::Array< T, N >::reserve ( size_type  newSize)
inline
157 {
158 if (newSize > _limit)
159 {
160 throw PacketArrayMaxCapacityException(newSize, _limit);
161 }
162
163 _storage.reserve(newSize);
164 }

References WorldPackets::Array< T, N >::_limit, and WorldPackets::Array< T, N >::_storage.

◆ resize()

template<typename T , std::size_t N = 1000>
void WorldPackets::Array< T, N >::resize ( size_type  newSize)
inline
147 {
148 if (newSize > _limit)
149 {
150 throw PacketArrayMaxCapacityException(newSize, _limit);
151 }
152
153 _storage.resize(newSize);
154 }

References WorldPackets::Array< T, N >::_limit, and WorldPackets::Array< T, N >::_storage.

Referenced by WorldPackets::LFG::LFGJoin::Read().

◆ size()

template<typename T , std::size_t N = 1000>
size_type WorldPackets::Array< T, N >::size ( ) const
inline
140{ return _storage.size(); }

References WorldPackets::Array< T, N >::_storage.

Member Data Documentation

◆ _limit

◆ _storage