2 //-----------------------------------------------------------------------------
6 #include <ctype.h> // For isspace
9 //-----------------------------------------------------------------------------
13 //-----------------------------------------------------------------------------
14 gdcmDebug::gdcmDebug(int level) {
18 void gdcmDebug::Verbose(int Level, const char * Msg1, const char * Msg2) {
19 if (Level > DebugLevel)
21 std::cerr << Msg1 << ' ' << Msg2 << std::endl;
24 void gdcmDebug::Error( bool Test, const char * Msg1, const char * Msg2) {
27 std::cerr << Msg1 << ' ' << Msg2 << std::endl;
31 void gdcmDebug::Error(const char* Msg1, const char* Msg2,
33 std::cerr << Msg1 << ' ' << Msg2 << ' ' << Msg3 << std::endl;
37 void gdcmDebug::Assert(int Level, bool Test,
38 const char * Msg1, const char * Msg2) {
39 if (Level > DebugLevel)
42 std::cerr << Msg1 << ' ' << Msg2 << std::endl;
45 void gdcmDebug::Exit(int a) {
50 exit(a); // Found in #include <stdlib.h>
54 //-----------------------------------------------------------------------------
55 gdcmVR *gdcmGlobal::VR = (gdcmVR *)0;
56 gdcmTS *gdcmGlobal::TS = (gdcmTS *)0;
57 gdcmDictSet *gdcmGlobal::Dicts = (gdcmDictSet *)0;
60 gdcmGlobal::gdcmGlobal(void) {
61 if (VR || TS || Dicts)
62 dbg.Verbose(0, "gdcmGlobal::gdcmGlobal : VR or TS or Dicts already allocated");
65 Dicts = new gdcmDictSet();
68 gdcmGlobal::~gdcmGlobal() {
74 gdcmVR *gdcmGlobal::GetVR(void) {
78 gdcmTS *gdcmGlobal::GetTS(void) {
82 gdcmDictSet *gdcmGlobal::GetDicts(void) {
86 //-----------------------------------------------------------------------------
87 // Because is not yet available in g++2.96
88 std::istream& eatwhite(std::istream& is) {
99 ///////////////////////////////////////////////////////////////////////////
100 // Because is not available in C++ (?)
101 void Tokenize (const std::string& str,
102 std::vector<std::string>& tokens,
103 const std::string& delimiters) {
104 std::string::size_type lastPos = str.find_first_not_of(delimiters,0);
105 std::string::size_type pos = str.find_first_of (delimiters,lastPos);
106 while (std::string::npos != pos || std::string::npos != lastPos) {
107 tokens.push_back(str.substr(lastPos, pos - lastPos));
108 lastPos = str.find_first_not_of(delimiters, pos);
109 pos = str.find_first_of (delimiters, lastPos);
114 ///////////////////////////////////////////////////////////////////////////
115 // to prevent a flashing screen when non-printable character
116 char *_cleanString(char *v) {
130 ///////////////////////////////////////////////////////////////////////////
131 // to prevent a flashing screen when non-printable character
132 std::string _CreateCleanString(std::string s) {
135 for(int i=0;i<str.size();i++)
143 if(!isprint(s[str.size()-1]))
144 if(s[str.size()-1]==0)
145 str[str.size()-1]=' ';