]> Creatis software - gdcm.git/blobdiff - src/gdcmBinEntry.cxx
* src/gdcmFile.h : bug fix. Variable type and variable name had same name
[gdcm.git] / src / gdcmBinEntry.cxx
index 22dbae3ca4d48ae2f19db5d7d5b56784afdd925d..b27d35ccbea7875ad511c3ccfaeea0f1ab84dc40 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmBinEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/11/15 16:12:30 $
-  Version:   $Revision: 1.36 $
+  Date:      $Date: 2004/11/30 16:29:01 $
+  Version:   $Revision: 1.41 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -19,6 +19,7 @@
 #include "gdcmBinEntry.h"
 #include "gdcmDebug.h"
 #include <fstream>
+#include <iostream> // for std::ios_base, since <ios> does not exist on gcc/Solaris
 
 namespace gdcm 
 {
@@ -32,6 +33,7 @@ namespace gdcm
 BinEntry::BinEntry(DictEntry* e) : ValEntry(e)
 {
    BinArea = 0;
+   SelfArea = true;
 }
 
 /**
@@ -49,6 +51,7 @@ BinEntry::BinEntry(DocEntry* e) : ValEntry(e->GetDictEntry())
    //SQDepthLevel = e->GetDepthLevel();
 
    BinArea = 0; // let's be carefull !
+   SelfArea = true;
 }
 
 /**
@@ -56,7 +59,7 @@ BinEntry::BinEntry(DocEntry* e) : ValEntry(e->GetDictEntry())
  */
 BinEntry::~BinEntry()
 {
-   if (BinArea)
+   if (BinArea && SelfArea)
    {
       delete[] BinArea;
       BinArea = 0; // let's be carefull !
@@ -72,6 +75,7 @@ BinEntry::~BinEntry()
  
 void BinEntry::Print(std::ostream &os)
 {
+   os << "B ";
    DocEntry::Print(os);
    std::ostringstream s;
    void* binArea = GetBinArea();
@@ -102,9 +106,9 @@ void BinEntry::Print(std::ostream &os)
  * @param fp already open file pointer
  * @param filetype type of the file to be written
 */
-void BinEntry::Write(std::ofstream* fp, FileType filetype)
+void BinEntry::WriteContent(std::ofstream* fp, FileType filetype)
 {
-   DocEntry::Write(fp, filetype);
+   DocEntry::WriteContent(fp, filetype);
    void* binArea = GetBinArea();
    int lgr = GetLength();
    if (binArea)
@@ -117,7 +121,7 @@ void BinEntry::Write(std::ofstream* fp, FileType filetype)
    else
    {
     // nothing was loaded, but we need to skip space on disc
-      fp->seekp(lgr, std::ios_base::cur);
+      fp->seekp(lgr, std::ios::cur);
    }
 }
 //-----------------------------------------------------------------------------
@@ -125,11 +129,13 @@ void BinEntry::Write(std::ofstream* fp, FileType filetype)
 
 
 /// \brief Sets the value (non string) of the current Dicom Header Entry
-void BinEntry::SetBinArea( uint8_t* area )  
+void BinEntry::SetBinArea( uint8_t* area, bool self )  
 { 
-   if (BinArea)
+   if (BinArea && SelfArea)
       delete[] BinArea;
+
    BinArea = area;
+   SelfArea=self;
 }
 
 //-----------------------------------------------------------------------------