]> Creatis software - gdcm.git/blobdiff - src/gdcmSQItem.cxx
* FIX: src/* fix the doxygen warnings.
[gdcm.git] / src / gdcmSQItem.cxx
index d308079d2099d4e6a5f98fb6a44743aba07a5f15..166fd40a7e93247d13bed96db53da4365ecf0cb0 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmSQItem.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/10/25 03:35:20 $
-  Version:   $Revision: 1.31 $
+  Date:      $Date: 2004/11/10 18:27:23 $
+  Version:   $Revision: 1.36 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -27,7 +27,6 @@
 
 namespace gdcm 
 {
-
 //-----------------------------------------------------------------------------
 // Constructor / Destructor
 /**
@@ -49,7 +48,7 @@ SQItem::~SQItem()
                              cc != DocEntries.end();
                              ++cc)
    {
-      delete (*cc);
+      delete *cc;
    }
    DocEntries.clear();
 }
@@ -70,7 +69,7 @@ SQItem::~SQItem()
          s << "   | " ;
       }
    }
-   std::cout << s.str() << " --- SQItem number " << SQItemNumber  << std::endl;
+   //std::cout << s.str() << " --- SQItem number " << SQItemNumber  << std::endl;
    for (ListDocEntry::iterator i  = DocEntries.begin();
                                i != DocEntries.end();
                              ++i)
@@ -99,20 +98,24 @@ SQItem::~SQItem()
  */
 void SQItem::Write(std::ofstream* fp, FileType filetype)
 {
+   int j;
    uint16_t item[4] = { 0xfffe, 0xe000, 0xffff, 0xffff };
    uint16_t itemt[4]= { 0xfffe, 0xe00d, 0xffff, 0xffff };
 
     //we force the writting of an 'Item' Start Element
     // because we want to write the Item as a 'no Length' item
-   fp->write((char*)&item[0],8);  // fffe e000 ffff ffff 
+   for(j=0;j<4;++j)
+   {
+      binary_write( *fp, item[j]);  // fffe e000 ffff ffff 
+   }
      
-   for (ListDocEntry::iterator i = DocEntries.begin();  
-                              i != DocEntries.end();
-                             ++i)
+   for (ListDocEntry::iterator it = DocEntries.begin();  
+                              it != DocEntries.end();
+                             ++it)
    {   
       // we skip delimitors (start and end one) because 
       // we force them as 'no length'
-      if ( (*i)->GetGroup() == 0xfffe )
+      if ( (*it)->GetGroup() == 0xfffe )
       {
          continue;
       }
@@ -120,18 +123,21 @@ void SQItem::Write(std::ofstream* fp, FileType filetype)
       // Fix in order to make some MR PHILIPS images e-film readable
       // see gdcmData/gdcm-MR-PHILIPS-16-Multi-Seq.dcm:
       // we just *always* ignore spurious fffe|0000 tag ! 
-      if ( (*i)->GetGroup() == 0xfffe && (*i)->GetElement() == 0x0000 )
+      if ( (*it)->GetGroup() == 0xfffe && (*it)->GetElement() == 0x0000 )
       {
          break; // FIXME : continue; ?!?
       }
 
-      (*i)->Write(fp, filetype);
+      (*it)->Write(fp, filetype);
    }
       
     //we force the writting of an 'Item Delimitation' item
     // because we wrote the Item as a 'no Length' item
-   fp->write((char*)&itemt[0],8);  // fffe e000 ffff ffff 
-
+   for(j=0;j<4;++j)
+   {
+      binary_write( *fp, itemt[j]);  // fffe e000 ffff ffff 
+   }
 }
 
 //-----------------------------------------------------------------------------
@@ -185,13 +191,12 @@ bool SQItem::SetEntryByNumber(std::string const & val, uint16_t group,
             Dict *pubDict = Global::GetDicts()->GetDefaultPubDict();
             // if the invoked (group,elem) doesn't exist inside the Dictionary
             // we create a VirtualDictEntry
-            DictEntry *dictEntry = pubDict->GetDictEntryByNumber(group,
-                                                                     element);
+            DictEntry *dictEntry = pubDict->GetDictEntryByNumber(group, element);
             if (dictEntry == NULL)
             {
                dictEntry = 
                   Global::GetDicts()->NewVirtualDictEntry(group, element,
-                                                              "UN", "??", "??");
+                                                          "UN", "??", "??");
             } 
             // we assume the constructor didn't fail
             entry = new ValEntry(dictEntry);