Example of Reading a stack, converting and verifying types, and finally popping them all from the stack.
#include <memory>
#include <iostream>
#include <string>
#include <vector>
Result doSomething(Stack& stack) {
StackIterator iter = stack.begin();
iter >> item1
>> item2
>> item4
>> item5;
if(!iter) {
return iter.getResult();
}
stack.popAfter(iter);
return Result();
}
int main(int argc, char** argv) {
Stack stack;
stack.push(variable);
stack.push(variable);
stack.push(variable);
stack.push(variable);
stack.push(number);
stack.getVariables().set(variable->getName(), number);
const Result result = doSomething(stack);
std::cout << result.toString() << std::endl;
return 0;
}
std::shared_ptr< Number > Ptr
static Number::Ptr create(float theValue)
Create with theValue to represent.
std::shared_ptr< StackItem > Ptr
@ NO_DEREFERENCE_NEXT
Do not dereference the next read.
static Variable::Ptr create(const std::string &theName)
Create with theName to represent.
std::shared_ptr< Variable > Ptr
Container of Calculator resources.