src/tool/error.h

Go to the documentation of this file.
00001 /******************************************************************************
00002  *  Wormux is a convivial mass murder game.
00003  *  Copyright (C) 2001-2004 Lawrence Azzoug.
00004  *
00005  *  This program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
00018  ******************************************************************************
00019  * Refresh des erreurs, exceptions, assertions, etc.
00020  *****************************************************************************/
00021 
00022 #ifndef ERROR_H
00023 #define ERROR_H
00024 
00025 #ifndef BASE_H
00026 #  error "You have to include base.h only (not the error.h file)"
00027 #endif
00028 
00029 #include <string>
00030 
00031 void MissedAssertion (const char *filename, unsigned long line,
00032                        const char *message);
00033 void WakeUpDebugger();
00034 
00035 // Assertion (disabled in release mode)
00036 #undef assert
00037 #  define assert(COND) \
00038      if (!(COND)) MissedAssertion (__FILE__, __LINE__, #COND);
00039 
00040 // Force une assertion
00041 #define FORCE_ASSERT(COND) \
00042   if (!(COND)) MissedAssertion (__FILE__, __LINE__, #COND);
00043 
00044 void TriggerError (const char *filename, unsigned long line, 
00045                       const std::string &txt);
00046 
00047 #define Error(txt) TriggerError(__FILE__, __LINE__, txt)
00048 
00049 
00050 class CError : public std::exception
00051 {
00052 protected:
00053   std::string m_filename, m_txt;
00054   unsigned long m_line;
00055 
00056 public:
00057   CError (const char *filename, unsigned long line, const std::string &txt);
00058   ~CError() throw();
00059   virtual const char* what() const throw();
00060   std::ostream& operator<< (std::ostream &os) const;
00061 };
00062 
00063 #endif

Generated on Mon Jan 1 13:10:59 2007 for Wormux by  doxygen 1.4.7