Calculator
Extensible stack-based calculator primarily in library form
Calculator::Stack Class Reference

Stack of values to process from. More...

#include <Stack.h>

Public Types

typedef unsigned int Count
 Count of StackItems. More...
 

Public Member Functions

 Stack ()
 
 Stack (const Stack &rhs)=delete
 
 Stack (Stack &&rhs)=delete
 
Stackoperator= (const Stack &rhs)=delete
 
Stackoperator= (Stack &&rhs)=delete
 
Count getDepth () const
 
VariableSetgetVariables ()
 
void reset ()
 Reset the stack including pop all variables and reset the variables. More...
 
void popAll ()
 Pop all items from the stack. More...
 
StackIterator begin ()
 
StackIterator end ()
 
void popAfter (StackIterator &iter)
 Pop all items after iter on the Stack. More...
 
void push (StackItemPtr item)
 Push item onto the stack. More...
 
std::string toString () const
 Create string representation of the current contents of the Stack. More...
 

Detailed Description

Stack of values to process from.

Contains StackItem::Ptr objects.

Todo:
Provide load / save operations. Provide the ability to write and read Calculator.txt files which will restore the existing state.

Definition at line 208 of file Stack.h.

Member Typedef Documentation

◆ Count

typedef unsigned int Calculator::Stack::Count

Count of StackItems.

Definition at line 215 of file Stack.h.

Constructor & Destructor Documentation

◆ Stack() [1/3]

Calculator::Stack::Stack ( )

Definition at line 199 of file Stack.cpp.

◆ Stack() [2/3]

Calculator::Stack::Stack ( const Stack rhs)
delete

◆ Stack() [3/3]

Calculator::Stack::Stack ( Stack &&  rhs)
delete

Member Function Documentation

◆ begin()

StackIterator Calculator::Stack::begin ( )
Returns
StackIterator at the top of the Stack
Note
This should be a const method; however, the underlying implementation (STL) would only provide a const_iterator. This would be just fine for its use; however, std::vector::erase requires a non-const iterator, which means this must be non-const. I could const cast around this, but I'll go simpler.

Definition at line 221 of file Stack.cpp.

◆ end()

StackIterator Calculator::Stack::end ( )
Returns
StackIterator after the bottom of the Stack
Note
This should be a const method; however, the underlying implementation (STL) would only provide a const_iterator. This would be just fine for its use; however, std::vector::erase requires a non-const iterator, which means this must be non-const. I could const cast around this, but I'll go simpler.

Definition at line 227 of file Stack.cpp.

◆ getDepth()

Stack::Count Calculator::Stack::getDepth ( ) const
Returns
number of StackItems on the Stack

Definition at line 204 of file Stack.cpp.

◆ getVariables()

VariableSet & Calculator::Stack::getVariables ( )
Returns
the VariableSet

Definition at line 208 of file Stack.cpp.

◆ operator=() [1/2]

Stack& Calculator::Stack::operator= ( const Stack rhs)
delete

◆ operator=() [2/2]

Stack& Calculator::Stack::operator= ( Stack &&  rhs)
delete

◆ popAfter()

void Calculator::Stack::popAfter ( StackIterator iter)

Pop all items after iter on the Stack.

Definition at line 233 of file Stack.cpp.

◆ popAll()

void Calculator::Stack::popAll ( )

Pop all items from the stack.

Definition at line 217 of file Stack.cpp.

◆ push()

void Calculator::Stack::push ( StackItemPtr  item)

Push item onto the stack.

Parameters
itemto push

Definition at line 241 of file Stack.cpp.

◆ reset()

void Calculator::Stack::reset ( )

Reset the stack including pop all variables and reset the variables.

Definition at line 212 of file Stack.cpp.

◆ toString()

std::string Calculator::Stack::toString ( ) const

Create string representation of the current contents of the Stack.

Definition at line 245 of file Stack.cpp.


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