]> Creatis software - gdcm.git/blob - src/gdcmVR.cxx
* src/gdcmDictSet.h : set the method BuildDictPath in public
[gdcm.git] / src / gdcmVR.cxx
1 // gdcmVR.cxx
2 #include <fstream>
3
4 #include "gdcmVR.h"
5 #include "gdcmUtil.h"
6
7 #ifndef PUB_DICT_PATH
8 #  define PUB_DICT_PATH     "../Dicts/"
9 #endif
10 #define DICT_VR "dicomVR.dic"
11
12 gdcmVR::gdcmVR(void) {
13    std::string filename=gdcmDictSet::BuildDictPath() + std::string(DICT_VR);
14    std::ifstream from(filename.c_str());
15    dbg.Error(!from, "gdcmVR::gdcmVR: can't open dictionary",filename.c_str());
16
17    char buff[1024];
18    std::string key;
19    std::string name;
20
21    while (!from.eof()) {
22       eatwhite(from);
23       from.getline(buff, 1024, ' ');
24       key = buff;
25       eatwhite(from);
26       from.getline(buff, 1024, ';');
27       name = buff;
28
29       eatwhite(from);
30       from.getline(buff, 1024, '\n');
31
32       if(key!="")
33       {
34          vr[key]=name;
35       }
36    }
37    from.close();
38 }
39
40 gdcmVR::~gdcmVR() {
41    vr.clear();
42 }
43
44 int gdcmVR::Count(VRKey key) {
45    return vr.count(key);
46 }