queryparser/termgenerator.cc

Go to the documentation of this file.
00001 
00004 /* Copyright (C) 2007 Olly Betts
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00019  */
00020 
00021 #include <config.h>
00022 
00023 #include <xapian/termgenerator.h>
00024 #include <xapian/types.h>
00025 #include <xapian/unicode.h>
00026 
00027 #include "termgenerator_internal.h"
00028 
00029 #include "utils.h"
00030 
00031 using namespace std;
00032 using namespace Xapian;
00033 
00034 TermGenerator::TermGenerator(const TermGenerator & o) : internal(o.internal) { }
00035 
00036 TermGenerator &
00037 TermGenerator::operator=(const TermGenerator & o) {
00038     internal = o.internal;
00039     return *this;
00040 }
00041 
00042 TermGenerator::TermGenerator() : internal(new TermGenerator::Internal) { }
00043 
00044 TermGenerator::~TermGenerator() { }
00045 
00046 void
00047 TermGenerator::set_stemmer(const Xapian::Stem & stemmer)
00048 {
00049     internal->stemmer = stemmer;
00050 }
00051 
00052 void
00053 TermGenerator::set_stopper(const Xapian::Stopper * stopper)
00054 {
00055     internal->stopper = stopper;
00056 }
00057 
00058 void
00059 TermGenerator::set_document(const Xapian::Document & doc)
00060 {
00061     internal->doc = doc;
00062     internal->termpos = 0;
00063 }
00064 
00065 const Xapian::Document &
00066 TermGenerator::get_document() const
00067 {
00068     return internal->doc;
00069 }
00070 
00071 void
00072 TermGenerator::set_database(const Xapian::WritableDatabase &db)
00073 {
00074     internal->db = db;
00075 }
00076 
00077 TermGenerator::flags
00078 TermGenerator::set_flags(flags toggle, flags mask)
00079 {
00080     TermGenerator::flags old_flags = internal->flags;
00081     internal->flags = flags((old_flags & mask) ^ toggle);
00082     return old_flags;
00083 }
00084 
00085 void
00086 TermGenerator::index_text(const Xapian::Utf8Iterator & itor,
00087                           Xapian::termcount weight,
00088                           const std::string & prefix)
00089 {
00090     internal->index_text(itor, weight, prefix, true);
00091 }
00092 
00093 void
00094 TermGenerator::index_text_without_positions(const Xapian::Utf8Iterator & itor,
00095                                             Xapian::termcount weight,
00096                                             const std::string & prefix)
00097 {
00098     internal->index_text(itor, weight, prefix, false);
00099 }
00100 
00101 void
00102 TermGenerator::increase_termpos(Xapian::termcount delta)
00103 {
00104     internal->termpos += delta;
00105 }
00106 
00107 Xapian::termcount
00108 TermGenerator::get_termpos() const
00109 {
00110     return internal->termpos;
00111 }
00112 
00113 void
00114 TermGenerator::set_termpos(Xapian::termcount termpos)
00115 {
00116     internal->termpos = termpos;
00117 }
00118 
00119 string
00120 TermGenerator::get_description() const
00121 {
00122     string s("Xapian::TermGenerator(");
00123     if (internal.get()) {
00124         s += "stem=";
00125         s += internal->stemmer.get_description();
00126         if (internal->stopper) {
00127             s += ", stopper set";
00128         }
00129         s += ", doc=";
00130         s += internal->doc.get_description();
00131         s += ", termpos=";
00132         s += om_tostring(internal->termpos);
00133     }
00134     s += ")";
00135     return s;
00136 }

Documentation for Xapian (version 1.0.10).
Generated on 24 Dec 2008 by Doxygen 1.5.2.