session.hh
Go to the documentation of this file.
namespace SCalc {
class ParserResult;
class Expression;
class FuncDef;
std::string version();
class Session {
protected:
std::vector<std::string> variables;
std::map<std::string,int> variables_numbers;
std::map<int, double> values;
std::map<std::string, int> functions_numbers;
std::vector<FuncDef *> functions;
public:
Session();
~Session();
ParserResult * eval(const char *);
void eval_and_free(const char *);
int register_varname(const std::string &str);
int register_varname(const char * str);
const char * varname(int i);
std::vector<std::string> varnames() {
std::vector<std::string> d = variables;
return d;
};
int nb_vars_defined() {return variables.size();};
int set_var(int, double);
int set_var(const char * var, double val) {
return set_var(register_varname(var), val);
};
int set_var(const std::string & var, double val) {
return set_var(register_varname(var), val);
};
int unset_var(int);
int unset_var(std::string varname);
int unset_var(const char * varname) {
return unset_var(std::string(varname));
};
int nb_vars_set() {return values.size();};
std::set<int> vars_set();
void fill_default(double * );
int evaluable(Expression * expr);
int register_func_def(FuncDef *);
int replace_func_def(FuncDef *);
int get_func(std::string);
int get_func(const char * name)
{ return get_func(std::string(name));};
FuncDef * get_func_def(std::string);
FuncDef * get_func_def(const char * name)
{ return get_func_def(std::string(name));};
int nb_args_func(std::string);
int nb_args_func(const char * name)
{ return nb_args_func(std::string(name));};
int nb_funcs() { return functions.size();};
std::vector<std::string> func_names();
Expression * constant(double value);
};
};