X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmVR.cxx;h=3e461697ba8c319de06d5007c58d3f486dcc807a;hb=951d1f96c7bff6329f19fa28444fae5c941c352d;hp=bf12afe851d0a8db6bd585007fcf8e8211061e38;hpb=746c9ec7ec0fbe389b0894c80a8393ecd5472479;p=gdcm.git diff --git a/src/gdcmVR.cxx b/src/gdcmVR.cxx index bf12afe8..3e461697 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/28 09:30:58 $ - Version: $Revision: 1.14 $ + Date: $Date: 2005/06/24 10:55:59 $ + Version: $Revision: 1.37 $ 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