EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Buffer::const_iterator< T > Class Template Reference

Buffer's const iterator. More...

#include "Buffer.h"

Inheritance diagram for Buffer::const_iterator< T >:
Collaboration diagram for Buffer::const_iterator< T >:

Public Types

typedef _Base::iterator_category iterator_category
 Typedef for iterator category. More...
 
typedef _Base::value_type value_type
 Typedef for value type. More...
 
typedef _Base::difference_type difference_type
 Typedef for difference type. More...
 
typedef _Base::pointer pointer
 Typedef for pointer. More...
 
typedef _Base::reference reference
 Typedef for reference. More...
 
typedef const T * const_pointer
 Typedef for const pointer. More...
 
typedef const T & const_reference
 Typedef for const reference. More...
 

Public Member Functions

 const_iterator (const Buffer *buffer=NULL, size_type index=0)
 Default constructor. More...
 
 const_iterator (const const_iterator &oth)
 Copy constructor. More...
 
const_iteratoroperator= (const const_iterator &oth)
 Copy operator. More...
 
template<typename T2 >
const_iterator< T2 > As () const
 Converts const_iterator to another const_iterator with different type. More...
 
const_reference operator* () const
 Dereference operator. More...
 
const_pointer operator-> () const
 Dereference operator. More...
 
const_reference operator[] (difference_type diff) const
 Subscript operator. More...
 
const_iterator operator+ (difference_type diff) const
 Sum operator. More...
 
const_iteratoroperator+= (difference_type diff)
 Add operator. More...
 
const_iteratoroperator++ ()
 Preincrement operator. More...
 
const_iterator operator++ (int)
 Postincrement operator. More...
 
const_iterator operator- (difference_type diff) const
 Diff operator. More...
 
const_iteratoroperator-= (difference_type diff)
 Subtract operator. More...
 
const_iteratoroperator-- ()
 Predecrement operator. More...
 
const_iterator operator-- (int)
 Postdecrement operator. More...
 
difference_type operator- (const const_iterator &oth) const
 Diff operator. More...
 
bool operator== (const const_iterator &oth) const
 Equal operator. More...
 
bool operator!= (const const_iterator &oth) const
 Non-equal operator. More...
 
bool operator< (const const_iterator &oth) const
 Less-than operator. More...
 
bool operator> (const const_iterator &oth) const
 Greater-than operator. More...
 
bool operator<= (const const_iterator &oth) const
 Less-equal operator. More...
 
bool operator>= (const const_iterator &oth) const
 Greater-equal operator. More...
 

Protected Attributes

size_type mIndex
 Index in buffer, in bytes. More...
 
const BuffermBuffer
 The parent Buffer. More...
 

Private Types

typedef std::iterator
< std::random_access_iterator_tag,
T > 
_Base
 Typedef for our base due to readibility. More...
 

Detailed Description

template<typename T>
class Buffer::const_iterator< T >

Buffer's const iterator.

Author
Bloody.Rabbit

Definition at line 52 of file Buffer.h.

Member Typedef Documentation

template<typename T>
typedef std::iterator< std::random_access_iterator_tag, T > Buffer::const_iterator< T >::_Base
private

Typedef for our base due to readibility.

Definition at line 56 of file Buffer.h.

template<typename T>
typedef const T* Buffer::const_iterator< T >::const_pointer

Typedef for const pointer.

Definition at line 71 of file Buffer.h.

template<typename T>
typedef const T& Buffer::const_iterator< T >::const_reference

Typedef for const reference.

Definition at line 73 of file Buffer.h.

template<typename T>
typedef _Base::difference_type Buffer::const_iterator< T >::difference_type

Typedef for difference type.

Definition at line 64 of file Buffer.h.

template<typename T>
typedef _Base::iterator_category Buffer::const_iterator< T >::iterator_category

Typedef for iterator category.

Definition at line 60 of file Buffer.h.

template<typename T>
typedef _Base::pointer Buffer::const_iterator< T >::pointer

Typedef for pointer.

Definition at line 66 of file Buffer.h.

template<typename T>
typedef _Base::reference Buffer::const_iterator< T >::reference

Typedef for reference.

Definition at line 68 of file Buffer.h.

template<typename T>
typedef _Base::value_type Buffer::const_iterator< T >::value_type

Typedef for value type.

Definition at line 62 of file Buffer.h.

Constructor & Destructor Documentation

template<typename T>
Buffer::const_iterator< T >::const_iterator ( const Buffer buffer = NULL,
size_type  index = 0 
)
inline

Default constructor.

Parameters
[in]bufferThe parent Buffer.
[in]indexThe index.

Definition at line 81 of file Buffer.h.

