mifluz

WordCursorOne.h

Go to the documentation of this file.
00001 //
00002 // WordCursorOne.h
00003 //
00004 // NAME
00005 // 
00006 // search and retrieve entries in a WordListOne object.
00007 //
00008 // SYNOPSIS
00009 // 
00010 // #include <WordList.h>
00011 //
00012 // int callback(WordList *, WordDBCursor& , const WordReference *, Object &)
00013 // {
00014 // ...
00015 // }
00016 //
00017 // Object* data = ...
00018 //
00019 // WordList *words = ...;
00020 //
00021 // WordCursor *search = words->Cursor(callback, data);
00022 // WordCursor *search = words->Cursor(WordKey("word <UNDEF> <UNDEF>"));
00023 // WordCursor *search = words->Cursor(WordKey("word <UNDEF> <UNDEF>"), callback, data);
00024 // WordCursor *search = words->Cursor(WordKey());
00025 //
00026 // ...
00027 //
00028 // if(search->Walk() == NOTOK) bark;
00029 // List* results = search->GetResults();
00030 //
00031 // search->WalkInit();
00032 // if(search->WalkNext() == OK)
00033 // dosomething(search->GetFound());
00034 // search->WalkFinish();
00035 // 
00036 // DESCRIPTION
00037 // 
00038 // WordCursorOne is a WordCursor derived class that implements search
00039 // in a WordListOne object. It currently is the only derived class of
00040 // the WordCursor object. Most of its behaviour is described in the
00041 // WordCursor manual page, only the behaviour specific to WordCursorOne
00042 // is documented here.
00043 //
00044 //
00045 // END
00046 //
00047 // Part of the ht://Dig package <http://www.htdig.org/>
00048 // Copyright (c) 1999, 2000, 2001 The ht://Dig Group
00049 // For copyright details, see the file COPYING in your distribution
00050 // or the GNU General Public License version 2 or later
00051 // <http://www.gnu.org/copyleft/gpl.html>
00052 //
00053 // $Id: WordCursorOne_8h-source.html,v 1.1 2008年06月08日 10:12:59 sebdiaz Exp $
00054 //
00055 
00056 #ifndef _WordCursorOne_h_
00057 #define _WordCursorOne_h_
00058 
00059 #ifndef SWIG
00060 #include "htString.h"
00061 #include "WordKey.h"
00062 #include "WordDB.h"
00063 #include "WordCursor.h"
00064 
00065 class WordList;
00066 class WordDBCursor;
00067 class WordDead;
00068 
00069 #endif /* SWIG */
00070 
00071 class WordCursorOne : public WordCursor
00072 {
00073 public:
00074 #ifndef SWIG
00075 //-
00076 // Private constructor. Creator of the object must then call Initialize()
00077 // prior to using any other methods.
00078 //
00079 WordCursorOne(WordList *words);
00080 //-
00081 // Private constructor. See WordList::Cursor method with same prototype for
00082 // description.
00083 //
00084 WordCursorOne(WordList *words, wordlist_walk_callback_t callback, Object * callback_data);
00085 //-
00086 // Private constructor. See WordList::Cursor method with same prototype for
00087 // description.
00088 //
00089 WordCursorOne(WordList *words, const WordKey &searchKey, int action = HTDIG_WORDLIST_WALKER);
00090 //-
00091 // Private constructor. See WordList::Cursor method with same prototype for
00092 // description.
00093 //
00094 WordCursorOne(WordList *words, const WordKey &searchKey, wordlist_walk_callback_t callback, Object * callback_data);
00095 #endif /* SWIG */
00096 virtual ~WordCursorOne() {
00097 if(cursor) delete cursor;
00098 }
00099 virtual void Clear();
00100 virtual void ClearInternal();
00101 virtual void ClearResult();
00102 
00103 virtual inline int ContextSave(String& buffer) const { found.Get(buffer); return OK; }
00104 virtual int ContextRestore(const String& buffer);
00105 
00106 #ifndef SWIG
00107 virtual int Walk();
00108 #endif /* SWIG */
00109 virtual int WalkInit();
00110 virtual int WalkRewind();
00111 virtual int WalkNext();
00112 #ifndef SWIG
00113 virtual int WalkNextStep();
00114 #endif /* SWIG */
00115 virtual int WalkFinish();
00116 //
00117 // Find out if cursor should better jump to the next possible key
00118 // (DB_SET_RANGE) instead of sequential iterating (DB_NEXT). If it
00119 // is decided that jump is a better move : cursor_set_flags =
00120 // DB_SET_RANGE key = calculated next possible key Else do nothing
00121 // Return OK if skipping successfull. Returns WORD_WALK_ATEND if no
00122 // more possible match, reached the maximum. Returns
00123 // WORD_WALK_FAILED on general failure, occurs if called and no
00124 // skipping necessary.
00125 // 
00126 int SkipUselessSequentialWalking();
00127 
00128 virtual int Seek(const WordKey& patch);
00129 
00130 #ifndef SWIG
00131 virtual int Get(String& bufferout) const;
00132 inline String Get() const { String tmp; Get(tmp); return tmp; }
00133 
00134 protected:
00135 
00136 int Initialize(WordList *nwords, const WordKey &nsearchKey, wordlist_walk_callback_t ncallback, Object * ncallback_data, int naction);
00137 
00138 //
00139 // Internal state
00140 //
00141 //
00142 // The actual Berkeley DB cursor.
00143 //
00144 WordDBCursor* cursor;
00145 //
00146 // The latest retrieved key and data
00147 //
00148 String key;
00149 String data;
00150 //
00151 // The shorted prefix key computed from searchKey
00152 //
00153 WordKey prefixKey;
00154 //
00155 // WalkNext leap is either DB_NEXT or DB_SET_RANGE.
00156 //
00157 int cursor_get_flags;
00158 //
00159 // True if search key is a prefix key
00160 //
00161 int searchKeyIsSameAsPrefix;
00162 #endif /* SWIG */
00163 };
00164 
00165 #endif /* _WordCursorOne_h_ */

Generated on Sun Jun 8 10:56:40 2008 for GNUmifluz by doxygen 1.5.5

AltStyle によって変換されたページ (->オリジナル) /