wxwidgets: Hide dumper called "NULL"
[lsnes.git] / include / library / exrethrow.hpp
blobc3c4c55f494403a58a234c78c88c398c03c322b6
1 #ifndef _library__exrethrow__hpp__included__
2 #define _library__exrethrow__hpp__included__
4 #include <stdexcept>
5 #include <functional>
7 namespace exrethrow
9 /**
10 * Add a exception type.
12 void add_ex_spec(unsigned prio, std::function<bool(std::exception& e)> identify,
13 std::function<void()> (*throwfn)(std::exception& e));
14 std::function<void()> get_throw_fn(std::exception& e);
16 /**
17 * Exception type specifier.
19 template<typename T, unsigned prio> class ex_spec
21 public:
22 ex_spec()
24 add_ex_spec(prio, [](std::exception& e) -> bool { return (dynamic_cast<T*>(&e) != NULL); },
25 [](std::exception& e) -> std::function<void()> { T _ex = *dynamic_cast<T*>(&e);
26 return [_ex]() -> void { throw _ex; }; });
31 /**
32 * Exception storage
34 class storage
36 public:
37 /**
38 * Null object.
40 storage();
41 /**
42 * Store an exception.
44 * Parameter e: The exception.
46 storage(std::exception& e);
47 /**
48 * Rethrow the exception.
50 void rethrow();
51 /**
52 * Is anything here?
54 operator bool();
55 private:
56 bool null;
57 bool oom;
58 std::function<void()> do_rethrow;
62 #endif