Use the gdcmDocEntry::Print() and Write() instead.
+2004-06-21 Eric Boix <Eric.Boix@creatis.insa-lyon.fr>
+   * gdcmDocEntry::PrintCommonPart() and ::WriteCommonPart() removed.
+     Use the gdcmDocEntry::Print() and Write() instead.
+
 2004-06-22 Jean-Pierre Roux
    In order : to write Sequences, whatever their imbrication level, 
                 : to allow user to create his own Sequences
 
   Program:   gdcm
   Module:    $RCSfile: gdcmBinEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/06/22 14:42:01 $
-  Version:   $Revision: 1.15 $
+  Date:      $Date: 2004/06/23 13:02:35 $
+  Version:   $Revision: 1.16 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
  
 void gdcmBinEntry::Print(std::ostream &os)
 {
-   //gdcmValEntry::Print(os);  // replaced by PrintCommonPart 
-                               // to avoid bugging the display
-   PrintCommonPart(os);
+   gdcmDocEntry::Print(os);
    std::ostringstream s;
    if (voidArea != NULL)
    {
       s << " [gdcm::Binary data NOT loaded]"
         << std::endl;
    }
-   os << s.str();
 }
 
 /*
  * \brief   canonical Writer
  */
-void gdcmBinEntry::Write(FILE *fp) {
+void gdcmBinEntry::Write(FILE *fp, FileType filetype) {
+   gdcmDocEntry::Write(fp, filetype);
    void *voidArea = GetVoidArea();
    int lgr=GetLength();
    if (voidArea != NULL) 
 
   Program:   gdcm
   Module:    $RCSfile: gdcmBinEntry.h,v $
   Language:  C++
-  Date:      $Date: 2004/06/22 14:42:02 $
-  Version:   $Revision: 1.10 $
+  Date:      $Date: 2004/06/23 13:02:36 $
+  Version:   $Revision: 1.11 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
    ~gdcmBinEntry(void);
    
    void Print(std::ostream &os = std::cout);
-   virtual void Write(FILE *fp);
+   virtual void Write(FILE*, FileType);
 
    /// \brief Returns the area value of the current Dicom Header Entry
    ///  when it's not string-translatable (e.g : a LUT table)         
 
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/06/23 02:13:14 $
-  Version:   $Revision: 1.51 $
+  Date:      $Date: 2004/06/23 13:02:36 $
+  Version:   $Revision: 1.52 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
    }
 
    for(it=elemList.begin();it!=elemList.end();++it) {
-      std::cout << "it " << std::endl;
       tmpGr=it->group;
       tmpEl=it->elem;
       dictEntry=GetPubDict()->GetDictEntryByNumber(tmpGr,tmpEl);
 
   Program:   gdcm
   Module:    $RCSfile: gdcmDocEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/06/22 13:47:33 $
-  Version:   $Revision: 1.8 $
+  Date:      $Date: 2004/06/23 13:02:36 $
+  Version:   $Revision: 1.9 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
    entry = in;
 }
 
-/**
- * \ingroup gdcmDocEntry
- * \brief   Canonical Printer
- * @param   os ostream we want to print in
- */
-void gdcmDocEntry::Print(std::ostream & os) {
-   std::ostringstream s;
-   s << std::endl;
-   PrintCommonPart(os);
-   os << s.str();
-}
-
 //-----------------------------------------------------------------------------
 // Print
 /**
  * \ingroup gdcmDocEntry
  * \brief   Prints the common part of gdcmValEntry, gdcmBinEntry, gdcmSeqEntry
+ * @param   os ostream we want to print in
  */
-void gdcmDocEntry::PrintCommonPart(std::ostream & os) {
+void gdcmDocEntry::Print(std::ostream & os) {
 
    printLevel=2; // FIXME
    
  * \brief   Writes the common part of any gdcmValEntry, gdcmBinEntry, gdcmSeqEntry
  */
 void gdcmDocEntry::Write(FILE *fp, FileType filetype) {
-   std::cout << "gdcmDocEntry::Write : Is that what you wanted to do ? " << std::endl;
-   WriteCommonPart(fp, filetype);
-}
-
-/**
- * \ingroup gdcmDocEntry
- * \brief   Writes the common part of any gdcmValEntry, gdcmBinEntry, gdcmSeqEntry
- */
-void gdcmDocEntry::WriteCommonPart(FILE *fp, FileType filetype) {
 
    guint16 group  = GetGroup();
    VRKey   vr     = GetVR();
 
   Program:   gdcm
   Module:    $RCSfile: gdcmDocEntry.h,v $
   Language:  C++
-  Date:      $Date: 2004/06/22 13:47:33 $
-  Version:   $Revision: 1.10 $
+  Date:      $Date: 2004/06/23 13:02:36 $
+  Version:   $Revision: 1.11 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
    virtual void Print (std::ostream & os = std::cout); 
    virtual void Write(FILE *fp, FileType filetype);
    
-   void gdcmDocEntry::PrintCommonPart(std::ostream & os);
-   void gdcmDocEntry::WriteCommonPart(FILE *fp, FileType filetype);
-         
    guint32 GetFullLength(void);
    
    void Copy(gdcmDocEntry *doc);
 
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/06/23 09:30:22 $
-  Version:   $Revision: 1.26 $
+  Date:      $Date: 2004/06/23 13:02:36 $
+  Version:   $Revision: 1.27 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
  * if ( filetype == ACR)
  *    UpdateGroupLength(true,ACR);
  */
- 
-   Write(fp,filetype);  // the gdcmElementSet one !
+       
+       gdcmElementSet::Write(fp,filetype);
 
    /// WriteEntries(fp,type); // old stuff
    return true;
 
   Program:   gdcm
   Module:    $RCSfile: gdcmElementSet.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/06/22 14:42:02 $
-  Version:   $Revision: 1.12 $
+  Date:      $Date: 2004/06/23 13:02:36 $
+  Version:   $Revision: 1.13 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
   *          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) )
+         PrintEndLine = false;
+      if (PrintEndLine)
+         os << std::endl;
    } 
 }
 
   *          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);
