]> Creatis software - gdcm.git/blobdiff - src/gdcmUtil.cxx
* ENH : add methods in gdcmObject to get the hash table or the list of
[gdcm.git] / src / gdcmUtil.cxx
index 40143310270811fa753301afa7bf6ac6663befc2..faad02548843d592f30abff1a2bfc3bdb439a2f2 100644 (file)
@@ -52,37 +52,44 @@ void gdcmDebug::Exit(int a) {
 }
 
 //-----------------------------------------------------------------------------
-gdcmVR      * gdcmGlobal::VR    = (gdcmVR*)0;
-gdcmTS      * gdcmGlobal::TS    = (gdcmTS*)0;
-gdcmDictSet * gdcmGlobal::Dicts = (gdcmDictSet*)0;
+gdcmDictSet         *gdcmGlobal::Dicts  = (gdcmDictSet *)0;
+gdcmVR              *gdcmGlobal::VR     = (gdcmVR *)0;
+gdcmTS              *gdcmGlobal::TS     = (gdcmTS *)0;
+gdcmDicomDirElement *gdcmGlobal::ddElem = (gdcmDicomDirElement *)0;
 gdcmGlobal gdcmGlob;
 
 gdcmGlobal::gdcmGlobal(void) {
    if (VR || TS || Dicts)
       dbg.Verbose(0, "gdcmGlobal::gdcmGlobal : VR or TS or Dicts already allocated");
+   Dicts = new gdcmDictSet();
    VR = new gdcmVR();
    TS = new gdcmTS();
-   Dicts = new gdcmDictSet();
+   ddElem = new gdcmDicomDirElement();
 }
 
 gdcmGlobal::~gdcmGlobal() {
+   delete Dicts;
    delete VR;
    delete TS;
-   delete Dicts;
+   delete ddElem;
 }
 
-gdcmVR * gdcmGlobal::GetVR(void) {
+gdcmVR *gdcmGlobal::GetVR(void) {
    return VR;
 }
 
-gdcmTS * gdcmGlobal::GetTS(void) {
+gdcmTS *gdcmGlobal::GetTS(void) {
    return TS;
 }
 
-gdcmDictSet * gdcmGlobal::GetDicts(void) {
+gdcmDictSet *gdcmGlobal::GetDicts(void) {
    return Dicts;
 }
 
+gdcmDicomDirElement *gdcmGlobal::GetDicomDirElements(void) {
+   return ddElem;
+}
+
 //-----------------------------------------------------------------------------
 // Because is not yet available in g++2.96
 std::istream& eatwhite(std::istream& is) {
@@ -113,16 +120,16 @@ void Tokenize (const std::string& str,
 
 ///////////////////////////////////////////////////////////////////////////
 // to prevent a flashing screen when non-printable character
-char * _cleanString(char *v) {
+char *_cleanString(char *v) {
    char *d;
    int i, l;
    l = strlen(v);
    for (i=0,d=v; 
-        i<l ; 
-        i++,d++) {
-      if (!isprint(*d))
+      i<l ; 
+      i++,d++) {
+         if (!isprint(*d))
          *d = '.';
-      }        
+   }   
    return v;
 }
 
@@ -130,13 +137,19 @@ char * _cleanString(char *v) {
 ///////////////////////////////////////////////////////////////////////////
 // to prevent a flashing screen when non-printable character
 std::string _CreateCleanString(std::string s) {
-  std::string str=s;
-  for(int i=0;i<str.size();i++)
-  {
-    if(!isprint(str[i]))
-      str[i]='.';
-  }
+   std::string str=s;
+
+   for(int i=0;i<str.size();i++)
+   {
+      if(!isprint(str[i]))
+         str[i]='.';
+   }
 
-  return(str);
-}
 
+   if(str.size()>0)
+      if(!isprint(s[str.size()-1]))
+         if(s[str.size()-1]==0)
+            str[str.size()-1]=' ';
+
+   return(str);
+}