]> Creatis software - gdcm.git/blob - src/gdcmDictEntry.cxx
remove H Table NameHT
[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  * \ingroup gdcmDictEntry
10  * \brief   Construtor
11  * @param   InGroup
12  * @param   InElement
13  * @param   InVr
14  * @param   InFourth  // DO NOT use any longer
15  *                       NOT part of the Dicom Standard
16  * @param   InName 
17 */
18
19 gdcmDictEntry::gdcmDictEntry(guint16 InGroup, guint16 InElement,
20                              std::string  InVr, std::string InFourth,
21                              std::string  InName) {
22         group           = InGroup;
23         element         = InElement;
24         vr              = InVr;
25         fourth          = InFourth;
26         name            = InName;
27         key             = TranslateToKey(group, element);
28 }
29
30 /**
31  * \ingroup gdcmDictEntry
32  * \brief   concatenates 2 guint16 (supposed to be a Dicom group number 
33  *                                             and a Dicom element number)
34  * @param  group the Dicom group   number used to build the tag
35  * @param  group the Dicom element number used to build the tag
36  * return the built tag
37  */
38
39 TagKey gdcmDictEntry::TranslateToKey(guint16 group, guint16 element) {
40         char trash[10];
41         TagKey key;
42         // CLEAN ME: better call the iostream<< with the hex manipulator on.
43         // This requires some reading of the stdlibC++ sources to make the
44         // proper call (or copy).
45         sprintf(trash, "%04x|%04x", group , element);
46         key = trash;  // Convertion through assignement
47         return key;
48 }
49
50 /**
51  * \ingroup     gdcmDictEntry
52  * \brief       If-and only if-the V(alue) R(epresentation)
53  *              is unset then overwrite it.
54  * @param NewVr New V(alue) R(epresentation) to be set.
55  */
56 void gdcmDictEntry::SetVR(std::string NewVr) {
57         if ( IsVrUnknown() )
58                 vr = NewVr;
59         else {
60                 dbg.Error(true, "gdcmDictEntry::SetVR",
61                           "Overwriting vr might compromise a dictionary");
62         }
63 }