82  : mIndex( index ),
83  mBuffer( buffer )
84  {
85  }
const Buffer * mBuffer
The parent Buffer.
Definition: Buffer.h:223
size_type mIndex
Index in buffer, in bytes.
Definition: Buffer.h:221
template<typename T>
Buffer::const_iterator< T >::const_iterator ( const const_iterator< T > &  oth)
inline

Copy constructor.

Definition at line 87 of file Buffer.h.

88  : mIndex( oth.mIndex ),
89  mBuffer( oth.mBuffer )
90  {
91  }
const Buffer * mBuffer
The parent Buffer.
Definition: Buffer.h:223
size_type mIndex
Index in buffer, in bytes.
Definition: Buffer.h:221

Member Function Documentation

template<typename T>
template<typename T2 >
const_iterator< T2 > Buffer::const_iterator< T >::As ( ) const
inline

Converts const_iterator to another const_iterator with different type.

Returns
The new const_iterator.

Definition at line 108 of file Buffer.h.

Referenced by UnmarshalStream::LoadPackedRow(), UnmarshalStream::Peek(), and StreamPacketizer::Process().

108 { return const_iterator< T2 >( mBuffer, mIndex ); }
const Buffer * mBuffer
The parent Buffer.
Definition: Buffer.h:223
size_type mIndex
Index in buffer, in bytes.
Definition: Buffer.h:221

Here is the caller graph for this function:

template<typename T>
bool Buffer::const_iterator< T >::operator!= ( const const_iterator< T > &  oth) const
inline

Non-equal operator.

Definition at line 196 of file Buffer.h.

196 { return !( *this == oth ); }
template<typename T>
const_reference Buffer::const_iterator< T >::operator* ( ) const
inline

Dereference operator.

Definition at line 111 of file Buffer.h.

112  {
113  // make sure we have valid buffer
114  assert( mBuffer );
115  // make sure we're not going off the bounds
116  assert( 1 <= mBuffer->end< value_type >() - *this );
117 
118  // obtain the value and return
119  return *(const_pointer)&( mBuffer->mBuffer )[ mIndex ];
120  }
const T * const_pointer
Typedef for const pointer.
Definition: Buffer.h:71
const Buffer * mBuffer
The parent Buffer.
Definition: Buffer.h:223
uint8 * mBuffer
Pointer to start of buffer.
Definition: Buffer.h:711
_Base::value_type value_type
Typedef for value type.
Definition: Buffer.h:62
size_type mIndex
Index in buffer, in bytes.
Definition: Buffer.h:221
iterator< T > end()
Definition: Buffer.h:387
template<typename T>
const_iterator Buffer::const_iterator< T >::operator+ ( difference_type  diff) const
inline

Sum operator.

Definition at line 127 of file Buffer.h.

128  {
129  const_iterator res( *this );
130  return ( res += diff );
131  }
const_iterator(const Buffer *buffer=NULL, size_type index=0)
Default constructor.
Definition: Buffer.h:81
template<typename T>
const_iterator& Buffer::const_iterator< T >::operator++ ( )
inline

Preincrement operator.

Definition at line 151 of file Buffer.h.

151 { return ( *this += 1 ); }
template<typename T>
const_iterator Buffer::const_iterator< T >::operator++ ( int  )
inline

Postincrement operator.

Definition at line 153 of file Buffer.h.

154  {
155  const_iterator res( *this );
156  ++*this;
157  return res;
158  }
const_iterator(const Buffer *buffer=NULL, size_type index=0)
Default constructor.
Definition: Buffer.h:81
template<typename T>
const_iterator& Buffer::const_iterator< T >::operator+= ( difference_type  diff)
inline

Add operator.

Definition at line 133 of file Buffer.h.

134  {
135  // turn the diff into byte diff
136  const difference_type res = ( diff * sizeof( value_type ) );
137 
138  // make sure we have valid buffer
139  assert( mBuffer );
140  // make sure we won't go negative
141  assert( 0 <= mIndex + res );
142  // make sure we won't go past end
143  assert( mIndex + res <= mBuffer->size() );
144 
145  // set new index
146  mIndex += res;
147 
148  return *this;
149  }
const Buffer * mBuffer
The parent Buffer.
Definition: Buffer.h:223
_Base::difference_type difference_type
Typedef for difference type.
Definition: Buffer.h:64
_Base::value_type value_type
Typedef for value type.
Definition: Buffer.h:62
size_type size() const
Definition: Buffer.h:610
size_type mIndex
Index in buffer, in bytes.
Definition: Buffer.h:221
template<typename T>
const_iterator Buffer::const_iterator< T >::operator- ( difference_type  diff) const
inline

Diff operator.

Definition at line 161 of file Buffer.h.

