-rw-r--r-- | include/opkele/debug.h | 17 | ||||
-rw-r--r-- | include/opkele/exception.h | 7 |
2 files changed, 19 insertions, 5 deletions
diff --git a/include/opkele/debug.h b/include/opkele/debug.h new file mode 100644 index 0000000..a02f8d4 --- a/dev/null +++ b/include/opkele/debug.h @@ -0,0 +1,17 @@ +#ifndef __OPKELE_DEBUG_H +#define __OPKELE_DEBUG_H + +#ifdef NDEBUG + +#define D_(x) ((void)0) +#define DOUT_(x) ((void)0) + +#else /* NDEBUG */ + +#define D_(x) x +#include <iostream> +#define DOUT_(x) std::clog << x << std::endl + +#endif /* NDEBUG */ + +#endif /* __OPKELE_DEBUG_H */ diff --git a/include/opkele/exception.h b/include/opkele/exception.h index 36bd07a..64f189e 100644 --- a/include/opkele/exception.h +++ b/include/opkele/exception.h @@ -32,103 +32,100 @@ */ # define OPKELE_RETHROW catch(konforka::exception& e) { e.see(CODEPOINT); throw; } #else /* OPKELE_HAVE_KONFORKA */ # include <exception> # include <string> /** * the exception parameter declaration */ # define OPKELE_E_PARS const string& w /** * the dummy prefix for exception parameters list to prepend in the absence of * konforka library */ # define OPKELE_E_CONS_ /** * the dummy placeholder for konforka exception codepoint specification */ # define OPKELE_CP_ /** * the dummy define for the opening function-try-block */ # define OPKELE_FUNC_TRY /** * the dummy define for the konforka-based rethrow of exception */ # define OPKELE_RETHROW #endif /* OPKELE_HAVE_KONFORKA */ /** * the exception parameters list to pass to constructor */ # define OPKELE_E_CONS OPKELE_E_CONS_ w namespace opkele { using std::string; /** * the base opkele exception class */ class exception : public # ifdef OPKELE_HAVE_KONFORKA konforka::exception # else std::exception # endif { public: # ifdef OPKELE_HAVE_KONFORKA explicit - exception(const string& fi,const string& fu,int l,const string& w) - : konforka::exception(fi,fu,l,w) { } + exception(const string& fi,const string& fu,int l,const string& w); # else /* OPKELE_HAVE_KONFORKA */ string _what; - explicit - exception(const string& w) - : _what(w) { } + explicit exception(const string& w); virtual ~exception() throw(); virtual const char * what() const throw(); # endif /* OPKELE_HAVE_KONFORKA */ }; /** * thrown in case of failed conversion */ class failed_conversion : public exception { public: failed_conversion(OPKELE_E_PARS) : exception(OPKELE_E_CONS) { } }; /** * thrown in case of failed lookup (either parameter or persistent store) */ class failed_lookup : public exception { public: failed_lookup(OPKELE_E_PARS) : exception(OPKELE_E_CONS) { } }; /** * thrown in case of bad input (either local or network) */ class bad_input : public exception { public: bad_input(OPKELE_E_PARS) : exception(OPKELE_E_CONS) { } }; /** * thrown on failed assertion */ class failed_assertion : public exception { public: failed_assertion(OPKELE_E_PARS) : exception(OPKELE_E_CONS) { } }; /** * thrown if the handle being retrieved is invalid */ class invalid_handle : public exception { public: invalid_handle(OPKELE_E_PARS) : exception(OPKELE_E_CONS) { } }; /** |