00001 /***************************************************************************
00002 * This file is part of the MagiC++ library. *
00003 * *
00004 * Copyright (C) 1998-2001 Marko Grönroos <magi@iki.fi> *
00005 * *
00006 ***************************************************************************
00007 * *
00008 * This library is free software; you can redistribute it and/or *
00009 * modify it under the terms of the GNU Library General Public *
00010 * License as published by the Free Software Foundation; either *
00011 * version 2 of the License, or (at your option) any later version. *
00012 * *
00013 * This library is distributed in the hope that it will be useful, *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
00016 * Library General Public License for more details. *
00017 * *
00018 * You should have received a copy of the GNU Library General Public *
00019 * License along with this library; see the file COPYING.LIB. If *
00020 * not, write to the Free Software Foundation, Inc., 59 Temple Place *
00021 * - Suite 330, Boston, MA 02111-1307, USA. *
00022 * *
00023 ***************************************************************************/
00024
00025 #ifndef __MAGISUPP_H__
00026 #define __MAGISUPP_H__
00027
00028
00029 #include "magic/mconfig.h"
00030
00031 // Remove new-redefinition
00032 #ifdef new
00033 #undef new
00034 #define new_UNDEFD
00035 #endif
00036
00037
00038 //#include<stdexcept>
00039
00040 // Restore new-redefinition
00041 #ifdef new_UNDEFD
00042 #define new DEBUG_NEW
00043 #undef new_UNDEFD
00044 #endif
00045
00046 #include "magic/mdebug.h"
00047
00048
00049 #define BEGIN_NAMESPACE(ns) namespace ns {
00050 #define END_NAMESPACE }
00051
00053 // Debugging macros
00054
00064 enum assertmodes {ASSERT_THROW=0, ASSERT_CRASH=1, ASSERT_EXIT=2, ASSERT_DONTCARE=3};
00065
00066 extern FILE* dbgout;
00067
00070 extern int assertmode;
00071
00073 extern void assertwith (const char* filename, int lineno, const char* funcname,
00074 const char* condition=NULL, const char* message=NULL);
00075
00076 #ifndef DEBUG_MODE
00077 #define NODEBUG
00078 #endif
00079
00080 #include "magic/mdebug.h"
00081
00082 #ifdef MSDOS
00083 #define IOSBINARY binary
00084 #else // UNIX
00085 #define IOSBINARY bin
00086 #endif
00087
00088 // Screen manipulation (minicurses)
00089
00090 #define clrscr() {cout << "\033[H\033[J";}
00091
00092 #define randomize {srand (time (NULL));}
00093 //#define rnd(range) {return
00094
00095 #include "magic/mexception.h"
00096
00097 EXCEPTIONCLASS (must_overload);
00098 // For abstract classes that can't use =0
00099 #define MUST_OVERLOAD {assertwith (__FILE__, __LINE__, __FUNCTION__, "MUST_OVERLOAD", format("%%ERR: Method of baseclass must be overloaded by descendant %s", typeid(*this).name()));}
00100
00101 EXCEPTIONCLASS (forbidden_call);
00102 #define FORBIDDEN {throw forbidden_call (format("%%ERR: Forbidden execution at %s[%d]: %s()", __FILE__, __LINE__, __FUNCTION__));}
00103
00104 #endif
00105
00106
1.2.6 written by Dimitri van Heesch,
© 1997-2001