Main Page   Class Hierarchy   Compound List   File List   Compound Members  

error.cpp

00001 /*=============================================================================
00002         File: error.cpp
00003      Purpose: Implementation of general error reporting class
00004     Revision: $Id: error.cpp,v 1.8 2003/01/13 19:41:19 philosophil Exp $
00005   Created by:    Philippe Lavoie          (3 Oct, 1996)
00006  Modified by: 
00007 
00008  Copyright notice:
00009           Copyright (C) 1996-1997 Philippe Lavoie
00010  
00011           This library is free software; you can redistribute it and/or
00012           modify it under the terms of the GNU Library General Public
00013           License as published by the Free Software Foundation; either
00014           version 2 of the License, or (at your option) any later version.
00015  
00016           This library is distributed in the hope that it will be useful,
00017           but WITHOUT ANY WARRANTY; without even the implied warranty of
00018           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019           Library General Public License for more details.
00020  
00021           You should have received a copy of the GNU Library General Public
00022           License along with this library; if not, write to the Free
00023           Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00024 =============================================================================*/
00025 
00026 #ifndef PLIB_ERROR_SOURCE
00027 #define PLIB_ERROR_SOURCE
00028 
00029 #include "error.h"
00030 
00031 //#include <stream.h>
00032 #include <string.h>
00033 
00036 namespace PLib {
00037 
00047 #ifndef USING_VCC
00048 Error::Error(const char *title) :  ErrorStream(), prog(0)
00049 #else
00050 Error::Error(const char *title) : prog(0)
00051 #endif
00052 {
00053   int l = strlen( title ) + 1;
00054 
00055   prog = new char[l];
00056   strcpy(prog, title);
00057 #ifndef USING_VCC
00058   // Can't remember why I had the following before, and now gcc-3.0 complains.
00059   //  init (&__my_sb);
00060 #endif
00061   clear() ;
00062 
00063 }
00064 
00080 void Error::report(const char *msg)
00081 {
00082   if ( msg == 0 )               // message must have been sent via <<
00083     cerr << str() ;
00084   else
00085     cerr << msg;
00086 
00087   cerr << '\n';
00088 #ifdef DEBUG_PLIB
00089   cerr << "\n\nThe program is now in an infinte loop. Press CTRL-c to exit.\n" ;
00090 #endif
00091   
00092 }
00093 
00109 void Error::warning(const char *msg)
00110 {
00111   cerr << "\nRoutine: " << prog << "\nWarning: ";
00112 
00113   report( msg );
00114 
00115 }
00116 
00137 void Error::fatal(const char *msg)
00138 {
00139   cerr << "\nRoutine: " << prog << "\nFatal error: ";
00140   
00141   report( msg );
00142 #ifdef DEBUG_PLIB
00143   while(1){ ; }
00144 #else
00145   exit(1);
00146 #endif
00147 }
00148 
00169 void Error::memory(const void *p)
00170 {
00171   if ( p == 0)
00172     {
00173       cerr << "\nRoutine: " << prog << " Memory allocation error\n";
00174 #ifdef DEBUG_PLIB
00175       while (1) { ; }
00176 #else
00177       exit(1);
00178 #endif
00179     }  
00180 }
00181 
00182 }
00183 
00184 #ifdef NO_IMPLICIT_TEMPLATES
00185 
00186 
00187 #if GCC_VERSION >= 30000
00188 template std::basic_ostream<char, std::char_traits<char> >& std::operator<< <char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, std::_Setw);
00189 #else
00190 
00191 #endif
00192 
00193 
00194 
00195 #endif
00196 
00197 
00198 #endif // PLIB_ERROR_SOURCE
00199 

Generated on Tue Jun 24 13:26:55 2003 for NURBS++ by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002