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

C:/temp/src/j2k/Fred/Error/JErrorHandler.cpp

Go to the documentation of this file.
00001 #ifndef __J2K__JErrorHandler_CPP__
00002 #define __J2K__JErrorHandler_CPP__
00003 
00004 /*
00005  We can't use JString or any other J2K classes, since we are not sure,
00006  where the error occured and so, we can only rely on ourself !
00007  Hoping that this class works well... =)
00008 
00009  We are using a single forward link-list of " void function( ARG ) ",
00010  the function must be public and static inside or outside a class,
00011  even if an object of that class was not build anywhere.
00012  It might look "weird" but it's VERY convenient!  =]
00013 */
00014 
00015 #include <j2k/Fred/Error/JErrorHandler.hpp>
00016 
00017 __J2K__EXTERN_C
00018 
00019 
00020 static void defaultErrorHandler( MC_JErrorHandlerArg )
00021  {
00022    register size_t l = (size_t)level;
00023    register size_t n = (size_t)no;
00024 
00025    char* errmsgtbl = "";
00026    char* levmsg    = "";
00027 
00028    if ( n < __J2K__MAX_ERROR ) {
00029      errmsgtbl = (char*)JErrorMsg[ n ];
00030    }
00031 
00032    if ( l < 6 ) { 
00033      levmsg = (char*)JErrorLevelMsg[ l ]; 
00034    }
00035 
00036    char buf[600];
00037    memset( buf, 0, 600 );
00038 
00039    sprintf( buf,
00040             "\n\n***********************************************\n"  
00041             "An error of type #%d of level %d/5 has occured\n"
00042             "at line %d of file %s,\n\n"
00043             "Here's a brief description of the error:\n"
00044             "%s \n[%s]\n%s"
00045             "\n\n***********************************************\n\n", 
00046             n, l, line, file, levmsg, errmsgtbl, errmsg 
00047           );
00048 
00049    // Abort if critical.
00050    // assert( n <= __J2K__NON_FATAL_ERROR  && l <= __J2K__MaxErrorLevel );
00051  }
00052 
00053 static void cheapError( int line, const char* file, const char* errmsg ) {
00054 
00055    char buf[600];
00056    memset( buf, 0, 600 );
00057 
00058    sprintf( buf,
00059             "\n\n***********************************************\n"  
00060             "An error has occured"
00061             "at line %d of file %s,\n\n"
00062             "Here's a brief description of the error:\n"
00063             "\n%s\n"
00064             "\n\n***********************************************\n\n",
00065             line, file, errmsg 
00066           );
00067 }
00068 
00069 __J2K__END_C
00070 
00071   JErrorHandler::~JErrorHandler() 
00072   {
00073     if ( next != NULL ) {   // Cascade deletion of the linked-list.
00074       delete next;
00075     }
00076 
00077     next = NULL;
00078   }
00079 
00080 #endif

Generated on Sun Oct 14 18:46:31 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001