X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmDict.cxx;h=a314a91a09b4a7caf3cc91c850117da3d106c7f9;hb=76ac46b16fd92d0fb444f786d4946424d9029315;hp=6d20d5eb0ac5ed39b0fe8d6ff9ebaaf8f98c0ade;hpb=17ebda2271dd65565f512e835546b22c22ebbbb0;p=gdcm.git diff --git a/src/gdcmDict.cxx b/src/gdcmDict.cxx index 6d20d5eb..a314a91a 100644 --- a/src/gdcmDict.cxx +++ b/src/gdcmDict.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDict.cxx,v $ Language: C++ - Date: $Date: 2006/04/11 16:03:26 $ - Version: $Revision: 1.84 $ + Date: $Date: 2007/05/23 14:18:09 $ + Version: $Revision: 1.87 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -24,7 +24,7 @@ #include #include -namespace gdcm +namespace GDCM_NAME_SPACE { //----------------------------------------------------------------------------- /// \brief auto generated function, to fill up the Dicom Dictionnary, @@ -56,7 +56,7 @@ Dict::Dict(std::string const &filename) FillDefaultDataDict( this ); } else - { + { gdcmDebugMacro( "in Dict::Dict, DoTheLoadingJob filename =[" << filename << "]" ); DoTheLoadingJob(from); @@ -82,7 +82,6 @@ Dict::~Dict() */ bool Dict::AddDict(std::string const &filename) { - std::ifstream from( filename.c_str() ); if ( !from ) { @@ -96,7 +95,6 @@ bool Dict::AddDict(std::string const &filename) } } - /** * \brief Removes from the current Dicom Dict all the entries held in a source dictionary * \note it concerns only Private Dictionnary @@ -118,10 +116,14 @@ bool Dict::RemoveDict(std::string const &filename) TagName vm; TagName name; - while (!from.eof() && from) + while ( true ) { from >> std::hex; from >> group; + + if (from.eof()) + break; + from >> elem; from >> vr; from >> vm; @@ -157,10 +159,10 @@ bool Dict::AddEntry(DictEntry *newEntry) } } -/** - * \brief replaces an already existing Dicom Element by a new one - * @param newEntry new entry (overwrites any previous one with same tag) - * @return false if Dicom Element doesn't exist +/* + * \ brief replaces an already existing Dicom Element by a new one + * @ param newEntry new entry (overwrites any previous one with same tag) + * @ return false if Dicom Element doesn't exist */ /* seems to be useless @@ -177,6 +179,7 @@ bool Dict::ReplaceEntry(DictEntry *newEntry) // seems to be useless return false; } */ + /** * \brief removes an already existing Dicom Dictionary Entry, * identified by its Tag @@ -242,7 +245,7 @@ DictEntry *Dict::GetEntry(TagKey const &key) return it->second; } /** - * \brief Get the dictionary entry identified by it's "group" and "element") + * \brief Get the dictionary entry identified by its "group" and "element") * @param group Group number of the searched entry. * @param elem Element number of the searched entry. * @return the corresponding dictionary entry when existing, NULL otherwise @@ -296,6 +299,9 @@ DictEntry *Dict::GetNextEntry() */ void Dict::DoTheLoadingJob(std::ifstream &from) { + if (!from) + return; + uint16_t group; uint16_t elem; VRKey vr; @@ -303,16 +309,20 @@ void Dict::DoTheLoadingJob(std::ifstream &from) TagName name; DictEntry *newEntry; - while (!from.eof() && from) + while ( true ) { from >> std::hex; - from >> group; + from >> group; from >> elem; from >> vr; from >> vm; from >> std::ws; //remove white space std::getline(from, name); - + + if(from.eof()) { + break; + } + newEntry = DictEntry::New(group, elem, vr, vm, name); AddEntry(newEntry); newEntry->Delete();