Bart Janssens / SVL
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Basics.cpp Source File

Basics.cpp

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