Calculator Step 3

- Main Page
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Private Member Functions | List of all members
node_impl Class Referenceabstract

`#include <node_impl.hpp>`

Inheritance diagram for node_impl:

## Public Member Functions
| node_impl ()
virtual | ~node_impl ()
void | print (std::ostream &stream, int indent) const
double | evaluate () const
std::string | to_string () const

## Private Member Functions
| node_impl (node_impl const &n)=delete
node_impl & | operator= (node_impl const &n)=delete
virtual void | print_node (std::ostream &stream, int indent) const =0
virtual double | evaluate_node () const =0
virtual std::string | evaluate_string () const

## Detailed Description

Base class for all parse tree nodes. The node classes all derive from node_impl. Each derived class overrides print_node(), for debugging and evalute_node() to evaluate the node. A few classes also override evaluate_string(), but most classes can inherit the node_impl::evaluate_string implementation, which prints the result of calling evaluate().

Definition at line 17 of file node_impl.hpp.

## Constructor & Destructor Documentation

node_impl::node_impl | ( |  | ) |

Definition at line 9 of file node_impl.cpp.

10 {}

node_impl::~node_impl | ( |  | ) |
| virtual

Definition at line 12 of file node_impl.cpp.

13 {}

node_impl::node_impl | ( | node_impl const & | n | ) |
| private delete

## Member Function Documentation

double node_impl::evaluate | ( |  | ) | const

Definition at line 21 of file node_impl.cpp.

References evaluate_node().

Referenced by evaluate_string().

23 {
24 return evaluate_node();
25 }
node_impl::evaluate_node
virtual double evaluate_node() const =0

virtual double node_impl::evaluate_node | ( |  | ) | const
| private pure virtual

Implemented in node_divide, node_multiply, node_subtract, node_add, node_negate, node_binary, node_unary, node_assign, node_identifier, node_number, and node_void.

Referenced by evaluate().

std::string node_impl::evaluate_string | ( |  | ) | const
| private virtual

Reimplemented in node_identifier, and node_void.

Definition at line 33 of file node_impl.cpp.

References evaluate().

Referenced by to_string().

35 {
36 std::ostringstream stream{};
37 stream << evaluate();
38 return stream.str();
39 }
node_impl::evaluate
double evaluate() const
Definition: node_impl.cpp:21

node_impl& node_impl::operator= | ( | node_impl const & | n | ) |
| private delete

void node_impl::print | ( | std::ostream & | stream,
|  | int | indent
| ) |  | const

Definition at line 15 of file node_impl.cpp.

References print_node().

17 {
18 print_node(stream, indent);
19 }
node_impl::print_node
virtual void print_node(std::ostream &stream, int indent) const =0

virtual void node_impl::print_node | ( | std::ostream & | stream,
|  | int | indent
| ) |  | const
| private pure virtual

Implemented in node_divide, node_multiply, node_subtract, node_add, node_negate, node_binary, node_unary, node_assign, node_identifier, node_number, and node_void.

Referenced by print().

std::string node_impl::to_string | ( |  | ) | const

Definition at line 27 of file node_impl.cpp.

References evaluate_string().

29 {
30 return evaluate_string();
31 }
node_impl::evaluate_string
virtual std::string evaluate_string() const
Definition: node_impl.cpp:33

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

- node_impl.hpp
- node_impl.cpp