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

#include <node_impl.hpp>

Inheritance diagram for node_negate:
node_unary node_impl

Public Member Functions

 node_negate (node operand)
 
 node_negate (std::istream &stream)
 
- Public Member Functions inherited from node_unary
 node_unary (node operand)
 
node operand () 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
 

Additional Inherited Members

- Static Public Member Functions inherited from node_impl
static std::shared_ptr< node_implread_node (std::istream &stream)
 
- Protected Member Functions inherited from node_unary
 node_unary (std::istream &stream)
 
double evaluate_operand () const
 

Detailed Description

Unary negation.

Definition at line 166 of file node_impl.hpp.

Constructor & Destructor Documentation

node_negate::node_negate ( node  operand)

Definition at line 405 of file node_impl.cpp.

406 : node_unary{operand}
407 {}
node_negate::node_negate ( std::istream &  stream)

Definition at line 409 of file node_impl.cpp.

410 : node_unary{stream}
411 {}

Member Function Documentation

double node_negate::evaluate_node ( ) const
overrideprivatevirtual

Implements node_unary.

Definition at line 420 of file node_impl.cpp.

References node_unary::evaluate_operand().

422 {
423  return -evaluate_operand();
424 }
double evaluate_operand() const
Definition: node_impl.cpp:366
void node_negate::print_node ( std::ostream &  stream,
int  indent 
) const
overrideprivatevirtual

Implements node_unary.

Definition at line 413 of file node_impl.cpp.

References node_unary::operand(), and node::print().

415 {
416  stream << std::setw(indent) << "" << "-\n";
417  operand().print(stream, indent + 2);
418 }
void print(std::ostream &stream, int indent=0) const
Definition: node.cpp:54
node operand() const
Definition: node_impl.cpp:360
void node_negate::save_node ( std::ostream &  stream) const
overrideprivatevirtual

Implements node_unary.

Definition at line 426 of file node_impl.cpp.

References node_unary::operand(), and node::save().

428 {
429  stream << "negate ";
430  operand().save(stream);
431 }
node operand() const
Definition: node_impl.cpp:360
void save(std::ostream &stream) const
Definition: node.cpp:78

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