1.1 --- a/src/lemon/attic/error.h Mon Nov 15 12:25:39 2004 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,82 +0,0 @@
1.4 -/* -*- C++ -*-
1.5 - * src/lemon/error.h - Part of LEMON, a generic C++ optimization library
1.6 - *
1.7 - * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
1.8 - * (Egervary Combinatorial Optimization Research Group, EGRES).
1.9 - *
1.10 - * Permission to use, modify and distribute this software is granted
1.11 - * provided that this copyright notice appears in all copies. For
1.12 - * precise terms see the accompanying LICENSE file.
1.13 - *
1.14 - * This software is provided "AS IS" with no warranty of any kind,
1.15 - * express or implied, and with no claim as to its suitability for any
1.16 - * purpose.
1.17 - *
1.18 - */
1.19 -
1.20 -#ifndef LEMON_ERROR_H
1.21 -#define LEMON_ERROR_H
1.22 -
1.23 -//! \ingroup misc
1.24 -//! \file
1.25 -//! \brief Basic error handling (signaling) routines.
1.26 -
1.27 -#include <exception>
1.28 -#include <string>
1.29 -#include <sstream>
1.30 -
1.31 -
1.32 -namespace lemon {
1.33 -
1.34 - /**
1.35 - * \brief Generic exception class.
1.36 - *
1.37 - * \todo Do we need this?
1.38 - *
1.39 - * \todo Don't we need different kind of exceptions for different kind
1.40 - * of errors?
1.41 - * Shouldn't we use \<stdexcept\> instead?
1.42 - */
1.43 - class Exception : public std::exception {
1.44 - protected:
1.45 - std::ostringstream buf;
1.46 - public:
1.47 - Exception() {}
1.48 - explicit Exception(const std::string &s) { buf << s; }
1.49 - Exception(const Exception &e) : std::exception() {
1.50 - buf << e.buf.str();
1.51 - }
1.52 - virtual ~Exception() throw() {}
1.53 -
1.54 - virtual const char* what() const throw() {
1.55 - return buf.str().c_str();
1.56 - }
1.57 -
1.58 - Exception& operator<<(std::string const& s) { buf << s; return *this; }
1.59 - Exception& operator<<(char const *s) { buf << s; return *this; }
1.60 - Exception& operator<<(int i) { buf << i; return *this; }
1.61 - };
1.62 -
1.63 - /**
1.64 - * \brief Generic error signaling function.
1.65 - *
1.66 - * \todo Do we really need this? Is it helpful?
1.67 - */
1.68 - inline void fault(const std::string &msg) {
1.69 - throw Exception(msg);
1.70 - }
1.71 -
1.72 - /**
1.73 - * \brief Macro for mark not yet implemented features.
1.74 - *
1.75 - * \todo Is this the right place for this? It should be used only in
1.76 - * modules under development.
1.77 - */
1.78 -
1.79 -# define FIXME(msg) \
1.80 - do { throw ::lemon::Exception() << "FIXME: " msg " (in: " \
1.81 - __FILE__ ", " << __LINE__ << ")"; \
1.82 - } while(false)
1.83 -
1.84 -}
1.85 -#endif // LEMON_ERROR_H
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/src/lemon/error.h Mon Nov 15 13:10:35 2004 +0000
2.3 @@ -0,0 +1,81 @@
2.4 +/* -*- C++ -*-
2.5 + * src/lemon/error.h - Part of LEMON, a generic C++ optimization library
2.6 + *
2.7 + * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
2.8 + * (Egervary Combinatorial Optimization Research Group, EGRES).
2.9 + *
2.10 + * Permission to use, modify and distribute this software is granted
2.11 + * provided that this copyright notice appears in all copies. For
2.12 + * precise terms see the accompanying LICENSE file.
2.13 + *
2.14 + * This software is provided "AS IS" with no warranty of any kind,
2.15 + * express or implied, and with no claim as to its suitability for any
2.16 + * purpose.
2.17 + *
2.18 + */
2.19 +
2.20 +#ifndef LEMON_ERROR_H
2.21 +#define LEMON_ERROR_H
2.22 +
2.23 +//! \ingroup misc
2.24 +//! \file
2.25 +//! \brief Basic error handling (signaling) routines.
2.26 +
2.27 +#include <exception>
2.28 +#include <string>
2.29 +#include <sstream>
2.30 +
2.31 +
2.32 +namespace lemon {
2.33 +
2.34 + /**
2.35 + * \brief Generic exception class.
2.36 + *
2.37 + * \todo Do we need this?
2.38 + *
2.39 + * \todo Don't we need different kind of exceptions for different kind
2.40 + * of errors?
2.41 + * Shouldn't we use \<stdexcept\> instead?
2.42 + */
2.43 + class Exception : public std::exception {
2.44 + protected:
2.45 + std::ostringstream buf;
2.46 + public:
2.47 + Exception() {}
2.48 + explicit Exception(const std::string &s) { buf << s; }
2.49 + Exception(const Exception &e) : std::exception() {
2.50 + buf << e.buf.str();
2.51 + }
2.52 + virtual ~Exception() throw() {}
2.53 +
2.54 + virtual const char* what() const throw() {
2.55 + return buf.str().c_str();
2.56 + }
2.57 +
2.58 + template <typename T>
2.59 + Exception& operator<<(T const& t) { buf << t; return *this; }
2.60 + };
2.61 +
2.62 + /**
2.63 + * \brief Generic error signaling function.
2.64 + *
2.65 + * \todo Do we really need this? Is it helpful?
2.66 + */
2.67 + inline void fault(const std::string &msg) {
2.68 + throw Exception(msg);
2.69 + }
2.70 +
2.71 + /**
2.72 + * \brief Macro for mark not yet implemented features.
2.73 + *
2.74 + * \todo Is this the right place for this? It should be used only in
2.75 + * modules under development.
2.76 + */
2.77 +
2.78 +# define FIXME(msg) \
2.79 + do { throw ::lemon::Exception() << "FIXME: " msg " (in: " \
2.80 + __FILE__ ", " << __LINE__ << ")"; \
2.81 + } while(false)
2.82 +
2.83 +}
2.84 +#endif // LEMON_ERROR_H