queryparser/queryparser_internal.h

Go to the documentation of this file.
00001 /* queryparser_internal.h: The non-lemon-generated parts of the QueryParser
00002  * class.
00003  *
00004  * Copyright (C) 2005,2006,2007 Olly Betts
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License as
00008  * published by the Free Software Foundation; either version 2 of the
00009  * License, or (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
00019  * USA
00020  */
00021 
00022 #ifndef XAPIAN_INCLUDED_QUERYPARSER_INTERNAL_H
00023 #define XAPIAN_INCLUDED_QUERYPARSER_INTERNAL_H
00024 
00025 #include <xapian/base.h>
00026 #include <xapian/database.h>
00027 #include <xapian/query.h>
00028 #include <xapian/queryparser.h>
00029 #include <xapian/stem.h>
00030 
00031 #include <list>
00032 #include <map>
00033 
00034 using namespace std;
00035 
00036 class State;
00037 
00039 struct PrefixInfo {
00041     bool filter;
00042 
00044     list<string> prefixes;
00045 
00046     PrefixInfo(bool filter_, const string & prefix)
00047         : filter(filter_)
00048     {
00049         prefixes.push_back(prefix);
00050     }
00051 };
00052 
00053 namespace Xapian {
00054 
00055 class Utf8Iterator;
00056 
00057 class QueryParser::Internal : public Xapian::Internal::RefCntBase {
00058     friend class QueryParser;
00059     friend class ::State;
00060     Stem stemmer;
00061     stem_strategy stem_action;
00062     const Stopper * stopper;
00063     Query::op default_op;
00064     const char * errmsg;
00065     Database db;
00066     list<string> stoplist;
00067     multimap<string, string> unstem;
00068 
00069     // Map "from" -> "A" ; "subject" -> "C" ; "newsgroups" -> "G" ;
00070     // "foobar" -> "XFOO". FIXME: it does more than this now!
00071     map<string, PrefixInfo> prefixmap;
00072 
00073     list<ValueRangeProcessor *> valrangeprocs;
00074 
00075     string corrected_query;
00076 
00077     void add_prefix(const string &field, const string &prefix, bool filter);
00078 
00079     std::string parse_term(Utf8Iterator &it, const Utf8Iterator &end,
00080                            bool &was_acronym);
00081 
00082   public:
00083     Internal() : stem_action(STEM_NONE), stopper(NULL),
00084         default_op(Query::OP_OR), errmsg(NULL) { }
00085     Query parse_query(const string & query_string, unsigned int flags, const string & default_prefix);
00086 };
00087 
00088 }
00089 
00090 #endif // XAPIAN_INCLUDED_QUERYPARSER_INTERNAL_H

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