X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmVR.cxx;h=ea98ceb8e0fbc2d5e0c93bea17151152040da665;hb=8d704be3e460a26db22f2d41dbaf02811bc71a45;hp=dbe4d2d5f109ccd79e5afc26bce7f7b0d74ea5c4;hpb=2012716d624d631dcdb825fdd4470908e115a717;p=gdcm.git diff --git a/src/gdcmVR.cxx b/src/gdcmVR.cxx index dbe4d2d5..ea98ceb8 100644 --- a/src/gdcmVR.cxx +++ b/src/gdcmVR.cxx @@ -3,12 +3,12 @@ Program: gdcm Module: $RCSfile: gdcmVR.cxx,v $ Language: C++ - Date: $Date: 2004/06/20 18:08:48 $ - Version: $Revision: 1.13 $ + Date: $Date: 2005/02/11 15:22:19 $ + 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 - http://www.creatis.insa-lyon.fr/Public/Gdcm/License.htm for details. + http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR @@ -16,71 +16,68 @@ =========================================================================*/ -#include - -#include - #include "gdcmVR.h" #include "gdcmUtil.h" #include "gdcmDictSet.h" #include "gdcmDebug.h" +#include +#include + +namespace gdcm +{ //----------------------------------------------------------------------------- +/// \brief auto generated function, to fill up the 'Value Representation' +/// Dictionnary, if relevant file is not found on user's disk +void FillDefaultVRDict(VRHT &vr); + +//----------------------------------------------------------------------------- +// Constructor / Destructor /** * \brief Constructor */ -gdcmVR::gdcmVR(void) +VR::VR() { - std::string filename=gdcmDictSet::BuildDictPath() + std::string(DICT_VR); + std::string filename = DictSet::BuildDictPath() + DICT_VR; std::ifstream from(filename.c_str()); - dbg.Error(!from, "gdcmVR::gdcmVR: can't open dictionary",filename.c_str()); - - char buff[1024]; - std::string key; - std::string name; - - while (!from.eof()) + if(!from) { - eatwhite(from); - from.getline(buff, 1024, ' '); - key = buff; - eatwhite(from); - from.getline(buff, 1024, ';'); - name = buff; - - eatwhite(from); - from.getline(buff, 1024, '\n'); - - if(key!="") + gdcmWarningMacro("Can't open dictionary" << filename.c_str()); + FillDefaultVRDict(vr); + } + else + { + char buff[1024]; + VRKey key; + VRAtr name; + + while (!from.eof()) { - vr[key]=name; + from >> std::ws; + from.getline(buff, 1024, ' '); + key = buff; + from >> std::ws; + from.getline(buff, 1024, ';'); + name = buff; + + from >> std::ws; + from.getline(buff, 1024, '\n'); + + if(key != "") + { + vr[key] = name; + } } + from.close(); } - from.close(); } /** * \brief Destructor */ -gdcmVR::~gdcmVR() { - vr.clear(); -} - -//----------------------------------------------------------------------------- -// Print -/** - * \brief Print all - * @param os The output stream to be written to. - */ -void gdcmVR::Print(std::ostream &os) +VR::~VR() { - std::ostringstream s; - - for (VRHT::iterator it = vr.begin(); it != vr.end(); ++it) - { - s << "VR : "<first<<" = "<second<first << " = " << it->second << std::endl; + } + os << s.str(); +} + +//----------------------------------------------------------------------------- +} // end namespace gdcm