X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmDocEntry.cxx;h=b6d8f0ad51c669fb6a1af01df1d094e43b9d3fba;hb=3ba8c03aa6cb08add6599a1ec7b2b693a967db62;hp=61cc963477ee0e5d85a5315dd215c659715aaa9a;hpb=1d69b92978803204089d270599133917d944c651;p=gdcm.git diff --git a/src/gdcmDocEntry.cxx b/src/gdcmDocEntry.cxx index 61cc9634..b6d8f0ad 100644 --- a/src/gdcmDocEntry.cxx +++ b/src/gdcmDocEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntry.cxx,v $ Language: C++ - Date: $Date: 2004/10/12 04:35:45 $ - Version: $Revision: 1.27 $ + Date: $Date: 2004/11/25 15:46:11 $ + Version: $Revision: 1.33 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -22,6 +22,8 @@ #include "gdcmUtil.h" #include // for std::ios::left, ... +#include + namespace gdcm { @@ -41,6 +43,11 @@ DocEntry::DocEntry(DictEntry* in) DicomDict = in; SetKey( in->GetKey( ) ); Offset = 0 ; // To avoid further missprinting + + // init some variables + ReadLength = 0; + UsableLength = 0; + PrintLevel = 0; } //----------------------------------------------------------------------------- @@ -55,15 +62,12 @@ void DocEntry::Print(std::ostream& os) PrintLevel = 2; // FIXME size_t o; - unsigned short int g, e; std::string st; TSKey v; std::string d2, vr; std::ostringstream s; uint32_t lgth; - g = GetGroup(); - e = GetElement(); o = GetOffset(); vr = GetVR(); @@ -116,7 +120,7 @@ void DocEntry::Print(std::ostream& os) * @param fp already open file pointer * @param filetype type of the file to be written */ -void DocEntry::Write(FILE* fp, FileType filetype) +void DocEntry::WriteContent(std::ofstream* fp, FileType filetype) { uint32_t ffff = 0xffffffff; uint16_t group = GetGroup(); @@ -135,9 +139,9 @@ void DocEntry::Write(FILE* fp, FileType filetype) // // ----------- Writes the common part // - fwrite ( &group,(size_t)2 ,(size_t)1 ,fp); //group - fwrite ( &el, (size_t)2 ,(size_t)1 ,fp); //element - + binary_write( *fp, group); //group + binary_write( *fp, el); //element + if ( filetype == ExplicitVR ) { // Special case of delimiters: @@ -153,8 +157,8 @@ void DocEntry::Write(FILE* fp, FileType filetype) // TODO : verify if the Sequence Delimitor Item was forced during Parsing - int ff = 0xffffffff; - fwrite (&ff,(size_t)4 ,(size_t)1 ,fp); + uint32_t ff = 0xffffffff; + binary_write(*fp, ff); return; } @@ -165,31 +169,32 @@ void DocEntry::Write(FILE* fp, FileType filetype) { // Unknown was 'written' // deal with Little Endian - fwrite ( &shortLgr,(size_t)2 ,(size_t)1 ,fp); - fwrite ( &z, (size_t)2 ,(size_t)1 ,fp); + binary_write(*fp, shortLgr); + binary_write(*fp, z); } else { - fwrite (vr.c_str(),(size_t)2 ,(size_t)1 ,fp); + binary_write(*fp, vr); + assert( vr.size() == 2 ); if ( (vr == "OB") || (vr == "OW") || (vr == "SQ") || (vr == "UN") ) { - fwrite ( &z, (size_t)2 ,(size_t)1 ,fp); + binary_write(*fp, z); if (vr == "SQ") { // we set SQ length to ffffffff // and we shall write a Sequence Delimitor Item // at the end of the Sequence! - fwrite ( &ffff,(size_t)4 ,(size_t)1 ,fp); + binary_write(*fp, ffff); } else { - fwrite ( &lgr,(size_t)4 ,(size_t)1 ,fp); + binary_write(*fp, lgr); } } else { - fwrite ( &shortLgr,(size_t)2 ,(size_t)1 ,fp); + binary_write(*fp, shortLgr); } } } @@ -197,11 +202,11 @@ void DocEntry::Write(FILE* fp, FileType filetype) { if (vr == "SQ") { - fwrite ( &ffff,(size_t)4 ,(size_t)1 ,fp); + binary_write(*fp, ffff); } else { - fwrite ( &lgr,(size_t)4 ,(size_t)1 ,fp); + binary_write(*fp, lgr); } } } @@ -241,7 +246,7 @@ uint32_t DocEntry::GetFullLength() */ void DocEntry::Copy (DocEntry* e) { - DicomDict = e->DicomDict; +// DicomDict = e->DicomDict; UsableLength = e->UsableLength; ReadLength = e->ReadLength; ImplicitVR = e->ImplicitVR;