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