1 // $Header: /cvs/public/gdcm/src/gdcmUtil.cxx,v 1.16 2003/09/05 11:53:39 malaterre Exp $
3 //This is needed when compiling in debug mode
5 // 'identifier' : class 'type' needs to have dll-interface to be used by
6 // clients of class 'type2'
7 #pragma warning ( disable : 4251 )
8 // 'identifier' : identifier was truncated to 'number' characters in the
10 #pragma warning ( disable : 4786 )
14 #include <ctype.h> // For isspace
22 gdcmDebug::gdcmDebug(int level) {
26 void gdcmDebug::Verbose(int Level, const char * Msg1, const char * Msg2) {
27 if (Level > DebugLevel)
29 std::cerr << Msg1 << ' ' << Msg2 << '\n';
32 void gdcmDebug::Assert(int Level, bool Test,
33 const char * Msg1, const char * Msg2) {
34 if (Level > DebugLevel)
37 std::cerr << Msg1 << ' ' << Msg2 << '\n';
40 void gdcmDebug::Error( bool Test, const char * Msg1, const char * Msg2) {
43 std::cerr << Msg1 << ' ' << Msg2 << '\n';
47 void gdcmDebug::Error(const char* Msg1, const char* Msg2,
49 std::cerr << Msg1 << ' ' << Msg2 << ' ' << Msg3 << '\n';
53 void gdcmDebug::Exit(int a) {
58 exit(a); // Found in #include <stdlib.h>
62 ///////////////////////////////////////////////////////////////////////////
63 gdcmVR * gdcmGlobal::VR = (gdcmVR*)0;
64 gdcmTS * gdcmGlobal::TS = (gdcmTS*)0;
65 gdcmDictSet * gdcmGlobal::Dicts = (gdcmDictSet*)0;
68 gdcmGlobal::gdcmGlobal(void) {
69 if (VR || TS || Dicts)
70 dbg.Verbose(0, "gdcmGlobal::gdcmGlobal : VR or TS or Dicts already allocated");
73 Dicts = new gdcmDictSet();
76 gdcmGlobal::~gdcmGlobal() {
82 gdcmVR * gdcmGlobal::GetVR(void) {
86 gdcmTS * gdcmGlobal::GetTS(void) {
89 gdcmDictSet * gdcmGlobal::GetDicts(void) {
93 ///////////////////////////////////////////////////////////////////////////
94 // Because is not yet available in g++2.96
95 istream& eatwhite(istream& is) {
106 ///////////////////////////////////////////////////////////////////////////
107 // Because is not available in C++ (?)
109 void Tokenize (const string& str,
110 vector<string>& tokens,
111 const string& delimiters) {
112 string::size_type lastPos = str.find_first_not_of(delimiters,0);
113 string::size_type pos = str.find_first_of (delimiters,lastPos);
114 while (string::npos != pos || string::npos != lastPos) {
115 tokens.push_back(str.substr(lastPos, pos - lastPos));
116 lastPos = str.find_first_not_of(delimiters, pos);
117 pos = str.find_first_of (delimiters, lastPos);
122 ///////////////////////////////////////////////////////////////////////////
123 // to prevent a flashing screen when non-printable character
125 char * _cleanString(char *v) {
139 ///////////////////////////////////////////////////////////////////////////
140 // to prevent a flashing screen when non-printable character
142 char * _CreateCleanString(string s) {
157 ///////////////////////////////////////////////////////////////////////////
159 // because it may not be associated to a dictionary ...
161 std::string TranslateToKey(guint16 group, guint16 element) {
164 // CLEAN ME: better call the iostream<< with the hex manipulator on.
165 // This requires some reading of the stdlibC++ sources to make the
166 // proper call (or copy).
167 sprintf(trash, "%04x|%04x", group , element);
168 key = trash; // Convertion through assignement