1 /*=========================================================================
4 Module: $RCSfile: gdcmVR.cxx,v $
6 Date: $Date: 2004/09/10 18:54:39 $
7 Version: $Revision: 1.16 $
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.htm 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 =========================================================================*/
25 #include "gdcmDictSet.h"
26 #include "gdcmDebug.h"
28 //-----------------------------------------------------------------------------
34 std::string filename=gdcmDictSet::BuildDictPath() + std::string(DICT_VR);
35 std::ifstream from(filename.c_str());
36 dbg.Error(!from, "gdcmVR::gdcmVR: can't open dictionary",filename.c_str());
45 from.getline(buff, 1024, ' ');
48 from.getline(buff, 1024, ';');
52 from.getline(buff, 1024, '\n');
69 //-----------------------------------------------------------------------------
73 * @param os The output stream to be written to.
75 void gdcmVR::Print(std::ostream &os)
79 for (gdcmVRHT::iterator it = vr.begin(); it != vr.end(); ++it)
81 s << "VR : "<<it->first<<" = "<<it->second<<std::endl;
86 //-----------------------------------------------------------------------------
89 * \brief Get the count for an element
90 * @param key key to count
92 int gdcmVR::Count(gdcmVRKey key)
98 * \brief Simple predicate that checks wether the given argument
99 * corresponds to the Value Representation of a \ref gdcmBinEntry .
100 * This predicate is the negation of
101 * \ref gdcmVR::IsVROfGdcmStringRepresentable .
102 * @param tested value representation to check for.
104 bool gdcmVR::IsVROfGdcmBinaryRepresentable(gdcmVRKey tested)
106 //std::cout << "gdcmVR::IsVROfGdcmBinaryRepresentable===================="
107 // << tested << std::endl;
109 if ( tested == "unkn")
112 if ( ! Count(tested) )
114 dbg.Verbose(0, "gdcmVR::IsVROfGdcmBinaryRepresentable: tested not a VR!");
118 if ( IsVROfGdcmStringRepresentable(tested) )
120 dbg.Verbose(0, "gdcmVR::IsVROfGdcmBinaryRepresentable: binary VR !");
128 * \brief Simple predicate that checks wether the given argument
129 * corresponds to the Value Representation of a \ref gdcmValEntry
130 * but NOT a \ref gdcmBinEntry.
131 * @param tested value representation to check for.
133 bool gdcmVR::IsVROfGdcmStringRepresentable(gdcmVRKey tested)
136 if ( ! Count(tested) )
138 dbg.Verbose(0, "gdcmVR::IsVROfGdcmStringRepresentable: tested not a VR!");
142 if (tested == "AE" || tested == "AS" || tested == "DA" || tested == "PN" ||
143 tested == "UI" || tested == "TM" || tested == "SH" || tested == "LO" ||
144 tested == "CS" || tested == "IS" || tested == "LO" || tested == "LT" ||
145 tested == "SH" || tested == "ST" || tested == "DS" || tested == "SL" ||
146 tested == "SS" || tested == "UL" || tested == "US" || tested == "UN")
153 //-----------------------------------------------------------------------------
156 //-----------------------------------------------------------------------------
159 //-----------------------------------------------------------------------------