]> Creatis software - gdcm.git/blobdiff - src/gdcmElementSet.cxx
BUG: very same bug when using char* instead of string
[gdcm.git] / src / gdcmElementSet.cxx
index 95cea960349661b6f3252676549d6f7dd256e0cd..f22b4ae0fe2830fd9d0ca77886101eddb2c0b18a 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmElementSet.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/06/22 14:37:04 $
-  Version:   $Revision: 1.11 $
+  Date:      $Date: 2004/07/02 13:55:27 $
+  Version:   $Revision: 1.15 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -60,11 +60,21 @@ gdcmElementSet::~gdcmElementSet()
   *          from the H Table
   * @return
   */ 
-void gdcmElementSet::Print(std::ostream & os) {
+void gdcmElementSet::Print(std::ostream & os)
+{
+   gdcmDocEntry* Entry;
    for (TagDocEntryHT::iterator i = tagHT.begin(); i != tagHT.end(); ++i)  
    {
-      //(i)->second->SetPrintLevel(printLevel);
-      (i->second)->Print(os);   
+      Entry = i->second;
+      Entry->Print(os);   
+      bool PrintEndLine = true;
+      if ( gdcmSeqEntry* SeqEntry = dynamic_cast<gdcmSeqEntry*>(Entry) )
+      {
+         (void)SeqEntry;  //not used
+         PrintEndLine = false;
+      }
+      if (PrintEndLine)
+         os << std::endl;
    } 
 }
 
@@ -73,35 +83,12 @@ void gdcmElementSet::Print(std::ostream & os) {
   *          from the H Table
   * @return
   */ 
-void gdcmElementSet::Write(FILE *fp, FileType filetype) {
-
-// Troubles expected : BinEntries ARE ValEntries :-(
-// BinEntry is checked first, then ValEntry;
+void gdcmElementSet::Write(FILE *fp, FileType filetype)
+{
 
-   gdcmDocEntry *e;
    for (TagDocEntryHT::iterator i = tagHT.begin(); i != tagHT.end(); ++i)  
    {
-      e=i->second;
-      e->WriteCommonPart(fp, filetype);
-      std::cout<<e->GetKey() << " " << std::hex << e->GetVR() << " " 
-               << e->GetName()
-               << std::endl;
-
-// e->Write(fp,filetype); // This will be the right way to proceed !
-
-      if (gdcmBinEntry* BinEntry = dynamic_cast< gdcmBinEntry* >(e) ) {
-         BinEntry->Write(fp,filetype);
-         continue;
-      }
-     if (gdcmValEntry* ValEntry = dynamic_cast< gdcmValEntry* >(e) ) {
-         ValEntry->Write(fp);
-         continue;
-      }
-
-      if (gdcmSeqEntry* SeqEntry = dynamic_cast< gdcmSeqEntry* >(e) ) {
-         SeqEntry->Write(fp,filetype);
-         continue;
-      } 
+      i->second->Write(fp, filetype);
    } 
 }
 //-----------------------------------------------------------------------------
@@ -112,13 +99,12 @@ void gdcmElementSet::Write(FILE *fp, FileType filetype) {
 //-----------------------------------------------------------------------------
 // Private
 
-
 /**
  * \brief   add a new Dicom Element pointer to the H Table
  * @param   NewEntry entry to add
  */
 bool gdcmElementSet::AddEntry( gdcmDocEntry *NewEntry) {
-   TagKey key;
+   gdcmTagKey key;
    key = NewEntry->GetKey();
 
    if(tagHT.count(key) == 1)
@@ -140,7 +126,7 @@ bool gdcmElementSet::AddEntry( gdcmDocEntry *NewEntry) {
  */
 bool gdcmElementSet::RemoveEntry( gdcmDocEntry *EntryToRemove)
 {
-   TagKey key = EntryToRemove->GetKey();
+   gdcmTagKey key = EntryToRemove->GetKey();
    if(tagHT.count(key) == 1)
    {
       tagHT.erase(key);