1 /*=========================================================================
4 Module: $RCSfile: gdcmVR.cxx,v $
6 Date: $Date: 2005/10/21 08:28:03 $
7 Version: $Revision: 1.45 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
21 #include "gdcmDictSet.h"
22 #include "gdcmDebug.h"
30 //-----------------------------------------------------------------------------
31 /// \brief auto generated function, to fill up the 'Value Representation'
32 /// Dictionnary, if relevant file is not found on user's disk
33 void FillDefaultVRDict(VRHT &vr);
35 //-----------------------------------------------------------------------------
36 // Constructor / Destructor
42 std::string filename = DictSet::BuildDictPath() + DICT_VR;
43 std::ifstream from(filename.c_str());
46 gdcmWarningMacro("Can't open dictionary " << filename.c_str());
47 FillDefaultVRDict(vr);
58 from.getline(buff, 1024, ' ');
59 if( strcmp(buff,"") == 0)
64 from.getline(buff, 1024, ';');
68 from.getline(buff, 1024, '\n');
84 //-----------------------------------------------------------------------------
88 * \brief Simple predicate that checks whether the given argument
89 * corresponds to the Value Representation of a \ref DataEntry .
90 * @param tested value representation to check for.
92 bool VR::IsVROfBinaryRepresentable(VRKey const &tested)
94 //if ( tested == GDCM_UNKNOWN)
96 //std::cout << "---------- never used --------------" << tested
101 if ( IsVROfStringRepresentable(tested) )
104 if ( IsVROfSequence(tested) )
111 * \brief Simple predicate that checks whether the given argument
112 * corresponds to the Value Representation of a representable
114 * @param tested value representation to be checked.
116 bool VR::IsVROfStringRepresentable(VRKey const &tested)
118 return tested == "AE" ||
137 // Should be quicker --> But it doesn't work : revert to old code
139 return tested != "FL" &&
143 tested != "AT" && // Attribute Tag ?!?
148 unsigned short VR::GetAtomicElementLength(VRKey const &tested)
150 // Unsigned & signed short
151 if( tested == "US" || tested == "SS" )
153 // Unsigned & signed long
154 if( tested == "UL" || tested == "SL" )
168 // VS6 need a single implementation in the dll
169 #if defined(_MSC_VER) && (_MSC_VER == 1200)
170 bool VR::IsValidVR(VRKey const &key)
172 return vr.find(key) != vr.end();
176 //-----------------------------------------------------------------------------
179 //-----------------------------------------------------------------------------
182 //-----------------------------------------------------------------------------
186 * @param os The output stream to be written to.
188 void VR::Print(std::ostream &os)
190 for (VRHT::iterator it = vr.begin(); it != vr.end(); ++it)
192 os << "VR : " << it->first << " = " << it->second << std::endl;
196 //-----------------------------------------------------------------------------
197 } // end namespace gdcm