]> Creatis software - gdcm.git/blobdiff - src/gdcmUtil.cxx
* bug fix in the Python demos, due to the recent changes
[gdcm.git] / src / gdcmUtil.cxx
index b9db1c163a03d4abef26bf7c724c6c1e7d632a3f..01808c8189c8a4a680da44edc54d0969fdeec552 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmUtil.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/08/25 14:55:47 $
-  Version:   $Revision: 1.160 $
+  Date:      $Date: 2005/10/20 07:25:10 $
+  Version:   $Revision: 1.166 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -186,22 +186,23 @@ int Util::CountSubstring (const std::string &str,
  */
 bool Util::IsCleanString(std::string const &s)
 {
-  std::cout<< std::endl << s << std::endl;
+   std::cout<< std::endl << s << std::endl;
    for(unsigned int i=0; i<s.size(); i++)
    {
-      std::cout<< std::endl << i << " : " << (unsigned char)s[i] << std::endl;
+      //std::cout<< std::endl << i << " : " << (unsigned char)s[i] << std::endl;
       if (!isprint((unsigned char)s[i]) )
       {
          return false;
       }
    }
-return true;   
+   return true;   
 }
 
 /**
  * \brief  Checks whether an 'area' is printable or not (in order
  *         to avoid corrupting the terminal of invocation when printing)
- * @param s string to check
+ * @param s area to check (uint8_t is just for prototyping. feel free to cast)
+ * @param l area length to check
  */
 bool Util::IsCleanArea(uint8_t *s, int l)
 {
@@ -217,7 +218,7 @@ bool Util::IsCleanArea(uint8_t *s, int l)
 /**
  * \brief  Weed out a string from the non-printable characters (in order
  *         to avoid corrupting the terminal of invocation when printing)
- * @param s string to remove non printable characters from
+ * @param s string to check (uint8_t is just for prototyping. feel free to cast)
  */
 std::string Util::CreateCleanString(std::string const &s)
 {
@@ -248,7 +249,8 @@ std::string Util::CreateCleanString(std::string const &s)
 /**
  * \brief  Weed out a string from the non-printable characters (in order
  *         to avoid corrupting the terminal of invocation when printing)
- * @param s string to remove non printable characters from
+ * @param s area to process (uint8_t is just for prototyping. feel free to cast)
+ * @param l area length to check
  */
 std::string Util::CreateCleanString(uint8_t *s, int l)
 {
@@ -266,7 +268,6 @@ std::string Util::CreateCleanString(uint8_t *s, int l)
       }
    }
 
-
    return str;
 }
 /**
@@ -895,7 +896,7 @@ std::string Util::CreateUniqueUID(const std::string &root)
    append += Util::GDCM_MAC_ADRESS;
    append += ".";
    append += Util::GetCurrentDateTime();
-
+   append += ".";
    //Also add a mini random number just in case:
    char tmp[10];
    int r = (int) (100.0*rand()/RAND_MAX);
@@ -938,9 +939,7 @@ std::ostream &binary_write(std::ostream &os, const uint16_t &val)
 {
 #if defined(GDCM_WORDS_BIGENDIAN) || defined(GDCM_FORCE_BIGENDIAN_EMULATION)
    uint16_t swap;
-   //swap = ((( val << 8 ) & 0xff00 ) | (( val >> 8 ) & 0x00ff ) );
-   //save CPU time
-   swap = ( val << 8 |  val >> 8  );
+   swap = ( val << 8 | val >> 8 );
 
    return os.write(reinterpret_cast<const char*>(&swap), 2);
 #else
@@ -957,9 +956,6 @@ std::ostream &binary_write(std::ostream &os, const uint32_t &val)
 {
 #if defined(GDCM_WORDS_BIGENDIAN) || defined(GDCM_FORCE_BIGENDIAN_EMULATION)
    uint32_t swap;
-//   swap = ( ((val<<24) & 0xff000000) | ((val<<8)  & 0x00ff0000) | 
-//            ((val>>8)  & 0x0000ff00) | ((val>>24) & 0x000000ff) );
-// save CPU time
    swap = (  (val<<24)               | ((val<<8)  & 0x00ff0000) | 
             ((val>>8)  & 0x0000ff00) |  (val>>24)               );
    return os.write(reinterpret_cast<const char*>(&swap), 4);