Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

include/xapian/query.h

Go to the documentation of this file.
00001 
00024 #ifndef XAPIAN_INCLUDED_QUERY_H
00025 #define XAPIAN_INCLUDED_QUERY_H
00026 
00027 #include <xapian/types.h>
00028 
00029 namespace Xapian {
00030 
00031 class TermIterator;
00032 
00036 class Query {
00037   public:
00039     class Internal;
00041     Internal *internal;
00042 
00044     typedef enum {
00046         OP_AND,
00047 
00049         OP_OR,
00050 
00052         OP_AND_NOT,
00053 
00055         OP_XOR,
00056 
00058         OP_AND_MAYBE,
00059 
00061         OP_FILTER,
00062 
00071         OP_NEAR,
00072 
00081         OP_PHRASE,
00082 
00089         OP_WEIGHT_CUTOFF,
00090 
00094         OP_ELITE_SET
00095     } op;
00096 
00098     Query(const Query & copyme);
00099 
00101     Query & operator=(const Query & copyme);
00102 
00111     Query();
00112 
00114     ~Query();
00115 
00117     Query(const termname & tname, termcount wqf = 1, termpos term_pos = 0);
00118 
00120     Query(Query::op op_, const Query & left, const Query & right);
00121 
00123     Query(Query::op op_, const termname & left, const termname & right);
00124 
00135     template <class Iterator>
00136     Query(Query::op op_, Iterator qbegin, Iterator qend);
00137 
00143     template <class SubQ>
00144     Query(Query::op op_, SubQ q);
00145 
00148     void set_window(termpos window);
00149 
00152     void set_cutoff(weight cutoff);
00153 
00155     void set_elite_set_size(termcount size);
00156 
00161     termcount get_length() const;
00162 
00168     termcount set_length(termcount qlen);
00169 
00175     TermIterator get_terms_begin() const;
00176 
00180     TermIterator get_terms_end() const;
00181 
00183     //  an empty iterator ctor)
00184     bool is_empty() const;
00185             
00189     std::string get_description() const;
00190 
00191   private:
00192     void add_subquery(const Query & subq);
00193     void add_subquery(const Query * subq);
00194     void add_subquery(const termname & tname);
00195     void start_construction(Query::op op_);
00196     void end_construction();
00197     void abort_construction();
00198 };
00199 
00200 template <class Iterator>
00201 Query::Query(Query::op op_, Iterator qbegin, Iterator qend) : internal(0)
00202 {
00203     try {
00204         start_construction(op_);
00205 
00206         /* Add all the elements */
00207         while (qbegin != qend) {
00208             add_subquery(*qbegin);
00209             ++qbegin;
00210         }
00211 
00212         end_construction();
00213     } catch (...) {
00214         abort_construction();
00215         throw;
00216     }
00217 }
00218 
00219 template <class SubQ>
00220 Query::Query(Query::op op_, SubQ q) : internal(0)
00221 {
00222     try {
00223         start_construction(op_);
00224         add_subquery(q);
00225         end_construction();
00226     } catch (...) {
00227         abort_construction();
00228         throw;
00229     }
00230 }
00231 
00232 inline
00233 Query::Query(Query::op op_, const termname & left, const termname & right)
00234         : internal(0)
00235 {
00236     try {
00237         start_construction(op_);
00238         add_subquery(left);
00239         add_subquery(right);
00240         end_construction();
00241     } catch (...) {
00242         abort_construction();
00243         throw;
00244     }
00245 }
00246 
00247 };
00248 
00249 #endif

Documentation for Xapian (version 0.6.3).
Generated on 24 Dec 2002 by Doxygen 1.2.15.