]> Creatis software - gdcm.git/blob - src/gdcmDict.cxx
* Truckload of changes. Parsing of header is barely functional
[gdcm.git] / src / gdcmDict.cxx
1 #include <fstream>
2 #include "gdcmlib.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         char trash[10];
13         TagKey key, vr, fourth, name;
14         while (!from.eof()) {
15                 from >> hex >> group >> element;
16                 eatwhite(from);
17                 from.getline(buff, 256, ' ');
18                 vr = buff;
19                 eatwhite(from);
20                 from.getline(buff, 256, ' ');
21                 fourth = buff;
22                 from.getline(buff, 256, '\n');
23                 name = buff;
24                 gdcmDictEntry * newEntry = new gdcmDictEntry(group, element,
25                                                          vr, fourth, name);
26                 entries[gdcmDictEntry::TranslateToKey(group, element)] = newEntry;
27         }
28    from.close();
29 }
30
31 void gdcmDict::Print(ostream& os) {
32         for (TagHT::iterator tag = entries.begin(); tag != entries.end(); ++tag){
33        os << "Tag : ";
34        os << "(" << hex << tag->second->GetGroup() << ',';
35        os << hex << tag->second->GetElement() << ") = " << dec;
36        os << tag->second->GetVR() << ", ";
37        os << tag->second->GetFourth() << ", ";
38        os << tag->second->GetName() << "."  << endl;
39     }
40 }
41
42 gdcmDictEntry * gdcmDict::GetTag(guint32 group, guint32 element) {
43         TagKey key = gdcmDictEntry::TranslateToKey(group, element);
44         TagHT::iterator found = entries.find(key);
45         return found->second;
46 }