Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dynamic exception specifications #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 14 additions & 23 deletions fityk/fityk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ Fityk::~Fityk()
delete p_;
}

void Fityk::execute(string const& s) throw(SyntaxError, ExecuteError,
ExitRequestedException)
void Fityk::execute(string const& s)
{
try {
priv_->parse_and_execute_line(s);
Expand All @@ -139,8 +138,7 @@ void Fityk::execute(string const& s) throw(SyntaxError, ExecuteError,
CATCH_EXECUTE_ERROR
}

string Fityk::get_info(string const& s, int dataset) throw(SyntaxError,
ExecuteError)
string Fityk::get_info(string const& s, int dataset)
{
try {
string result;
Expand All @@ -152,8 +150,7 @@ string Fityk::get_info(string const& s, int dataset) throw(SyntaxError,
return "";
}

realt Fityk::calculate_expr(string const& s, int dataset) throw(SyntaxError,
ExecuteError)
realt Fityk::calculate_expr(string const& s, int dataset)
{
try {
Lexer lex(s.c_str());
Expand Down Expand Up @@ -209,7 +206,7 @@ const Func* Fityk::get_function(const std::string& name) const
return priv_->mgr.functions()[n];
}

vector<Func*> Fityk::get_components(int dataset, char fz) throw(ExecuteError)
vector<Func*> Fityk::get_components(int dataset, char fz)
{
const Model *model = priv_->dk.get_model(hd(priv_, dataset));
const vector<int>& indexes = model->get_fz(fz).idx;
Expand All @@ -220,7 +217,7 @@ vector<Func*> Fityk::get_components(int dataset, char fz) throw(ExecuteError)
return ret;
}

realt Fityk::get_model_value(realt x, int dataset) const throw(ExecuteError)
realt Fityk::get_model_value(realt x, int dataset) const
{
try {
return priv_->dk.get_model(hd(priv_, dataset))->value(x);
Expand All @@ -230,7 +227,6 @@ realt Fityk::get_model_value(realt x, int dataset) const throw(ExecuteError)
}

vector<realt> Fityk::get_model_vector(vector<realt> const& x, int dataset)
throw(ExecuteError)
{
vector<realt> xx(x);
vector<realt> yy(x.size(), 0.);
Expand All @@ -241,7 +237,7 @@ vector<realt> Fityk::get_model_vector(vector<realt> const& x, int dataset)
return yy;
}

const Var* Fityk::get_variable(string const& name) const throw(ExecuteError)
const Var* Fityk::get_variable(string const& name) const
{
try {
string vname;
Expand Down Expand Up @@ -274,7 +270,6 @@ double Fityk::get_view_boundary(char side)
}

void Fityk::load(LoadSpec const& spec, int dataset)
throw(ExecuteError)
{
if (dataset == DEFAULT_DATASET)
dataset = priv_->dk.default_idx();
Expand All @@ -290,7 +285,7 @@ void Fityk::load_data(int dataset,
vector<realt> const& x,
vector<realt> const& y,
vector<realt> const& sigma,
string const& title) throw(ExecuteError)
string const& title)
{
try {
priv_->dk.data(dataset)->load_arrays(x, y, sigma, title);
Expand All @@ -299,15 +294,14 @@ void Fityk::load_data(int dataset,
}

void Fityk::add_point(realt x, realt y, realt sigma, int dataset)
throw(ExecuteError)
{
try {
priv_->dk.data(hd(priv_, dataset))->add_one_point(x, y, sigma);
}
CATCH_EXECUTE_ERROR
}

vector<Point> const& Fityk::get_data(int dataset) throw(ExecuteError)
vector<Point> const& Fityk::get_data(int dataset)
{
static const vector<Point> empty;
try {
Expand Down Expand Up @@ -335,23 +329,21 @@ void Fityk::redir_messages(FILE *stream)
}

void Fityk::set_option_as_string(const string& opt, const string& val)
throw(ExecuteError)
{
priv_->mutable_settings_mgr()->set_as_string(opt, val);
}

void Fityk::set_option_as_number(const string& opt, double val)
throw(ExecuteError)
{
priv_->mutable_settings_mgr()->set_as_number(opt, val);
}

string Fityk::get_option_as_string(const string& opt) const throw(ExecuteError)
string Fityk::get_option_as_string(const string& opt) const
{
return priv_->settings_mgr()->get_as_string(opt, /*quote_str=*/false);
}

double Fityk::get_option_as_number(const string& opt) const throw(ExecuteError)
double Fityk::get_option_as_number(const string& opt) const
{
return priv_->settings_mgr()->get_as_number(opt);
}
Expand All @@ -366,7 +358,7 @@ string Fityk::input(string const& prompt)
return priv_->ui()->get_input_from_user(prompt);
}

realt Fityk::get_wssr(int dataset) throw(ExecuteError)
realt Fityk::get_wssr(int dataset)
{
try {
return get_wssr_or_ssr(priv_, dataset, true);
Expand All @@ -375,7 +367,7 @@ realt Fityk::get_wssr(int dataset) throw(ExecuteError)
return 0.;
}

realt Fityk::get_ssr(int dataset) throw(ExecuteError)
realt Fityk::get_ssr(int dataset)
{
try {
return get_wssr_or_ssr(priv_, dataset, false);
Expand All @@ -384,7 +376,7 @@ realt Fityk::get_ssr(int dataset) throw(ExecuteError)
return 0.;
}

realt Fityk::get_rsquared(int dataset) throw(ExecuteError)
realt Fityk::get_rsquared(int dataset)
{
try {
if (dataset == ALL_DATASETS) {
Expand All @@ -402,7 +394,7 @@ realt Fityk::get_rsquared(int dataset) throw(ExecuteError)
return 0.;
}

int Fityk::get_dof(int dataset) throw(ExecuteError)
int Fityk::get_dof(int dataset)
{
try {
return priv_->get_fit()->get_dof(get_datasets_(priv_, dataset));
Expand All @@ -412,7 +404,6 @@ int Fityk::get_dof(int dataset) throw(ExecuteError)
}

vector<vector<realt> > Fityk::get_covariance_matrix(int dataset)
throw(ExecuteError)
{
try {
vector<Data*> dss = get_datasets_(priv_, dataset);
Expand Down
61 changes: 23 additions & 38 deletions fityk/fityk.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,8 @@ class FITYK_API Func

virtual const std::string& get_template_name() const = 0;
virtual std::string get_param(int n) const = 0;
virtual const std::string& var_name(const std::string& param) const
throw(ExecuteError) = 0;
virtual realt get_param_value(const std::string& param) const
throw(ExecuteError) = 0;
virtual const std::string& var_name(const std::string& param) const = 0;
virtual realt get_param_value(const std::string& param) const = 0;
virtual realt value_at(realt x) const = 0;
protected:
Func(const std::string name_) : name(name_) {}
Expand Down Expand Up @@ -179,26 +177,23 @@ class FITYK_API Fityk
// @{

/// execute command; throws exception on error
void execute(std::string const& s) throw(SyntaxError, ExecuteError,
ExitRequestedException);
void execute(std::string const& s);


/// load data from file (path should be ascii or utf8, col=0 is index)
void load(LoadSpec const& spec, int dataset=DEFAULT_DATASET)
throw(ExecuteError);
void load(LoadSpec const& spec, int dataset=DEFAULT_DATASET);
void load(std::string const& path, int dataset=DEFAULT_DATASET)
throw(ExecuteError) { load(LoadSpec(path), dataset); }
{ load(LoadSpec(path), dataset); }

/// load data from arrays
void load_data(int dataset,
std::vector<realt> const& x,
std::vector<realt> const& y,
std::vector<realt> const& sigma,
std::string const& title="") throw(ExecuteError);
std::string const& title="");

/// add one data point to dataset
void add_point(realt x, realt y, realt sigma, int dataset=DEFAULT_DATASET)
throw(ExecuteError);
void add_point(realt x, realt y, realt sigma, int dataset=DEFAULT_DATASET);

// @}

Expand All @@ -222,14 +217,10 @@ class FITYK_API Fityk

/// @name settings
// @{
void set_option_as_string(const std::string& opt, const std::string& val)
throw(ExecuteError);
void set_option_as_number(const std::string& opt, double val)
throw(ExecuteError);
std::string get_option_as_string(const std::string& opt) const
throw(ExecuteError);
double get_option_as_number(const std::string& opt) const
throw(ExecuteError);
void set_option_as_string(const std::string& opt, const std::string& val);
void set_option_as_number(const std::string& opt, double val);
std::string get_option_as_string(const std::string& opt) const;
double get_option_as_number(const std::string& opt) const;
// @}

/// @name input/output
Expand All @@ -255,12 +246,10 @@ class FITYK_API Fityk
// @{

/// return output of the info command
std::string get_info(std::string const& s, int dataset=DEFAULT_DATASET)
throw(SyntaxError, ExecuteError);
std::string get_info(std::string const& s, int dataset=DEFAULT_DATASET);

/// return expression value, similarly to the print command
realt calculate_expr(std::string const& s, int dataset=DEFAULT_DATASET)
throw(SyntaxError, ExecuteError);
realt calculate_expr(std::string const& s, int dataset=DEFAULT_DATASET);

//(planned)
/// returns dataset titles
Expand All @@ -275,8 +264,7 @@ class FITYK_API Fityk
int get_default_dataset() const;

/// get data points
std::vector<Point> const& get_data(int dataset=DEFAULT_DATASET)
throw(ExecuteError);
std::vector<Point> const& get_data(int dataset=DEFAULT_DATASET);

/// returns number of simple-variables (parameters that can be fitted)
int get_parameter_count() const;
Expand All @@ -288,7 +276,7 @@ class FITYK_API Fityk
std::vector<Var*> all_variables() const;

/// returns variable $name
const Var* get_variable(std::string const& name) const throw(ExecuteError);
const Var* get_variable(std::string const& name) const;

/// returns all %functions
std::vector<Func*> all_functions() const;
Expand All @@ -297,17 +285,14 @@ class FITYK_API Fityk
const Func* get_function(const std::string& name) const;

/// returns %functions used in dataset
std::vector<Func*> get_components(int dataset=DEFAULT_DATASET, char fz='F')
throw(ExecuteError);
std::vector<Func*> get_components(int dataset=DEFAULT_DATASET, char fz='F');

/// returns the value of the model for a given dataset at x
realt get_model_value(realt x, int dataset=DEFAULT_DATASET) const
throw(ExecuteError);
realt get_model_value(realt x, int dataset=DEFAULT_DATASET) const;

/// multiple point version of the get_model_value()
std::vector<realt>
get_model_vector(std::vector<realt> const& x, int dataset=DEFAULT_DATASET)
throw(ExecuteError);
get_model_vector(std::vector<realt> const& x, int dataset=DEFAULT_DATASET);

/// get coordinates of rectangle set by the plot command
/// side is one of L(eft), R(ight), T(op), B(ottom)
Expand All @@ -319,20 +304,20 @@ class FITYK_API Fityk
// @{

/// get WSSR for given dataset or for all datasets
realt get_wssr(int dataset=ALL_DATASETS) throw(ExecuteError);
realt get_wssr(int dataset=ALL_DATASETS);

/// get SSR for given dataset or for all datasets
realt get_ssr(int dataset=ALL_DATASETS) throw(ExecuteError);
realt get_ssr(int dataset=ALL_DATASETS);

/// get R-squared for given dataset or for all datasets
realt get_rsquared(int dataset=ALL_DATASETS) throw(ExecuteError);
realt get_rsquared(int dataset=ALL_DATASETS);

/// get number of degrees-of-freedom for given dataset or for all datasets
int get_dof(int dataset=ALL_DATASETS) throw(ExecuteError);
int get_dof(int dataset=ALL_DATASETS);

/// get covariance matrix (for given dataset or for all datasets)
std::vector<std::vector<realt> >
get_covariance_matrix(int dataset=ALL_DATASETS) throw(ExecuteError);
get_covariance_matrix(int dataset=ALL_DATASETS);
// @}

/// UiApi contains functions used by CLI and may be used to implement
Expand Down
2 changes: 1 addition & 1 deletion fityk/func.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ int Function::get_param_nr(const string& param) const
return n;
}

realt Function::get_param_value(const string& param) const throw(ExecuteError)
realt Function::get_param_value(const string& param) const
{
realt a;
if (!param.empty() && islower(param[0]))
Expand Down
4 changes: 1 addition & 3 deletions fityk/func.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ class FITYK_API Function : public Func
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated"
#endif
virtual realt get_param_value(const std::string& param) const
throw(ExecuteError); // exc. spec. is used by SWIG
virtual realt get_param_value(const std::string& param) const;

realt numarea(realt x1, realt x2, int nsteps) const;

Expand All @@ -104,7 +103,6 @@ class FITYK_API Function : public Func
// implementation of members of Func
virtual const std::string& get_template_name() const { return tp_->name; }
virtual const std::string& var_name(const std::string& param) const
throw(ExecuteError) // exc. spec. is used by SWIG
{ return used_vars_.get_name(get_param_nr(param)); }
#if defined(__clang__)
#pragma clang diagnostic pop
Expand Down