ManaPlus
Public Member Functions | Data Fields
MStack< T > Struct Template Reference

#include <mstack.h>

Public Member Functions

 MStack (const size_t maxSize)
 
 ~MStack ()
 
T & push ()
 
T & getPop ()
 
const T & getPopConst ()
 
void pop ()
 
T & top () const
 
const T & topConst () const
 
void clear ()
 
bool empty () const
 

Data Fields

T * mStack
 
size_t mMaxSize
 
T * mPointer
 
const T *const mStartPointer
 
const T *const mEndPointer
 

Detailed Description

template<typename T>
struct MStack< T >

Definition at line 30 of file mstack.h.

Constructor & Destructor Documentation

◆ MStack()

template<typename T >
MStack< T >::MStack ( const size_t  maxSize)
inlineexplicit

Definition at line 32 of file mstack.h.

32  :
33  mStack(new T[maxSize]),
34  mMaxSize(maxSize),
35  mPointer(mStack - 1),
36  mStartPointer(mStack - 1),
37  mEndPointer(mStack + maxSize - 1)
38  {
39  }
const T *const mStartPointer
Definition: mstack.h:97
T * mPointer
Definition: mstack.h:96
const T *const mEndPointer
Definition: mstack.h:98
size_t mMaxSize
Definition: mstack.h:95
T * mStack
Definition: mstack.h:93

◆ ~MStack()

template<typename T >
MStack< T >::~MStack ( )
inline

Definition at line 41 of file mstack.h.

42  {
43  delete [] mStack;
44  }

References MStack< T >::mStack.

Member Function Documentation

◆ clear()

template<typename T >
void MStack< T >::clear ( )
inline

Definition at line 83 of file mstack.h.

84  {
85  mPointer = mStack - 1;
86  }

References MStack< T >::mPointer, and MStack< T >::mStack.

◆ empty()

template<typename T >
bool MStack< T >::empty ( ) const
inline

Definition at line 88 of file mstack.h.

89  {
90  return mPointer == mStartPointer;
91  }

References MStack< T >::mPointer, and MStack< T >::mStartPointer.

Referenced by Graphics::popClipArea().

◆ getPop()

template<typename T >
T& MStack< T >::getPop ( )
inline

Definition at line 58 of file mstack.h.

59  {
60  return *(mPointer--);
61  }

References MStack< T >::mPointer.

◆ getPopConst()

template<typename T >
const T& MStack< T >::getPopConst ( )
inline

Definition at line 63 of file mstack.h.

64  {
65  return *(mPointer--);
66  }

References MStack< T >::mPointer.

◆ pop()

template<typename T >
void MStack< T >::pop ( )
inline

Definition at line 68 of file mstack.h.

69  {
70  mPointer --;
71  }

References MStack< T >::mPointer.

Referenced by Graphics::popClipArea().

◆ push()

template<typename T >
T& MStack< T >::push ( )
inline

Definition at line 48 of file mstack.h.

49  {
50  if (mPointer == mEndPointer)
51  {
52  logger->log("error: max stack size reached");
53  return *mPointer;
54  }
55  return *(++mPointer);
56  }
void log(const char *const log_text,...)
Definition: logger.cpp:269
Logger * logger
Definition: logger.cpp:89

References Logger::log(), logger, MStack< T >::mEndPointer, and MStack< T >::mPointer.

◆ top()

template<typename T >
T& MStack< T >::top ( ) const
inline

Definition at line 73 of file mstack.h.

74  {
75  return *mPointer;
76  }

References MStack< T >::mPointer.

Referenced by Graphics::getTopClip().

◆ topConst()

template<typename T >
const T& MStack< T >::topConst ( ) const
inline

Definition at line 78 of file mstack.h.

79  {
80  return *mPointer;
81  }

References MStack< T >::mPointer.

Field Documentation

◆ mEndPointer

template<typename T >
const T* const MStack< T >::mEndPointer

Definition at line 98 of file mstack.h.

Referenced by MStack< T >::push().

◆ mMaxSize

template<typename T >
size_t MStack< T >::mMaxSize

Definition at line 95 of file mstack.h.

◆ mPointer

template<typename T >
T* MStack< T >::mPointer

◆ mStack

template<typename T >
T* MStack< T >::mStack

Definition at line 93 of file mstack.h.

Referenced by MStack< T >::clear(), and MStack< T >::~MStack().

◆ mStartPointer

template<typename T >
const T* const MStack< T >::mStartPointer

Definition at line 97 of file mstack.h.

Referenced by MStack< T >::empty().


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