Fix compilation failure with GCC 4.8
[xapian.git] / xapian-core / queryparser / termgenerator.cc
blobaab63e78491d1781e4e3374e8f55c727d8da4e11
1 /** @file termgenerator.cc
2 * @brief TermGenerator class implementation
3 */
4 /* Copyright (C) 2007,2012 Olly Betts
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #include <config.h>
23 #include <xapian/termgenerator.h>
24 #include <xapian/types.h>
25 #include <xapian/unicode.h>
27 #include "termgenerator_internal.h"
29 #include "str.h"
31 using namespace std;
32 using namespace Xapian;
34 TermGenerator::TermGenerator(const TermGenerator &) = default;
36 TermGenerator &
37 TermGenerator::operator=(const TermGenerator &) = default;
39 TermGenerator::TermGenerator(TermGenerator &&) = default;
41 TermGenerator &
42 TermGenerator::operator=(TermGenerator &&) = default;
44 TermGenerator::TermGenerator() : internal(new TermGenerator::Internal) { }
46 TermGenerator::~TermGenerator() { }
48 void
49 TermGenerator::set_stemmer(const Xapian::Stem & stemmer)
51 internal->stemmer = stemmer;
54 void
55 TermGenerator::set_stopper(const Xapian::Stopper * stopper)
57 internal->stopper = stopper;
60 void
61 TermGenerator::set_document(const Xapian::Document & doc)
63 internal->doc = doc;
64 internal->cur_pos = 0;
67 const Xapian::Document &
68 TermGenerator::get_document() const
70 return internal->doc;
73 void
74 TermGenerator::set_database(const Xapian::WritableDatabase &db)
76 internal->db = db;
79 TermGenerator::flags
80 TermGenerator::set_flags(flags toggle, flags mask)
82 TermGenerator::flags old_flags = internal->flags;
83 internal->flags = flags((old_flags & mask) ^ toggle);
84 return old_flags;
87 void
88 TermGenerator::set_stemming_strategy(stem_strategy strategy)
90 internal->strategy = strategy;
93 void
94 TermGenerator::set_stopper_strategy(stop_strategy strategy)
96 internal->stop_mode = strategy;
99 void
100 TermGenerator::set_max_word_length(unsigned max_word_length)
102 internal->max_word_length = max_word_length;
105 void
106 TermGenerator::index_text(const Xapian::Utf8Iterator & itor,
107 Xapian::termcount weight,
108 const string & prefix)
110 internal->index_text(itor, weight, prefix, true);
113 void
114 TermGenerator::index_text_without_positions(const Xapian::Utf8Iterator & itor,
115 Xapian::termcount weight,
116 const string & prefix)
118 internal->index_text(itor, weight, prefix, false);
121 void
122 TermGenerator::increase_termpos(Xapian::termpos delta)
124 internal->cur_pos += delta;
127 Xapian::termpos
128 TermGenerator::get_termpos() const
130 return internal->cur_pos;
133 void
134 TermGenerator::set_termpos(Xapian::termpos termpos)
136 internal->cur_pos = termpos;
139 string
140 TermGenerator::get_description() const
142 string s("Xapian::TermGenerator(stem=");
143 s += internal->stemmer.get_description();
144 if (internal->stopper.get()) {
145 s += ", stopper set";
147 s += ", doc=";
148 s += internal->doc.get_description();
149 s += ", termpos=";
150 s += str(internal->cur_pos);
151 s += ")";
152 return s;