Calculator  Step 5
Public Member Functions | Private Member Functions | Private Attributes | List of all members
node_number Class Reference

#include <node_impl.hpp>

Inheritance diagram for node_number:
node_impl

Public Member Functions

 node_number (double value)
 
 node_number (std::istream &stream)
 
double value () const
 
- Public Member Functions inherited from node_impl
 node_impl ()
 
virtual ~node_impl ()
 
void print (std::ostream &stream, int indent) const
 
double evaluate () const
 
std::string to_string () const
 
identifier_list const & get_parameters () const
 
void save (std::ostream &stream) const
 

Private Member Functions

virtual void print_node (std::ostream &stream, int indent) const override
 
virtual double evaluate_node () const override
 
virtual void save_node (std::ostream &stream) const override
 

Private Attributes

double value_
 

Additional Inherited Members

- Static Public Member Functions inherited from node_impl
static std::shared_ptr< node_implread_node (std::istream &stream)
 

Detailed Description

Number data type. Used for numeric literals.

Definition at line 65 of file node_impl.hpp.

Constructor & Destructor Documentation

node_number::node_number ( double  value)

Definition at line 125 of file node_impl.cpp.

126 : node_impl{}, value_{value}
127 {}
double value_
Definition: node_impl.hpp:75
double value() const
Definition: node_impl.cpp:136
node_number::node_number ( std::istream &  stream)

Definition at line 129 of file node_impl.cpp.

130 : node_impl{}
131 {
132  if (not (stream >> value_))
133  throw calc_error{"malformed library file, cannot read number"};
134 }
double value_
Definition: node_impl.hpp:75

Member Function Documentation

double node_number::evaluate_node ( ) const
overrideprivatevirtual

Implements node_impl.

Definition at line 148 of file node_impl.cpp.

References value().

150 {
151  return value();
152 }
double value() const
Definition: node_impl.cpp:136
void node_number::print_node ( std::ostream &  stream,
int  indent 
) const
overrideprivatevirtual

Implements node_impl.

Definition at line 142 of file node_impl.cpp.

References value().

144 {
145  stream << std::setw(indent) << "" << value() << '\n';
146 }
double value() const
Definition: node_impl.cpp:136
void node_number::save_node ( std::ostream &  stream) const
overrideprivatevirtual

Implements node_impl.

Definition at line 154 of file node_impl.cpp.

References value().

156 {
157  stream << "number " << value() << '\n';
158 }
double value() const
Definition: node_impl.cpp:136
double node_number::value ( ) const

Definition at line 136 of file node_impl.cpp.

References value_.

Referenced by evaluate_node(), print_node(), and save_node().

138 {
139  return value_;
140 }
double value_
Definition: node_impl.hpp:75

Member Data Documentation

double node_number::value_
private

Definition at line 75 of file node_impl.hpp.

Referenced by value().


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