# HG changeset patch # User klao # Date 1100524235 0 # Node ID 21d1b4fa1b24294b0f746004f2da7ab550a02c11 # Parent 10d378f2821c337345ceacbbb2f8b619986e878f error.h brought back to life diff -r 10d378f2821c -r 21d1b4fa1b24 src/lemon/attic/error.h --- a/src/lemon/attic/error.h Mon Nov 15 12:25:39 2004 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,82 +0,0 @@ -/* -*- C++ -*- - * src/lemon/error.h - Part of LEMON, a generic C++ optimization library - * - * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport - * (Egervary Combinatorial Optimization Research Group, EGRES). - * - * Permission to use, modify and distribute this software is granted - * provided that this copyright notice appears in all copies. For - * precise terms see the accompanying LICENSE file. - * - * This software is provided "AS IS" with no warranty of any kind, - * express or implied, and with no claim as to its suitability for any - * purpose. - * - */ - -#ifndef LEMON_ERROR_H -#define LEMON_ERROR_H - -//! \ingroup misc -//! \file -//! \brief Basic error handling (signaling) routines. - -#include -#include -#include - - -namespace lemon { - - /** - * \brief Generic exception class. - * - * \todo Do we need this? - * - * \todo Don't we need different kind of exceptions for different kind - * of errors? - * Shouldn't we use \ instead? - */ - class Exception : public std::exception { - protected: - std::ostringstream buf; - public: - Exception() {} - explicit Exception(const std::string &s) { buf << s; } - Exception(const Exception &e) : std::exception() { - buf << e.buf.str(); - } - virtual ~Exception() throw() {} - - virtual const char* what() const throw() { - return buf.str().c_str(); - } - - Exception& operator<<(std::string const& s) { buf << s; return *this; } - Exception& operator<<(char const *s) { buf << s; return *this; } - Exception& operator<<(int i) { buf << i; return *this; } - }; - - /** - * \brief Generic error signaling function. - * - * \todo Do we really need this? Is it helpful? - */ - inline void fault(const std::string &msg) { - throw Exception(msg); - } - - /** - * \brief Macro for mark not yet implemented features. - * - * \todo Is this the right place for this? It should be used only in - * modules under development. - */ - -# define FIXME(msg) \ - do { throw ::lemon::Exception() << "FIXME: " msg " (in: " \ - __FILE__ ", " << __LINE__ << ")"; \ - } while(false) - -} -#endif // LEMON_ERROR_H diff -r 10d378f2821c -r 21d1b4fa1b24 src/lemon/error.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lemon/error.h Mon Nov 15 13:10:35 2004 +0000 @@ -0,0 +1,81 @@ +/* -*- C++ -*- + * src/lemon/error.h - Part of LEMON, a generic C++ optimization library + * + * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport + * (Egervary Combinatorial Optimization Research Group, EGRES). + * + * Permission to use, modify and distribute this software is granted + * provided that this copyright notice appears in all copies. For + * precise terms see the accompanying LICENSE file. + * + * This software is provided "AS IS" with no warranty of any kind, + * express or implied, and with no claim as to its suitability for any + * purpose. + * + */ + +#ifndef LEMON_ERROR_H +#define LEMON_ERROR_H + +//! \ingroup misc +//! \file +//! \brief Basic error handling (signaling) routines. + +#include +#include +#include + + +namespace lemon { + + /** + * \brief Generic exception class. + * + * \todo Do we need this? + * + * \todo Don't we need different kind of exceptions for different kind + * of errors? + * Shouldn't we use \ instead? + */ + class Exception : public std::exception { + protected: + std::ostringstream buf; + public: + Exception() {} + explicit Exception(const std::string &s) { buf << s; } + Exception(const Exception &e) : std::exception() { + buf << e.buf.str(); + } + virtual ~Exception() throw() {} + + virtual const char* what() const throw() { + return buf.str().c_str(); + } + + template + Exception& operator<<(T const& t) { buf << t; return *this; } + }; + + /** + * \brief Generic error signaling function. + * + * \todo Do we really need this? Is it helpful? + */ + inline void fault(const std::string &msg) { + throw Exception(msg); + } + + /** + * \brief Macro for mark not yet implemented features. + * + * \todo Is this the right place for this? It should be used only in + * modules under development. + */ + +# define FIXME(msg) \ + do { throw ::lemon::Exception() << "FIXME: " msg " (in: " \ + __FILE__ ", " << __LINE__ << ")"; \ + } while(false) + +} +#endif // LEMON_ERROR_H