Calculator Step 6

- Main Page
- Classes
- Files

- File List
- File Members

node.hpp
Go to the documentation of this file.
1 #ifndef NODE_HPP_
2 #define NODE_HPP_
3
4 #include <iosfwd>
5 #include <memory>
6 #include <string>
7 #include <vector>
8
9 #include "number.hpp"
10
12 class node_impl;
13
15 class node;
16
18 typedef std::vector<node> node_list;
19
21 typedef std::vector<std::string> identifier_list;
22
28 class node {
29 public:
31 node();
33 node(std::istream& stream);
37 node(long x);
41 node(int x);
45 node(double x);
49 node(number num);
53 node(std::string identifier);
58 node(char op, node operand);
64 node(node left, char op, node right);
69 node(identifier_list parameters, node definition);
74 node(std::string name, node_list arguments);
75
76 node(node const&) = default;
77 node(node&&) = default;
78 node& operator=(node const&) = default;
79 node& operator=(node&&) = default;
80 ~node() = default;
81
88 void print(std::ostream& stream, int indent = 0) const;
89
93 number evaluate() const;
98 std::string to_string() const;
103 identifier_list const& get_parameters() const;
104
108 void save(std::ostream& stream) const;
109
110 private:
112 static std::shared_ptr<node_impl> make_binary_operator(node, char, node);
113
114 std::shared_ptr<node_impl> pimpl_;
115 };
116
117 #endif
number
Definition: number.hpp:16
node_impl
Definition: node_impl.hpp:20
node
Definition: node.hpp:28
node::pimpl_
std::shared_ptr< node_impl > pimpl_
Definition: node.hpp:114
node::make_binary_operator
static std::shared_ptr< node_impl > make_binary_operator(node, char, node)
Factory function to make the binary operator nodes.
Definition: node.cpp:9
identifier_list
std::vector< std::string > identifier_list
A sequence of identifiers (e.g., parameter names).
Definition: node.hpp:21
node::operator=
node & operator=(node const &)=default
node::print
void print(std::ostream &stream, int indent=0) const
Definition: node.cpp:67
node::evaluate
number evaluate() const
Definition: node.cpp:73
node::to_string
std::string to_string() const
Definition: node.cpp:79
number.hpp
node::node
node()
Definition: node.cpp:23
node::get_parameters
identifier_list const & get_parameters() const
Definition: node.cpp:85
node_list
std::vector< node > node_list
A sequence of nodes.
Definition: node.hpp:15
node::save
void save(std::ostream &stream) const
Definition: node.cpp:91
node::~node
~node()=default