]> Creatis software - gdcm.git/blobdiff - src/gdcmValEntry.cxx
* src/gdcmBinEntry.cxx, gdcmSeqEntry.cxx, gdcmSQItem.cxx, gdcmValEntry.cxx :
[gdcm.git] / src / gdcmValEntry.cxx
index aaf16de4d076b6fd718fe6352df86048d173a7f6..673f9489ae023b6bdfbc1f2adc003998d0264af6 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmValEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/10/12 04:35:48 $
-  Version:   $Revision: 1.30 $
+  Date:      $Date: 2004/11/24 16:39:19 $
+  Version:   $Revision: 1.37 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -21,6 +21,8 @@
 #include "gdcmGlobal.h"
 #include "gdcmUtil.h"
 
+#include <fstream>
+
 namespace gdcm 
 {
 
@@ -74,6 +76,7 @@ void ValEntry::Print(std::ostream & os)
    TSKey v;
    std::string d2;
      
+   os << "V ";
    DocEntry::Print(os); 
 
    if (g == 0xfffe)
@@ -106,7 +109,7 @@ void ValEntry::Print(std::ostream & os)
       {
          if ( v.length() != 0 )  // for brain damaged headers
          {
-            if ( ! isdigit(v[v.length()-1]) )
+            if ( ! isdigit((unsigned char)v[v.length()-1]) )
             {
                v.erase(v.length()-1, 1);
             }
@@ -122,7 +125,7 @@ void ValEntry::Print(std::ostream & os)
          {
             if ( v.length() != 0 )  // for brain damaged headers
             {
-               if ( ! isdigit(v[v.length()-1]) )
+               if ( ! isdigit((unsigned char)v[v.length()-1]) )
                {
                   v.erase(v.length()-1, 1);
                }
@@ -138,7 +141,7 @@ void ValEntry::Print(std::ostream & os)
             {
                if ( v.length() != 0 )  // for brain damaged headers  
                {
-                  if ( ! isdigit(v[v.length()-1]) )
+                  if ( ! isdigit((unsigned char)v[v.length()-1]) )
                   {
                      v.erase(v.length()-1, 1);  
                   }
@@ -174,7 +177,7 @@ void ValEntry::Print(std::ostream & os)
 /*
  * \brief   canonical Writer
  */
-void ValEntry::Write(FILE* fp, FileType filetype)
+void ValEntry::Write(std::ofstream* fp, FileType filetype)
 {
    DocEntry::Write(fp, filetype);
 
@@ -186,7 +189,7 @@ void ValEntry::Write(FILE* fp, FileType filetype)
    }
       
    std::string vr = GetVR();
-   int lgr = GetReadLength();
+   unsigned int lgr = GetReadLength();
    if (vr == "US" || vr == "SS")
    {
       // some 'Short integer' fields may be mulivaluated
@@ -198,8 +201,7 @@ void ValEntry::Write(FILE* fp, FileType filetype)
       for (unsigned int i=0; i<tokens.size();i++)
       {
          uint16_t val_uint16 = atoi(tokens[i].c_str());
-         void* ptr = &val_uint16;
-         fwrite ( ptr,(size_t)2 ,(size_t)1 ,fp);
+         binary_write( *fp, val_uint16);
       }
       tokens.clear();
       return;
@@ -216,14 +218,14 @@ void ValEntry::Write(FILE* fp, FileType filetype)
       for (unsigned int i=0; i<tokens.size();i++)
       {
          uint32_t val_uint32 = atoi(tokens[i].c_str());
-         void* ptr = &val_uint32;
-         fwrite ( ptr,(size_t)4 ,(size_t)1 ,fp);
+         binary_write( *fp, val_uint32);
       }
       tokens.clear();
       return;
    } 
-          
-   fwrite (GetValue().c_str(), (size_t)lgr ,(size_t)1, fp); // Elem value
+
+   assert( lgr == GetValue().size() ); 
+   binary_write(*fp, GetValue());
 } 
 
 //-----------------------------------------------------------------------------