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