]> Creatis software - gdcm.git/blob - src/gdcmUtil.cxx
* python/testSuite.py unittest test suite added (uses Data)
[gdcm.git] / src / gdcmUtil.cxx
1 #include <ctype.h>   // For isspace
2 #include "gdcmUtil.h"
3
4 gdcmDebug::gdcmDebug(int level) {
5         DebugLevel = level;
6 }
7
8 void gdcmDebug::Verbose(int Level, const char * Msg1, const char * Msg2) {
9         if (Level > DebugLevel)
10                 return ;
11         cerr << Msg1 << ' ' << Msg2 << '\n';
12 }
13
14 void gdcmDebug::Assert(int Level, bool Test,
15                  const char * Msg1, const char * Msg2) {
16         if (Level > DebugLevel)
17                 return ;
18         if (!Test)
19                 cerr << Msg1 << ' ' << Msg2 << '\n';
20 }
21
22 void gdcmDebug::Error( bool Test, const char * Msg1, const char * Msg2) {
23         if (!Test)
24                 return;
25         std::cerr << Msg1 << ' ' << Msg2 << '\n';
26         Exit(1);
27 }
28
29 void gdcmDebug::Error(const char* Msg1, const char* Msg2,
30                       const char* Msg3) {
31         std::cerr << Msg1 << ' ' << Msg2 << ' ' << Msg3 << '\n';
32         Exit(1);
33 }
34
35 void gdcmDebug::Exit(int a) {
36 #ifdef __GNUC__
37         std::exit(a);
38 #endif
39 #ifdef _MSC_VER
40         exit(a);    // Found in #include <stdlib.h>
41 #endif
42 }
43
44 gdcmDebug dbg;
45
46 // Because is not yet available in g++2.06
47 istream& eatwhite(istream& is) {
48         char c;
49         while (is.get(c)) {
50                 if (!isspace(c)) {
51                         is.putback(c);
52                         break;
53                 }
54         }
55         return is;
56 }
57