-         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);
    } 
 }
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 // Private
 
-
 /**
  * \brief   add a new Dicom Element pointer to the H Table
  * @param   NewEntry entry to add
 
   Program:   gdcm
   Module:    $RCSfile: gdcmSQItem.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/06/23 02:13:14 $
-  Version:   $Revision: 1.15 $
+  Date:      $Date: 2004/06/23 13:02:36 $
+  Version:   $Revision: 1.16 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
  void gdcmSQItem::Print(std::ostream & os) {
    std::ostringstream s;
 
-   if (SQDepthLevel>0) {
+   if (SQDepthLevel>0)
+   {
       for (int i=0;i<SQDepthLevel;i++)
          s << "   | " ;
    }
    std::cout << s.str() << " --- SQItem number " << SQItemNumber  << std::endl;
-   for (ListDocEntry::iterator i = docEntries.begin();  
-        i != docEntries.end();
-        ++i)
+   for (ListDocEntry::iterator i  = docEntries.begin();  
+                               i != docEntries.end();
+                             ++i)
    {
-       os << s.str();
-      //(*i)->SetPrintLevel(printLevel); //self->GetPrintLevel() ?
-      (*i)->SetPrintLevel(2);
-      (*i)->Print(os);   
+      gdcmDocEntry* Entry = *i;
+      bool PrintEndLine = true;
+
+      os << s.str();
+      Entry->SetPrintLevel(2);
+      Entry->Print(os);   
+      if ( gdcmSeqEntry* SeqEntry = dynamic_cast<gdcmSeqEntry*>(Entry) )
+         PrintEndLine = false;
+      if (PrintEndLine)
+         os << std::endl;
    } 
 }
 
-
 /*
  * \ingroup gdcmSQItem
  * \brief   canonical Writer
  */
