00001
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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 }