162  {
163  const_iterator res( *this );
164  return ( res -= diff );
165  }
const_iterator(const Buffer *buffer=NULL, size_type index=0)
Default constructor.
Definition: Buffer.h:81
template<typename T>
difference_type Buffer::const_iterator< T >::operator- ( const const_iterator< T > &  oth) const
inline

Diff operator.

Definition at line 179 of file Buffer.h.

180  {
181  // make sure we have same parent buffer
182  assert( oth.mBuffer == mBuffer );
183  // return difference in element offset
184  return ( ( mIndex - oth.mIndex ) / sizeof( value_type ) );
185  }
const Buffer * mBuffer
The parent Buffer.
Definition: Buffer.h:223
_Base::value_type value_type
Typedef for value type.
Definition: Buffer.h:62
size_type mIndex
Index in buffer, in bytes.
Definition: Buffer.h:221
template<typename T>
const_iterator& Buffer::const_iterator< T >::operator-- ( )
inline

Predecrement operator.

Definition at line 169 of file Buffer.h.

169 { return ( *this -= 1 ); }
template<typename T>
const_iterator Buffer::const_iterator< T >::operator-- ( int  )
inline

Postdecrement operator.

Definition at line 171 of file Buffer.h.

172  {
173  const_iterator res( *this );
174  --*this;
175  return res;
176  }
const_iterator(const Buffer *buffer=NULL, size_type index=0)
Default constructor.
Definition: Buffer.h:81
template<typename T>
const_iterator& Buffer::const_iterator< T >::operator-= ( difference_type  diff)
inline

Subtract operator.

Definition at line 167 of file Buffer.h.

167 { return ( *this += ( -diff ) ); }
template<typename T>
const_pointer Buffer::const_iterator< T >::operator-> ( ) const
inline

Dereference operator.

Definition at line 122 of file Buffer.h.

122 { return &**this; }
template<typename T>
bool Buffer::const_iterator< T >::operator< ( const const_iterator< T > &  oth) const
inline

Less-than operator.

Definition at line 199 of file Buffer.h.

200  {
201  // make sure we have same parent buffer
202  assert( oth.mBuffer == mBuffer );
203  // return the result
204  return ( mIndex < oth.mIndex );
205  }
const Buffer * mBuffer
The parent Buffer.
Definition: Buffer.h:223
size_type mIndex
Index in buffer, in bytes.
Definition: Buffer.h:221
template<typename T>
bool Buffer::const_iterator< T >::operator<= ( const const_iterator< T > &  oth) const
inline

Less-equal operator.

Definition at line 215 of file Buffer.h.

215 { return !( *this > oth ); }
template<typename T>
const_iterator& Buffer::const_iterator< T >::operator= ( const const_iterator< T > &  oth)
inline

Copy operator.

Definition at line 94 of file Buffer.h.

95  {
96  mIndex = oth.mIndex;
97  mBuffer = oth.mBuffer;
98  return *this;
99  }
const Buffer * mBuffer
The parent Buffer.
Definition: Buffer.h:223
uint8 * mBuffer
Pointer to start of buffer.
Definition: Buffer.h:711
size_type mIndex
Index in buffer, in bytes.
Definition: Buffer.h:221
template<typename T>
bool Buffer::const_iterator< T >::operator== ( const const_iterator< T > &  oth) const
inline

Equal operator.

Definition at line 188 of file Buffer.h.

189  {
190  // make sure we have same parent buffer
191  assert( oth.mBuffer == mBuffer );
192  // return the result
193  return ( mIndex == oth.mIndex );
194  }
const Buffer * mBuffer
The parent Buffer.
Definition: Buffer.h:223
size_type mIndex
Index in buffer, in bytes.
Definition: Buffer.h:221
template<typename T>
bool Buffer::const_iterator< T >::operator> ( const const_iterator< T > &  oth) const
inline

Greater-than operator.

Definition at line 207 of file Buffer.h.

208  {
209  // make sure we have same parent buffer
210  assert( oth.mBuffer == mBuffer );
211  // return the result
212  return ( mIndex > oth.mIndex );
213  }
const Buffer * mBuffer
The parent Buffer.
Definition: Buffer.h:223
size_type mIndex
Index in buffer, in bytes.
Definition: Buffer.h:221
template<typename T>
bool Buffer::const_iterator< T >::operator>= ( const const_iterator< T > &  oth) const
inline

Greater-equal operator.

Definition at line 217 of file Buffer.h.

217 { return !( *this < oth ); }
template<typename T>
const_reference Buffer::const_iterator< T >::operator[] ( difference_type  diff) const
inline

Subscript operator.

Definition at line 124 of file Buffer.h.

124 { return *( *this + diff ); }

Member Data Documentation


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