1 /*=========================================================================
4 Module: $RCSfile: gdcmVR.cxx,v $
6 Date: $Date: 2005/06/24 10:55:59 $
7 Version: $Revision: 1.37 $
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"
29 //-----------------------------------------------------------------------------
30 /// \brief auto generated function, to fill up the 'Value Representation'
31 /// Dictionnary, if relevant file is not found on user's disk
32 void FillDefaultVRDict(VRHT &vr);
34 //-----------------------------------------------------------------------------
35 // Constructor / Destructor
41 std::string filename = DictSet::BuildDictPath() + DICT_VR;
42 std::ifstream from(filename.c_str());
45 gdcmWarningMacro("Can't open dictionary" << filename.c_str());
46 FillDefaultVRDict(vr);
57 from.getline(buff, 1024, ' ');
60 from.getline(buff, 1024, ';');
64 from.getline(buff, 1024, '\n');
83 //-----------------------------------------------------------------------------
86 * \brief Get the count for an element
87 * @param key key to count
89 int VR::Count(VRKey const &key)
95 * \brief Simple predicate that checks whether the given argument
96 * corresponds to the Value Representation of a \ref BinEntry .
97 * @param tested value representation to check for.
99 bool VR::IsVROfBinaryRepresentable(VRKey const &tested)
101 if ( tested == GDCM_UNKNOWN)
104 if ( IsVROfStringRepresentable(tested) )
107 if ( IsVROfSequence(tested) )
114 * \brief Simple predicate that checks whether the given argument
115 * corresponds to the Value Representation of a \ref ValEntry
116 * but NOT a \ref BinEntry.
117 * @param tested value representation to be checked.
119 bool VR::IsVROfStringRepresentable(VRKey const &tested)
121 return tested == "AE" ||
142 * \brief Simple predicate that checks whether the given argument
143 * corresponds to the Value Representation of a \ref SeqEntry
144 * @param tested value representation to check for.
146 bool VR::IsVROfSequence(VRKey const &tested)
148 return tested == "SQ";
151 bool VR::IsValidVR(VRKey const &key)
153 return vr.find(key) != vr.end();
156 //-----------------------------------------------------------------------------
159 //-----------------------------------------------------------------------------
162 //-----------------------------------------------------------------------------
166 * @param os The output stream to be written to.
168 void VR::Print(std::ostream &os)
170 std::ostringstream s;
172 for (VRHT::iterator it = vr.begin(); it != vr.end(); ++it)
174 s << "VR : " << it->first << " = " << it->second << std::endl;
179 //-----------------------------------------------------------------------------
180 } // end namespace gdcm