KDict converted to a singleton.
[jben.git] / dictionaries.cpp
blobcf2f0771cc0990b61f945bec77e98a360466080e
1 #include "dictionaries.h"
2 #include "preferences.h"
4 Dictionaries::Dictionaries() {
5 wdict = NULL;
6 kdict = NULL;
7 kradfile = NULL;
8 radkfile = NULL;
10 /* Load file names from preferences object - TO DO */
11 /* For now, just do a hard-coded load */
13 LoadWDict("edict2");
14 LoadKDict("kanjidic");
15 LoadKRadFile("kradfile");
16 LoadRadKFile("radkfile");
19 Dictionaries::~Dictionaries() {
20 if(wdict) delete wdict;
21 /* kdict should NOT be destroyed here; KDict::Destroy() should be called
22 instead. I did this in jben.cpp's OnExit event. */
23 if(kradfile) delete kradfile;
24 if(radkfile) delete radkfile;
27 bool Dictionaries::LoadWDict(const char* filename) {
28 int result;
29 wdict = WDict::LoadWDict(filename, result);
30 if(result == ED_SUCCESS) return true;
31 return false;
34 bool Dictionaries::LoadKDict(const char* filename) {
35 /* I have a feeling this class will be tossed soon, as
36 the 4 classes it loads will be consolidated down to 2
37 singletons, making this loader class obsolete. */
38 /* Because of the above, I'm ignoring the filename arg
39 for now. */
40 int result;
41 kdict = GetKDict();
42 if(kdict!=NULL && kdict->GetHashTable()!=NULL) return true;
43 return false;
46 bool Dictionaries::LoadKRadFile(const char* filename) {
47 int result = 0xDEADBEEF;
48 kradfile = KRadFile::LoadKRad(filename, result);
49 if(result == KRAD_SUCCESS) return true;
50 return false;
53 bool Dictionaries::LoadRadKFile(const char* filename) {
54 int result = 0xDEADBEEF;
55 radkfile = RadKFile::LoadRadK(filename, result);
56 if(result == RADK_SUCCESS) return true;
57 return false;
60 const WDict* Dictionaries::GetWDict() {return wdict;}
61 const KDict* Dictionaries::GetKDict() {return kdict;}
62 const KRadFile* Dictionaries::GetKRadFile() {return kradfile;}
63 const RadKFile* Dictionaries::GetRadKFile() {return radkfile;}