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