00001 /* documentterm.h: internal class representing a term in a modified document 00002 * 00003 * Copyright 1999,2000,2001 BrightStation PLC 00004 * Copyright 2002 Ananova Ltd 00005 * Copyright 2003,2007 Olly Betts 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License as 00009 * published by the Free Software Foundation; either version 2 of the 00010 * License, or (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 00020 * USA 00021 */ 00022 00023 #ifndef OM_HGUARD_DOCUMENTTERM_H 00024 #define OM_HGUARD_DOCUMENTTERM_H 00025 00026 #include "debuglog.h" 00027 00028 #include <string> 00029 #include <vector> 00030 00031 #include <xapian/types.h> 00032 00033 using namespace std; 00034 00036 class OmDocumentTerm { 00037 public: 00043 OmDocumentTerm(const string & tname_, Xapian::termcount wdf_) 00044 : tname(tname_), wdf(wdf_) 00045 { 00046 LOGCALL_VOID(DB, "OmDocumentTerm::OmDocumentTerm", tname_ | wdf_); 00047 } 00048 00051 string tname; 00052 00056 Xapian::termcount wdf; 00057 00058 typedef vector<Xapian::termpos> term_positions; 00059 00073 term_positions positions; 00074 00085 void add_position(Xapian::termpos tpos); 00086 00096 void remove_position(Xapian::termpos tpos); 00097 00099 void inc_wdf(Xapian::termcount inc) { wdf += inc; } 00100 00102 void dec_wdf(Xapian::termcount dec) { 00103 if (wdf <= dec) { 00104 wdf = 0; 00105 } else { 00106 wdf -= dec; 00107 } 00108 } 00109 00111 Xapian::termcount get_wdf() const { return wdf; } 00112 00114 string get_description() const; 00115 }; 00116 00117 #endif // OM_HGUARD_DOCUMENTTERM_H