- void gdcmSQItem::Write(FILE *fp,FileType filetype) {
-   gdcmDocEntry *Entry;
+void gdcmSQItem::Write(FILE *fp,FileType filetype)
+{
    for (ListDocEntry::iterator i = docEntries.begin();  
         i != docEntries.end();
         ++i)
    {
-      Entry=*i;
-      (Entry)->WriteCommonPart(fp, filetype);
-
-      if (gdcmBinEntry* BinEntry = dynamic_cast< gdcmBinEntry* >(Entry) ) {
-         BinEntry->Write(fp);
-         return;
-      }
-      if (gdcmValEntry* ValEntry = dynamic_cast< gdcmValEntry* >(Entry) ) {
-         ValEntry->Write(fp);
-         return;
-      }
-      if (gdcmSeqEntry* SeqEntry = dynamic_cast< gdcmSeqEntry* >(Entry) ) {
-         SeqEntry->Write(fp,filetype);
-         return;
-      }
+      (*i)->Write(fp, filetype);
    } 
 }
 
-
 //-----------------------------------------------------------------------------
 // Public
 /**
 
   Program:   gdcm
   Module:    $RCSfile: gdcmSeqEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/06/23 03:36:24 $
-  Version:   $Revision: 1.17 $
+  Date:      $Date: 2004/06/23 13:02:36 $
+  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
 }
 
 /**
- * \ingroup gdcmSeqEntry
  * \brief   Canonical destructor.
  */
 gdcmSeqEntry::~gdcmSeqEntry() {
       delete seq_term;
 }
 
-//-----------------------------------------------------------------------------
-// Print
 /*
  * \brief   canonical Printer
  */
 void gdcmSeqEntry::Print(std::ostream &os){
 
-   std::ostringstream s,s2;
-   std::string vr;
    // First, Print the Dicom Element itself.
    SetPrintLevel(2);   
-   PrintCommonPart(os);
-   s << std::endl;
-   os << s.str();   
+   gdcmDocEntry::Print(os);
+   os << std::endl;
 
-    if (GetReadLength() == 0)
-       return;
+   if (GetReadLength() == 0)
+      return;
 
-    // Then, Print each SQ Item   
-     for(ListSQItem::iterator cc = items.begin();cc != items.end();++cc)
+   // Then, Print each SQ Item   
+   for(ListSQItem::iterator cc = items.begin();cc != items.end();++cc)
    {
       (*cc)->Print(os);   
    }
    // at end, print the sequence terminator item, if any
    if (delimitor_mode) {
       for (int i=0;i<SQDepthLevel+1;i++)
-         s2 << "   | " ;
-      os << s2.str();
+         os << "   | " ;
       if (seq_term != NULL) {
          seq_term->Print(os);
       } 
       else 
-         std::cout
-             << "      -------------- should have a sequence terminator item"
-             << std::endl;      
+         os << "      -------------- should have a sequence terminator item";
    }                    
- }
-
+}
 
 /*
  * \brief   canonical Writer
  */
