]> Creatis software - gdcm.git/blob - src/gdcmDictEntry.cxx
Remove using namespace std;
[gdcm.git] / src / gdcmDictEntry.cxx
1 // gdcmDictEntry.cxx
2
3 //This is needed when compiling in debug mode
4 #ifdef _MSC_VER
5 // 'identifier' : class 'type' needs to have dll-interface to be used by
6 // clients of class 'type2'
7 #pragma warning ( disable : 4251 )
8 // 'identifier' : identifier was truncated to 'number' characters in the
9 // debug information
10 #pragma warning ( disable : 4786 )
11 #endif //_MSC_VER
12
13 #include <stdio.h>    // FIXME For sprintf
14 #include "gdcmDictEntry.h"
15 #include "gdcmUtil.h"
16
17
18 gdcmDictEntry::gdcmDictEntry(guint16 InGroup, guint16 InElement,
19                              std::string  InVr, std::string InFourth,
20                              std::string  InName) {
21         group           = InGroup;
22         element         = InElement;
23         vr              = InVr;
24         fourth          = InFourth;
25         name            = InName;
26         key             = TranslateToKey(group, element);
27 }
28
29 TagKey gdcmDictEntry::TranslateToKey(guint16 group, guint16 element) {
30         char trash[10];
31         TagKey key;
32         // CLEAN ME: better call the iostream<< with the hex manipulator on.
33         // This requires some reading of the stdlibC++ sources to make the
34         // proper call (or copy).
35         sprintf(trash, "%04x|%04x", group , element);
36         key = trash;  // Convertion through assignement
37         return key;
38 }
39
40 /**
41  * \ingroup     gdcmDictEntry
42  * \brief       If-and only if-the vr is unset then overwrite it.
43  * @param NewVr New vr to be set.
44  */
45 void gdcmDictEntry::SetVR(std::string NewVr) {
46         if ( IsVrUnknown() )
47                 vr = NewVr;
48         else {
49                 dbg.Error(true, "gdcmDictEntry::SetVR",
50                           "Overwriting vr might compromise a dictionary");
51         }
52 }
53
54 bool gdcmDictEntry::IsVrUnknown() {
55         if ( vr == "Unknown" )
56                 return true;
57         return false;
58 }