1 // $Header: /cvs/public/gdcm/src/gdcmUtil.cxx,v 1.22 2003/09/24 13:25:21 jpr 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
21 gdcmDebug::gdcmDebug(int level) {
25 void gdcmDebug::Verbose(int Level, const char * Msg1, const char * Msg2) {
26 if (Level > DebugLevel)
28 std::cerr << Msg1 << ' ' << Msg2 << std::endl;
31 void gdcmDebug::Assert(int Level, bool Test,
32 const char * Msg1, const char * Msg2) {
33 if (Level > DebugLevel)
36 std::cerr << Msg1 << ' ' << Msg2 << std::endl;
39 void gdcmDebug::Error( bool Test, const char * Msg1, const char * Msg2) {
42 std::cerr << Msg1 << ' ' << Msg2 << std::endl;
46 void gdcmDebug::Error(const char* Msg1, const char* Msg2,
48 std::cerr << Msg1 << ' ' << Msg2 << ' ' << Msg3 << std::endl;
52 void gdcmDebug::Exit(int a) {
57 exit(a); // Found in #include <stdlib.h>
61 ///////////////////////////////////////////////////////////////////////////
62 gdcmVR * gdcmGlobal::VR = (gdcmVR*)0;
63 gdcmTS * gdcmGlobal::TS = (gdcmTS*)0;
64 gdcmDictSet * gdcmGlobal::Dicts = (gdcmDictSet*)0;
67 gdcmGlobal::gdcmGlobal(void) {
68 if (VR || TS || Dicts)
69 dbg.Verbose(0, "gdcmGlobal::gdcmGlobal : VR or TS or Dicts already allocated");
72 Dicts = new gdcmDictSet();
75 gdcmGlobal::~gdcmGlobal() {
81 gdcmVR * gdcmGlobal::GetVR(void) {
85 gdcmTS * gdcmGlobal::GetTS(void) {
88 gdcmDictSet * gdcmGlobal::GetDicts(void) {
92 ///////////////////////////////////////////////////////////////////////////
93 // Because is not yet available in g++2.96
94 std::istream& eatwhite(std::istream& is) {
105 ///////////////////////////////////////////////////////////////////////////
106 // Because is not available in C++ (?)
108 void Tokenize (const std::string& str,
109 std::vector<std::string>& tokens,
110 const std::string& delimiters) {
111 std::string::size_type lastPos = str.find_first_not_of(delimiters,0);
112 std::string::size_type pos = str.find_first_of (delimiters,lastPos);
113 while (std::tring::npos != pos || std::string::npos != lastPos) {
114 tokens.push_back(str.substr(lastPos, pos - lastPos));
115 lastPos = str.find_first_not_of(delimiters, pos);
116 pos = str.find_first_of (delimiters, lastPos);
121 ///////////////////////////////////////////////////////////////////////////
122 // to prevent a flashing screen when non-printable character
124 char * _cleanString(char *v) {
138 ///////////////////////////////////////////////////////////////////////////
139 // to prevent a flashing screen when non-printable character
141 std::string _CreateCleanString(std::string s) {
155 for(int i=0;i<str.size();i++)
164 ///////////////////////////////////////////////////////////////////////////
166 // because it may not be associated to a dictionary ...
168 std::string TranslateToKey(guint16 group, guint16 element) {
171 // CLEAN ME: better call the iostream<< with the hex manipulator on.
172 // This requires some reading of the stdlibC++ sources to make the
173 // proper call (or copy).
174 sprintf(trash, "%04x|%04x", group , element);
175 key = trash; // Convertion through assignement