]> Creatis software - gdcm.git/blob - src/gdcmDictSet.cxx
First try on win32
[gdcm.git] / src / gdcmDictSet.cxx
1 #include <fstream>
2 #include <stdlib.h>  // For getenv
3 #include "gdcm.h"
4 #include "gdcmUtil.h"
5
6 #define PUB_DICT_NAME     "DicomV3Dict"
7 #define PUB_DICT_PATH     "../Dicts/"
8 #define PUB_DICT_FILENAME "dicomV3.dic"
9
10 gdcmDictSet::gdcmDictSet(void) {
11         SetDictPath();
12         if (! LoadDicomV3Dict())
13                           return;
14 }
15
16 void gdcmDictSet::SetDictPath(void) {
17         const char* EnvPath = (char*)0;
18         EnvPath = getenv("GDCM_DICT_PATH");
19         if (EnvPath && (strlen(EnvPath) != 0))
20                 DictPath = EnvPath;
21         else
22                 DictPath = PUB_DICT_PATH;
23 }
24
25 int gdcmDictSet::LoadDicomV3Dict(void) {
26         if (dicts.count(PUB_DICT_NAME))
27                 return 1;
28         return LoadDictFromFile(DictPath + PUB_DICT_FILENAME, PUB_DICT_NAME);
29 }
30
31 int gdcmDictSet::LoadDictFromFile(string FileName, DictKey Name) {
32         gdcmDict *NewDict = new gdcmDict(FileName.c_str());
33         dicts[Name] = NewDict;
34         return 0;
35 }
36
37 void gdcmDictSet::Print(ostream& os) {
38         for (DictSetHT::iterator dict = dicts.begin(); dict != dicts.end(); ++dict){
39                 os << "Printing dictionary " << dict->first << " \n";
40                 dict->second->Print(os);
41         }
42 }
43
44 gdcmDict * gdcmDictSet::GetDict(DictKey DictName) {
45         DictSetHT::iterator dict = dicts.find(DictName);
46         return dict->second;
47 }
48
49 gdcmDict * gdcmDictSet::GetDefaultPublicDict() {
50         return GetDict(PUB_DICT_NAME);
51 }