1 // $Header: /cvs/public/gdcm/src/gdcmUtil.cxx,v 1.25 2003/10/02 11:26:16 malaterre Exp $
6 #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 << std::endl;
22 void gdcmDebug::Assert(int Level, bool Test,
23 const char * Msg1, const char * Msg2) {
24 if (Level > DebugLevel)
27 std::cerr << Msg1 << ' ' << Msg2 << std::endl;
30 void gdcmDebug::Error( bool Test, const char * Msg1, const char * Msg2) {
33 std::cerr << Msg1 << ' ' << Msg2 << std::endl;
37 void gdcmDebug::Error(const char* Msg1, const char* Msg2,
39 std::cerr << Msg1 << ' ' << Msg2 << ' ' << Msg3 << std::endl;
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 already 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 std::istream& eatwhite(std::istream& is) {
96 ///////////////////////////////////////////////////////////////////////////
97 // Because is not available in C++ (?)
99 void Tokenize (const std::string& str,
100 std::vector<std::string>& tokens,
101 const std::string& delimiters) {
102 std::string::size_type lastPos = str.find_first_not_of(delimiters,0);
103 std::string::size_type pos = str.find_first_of (delimiters,lastPos);
104 while (std::string::npos != pos || std::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 std::string _CreateCleanString(std::string s) {
146 for(int i=0;i<str.size();i++)
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