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