1 // $Header: /cvs/public/gdcm/src/gdcmUtil.cxx,v 1.14 2003/07/01 10:04:36 frog 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 std::cerr << Msg1 << ' ' << Msg2 << '\n';
22 void gdcmDebug::Assert(int Level, bool Test,
23 const char * Msg1, const char * Msg2) {
24 if (Level > DebugLevel)
27 std::cerr << Msg1 << ' ' << Msg2 << '\n';
30 void gdcmDebug::Error( bool Test, const char * Msg1, const char * Msg2) {
33 std::cerr << Msg1 << ' ' << Msg2 << '\n';
37 void gdcmDebug::Error(const char* Msg1, const char* Msg2,
39 std::cerr << Msg1 << ' ' << Msg2 << ' ' << Msg3 << '\n';
43 void gdcmDebug::Exit(int a) {
48 exit(a); // Found in #include <stdlib.h>
52 ///////////////////////////////////////////////////////////////////////////
53 gdcmVR * gdcmGlobal::VR = (gdcmVR*)0;
54 gdcmTS * gdcmGlobal::TS = (gdcmTS*)0;
55 gdcmDictSet * gdcmGlobal::Dicts = (gdcmDictSet*)0;
58 gdcmGlobal::gdcmGlobal(void) {
59 if (VR || TS || Dicts)
60 dbg.Verbose(0, "gdcmGlobal::gdcmGlobal : VR or TS or Dicts allready allocated");
63 Dicts = new gdcmDictSet();
66 gdcmGlobal::~gdcmGlobal() {
72 gdcmVR * gdcmGlobal::GetVR(void) {
76 gdcmTS * gdcmGlobal::GetTS(void) {
79 gdcmDictSet * gdcmGlobal::GetDicts(void) {
83 ///////////////////////////////////////////////////////////////////////////
84 // Because is not yet available in g++2.96
85 istream& eatwhite(istream& is) {
96 ///////////////////////////////////////////////////////////////////////////
97 // Because is not available in C++ (?)
99 void Tokenize (const string& str,
100 vector<string>& tokens,
101 const string& delimiters) {
102 string::size_type lastPos = str.find_first_not_of(delimiters,0);
103 string::size_type pos = str.find_first_of (delimiters,lastPos);
104 while (string::npos != pos || string::npos != lastPos) {
105 tokens.push_back(str.substr(lastPos, pos - lastPos));
106 lastPos = str.find_first_not_of(delimiters, pos);
107 pos = str.find_first_of (delimiters, lastPos);
112 ///////////////////////////////////////////////////////////////////////////
113 // to prevent a flashing screen when non-printable character
115 char * _cleanString(char *v) {
129 ///////////////////////////////////////////////////////////////////////////
130 // to prevent a flashing screen when non-printable character
132 char * _CreateCleanString(string s) {
147 ///////////////////////////////////////////////////////////////////////////
149 // because it may not be associated to a dictionary ...
151 std::string TranslateToKey(guint16 group, guint16 element) {
154 // CLEAN ME: better call the iostream<< with the hex manipulator on.
155 // This requires some reading of the stdlibC++ sources to make the
156 // proper call (or copy).
157 sprintf(trash, "%04x|%04x", group , element);
158 key = trash; // Convertion through assignement