Calculator
Step 6
|
#include <fstream>
#include <istream>
#include <limits>
#include <map>
#include <ostream>
#include "calc_error.hpp"
#include "node.hpp"
#include "variables.hpp"
Go to the source code of this file.
Functions | |
bool | find_symbol (std::string const &name, node &value) |
node | get_variable (std::string const &name) |
void | set_variable (std::string const &name, node value) |
node | get_function (std::string const &name) |
void | set_function (std::string const &name, node value) |
void | save_library (std::string const &filename) |
void | load_library (std::string const &filename) |
bool find_symbol | ( | std::string const & | name, |
node & | value | ||
) |
node get_function | ( | std::string const & | name | ) |
Get the definition of a function.
name | The function name |
name
no_such_function | if the function is not defined |
Definition at line 65 of file variables.cpp.
References find_symbol().
Referenced by node_function_call::evaluate_node().
node get_variable | ( | std::string const & | name | ) |
Get the value of a variable.
name | The variable name |
name
or node() if the variable is undefined. Definition at line 49 of file variables.cpp.
References find_symbol().
Referenced by BOOST_AUTO_TEST_CASE(), and node_identifier::evaluate_node().
void load_library | ( | std::string const & | filename | ) |
Load variable and function definitions from a file. Definitions in the file overwrite existing definitions with the same name.
filename | The file name |
calc_error | for I/O errors |
Definition at line 100 of file variables.cpp.
References set_variable().
Referenced by parser::get_statement().
void save_library | ( | std::string const & | filename | ) |
Save all variable and function definitions to a file. The file is a simple text file, so you can examine it in any text editor.
filename | The name of the file. |
calc_error | if the file cannot be created |
Definition at line 79 of file variables.cpp.
Referenced by parser::get_statement().
void set_function | ( | std::string const & | name, |
node | definition | ||
) |
Set the definition of a function.
name | The function name |
definition | The function definition |
Definition at line 74 of file variables.cpp.
References set_variable().
Referenced by BOOST_AUTO_TEST_CASE(), and parser::get_statement().
void set_variable | ( | std::string const & | name, |
node | value | ||
) |
Set the value of a variable.
name | The variable name |
value | The value. if the variable is already defined, changes its value. |
Definition at line 60 of file variables.cpp.
Referenced by BOOST_AUTO_TEST_CASE(), load_library(), and set_function().