00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #ifndef _WordListOne_h_
00048 #define _WordListOne_h_
00049
00050 #include <fcntl.h>
00051 #include <stdio.h>
00052
00053 #include "WordList.h"
00054 #include "WordCursorOne.h"
00055 #include "WordDict.h"
00056 #include "WordMeta.h"
00057 #include "WordDead.h"
00058
00059 class WordContext;
00060
00061
00062
00063
00064 class WordListOne : public WordList
00065 {
00066 public:
00067
00068
00069
00070
00071
00072 WordListOne(WordContext* ncontext);
00073 virtual ~WordListOne();
00074
00075 virtual int Override(const WordReference& wordRef);
00076
00077 virtual inline int Exists(const WordReference& wordRef) {
00078 return (!Dead()->Exists(wordRef.Key()) && db->Exists(wordRef) == 0) ? OK : NOTOK; }
00079
00080 virtual int WalkDelete(const WordReference& wordRef);
00081 virtual inline int Delete(const WordReference& wordRef) {
00082 if(db->Del(wordRef) == 0)
00083 return dict->Unref(wordRef.GetWord());
00084 else
00085 return NOTOK;
00086 }
00087
00088
00089
00090
00091
00092
00093
00094 int DeleteCursor(WordDBCursor& cursor) { return cursor.Del(); }
00095
00096 virtual int Open(const String& filename, int mode);
00097 virtual int Close();
00098 virtual unsigned int Size() const;
00099 virtual int Pagesize() const {
00100 Configuration& config = context->GetConfiguration();
00101
00102 return config.Value("wordlist_page_size", 0);
00103 }
00104
00105 virtual inline WordDict *Dict() { return dict; }
00106 virtual inline WordMeta *Meta() { return meta; }
00107 virtual inline WordDead *Dead() { return dead; }
00108
00109 virtual List *operator [] (const WordReference& wordRef);
00110 virtual List *Prefix (const WordReference& prefix);
00111
00112 virtual List *Words() { return dict->Words(); }
00113 virtual List *WordRefs();
00114
00115 virtual inline WordCursor *Cursor(wordlist_walk_callback_t callback, Object *callback_data) { return new WordCursorOne(this, callback, callback_data); }
00116 virtual inline WordCursor *Cursor(const WordKey &searchKey, int action = HTDIG_WORDLIST_WALKER) { return new WordCursorOne(this, searchKey, action); }
00117 virtual inline WordCursor *Cursor(const WordKey &searchKey, wordlist_walk_callback_t callback, Object * callback_data) { return new WordCursorOne(this, searchKey, callback, callback_data); }
00118
00119 virtual WordKey Key(const String& bufferin);
00120
00121 virtual WordReference Word(const String& bufferin, int exists = 0);
00122
00123 virtual void BatchEnd();
00124
00125 virtual int Noccurrence(const String& key, unsigned int& noccurrence) const;
00126
00127 virtual int Write(FILE* f);
00128
00129 virtual inline int WriteDict(FILE* f) { return dict->Write(f); }
00130
00131 virtual int Read(FILE* f);
00132
00133 virtual List *Collect(const WordReference& word);
00134
00135 WordDB *db;
00136 WordDict *dict;
00137 WordMeta *meta;
00138 WordDead *dead;
00139 };
00140
00141 #endif
00142