]> Creatis software - gdcm.git/blob - src/gdcmTS.cxx
* src/*.[h|cxx] : coding style
[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 //-----------------------------------------------------------------------------
14 // Constructor / Destructor
15 gdcmTS::gdcmTS(void) {
16    std::string filename=gdcmDictSet::BuildDictPath() + std::string(DICT_TS);
17    std::ifstream from(filename.c_str());
18    dbg.Error(!from, "gdcmTS::gdcmTS: can't open dictionary",filename.c_str());
19
20    char buff[1024];
21    std::string key;
22    std::string name;
23
24    while (!from.eof()) {
25       eatwhite(from);
26       from.getline(buff, 1024, ' ');
27       key = buff;
28       eatwhite(from);
29       from.getline(buff, 1024, '\n');
30       name = buff;
31
32       if(key!="") {
33          ts[key]=name;
34       }
35    }
36    from.close();
37 }
38
39 gdcmTS::~gdcmTS() {
40    ts.clear();
41 }
42
43 //-----------------------------------------------------------------------------
44 // Print
45
46 //-----------------------------------------------------------------------------
47 // Public
48 int gdcmTS::Count(TSKey key) {
49    return ts.count(key);
50 }
51
52 std::string gdcmTS::GetValue(TSKey key) {
53    if (ts.count(key) == 0) 
54       return (GDCM_UNFOUND);
55    return ts[key];
56 }
57
58 //-----------------------------------------------------------------------------
59 // Protected
60
61 //-----------------------------------------------------------------------------
62 // Private
63
64 //-----------------------------------------------------------------------------