Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

debug.h

Go to the documentation of this file.
00001 /***************************************************************************
00002     debug.h  -  Debugging macros.
00003                              -------------------
00004     begin                : June 21 2002
00005     copyright            : (C) 2003 by Vojtìch Toman
00006     email                : vtoman@lit.cz
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00025 #ifndef DEBUG_H
00026 #define DEBUG_H
00027 
00028 
00029 #include <iostream>
00030 
00031 #include "exceptions.h"
00032 
00033 
00035 //#define DBG(_x_)              std::cerr << "[DBG] " << _x_ << std::endl
00036 #define DBG(_x_)                {}
00037 
00038 
00040 #define PRINT_SOURCE_POSITION   std::cerr << "In file " << __FILE__ << ", line " << __LINE__ << ": "
00041 
00042 
00050 #define CHECK_POINTER(_x_)                      \
00051 if ( !(_x_) )                                   \
00052   {                                             \
00053     PRINT_SOURCE_POSITION;                      \
00054     std::cerr << "Out of memory" << std::endl;  \
00055     throw ExaltNullPointerException();          \
00056   } 
00057 
00058 
00068 #define DELETE(_x_)             \
00069 {                               \
00070   CHECK_POINTER( (_x_) );       \
00071   delete (_x_);                 \
00072   (_x_) = 0;                    \
00073 }
00074 
00075 
00085 #define DELETE_ARRAY(_x_)       \
00086 {                               \
00087   CHECK_POINTER( (_x_) );       \
00088   delete[] (_x_);               \
00089   (_x_) = 0;                    \
00090 }
00091 
00092 
00093 
00103 #define NEW(_p_, _type_)        \
00104 {                               \
00105   (_p_) = new _type_;           \
00106   CHECK_POINTER( (_p_) );       \
00107 }
00108 
00109 
00110 #endif //DEBUG_H
00111 
00112 
00113 

Generated on Wed Feb 5 10:43:01 2003 for Exalt by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002