]> Creatis software - gdcm.git/commitdiff
ENH: If possible move the stl include after the gdcm ones, to avoid vc warnings
authormalaterre <malaterre>
Fri, 8 Oct 2004 04:43:37 +0000 (04:43 +0000)
committermalaterre <malaterre>
Fri, 8 Oct 2004 04:43:37 +0000 (04:43 +0000)
deprecated eatwhite I wasn't able to find the ref in any c++ refs, only microsoft implement it, thus fallback to a more standart c++ approach. This is mainly to get rid of any 'c' like include header
- and some minor cleanups

src/gdcmDicomDirElement.cxx
src/gdcmDict.cxx
src/gdcmTS.cxx
src/gdcmUtil.cxx
src/gdcmUtil.h
src/gdcmVR.cxx

index 84039168b58cd632dae248fca0ff2e9b2b08dd03..88df039aa62ba30bd3e78863d11b9bfb1b89d48c 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirElement.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/09/27 08:39:06 $
-  Version:   $Revision: 1.16 $
+  Date:      $Date: 2004/10/08 04:43:37 $
+  Version:   $Revision: 1.17 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
                                                                                 
 =========================================================================*/
 
-#include <fstream>
-#include <stdio.h>    // For sprintf
-#include <iostream>
-
 #include "gdcmDicomDirElement.h"
 #include "gdcmUtil.h"
 #include "gdcmDebug.h"
 #include "gdcmDictSet.h"
 
+#include <fstream>
+#include <stdio.h>    // For sprintf
+#include <iostream>
 
 //-----------------------------------------------------------------------------
 // Constructor / Destructor
