]> Creatis software - gdcm.git/blob - src/gdcmDictEntry.cxx
Commenataires?
[gdcm.git] / src / gdcmDictEntry.cxx
1 // gdcmDict.cxx
2
3 #include "gdcm.h"
4 #include "gdcmUtil.h"
5
6 gdcmDictEntry::gdcmDictEntry(guint16 InGroup, guint16 InElement,
7                              string  InVr, string InFourth, string InName) 
8 {
9         group = InGroup;
10         element = InElement;
11         vr = InVr;
12         fourth = InFourth;
13         name = InName;
14         key = TranslateToKey(group, element);
15 }
16
17 TagKey gdcmDictEntry::TranslateToKey(guint16 group, guint16 element) {
18         char trash[10];
19         TagKey key;
20         // CLEAN ME: better call the iostream<< with the hex manipulator on.
21         // This requires some reading of the stdlibC++ sources to make the
22         // proper call (or copy).
23         sprintf(trash, "%04x|%04x", group , element);
24         key = trash;  // Convertion through assignement
25         return key;
26 }
27
28 /**
29  * \ingroup     gdcmDictEntry
30  * \brief       If-and only if-the vr is unset then overwrite it.
31  * @param NewVr New vr to be set.
32  */
33 void gdcmDictEntry::SetVR(string NewVr) {
34         if ( IsVrUnknown() )
35                 vr = NewVr;
36         else {
37                 dbg.Error(true, "gdcmDictEntry::SetVR",
38                           "Overwriting vr might compromise a dictionary");
39         }
40 }
41
42 bool gdcmDictEntry::IsVrUnknown() {
43         if ( vr == "Unknown" )
44                 return true;
45         return false;
46 }