1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
|
/*
* Copyright 2005-2010 Fabrice Colin
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _QUERY_PROPERTIES_H
#define _QUERY_PROPERTIES_H
#include <string>
#include <set>
#include "Visibility.h"
using namespace std;
/// This represents a query.
class PINOT_EXPORT QueryProperties
{
public:
typedef enum { XAPIAN_QP = 0 } QueryType;
typedef enum { RELEVANCE = 0, DATE } SortOrder;
typedef enum { NOTHING = 0, ALL_RESULTS, NEW_RESULTS } IndexWhat;
QueryProperties();
QueryProperties(const string &name, const string &freeQuery,
QueryType type = XAPIAN_QP);
QueryProperties(const QueryProperties &other);
~QueryProperties();
QueryProperties &operator=(const QueryProperties &other);
bool operator==(const QueryProperties &other) const;
bool operator<(const QueryProperties &other) const;
/// Sets the name.
void setName(const string &name);
/// Gets the name.
string getName(void) const;
/// Sets the type.
void setType(QueryType type);
/// Gets the type.
QueryType getType(void) const;
/// Sets the sort order.
void setSortOrder(SortOrder order);
/// Gets the sort order.
SortOrder getSortOrder(void) const;
/// Sets the language to use for stemming.
void setStemmingLanguage(const string &language);
/// Gets the language to use for stemming.
string getStemmingLanguage(void) const;
/// Sets whether the query is sensitive to diacritics.
void setDiacriticSensitive(bool sensitive);
/// Gets whether the query is sensitive to diacritics.
bool getDiacriticSensitive(void) const;
/// Sets the query string.
void setFreeQuery(const string &freeQuery);
/// Gets the query string.
string getFreeQuery(bool withoutFilters = false) const;
/// Sets the maximum number of results.
void setMaximumResultsCount(unsigned int count);
/// Gets the maximum number of results.
unsigned int getMaximumResultsCount(void) const;
/// Sets whether results should be indexed.
void setIndexResults(IndexWhat indexResults);
/// Gets whether results should be indexed
IndexWhat getIndexResults(void) const;
/// Sets the name of the label to use for indexed documents.
void setLabelName(const string &labelName);
/// Gets the name of the label to use for indexed documents.
string getLabelName(void) const;
/// Sets whether the query was modified in some way.
void setModified(bool isModified);
/// Gets whether the query was modified in some way.
bool getModified(void) const;
/// Returns the query's terms.
void getTerms(set<string> &terms) const;
/// Returns whether the query is empty.
bool isEmpty() const;
protected:
string m_name;
QueryType m_type;
SortOrder m_order;
string m_language;
bool m_diacriticSensitive;
string m_freeQuery;
string m_freeQueryWithoutFilters;
unsigned int m_resultsCount;
IndexWhat m_indexResults;
string m_labelName;
bool m_modified;
void removeFilters(void);
};
#endif // _QUERY_PROPERTIES_H
|