Simple Vector Library 1.5 http://www.cs.cmu.edu/~ajw/doc/svl.html

Committer:
BartJanssens
Date:
Tue Jan 05 13:37:50 2016 +0000
Revision:
1:e25ff4b06ed2
Parent:
0:785cff1e5a7c
fixed va_list bug

Who changed what in which revision?

UserRevisionLine numberNew contents of line
BartJanssens 0:785cff1e5a7c 1 /*
BartJanssens 0:785cff1e5a7c 2 File: Basics.cpp
BartJanssens 0:785cff1e5a7c 3
BartJanssens 0:785cff1e5a7c 4 Function: Implements Basics.h
BartJanssens 0:785cff1e5a7c 5
BartJanssens 0:785cff1e5a7c 6 Author(s): Andrew Willmott
BartJanssens 0:785cff1e5a7c 7
BartJanssens 0:785cff1e5a7c 8 Copyright: (c) 1995-2001, Andrew Willmott
BartJanssens 0:785cff1e5a7c 9
BartJanssens 0:785cff1e5a7c 10 Notes:
BartJanssens 0:785cff1e5a7c 11
BartJanssens 0:785cff1e5a7c 12 */
BartJanssens 0:785cff1e5a7c 13
BartJanssens 0:785cff1e5a7c 14 #include "Basics.h"
BartJanssens 0:785cff1e5a7c 15 //#include <cstdio>
BartJanssens 0:785cff1e5a7c 16 //#include <cstdlib>
BartJanssens 0:785cff1e5a7c 17 //#include <iostream>
BartJanssens 0:785cff1e5a7c 18
BartJanssens 0:785cff1e5a7c 19
BartJanssens 0:785cff1e5a7c 20 //using namespace std;
BartJanssens 0:785cff1e5a7c 21
BartJanssens 0:785cff1e5a7c 22
BartJanssens 0:785cff1e5a7c 23 // --- Error functions for range and routine checking -------------------------
BartJanssens 0:785cff1e5a7c 24
BartJanssens 0:785cff1e5a7c 25
BartJanssens 0:785cff1e5a7c 26 static Void DebuggerBreak()
BartJanssens 0:785cff1e5a7c 27 {
BartJanssens 0:785cff1e5a7c 28 abort();
BartJanssens 0:785cff1e5a7c 29 }
BartJanssens 0:785cff1e5a7c 30
BartJanssens 0:785cff1e5a7c 31 Void _Assert(Int condition, const Char *errorMessage, const Char *file, Int line)
BartJanssens 0:785cff1e5a7c 32 {
BartJanssens 0:785cff1e5a7c 33 if (!condition)
BartJanssens 0:785cff1e5a7c 34 {
BartJanssens 0:785cff1e5a7c 35 //Char reply;
BartJanssens 0:785cff1e5a7c 36
BartJanssens 0:785cff1e5a7c 37 //cerr << "\n*** Assert failed (line " << line << " in " <<
BartJanssens 0:785cff1e5a7c 38 // file << "): " << errorMessage << endl;
BartJanssens 0:785cff1e5a7c 39 printf("\r\n*** Assert failed (line \"%d \" in \" %s \"): \"%s", line, file, errorMessage);
BartJanssens 0:785cff1e5a7c 40 //cerr << " Continue? [y/n] ";
BartJanssens 0:785cff1e5a7c 41 //cin >> reply;
BartJanssens 0:785cff1e5a7c 42
BartJanssens 0:785cff1e5a7c 43 //if (reply != 'y')
BartJanssens 0:785cff1e5a7c 44 //{
BartJanssens 0:785cff1e5a7c 45 DebuggerBreak();
BartJanssens 0:785cff1e5a7c 46 exit(1);
BartJanssens 0:785cff1e5a7c 47 //}
BartJanssens 0:785cff1e5a7c 48 }
BartJanssens 0:785cff1e5a7c 49 }
BartJanssens 0:785cff1e5a7c 50
BartJanssens 0:785cff1e5a7c 51 Void _Expect(Int condition, const Char *warningMessage, const Char *file, Int line)
BartJanssens 0:785cff1e5a7c 52 {
BartJanssens 0:785cff1e5a7c 53 if (!condition)
BartJanssens 0:785cff1e5a7c 54 //cerr << "\n*** Warning (line " << line << " in " << file << "): " <<
BartJanssens 0:785cff1e5a7c 55 // warningMessage << endl;
BartJanssens 0:785cff1e5a7c 56 printf("\r\n*** Warning (line \"%d \" in \" %s \"): \"%s", line, file, warningMessage);
BartJanssens 0:785cff1e5a7c 57 }
BartJanssens 0:785cff1e5a7c 58
BartJanssens 0:785cff1e5a7c 59 Void _CheckRange(Int i, Int lowerBound, Int upperBound,
BartJanssens 0:785cff1e5a7c 60 const Char *rangeMessage, const Char *file, Int line)
BartJanssens 0:785cff1e5a7c 61 {
BartJanssens 0:785cff1e5a7c 62 if (i < lowerBound || i >= upperBound)
BartJanssens 0:785cff1e5a7c 63 {
BartJanssens 0:785cff1e5a7c 64 //Char reply;
BartJanssens 0:785cff1e5a7c 65
BartJanssens 0:785cff1e5a7c 66 //cerr << "\n*** Range Error (line " << line << " in " << file <<
BartJanssens 0:785cff1e5a7c 67 // "): " << rangeMessage << endl;
BartJanssens 0:785cff1e5a7c 68 printf("\r\n*** Range Error (line \"%d \" in \" %s \"): \"%s", line, file, rangeMessage);
BartJanssens 0:785cff1e5a7c 69 //cerr << " Continue? [y/n] ";
BartJanssens 0:785cff1e5a7c 70 //cin >> reply;
BartJanssens 0:785cff1e5a7c 71
BartJanssens 0:785cff1e5a7c 72 //if (reply != 'y')
BartJanssens 0:785cff1e5a7c 73 //{
BartJanssens 0:785cff1e5a7c 74 DebuggerBreak();
BartJanssens 0:785cff1e5a7c 75 exit(1);
BartJanssens 0:785cff1e5a7c 76 //}
BartJanssens 0:785cff1e5a7c 77 }
BartJanssens 0:785cff1e5a7c 78 }