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

#include <node_impl.hpp>

Inheritance diagram for node_identifier:
node_impl

Public Member Functions

 node_identifier (std::string name)
 
 node_identifier (std::istream &stream)
 
std::string const & name () 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 std::string evaluate_string () const override
 
virtual void save_node (std::ostream &stream) const override
 

Private Attributes

std::string name_
 

Additional Inherited Members

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

Detailed Description

Identifier data type. Used for variable references.

Definition at line 81 of file node_impl.hpp.

Constructor & Destructor Documentation

node_identifier::node_identifier ( std::string  name)

Definition at line 161 of file node_impl.cpp.

162 : node_impl{}, name_{std::move(name)}
163 {}
std::string name_
Definition: node_impl.hpp:92
std::string const & name() const
Definition: node_impl.cpp:172
node_identifier::node_identifier ( std::istream &  stream)

Definition at line 165 of file node_impl.cpp.

166 : node_impl{}
167 {
168  if (not (stream >> name_))
169  throw calc_error{"malformed library file, cannot read identifier"};
170 }
std::string name_
Definition: node_impl.hpp:92

Member Function Documentation

double node_identifier::evaluate_node ( ) const
overrideprivatevirtual

Implements node_impl.

Definition at line 184 of file node_impl.cpp.

References node::evaluate(), get_variable(), and name().

186 {
187  return get_variable(name()).evaluate();
188 }
std::string const & name() const
Definition: node_impl.cpp:172
double evaluate() const
Definition: node.cpp:60
node get_variable(std::string const &name)
Definition: variables.cpp:49
std::string node_identifier::evaluate_string ( ) const
overrideprivatevirtual

Reimplemented from node_impl.

Definition at line 190 of file node_impl.cpp.

References name().

192 {
193  return name();
194 }
std::string const & name() const
Definition: node_impl.cpp:172
std::string const & node_identifier::name ( ) const

Definition at line 172 of file node_impl.cpp.

References name_.

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

174 {
175  return name_;
176 }
std::string name_
Definition: node_impl.hpp:92
void node_identifier::print_node ( std::ostream &  stream,
int  indent 
) const
overrideprivatevirtual

Implements node_impl.

Definition at line 178 of file node_impl.cpp.

References name().

180 {
181  stream << std::setw(indent) << "" << "identifier " << name() << '\n';
182 }
std::string const & name() const
Definition: node_impl.cpp:172
void node_identifier::save_node ( std::ostream &  stream) const
overrideprivatevirtual

Implements node_impl.

Definition at line 196 of file node_impl.cpp.

References name().

198 {
199  stream << "identifier " << name() << '\n';
200 }
std::string const & name() const
Definition: node_impl.cpp:172

Member Data Documentation

std::string node_identifier::name_
private

Definition at line 92 of file node_impl.hpp.

Referenced by name().


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