chiark / gitweb /
put source code into src subdirectory
[nlopt.git] / src / swig / nlopt-exceptions.i
1 // since exception specifications in C++ are evil, we instead provide
2 // %catches specifications here so that SWIG can generate language-specific
3 // exceptions (at least for exceptions explicitly thrown by NLopt)
4 //
5 // manually doing this stuff is annoying
6
7 %catches(std::bad_alloc) nlopt::opt::opt();
8 %catches(std::bad_alloc) nlopt::opt::opt(algorithm a, unsigned n);
9 %catches(std::bad_alloc) nlopt::opt::opt(const opt& f);
10 %catches(std::bad_alloc) nlopt::opt::operator=(opt const& f);
11
12 %catches(nlopt::roundoff_limited,nlopt::forced_stop,std::runtime_error,std::bad_alloc,std::invalid_argument) nlopt::opt::optimize(std::vector<double> &x, double &opt_f);
13 %catches(nlopt::roundoff_limited,nlopt::forced_stop,std::runtime_error,std::bad_alloc,std::invalid_argument) nlopt::opt::optimize(const std::vector<double> &x0);
14
15 %catches(std::runtime_error) nlopt::opt::get_algorithm();
16 %catches(std::runtime_error) nlopt::opt::get_algorithm_name();
17 %catches(std::runtime_error) nlopt::opt::get_dimension();
18
19 %catches(std::bad_alloc,std::invalid_argument) nlopt::opt::set_min_objective(func f, void *f_data);
20 %catches(std::bad_alloc,std::invalid_argument) nlopt::opt::set_min_objective(vfunc vf, void *f_data);
21 %catches(std::bad_alloc,std::invalid_argument) nlopt::opt::set_max_objective(func f, void *f_data);
22 %catches(std::bad_alloc,std::invalid_argument) nlopt::opt::set_max_objective(vfunc vf, void *f_data);
23
24 %catches(std::bad_alloc,std::invalid_argument) nlopt::opt::set_min_objective(func f, void *f_data, nlopt_munge md, nlopt_munge mc);
25 %catches(std::bad_alloc,std::invalid_argument) nlopt::opt::set_max_objective(func f, void *f_data, nlopt_munge md, nlopt_munge mc);
26
27 %catches(std::invalid_argument) nlopt::opt::remove_inequality_constraints();
28 %catches(std::bad_alloc,std::invalid_argument) nlopt::opt::add_inequality_constraint(func f, void *f_data, double tol=0);
29 %catches(std::bad_alloc,std::invalid_argument) nlopt::opt::add_inequality_constraint(vfunc vf, void *f_data, double tol=0);
30 %catches(std::invalid_argument) nlopt::opt::remove_equality_constraints();
31 %catches(std::bad_alloc,std::invalid_argument) nlopt::opt::add_equality_constraint(func f, void *f_data, double tol=0);
32 %catches(std::bad_alloc,std::invalid_argument) nlopt::opt::add_equality_constraint(vfunc vf, void *f_data, double tol=0);
33 %catches(std::bad_alloc,std::invalid_argument) nlopt::opt::add_inequality_mconstraint(mfunc mf, void *f_data, const std::vector<double> &tol);
34 %catches(std::bad_alloc,std::invalid_argument) nlopt::opt::add_equality_mconstraint(mfunc mf, void *f_data, const std::vector<double> &tol);
35
36 %catches(std::bad_alloc,std::invalid_argument) nlopt::opt::add_inequality_constraint(func f, void *f_data, nlopt_munge md, nlopt_munge mc, double tol=0);
37 %catches(std::bad_alloc,std::invalid_argument) nlopt::opt::add_equality_constraint(func f, void *f_data, nlopt_munge md, nlopt_munge mc, double tol=0);
38 %catches(std::bad_alloc,std::invalid_argument) nlopt::opt::add_inequality_mconstraint(mfunc mf, void *f_data, nlopt_munge md, nlopt_munge mc, const std::vector<double> &tol);
39 %catches(std::bad_alloc,std::invalid_argument) nlopt::opt::add_equality_mconstraint(mfunc mf, void *f_data, nlopt_munge md, nlopt_munge mc, const std::vector<double> &tol);
40
41 #define SET_EXCEPT(name, T) %catches(std::invalid_argument) nlopt::opt::set_##name(T val);
42 #define GET_EXCEPT(name) %catches(std::invalid_argument) nlopt::opt::get_##name();
43 #define SETVEC_EXCEPT(name) %catches(std::invalid_argument) nlopt::opt::set_##name(const std::vector<double> &v);
44 #define GETVEC_EXCEPT(name) %catches(std::bad_alloc,std::invalid_argument) nlopt::opt::get_##name(std::vector<double> &v);
45 #define GETSET_EXCEPT(name, T) GET_EXCEPT(name) SET_EXCEPT(name, T)
46 #define GETSETVEC_EXCEPT(name) GET_EXCEPT(name) SET_EXCEPT(name, double) GETVEC_EXCEPT(name) SETVEC_EXCEPT(name)
47
48 GETSETVEC_EXCEPT(lower_bounds)
49 GETSETVEC_EXCEPT(upper_bounds)
50
51 GETSET_EXCEPT(stopval, double)
52 GETSET_EXCEPT(ftol_rel, double)
53 GETSET_EXCEPT(ftol_abs, double)
54 GETSET_EXCEPT(xtol_rel, double)
55 GETSETVEC_EXCEPT(xtol_abs)
56 GETSET_EXCEPT(maxeval, int)
57 GETSET_EXCEPT(maxtime, double)
58 GETSET_EXCEPT(force_stop, int)
59
60 %catches(std::invalid_argument) nlopt::opt::force_stop();
61
62 %catches(std::bad_alloc,std::invalid_argument) nlopt::opt::set_local_optimizer(const opt &lo);
63
64 GETSET_EXCEPT(population, unsigned)
65 GETSET_EXCEPT(vector_storage, unsigned)
66 GETSETVEC_EXCEPT(initial_step)
67
68 %catches(std::bad_alloc,std::invalid_argument) nlopt::opt::set_default_initial_step(const std::vector<double> &x);
69 %catches(std::invalid_argument) nlopt::opt::get_initial_step(const std::vector<double> &x, std::vector<double> &dx);
70 %catches(std::bad_alloc,std::invalid_argument) nlopt::opt::get_initial_step_(const std::vector<double> &x);