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