Calculator  Step 6
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 ()
 
 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 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 84 of file node_impl.hpp.

Constructor & Destructor Documentation

node_identifier::node_identifier ( std::string  name)

Definition at line 160 of file node_impl.cpp.

161 : node_impl{}, name_{std::move(name)}
162 {}
std::string name_
Definition: node_impl.hpp:95
std::string const & name() const
Definition: node_impl.cpp:171
node_identifier::node_identifier ( std::istream &  stream)

Definition at line 164 of file node_impl.cpp.

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

Member Function Documentation

number node_identifier::evaluate_node ( ) const
overrideprivatevirtual

Implements node_impl.

Definition at line 183 of file node_impl.cpp.

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

185 {
186  return get_variable(name()).evaluate();
187 }
std::string const & name() const
Definition: node_impl.cpp:171
number evaluate() const
Definition: node.cpp:73
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 189 of file node_impl.cpp.

References name().

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

Definition at line 171 of file node_impl.cpp.

References name_.

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

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

Implements node_impl.

Definition at line 177 of file node_impl.cpp.

References name().

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

Implements node_impl.

Definition at line 195 of file node_impl.cpp.

References name().

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

Member Data Documentation

std::string node_identifier::name_
private

Definition at line 95 of file node_impl.hpp.

Referenced by name().


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