-void gdcmSeqEntry::Write(FILE *fp, FileType filetype) {
-  for(ListSQItem::iterator cc  = GetSQItems().begin();
-                           cc != GetSQItems().end();
-                         ++cc) {
-      std::cout << "Et un SQItem !" << std::endl;
-      (*cc)->Write(fp, filetype);  // Don't remove param filetype !
+void gdcmSeqEntry::Write(FILE *fp, FileType filetype)
+{
+   gdcmDocEntry::Write(fp, filetype);
+   for(ListSQItem::iterator cc  = GetSQItems().begin();
+                            cc != GetSQItems().end();
+                          ++cc)
+   {
+      (*cc)->Write(fp, filetype);   
    }  
 }
+
 //-----------------------------------------------------------------------------
 // Public
 
 
   Program:   gdcm
   Module:    $RCSfile: gdcmSeqEntry.h,v $
   Language:  C++
-  Date:      $Date: 2004/06/22 13:47:33 $
-  Version:   $Revision: 1.12 $
+  Date:      $Date: 2004/06/23 13:02:36 $
+  Version:   $Revision: 1.13 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
    virtual ~gdcmSeqEntry();
    
    virtual void Print(std::ostream &os = std::cout); 
-   virtual void Write(FILE *fp,FileType filetype);
+   virtual void Write(FILE *fp, FileType);
 
    /// \brief   returns the SQITEM chained List for this SeQuence.
    inline ListSQItem &GetSQItems() { return items; }
 
   Program:   gdcm
   Module:    $RCSfile: gdcmValEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/06/22 14:37:04 $
-  Version:   $Revision: 1.12 $
+  Date:      $Date: 2004/06/23 13:02:36 $
+  Version:   $Revision: 1.13 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
  */
 void gdcmValEntry::Print(std::ostream & os)
 {
+   guint16 g = GetGroup();
+   guint16 e = GetElement();
+   std::string vr = GetVR();
    std::ostringstream s; 
-   unsigned short int g, e;
    char st[20];
    TSKey v;
-   std::string d2, vr;
+   std::string d2;
      
-   PrintCommonPart(os); 
+   gdcmDocEntry::Print(os); 
 
-   g  = GetGroup();
-   
-   if (g == 0xfffe) {
-      s << std::endl;
-      os << s.str(); 
-      return;  // just to avoid identing all the remaining code     
+   if (g == 0xfffe)
+   {
+      // just to avoid identing all the remaining code     
+      return;
    }
    
-   e  = GetElement();
-   vr = GetVR();
    gdcmTS * ts = gdcmGlobal::GetTS();
     
    v  = GetValue();  // not applicable for SQ ...     
       }
    }
    //if (e == 0x0000) {        // elem 0x0000 --> group length 
-   if ( (vr == "UL") || (vr == "US") || (vr == "SL") || (vr == "SS") ) {
+   if ( (vr == "UL") || (vr == "US") || (vr == "SL") || (vr == "SS") )
+   {
       if (v == "4294967295") // to avoid troubles in convertion 
          sprintf (st," x(ffffffff)");
       else {
       }
       s << st;
    }
-        
-   s << std::endl;
-   os << s.str();   
+   os << s.str();
 }
 
-
 /*
  * \brief   canonical Writer
  */
-void gdcmValEntry::Write(FILE *fp) {
-      std::string vr=GetVR();
-      int lgr=GetLength();
-      if (vr == "US" || vr == "SS") {
-         // some 'Short integer' fields may be mulivaluated
-         // each single value is separated from the next one by '\'
-         // we split the string and write each value as a short int
-         std::vector<std::string> tokens;
-         tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
-         Tokenize (GetValue(), tokens, "\\");
-         for (unsigned int i=0; i<tokens.size();i++) {
-            guint16 val_uint16 = atoi(tokens[i].c_str());
-            void *ptr = &val_uint16;
-            fwrite ( ptr,(size_t)2 ,(size_t)1 ,fp);
-         }
-         tokens.clear();
-         return;
+void gdcmValEntry::Write(FILE *fp, FileType filetype)
+{
+   gdcmDocEntry::Write(fp, filetype);
+   std::string vr=GetVR();
+   int lgr=GetLength();
+   if (vr == "US" || vr == "SS")
+   {
+      // some 'Short integer' fields may be mulivaluated
+      // each single value is separated from the next one by '\'
+      // we split the string and write each value as a short int
+      std::vector<std::string> tokens;
+      tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
+      Tokenize (GetValue(), tokens, "\\");
+      for (unsigned int i=0; i<tokens.size();i++) {
+         guint16 val_uint16 = atoi(tokens[i].c_str());
+         void *ptr = &val_uint16;
+         fwrite ( ptr,(size_t)2 ,(size_t)1 ,fp);
+      }
+      tokens.clear();
+      return;
+   }
+   if (vr == "UL" || vr == "SL")
+   {
+      // Some 'Integer' fields may be multivaluated (multiple instances 
+      // of integers). But each single integer value is separated from the
+      // next one by '\' (backslash character). Hence we split the string
+      // along the '\' and write each value as an int:
+      std::vector<std::string> tokens;
+      tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
+      Tokenize (GetValue(), tokens, "\\");
+      for (unsigned int i=0; i<tokens.size();i++){
+         guint32 val_uint32 = atoi(tokens[i].c_str());
+         void *ptr = &val_uint32;
+         fwrite ( ptr,(size_t)4 ,(size_t)1 ,fp);
       }
-      if (vr == "UL" || vr == "SL") {
-         // Some 'Integer' fields may be multivaluated (multiple instances 
-         // of integers). But each single integer value is separated from the
-         // next one by '\' (backslash character). Hence we split the string
-         // along the '\' and write each value as an int:
-         std::vector<std::string> tokens;
-         tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
-         Tokenize (GetValue(), tokens, "\\");
-         for (unsigned int i=0; i<tokens.size();i++){
-            guint32 val_uint32 = atoi(tokens[i].c_str());
-            void *ptr = &val_uint32;
-            fwrite ( ptr,(size_t)4 ,(size_t)1 ,fp);
-         }
-         tokens.clear();
-         return;
-      }           
-      fwrite (GetValue().c_str(),
-              (size_t)lgr ,(size_t)1, fp); // Elem value
+      tokens.clear();
+      return;
+   }           
+   fwrite (GetValue().c_str(), (size_t)lgr ,(size_t)1, fp); // Elem value
 } 
 
 //-----------------------------------------------------------------------------
 
   Program:   gdcm
   Module:    $RCSfile: gdcmValEntry.h,v $
   Language:  C++
-  Date:      $Date: 2004/06/23 03:36:24 $
-  Version:   $Revision: 1.15 $
+  Date:      $Date: 2004/06/23 13:02:36 $
+  Version:   $Revision: 1.16 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
    inline void SetValue(std::string val)  { value = val;  };
    
    virtual void Print(std::ostream &os = std::cout); 
-   virtual void gdcmValEntry::Write(FILE *fp);           
+   virtual void Write(FILE *fp, FileType filetype);
 protected:
 
    /// \brief for 'non string' values. Will be move to gdcmBinEntry, later
    ///        The Value Representation (\ref gdcmVR) is indenpendently used
    ///        in order to interpret (decode) this field.
    std::string  value;
-
 };
 
 //-----------------------------------------------------------------------------