32 StackManipulator::StackManipulator(Operation theOp)
77 (*first)(stack, first);
78 (*second)(stack, second);
90 return Result({
"Internal Error: Missing StackManipulator."});
97 return std::string() +
98 "pop -- remove the top element\n" +
99 "dup -- add a copy of the top element\n" +
100 "swap -- exchange the top two values on the stack\n" +
101 "reset -- reset the stack including removing all elements of the and clearing all variables\n" +
102 "pop-all -- remove all elements of the stack";
107 if(0 == str.compare(
"pop")) {
109 }
else if(0 == str.compare(
"dup")) {
111 }
else if(0 == str.compare(
"swap")) {
113 }
else if(0 == str.compare(
"reset")) {
115 }
else if(0 == str.compare(
"pop-all")) {
Collection of Result information for an operation.
Stack of values to process from.
void popAfter(StackIterator &iter)
Pop all items after iter on the Stack.
void popAll()
Pop all items from the stack.
void reset()
Reset the stack including pop all variables and reset the variables.
std::shared_ptr< StackItem > Ptr
Iterator over a Stack from top to bottom.
@ NO_DEREFERENCE_NEXT
Do not dereference the next read.
const Result & getResult() const
virtual ~StackManipulatorCreator()
virtual StackOperator::Ptr create(const std::string &str)
virtual std::string getHelp() const
Stack Modifier for Stack Operations.
static StackManipulator::Ptr create(Operation operation)
Create to perform operation.
virtual Result operator()(Stack &stack, StackOperator::Ptr ofThis)
Execute this operator on stack.
Operation
Operations supported.
@ SWAP
Swap the top two elements.
@ POP_ALL
Clear the entire stack.
@ DUP
Duplicate the top value.
@ RESET
Clear the entire stack and set of variables.
@ POP
Pop the top value off and forget it.
std::shared_ptr< StackOperator > Ptr
const std::string Ok
Operation was successful.
Container of Calculator resources.