1 // $Header: /cvs/public/gdcm/src/gdcmUtil.cxx,v 1.13 2003/06/26 13:07:01 jpr Exp $
4 #include <ctype.h> // For isspace
12 gdcmDebug::gdcmDebug(int level) {
16 void gdcmDebug::Verbose(int Level, const char * Msg1, const char * Msg2) {
17 if (Level > DebugLevel)
19 cerr << Msg1 << ' ' << Msg2 << '\n';
23 void gdcmDebug::Verbose(int Level, char * Msg1, char * Msg2) {
24 if (Level > DebugLevel)
26 cerr << Msg1 << ' ' << Msg2 << '\n';
30 void gdcmDebug::Assert(int Level, bool Test,
31 const char * Msg1, const char * Msg2) {
32 if (Level > DebugLevel)
35 cerr << Msg1 << ' ' << Msg2 << '\n';
38 void gdcmDebug::Error( bool Test, const char * Msg1, const char * Msg2) {
41 std::cerr << Msg1 << ' ' << Msg2 << '\n';
45 void gdcmDebug::Error(const char* Msg1, const char* Msg2,
47 std::cerr << Msg1 << ' ' << Msg2 << ' ' << Msg3 << '\n';
51 void gdcmDebug::Exit(int a) {
56 exit(a); // Found in #include <stdlib.h>
60 ///////////////////////////////////////////////////////////////////////////
61 gdcmVR * gdcmGlobal::VR = (gdcmVR*)0;
62 gdcmTS * gdcmGlobal::TS = (gdcmTS*)0;
63 gdcmDictSet * gdcmGlobal::Dicts = (gdcmDictSet*)0;
66 gdcmGlobal::gdcmGlobal(void) {
67 if (VR || TS || Dicts)
68 dbg.Verbose(0, "gdcmGlobal::gdcmGlobal : VR or TS or Dicts allready allocated");
71 Dicts = new gdcmDictSet();
74 gdcmGlobal::~gdcmGlobal() {
80 gdcmVR * gdcmGlobal::GetVR(void) {
84 gdcmTS * gdcmGlobal::GetTS(void) {
87 gdcmDictSet * gdcmGlobal::GetDicts(void) {
91 ///////////////////////////////////////////////////////////////////////////
92 // Because is not yet available in g++2.96
93 istream& eatwhite(istream& is) {
104 ///////////////////////////////////////////////////////////////////////////
105 // Because is not available in C++ (?)
107 void Tokenize (const string& str,
108 vector<string>& tokens,
109 const string& delimiters) {
110 string::size_type lastPos = str.find_first_not_of(delimiters,0);
111 string::size_type pos = str.find_first_of (delimiters,lastPos);
112 while (string::npos != pos || string::npos != lastPos) {
113 tokens.push_back(str.substr(lastPos, pos - lastPos));
114 lastPos = str.find_first_not_of(delimiters, pos);
115 pos = str.find_first_of (delimiters, lastPos);
120 ///////////////////////////////////////////////////////////////////////////
121 // to prevent a flashing screen when non-printable character
123 char * _cleanString(char *v) {
137 ///////////////////////////////////////////////////////////////////////////
138 // to prevent a flashing screen when non-printable character
140 char * _CreateCleanString(string s) {
155 ///////////////////////////////////////////////////////////////////////////
157 // because it may not be associated to a dictionary ...
159 std::string TranslateToKey(guint16 group, guint16 element) {
162 // CLEAN ME: better call the iostream<< with the hex manipulator on.
163 // This requires some reading of the stdlibC++ sources to make the
164 // proper call (or copy).
165 sprintf(trash, "%04x|%04x", group , element);
166 key = trash; // Convertion through assignement