@@ -46,7 +45,7 @@ gdcmDicomDirElement::gdcmDicomDirElement()
 
    while (!from.eof())
    {
-      eatwhite(from);
+      from >> std::ws;  // used to be eatwhite(from);
       from.getline(buff, 1024, ' ');
       type = buff;
 
@@ -56,9 +55,9 @@ gdcmDicomDirElement::gdcmDicomDirElement()
       {
          from >> std::hex >> elem.group >> elem.elem;
 
-         eatwhite(from);
+         from >> std::ws; // used to be eatwhite(from);
          from.getline(buff, 1024, '"');
-         eatwhite(from);
+         from >> std::ws; // Used to be eatwhite(from);
          from.getline(buff, 1024, '"');
          elem.value = buff;
 
index 925451a32d4a68c392686f5c641f551b0541781b..c72dd48b7a9c41de580008850352aaf5206f7b97 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDict.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/09/27 08:39:06 $
-  Version:   $Revision: 1.43 $
+  Date:      $Date: 2004/10/08 04:43:38 $
+  Version:   $Revision: 1.44 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -49,7 +49,7 @@ gdcmDict::gdcmDict(std::string const & filename)
       from >> element;
       from >> vr;
       from >> fourth;
-      eatwhite(from);
+      from >> std::ws; // used to be eatwhite(from);
       std::getline(from, name);    /// MEMORY LEAK in std::getline<>
 
       gdcmDictEntry * newEntry = new gdcmDictEntry(group, element,
index 152aaebb91b9b4f7d09fbd995b4b02d9ab318513..82a25780a35fc20d3cf3cc8d0cc40e83b3331f31 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmTS.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/09/27 08:39:07 $
-  Version:   $Revision: 1.24 $
+  Date:      $Date: 2004/10/08 04:43:38 $
+  Version:   $Revision: 1.25 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
                                                                                 
 =========================================================================*/
 
-#include <fstream>
-#include <string>
-#include <iostream>
-
 #include "gdcmTS.h"
 #include "gdcmDebug.h"
 #include "gdcmUtil.h"
 #include "gdcmDictSet.h"
 
-
+#include <fstream>
+#include <string>
+#include <iostream>
 
 //-----------------------------------------------------------------------------
 // Constructor / Destructor
-gdcmTS::gdcmTS(void
+gdcmTS::gdcmTS() 
 {
    std::string filename=gdcmDictSet::BuildDictPath() + std::string(DICT_TS);
    std::ifstream from(filename.c_str());
@@ -38,13 +36,14 @@ gdcmTS::gdcmTS(void)
    std::string key;
    std::string name;
 
-   while (!from.eof()) {
+   while (!from.eof())
+   {
       from >> key;
 
-      eatwhite(from);
+      from >> std::ws; // used to be eatwhite(from);
       std::getline(from, name);    /// MEMORY LEAK
 
-      if(key!="") 
+      if(key!="")
       {
          ts[key]=name;
       }
@@ -52,6 +51,7 @@ gdcmTS::gdcmTS(void)
    from.close();
 }
 
+//-----------------------------------------------------------------------------
 gdcmTS::~gdcmTS() 
 {
    ts.clear();
@@ -84,8 +84,10 @@ int gdcmTS::Count(TSKey key)
 
 std::string gdcmTS::GetValue(TSKey key) 
 {
-   if (ts.count(key) == 0) 
+   if (ts.count(key) == 0)
+   {
       return GDCM_UNFOUND;
+   }
    return ts[key];
 }
 
index 2b59ead196c478d29db85dfdd86ccb9c6dc3c691..0b1b14a831a1ca9e0c38b61571afe26ebb834284 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmUtil.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/09/27 08:39:08 $
-  Version:   $Revision: 1.50 $
+  Date:      $Date: 2004/10/08 04:43:38 $
+  Version:   $Revision: 1.51 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 
 #include "gdcmUtil.h"
 #include "gdcmDebug.h"
-#include <stdio.h>
-#include <ctype.h>   // For isspace
-#include <string.h>  // CLEANME: could this be only string ? Related to Win32 ?
-#include <iostream>
-
-/**
- * \ingroup Globals
- * \brief   Because is not yet available in g++2.96
- */
-std::istream& eatwhite(std::istream& is) {
-   char c;
-   while (is.get(c)) {
-      if (!isspace(c)) {
-         is.putback(c);
-         break;
-      }
-   }
-   return is;
-}
 
 /**
  * \ingroup Globals
@@ -44,10 +25,12 @@ std::istream& eatwhite(std::istream& is) {
  */
 void Tokenize (const std::string& str,
                std::vector<std::string>& tokens,
-               const std::string& delimiters) {
+               const std::string& delimiters)
+{
    std::string::size_type lastPos = str.find_first_not_of(delimiters,0);
    std::string::size_type pos     = str.find_first_of    (delimiters,lastPos);
-   while (std::string::npos != pos || std::string::npos != lastPos) {
+   while (std::string::npos != pos || std::string::npos != lastPos)
+   {
       tokens.push_back(str.substr(lastPos, pos - lastPos));
       lastPos = str.find_first_not_of(delimiters, pos);
       pos     = str.find_first_of    (delimiters, lastPos);
@@ -60,18 +43,21 @@ void Tokenize (const std::string& str,
  *        Counts the number of occurences of a substring within a string
  */
  
- int CountSubstring (const std::string& str,
-                     const std::string& subStr) {
+int CountSubstring (const std::string& str,
+                    const std::string& subStr)
+{
    int count = 0;   // counts how many times it appears
    unsigned int x = 0;       // The index position in the string
 
    do
-    { x = str.find(subStr,x);       // Find the substring
+   {
+      x = str.find(subStr,x);       // Find the substring
       if (x != std::string::npos)   // If present
-        { count++;                  // increase the count
-          x += subStr.length();     // Skip this word
-        }
-    }
+      {
+         count++;                  // increase the count
+         x += subStr.length();     // Skip this word
+      }
+   }
    while (x != std::string::npos);  // Carry on until not present
 
    return count;
@@ -83,19 +69,28 @@ void Tokenize (const std::string& str,
  *         to avoid corrupting the terminal of invocation when printing)
  * @param s string to remove non printable characters from
  */
-std::string CreateCleanString(std::string s) {
-   std::string str=s;
+std::string CreateCleanString(std::string s)
+{
+   std::string str = s;
 
    for(unsigned int i=0;i<str.size();i++)
    {
       if(!isprint(str[i]))
+      {
          str[i]='.';
+      }
    }
 
    if(str.size()>0)
+   {
       if(!isprint(s[str.size()-1]))
+      {
          if(s[str.size()-1]==0)
+         {
             str[str.size()-1]=' ';
+         }
+      }
+   }
 
    return str;
 }
@@ -110,7 +105,7 @@ void NormalizePath(std::string &name)
    const char SEPARATOR_X      = '/';
    const char SEPARATOR_WIN    = '\\';
    const std::string SEPARATOR = "/";
-   int size=name.size();
+   int size = name.size();
 
    if((name[size-1]!=SEPARATOR_X)&&(name[size-1]!=SEPARATOR_WIN))
    {
@@ -135,6 +130,7 @@ std::string GetPath(std::string &fullName)
    {
       fullName.resize(pos2);
    }
+
    return fullName;
 }
 
@@ -145,21 +141,27 @@ std::string GetPath(std::string &fullName)
  */
 std::string GetName(std::string &fullName)
 {   
-  int fin=fullName.length()-1;
-  char a =fullName.c_str()[fin];
-  if (a == '/' || a == '\\') {
-     fin--;
-  }
-  int deb = 0;
-  for (int i=fin;i!=0;i--) {
-     if (fullName.c_str()[i] == '/' || fullName.c_str()[i] == '\\')  
-        break;
+   int fin = fullName.length()-1;
+   char a =fullName.c_str()[fin];
+   if (a == '/' || a == '\\')
+   {
+      fin--;
+   }
+   int deb = 0;
+   for (int i=fin;i!=0;i--)
+   {
+      if (fullName.c_str()[i] == '/' || fullName.c_str()[i] == '\\')
+      {
+         break;
+      }
       deb = i;
-  }    
+   }
 
-  std::string lastName;
-  for (int j=deb;j<fin+1;j++)
-    lastName=lastName+fullName.c_str()[j];
+   std::string lastName;
+   for (int j=deb;j<fin+1;j++)
+   {
+      lastName=lastName+fullName.c_str()[j];
+   }
 
   return lastName;
 } 
index 7c7a59532b2ea333df03c973f75c90dd5ee785aa..3e8056ca2378078643983e99490dfb4ae10d5c84 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmUtil.h,v $
   Language:  C++
-  Date:      $Date: 2004/10/07 21:05:40 $
-  Version:   $Revision: 1.32 $
+  Date:      $Date: 2004/10/08 04:43:38 $
+  Version:   $Revision: 1.33 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -32,8 +32,6 @@
  */
 
 //-----------------------------------------------------------------------------
-GDCM_EXPORT std::istream & eatwhite(std::istream & is);
-
 GDCM_EXPORT void Tokenize (const std::string& str,
                           std::vector<std::string>& tokens,
                           const std::string& delimiters = " ");
index 596ac9ee37a958771c2c8958ca9983ae55755f46..4cc07ea90e32e005e658d7ec3aff2bee6a5d2778 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmVR.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/09/27 08:39:08 $
-  Version:   $Revision: 1.17 $
+  Date:      $Date: 2004/10/08 04:43:38 $
+  Version:   $Revision: 1.18 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
                                                                                 
 =========================================================================*/
 
-#include <fstream>
-
-#include <iostream>
-
 #include "gdcmVR.h"
 #include "gdcmUtil.h"
 #include "gdcmDictSet.h"
 #include "gdcmDebug.h"
 
+#include <fstream>
+#include <iostream>
+
 //-----------------------------------------------------------------------------
 /**
  * \brief Constructor
  */
-gdcmVR::gdcmVR(void
+gdcmVR::gdcmVR() 
 {
    std::string filename=gdcmDictSet::BuildDictPath() + std::string(DICT_VR);
    std::ifstream from(filename.c_str());
@@ -41,14 +40,14 @@ gdcmVR::gdcmVR(void)
 
    while (!from.eof()) 
    {
-      eatwhite(from);
+      from >> std::ws; // used to be eatwhite(from);
       from.getline(buff, 1024, ' ');
       key = buff;
-      eatwhite(from);
+      from >> std::ws; // used to be eatwhite(from);
       from.getline(buff, 1024, ';');
       name = buff;
 
-      eatwhite(from);
+      from >> std::ws; // used to be eatwhite(from);
       from.getline(buff, 1024, '\n');
 
       if(key!="")
@@ -59,10 +58,12 @@ gdcmVR::gdcmVR(void)
    from.close();
 }
 
+//-----------------------------------------------------------------------------
 /**
  * \brief Destructor
  */
-gdcmVR::~gdcmVR() {
+gdcmVR::~gdcmVR()
+{
    vr.clear();
 }
 
@@ -94,6 +95,7 @@ int gdcmVR::Count(gdcmVRKey key)
    return vr.count(key);
 }
 
+//-----------------------------------------------------------------------------
 /**
  * \brief   Simple predicate that checks wether the given argument
  *          corresponds to the Value Representation of a \ref gdcmBinEntry .
@@ -124,6 +126,7 @@ bool gdcmVR::IsVROfGdcmBinaryRepresentable(gdcmVRKey tested)
    return true;
 }
 
+//-----------------------------------------------------------------------------
 /**
  * \brief   Simple predicate that checks wether the given argument
  *          corresponds to the Value Representation of a \ref gdcmValEntry