1 /*=========================================================================
4 Module: $RCSfile: gdcmVR.cxx,v $
6 Date: $Date: 2005/02/05 01:37:09 $
7 Version: $Revision: 1.35 $
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 void FillDefaultVRDict(VRHT &vr);
32 //-----------------------------------------------------------------------------
33 // Constructor / Destructor
39 std::string filename = DictSet::BuildDictPath() + DICT_VR;
40 std::ifstream from(filename.c_str());
43 gdcmWarningMacro("Can't open dictionary" << filename.c_str());
44 FillDefaultVRDict(vr);
55 from.getline(buff, 1024, ' ');
58 from.getline(buff, 1024, ';');
62 from.getline(buff, 1024, '\n');
81 //-----------------------------------------------------------------------------
84 * \brief Get the count for an element
85 * @param key key to count
87 int VR::Count(VRKey const &key)
93 * \brief Simple predicate that checks whether the given argument
94 * corresponds to the Value Representation of a \ref BinEntry .
95 * @param tested value representation to check for.
97 bool VR::IsVROfBinaryRepresentable(VRKey const &tested)
99 if ( tested == GDCM_UNKNOWN)
102 if ( IsVROfStringRepresentable(tested) )
105 if ( IsVROfSequence(tested) )
112 * \brief Simple predicate that checks whether the given argument
113 * corresponds to the Value Representation of a \ref ValEntry
114 * but NOT a \ref BinEntry.
115 * @param tested value representation to be checked.
117 bool VR::IsVROfStringRepresentable(VRKey const &tested)
119 return tested == "AE" ||
140 * \brief Simple predicate that checks whether the given argument
141 * corresponds to the Value Representation of a \ref SeqEntry
142 * @param tested value representation to check for.
144 bool VR::IsVROfSequence(VRKey const &tested)
146 return tested == "SQ";
149 bool VR::IsValidVR(VRKey const &key)
151 return vr.find(key) != vr.end();
154 //-----------------------------------------------------------------------------
157 //-----------------------------------------------------------------------------
160 //-----------------------------------------------------------------------------
164 * @param os The output stream to be written to.
166 void VR::Print(std::ostream &os)
168 std::ostringstream s;
170 for (VRHT::iterator it = vr.begin(); it != vr.end(); ++it)
172 s << "VR : " << it->first << " = " << it->second << std::endl;
177 //-----------------------------------------------------------------------------
178 } // end namespace gdcm