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

Basics.cc

Go to the documentation of this file.
00001 /*
00002     File:           Basics.cc
00003 
00004     Function:       Implements Basics.h
00005 
00006     Author(s):      Andrew Willmott
00007 
00008     Copyright:      (c) 1995-2000, Andrew Willmott
00009 
00010     Notes:          
00011 
00012 */
00013 
00014 #include "cl/Basics.h"
00015 #include <stdio.h>
00016 #include <stdlib.h>
00017 #include <iostream.h>
00018 
00019 
00020 // --- Error functions for range and routine checking -------------------------
00021 
00022 
00023 static Void DebuggerBreak()
00024 {
00025     abort();
00026 }
00027 
00028 Void _Assert(Int condition, const Char *errorMessage, const Char *file, Int line)
00029 {
00030     if (!condition)
00031     {
00032         Char reply;
00033         
00034         cerr << "\n*** Assert failed (line " << line << " in " << 
00035             file << "): " << errorMessage << endl;
00036         cerr << "    Continue? [y/n] ";
00037         cin >> reply;
00038         
00039         if (reply != 'y')
00040         {
00041             DebuggerBreak();
00042             exit(1);
00043         }
00044     }
00045 }
00046 
00047 Void _Expect(Int condition, const Char *warningMessage, const Char *file, Int line)
00048 {
00049     if (!condition)
00050         cerr << "\n*** Warning (line " << line << " in " << file << "): " <<
00051             warningMessage << endl;
00052 }
00053 
00054 Void _CheckRange(Int i, Int lowerBound, Int upperBound, 
00055                  const Char *rangeMessage, const Char *file, Int line)
00056 {
00057     if (i < lowerBound || i >= upperBound)
00058     {
00059         Char reply;
00060         
00061         cerr << "\n*** Range Error (line " << line << " in " << file <<
00062             "): " << rangeMessage << endl;  
00063         cerr << "    Continue? [y/n] ";
00064         cin >> reply;
00065         
00066         if (reply != 'y')
00067         {
00068             DebuggerBreak();
00069             exit(1);
00070         }
00071     }
00072 }

Generated at Sat Aug 5 00:16:31 2000 for Class Library by doxygen 1.1.0 written by Dimitri van Heesch, © 1997-2000