]> Creatis software - gdcm.git/blob - src/gdcmDict.cxx
* Straightforward temporary fixes for swig to build the python wrappers.
[gdcm.git] / src / gdcmDict.cxx
1 #include <fstream>
2 #include "gdcm.h"
3 #include "gdcmUtil.h"
4
5 gdcmDict::gdcmDict(char * FileName) {
6         std::ifstream from(FileName);
7         dbg.Error(!from, "gdcmDictSet::gdcmDictSet:",
8                   "can't open dictionary");
9         guint16 group, element;
10         // CLEANME : use defines for all those constants
11         char buff[1024];
12         TagKey key, vr, fourth, name;
13         while (!from.eof()) {
14                 from >> hex >> group >> element;
15                 eatwhite(from);
16                 from.getline(buff, 256, ' ');
17                 vr = buff;
18                 eatwhite(from);
19                 from.getline(buff, 256, ' ');
20                 fourth = buff;
21                 from.getline(buff, 256, '\n');
22                 name = buff;
23                 gdcmDictEntry * newEntry = new gdcmDictEntry(group, element,
24                                                          vr, fourth, name);
25                 entries[gdcmDictEntry::TranslateToKey(group, element)] = newEntry;
26         }
27    from.close();
28 }
29
30 void gdcmDict::Print(ostream& os) {
31         for (TagHT::iterator tag = entries.begin(); tag != entries.end(); ++tag){
32        os << "Tag : ";
33        os << "(" << hex << tag->second->GetGroup() << ',';
34        os << hex << tag->second->GetElement() << ") = " << dec;
35        os << tag->second->GetVR() << ", ";
36        os << tag->second->GetFourth() << ", ";
37        os << tag->second->GetName() << "."  << endl;
38     }
39 }
40
41 gdcmDictEntry * gdcmDict::GetTag(guint32 group, guint32 element) {
42         TagKey key = gdcmDictEntry::TranslateToKey(group, element);
43         TagHT::iterator found = entries.find(key);
44         return found->second;
45 }