Calculator  Step 6
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 ()
 
 node_impl (node_impl &&)=default
 
node_imploperator= (node_impl &&)=default
 
void print (std::ostream &stream, int indent) const
 
number 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 number 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)
 
number evaluate_operand () const
 

Detailed Description

Unary negation.

Definition at line 169 of file node_impl.hpp.

Constructor & Destructor Documentation

node_negate::node_negate ( node  operand)

Definition at line 404 of file node_impl.cpp.

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

Definition at line 408 of file node_impl.cpp.

409 : node_unary{stream}
410 {}

Member Function Documentation

number node_negate::evaluate_node ( ) const
overrideprivatevirtual

Implements node_unary.

Definition at line 419 of file node_impl.cpp.

References node_unary::evaluate_operand().

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

Implements node_unary.

Definition at line 412 of file node_impl.cpp.

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

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

Implements node_unary.

Definition at line 425 of file node_impl.cpp.

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

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

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