00001 // 00002 // Part of the ht://Dig package <http://www.htdig.org/> 00003 // Copyright (c) 1999, 2000, 2001 The ht://Dig Group 00004 // For copyright details, see the file COPYING in your distribution 00005 // or the GNU General Public License version 2 or later 00006 // <http://www.gnu.org/copyleft/gpl.html> 00007 // 00008 // $Id: WordMatch_8h-source.html,v 1.1 2008/06/08 10:13:16 sebdiaz Exp $ 00009 // 00010 00011 #ifndef _WordMatch_h 00012 #define _WordMatch_h 00013 00014 #include <WordKey.h> 00015 #include <WordContext.h> 00016 00017 // 00018 // Return value of the Search method, tells us which document 00019 // matched and why. 00020 // 00021 class WordMatch { 00022 public: 00023 WordMatch(WordContext* context) : match(context) { } 00024 00025 //- 00026 // Return a textual representation of the object. 00027 // 00028 String Get() const; 00029 00030 //- 00031 // The document that matched 00032 // 00033 WordKey match; 00034 //- 00035 // An ascii description of why it matched. 00036 // 00037 String info; 00038 //- 00039 // 1 if match is valid, 0 if match is not valid 00040 int valid; 00041 }; 00042 00043 class WordMatches { 00044 public: 00045 WordMatches(WordContext* ncontext) { 00046 size = 0; 00047 length = 0; 00048 matches = 0; 00049 context = ncontext; 00050 } 00051 00052 ~WordMatches() { 00053 if(matches) { 00054 for(unsigned int i = 0; i < size; i++) 00055 delete matches[i]; 00056 delete matches; 00057 } 00058 } 00059 00060 int Allocate(unsigned int nsize) { 00061 size = nsize; 00062 matches = new WordMatch* [size]; 00063 memset((char*)matches, '\0', sizeof(WordMatch*) * size); 00064 length = 0; 00065 00066 for(unsigned int i = 0; i < size; i++) { 00067 matches[i] = new WordMatch(context); 00068 matches[i]->valid = 0; 00069 } 00070 00071 return OK; 00072 } 00073 00074 WordContext* context; 00075 WordMatch** matches; 00076 // 00077 // Effective allocated size of the array 00078 // 00079 unsigned int size; 00080 // 00081 // Number of valid elements in the matches array. 00082 // 00083 unsigned int length; 00084 00085 }; 00086 00087 #endif /* _WordMatch_h */