00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef OM_HGUARD_OMQUERY_H
00025 #define OM_HGUARD_OMQUERY_H
00026
00027 #ifndef OM_HGUARD_OMTYPES_H
00028 #include "om/omtypes.h"
00029 #endif
00030 #ifndef OM_HGUARD_OMTERMLISTITERATOR_H
00031 #include "om/omtermlistiterator.h"
00032 #endif
00033
00035
00036
00037
00038
00042 class OmQuery {
00043 public:
00045 class Internal;
00047 Internal *internal;
00048
00050 typedef enum {
00052 OP_AND,
00053
00055 OP_OR,
00056
00058 OP_AND_NOT,
00059
00061 OP_XOR,
00062
00064 OP_AND_MAYBE,
00065
00067 OP_FILTER,
00068
00077 OP_NEAR,
00078
00087 OP_PHRASE,
00088
00095 OP_WEIGHT_CUTOFF,
00096
00100 OP_ELITE_SET
00101 } op;
00102
00104 OmQuery(const OmQuery & copyme);
00105
00107 OmQuery & operator=(const OmQuery & copyme);
00108
00117 OmQuery();
00118
00120 ~OmQuery();
00121
00123 OmQuery(const om_termname & tname_,
00124 om_termcount wqf_ = 1,
00125 om_termpos term_pos_ = 0);
00126
00128 OmQuery(OmQuery::op op_, const OmQuery & left, const OmQuery & right);
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00140 OmQuery(OmQuery::op op_,
00141 const om_termname & left, const om_termname & right);
00142
00153 template <class Iterator>
00154 OmQuery(OmQuery::op op_, Iterator qbegin, Iterator qend);
00155
00161 template <class SubQ>
00162 OmQuery(OmQuery::op op_, SubQ q);
00163
00166 void set_window(om_termpos window);
00167
00170 void set_cutoff(om_weight cutoff);
00171
00173 void set_elite_set_size(om_termcount size);
00174
00179 om_termcount get_length() const;
00180
00186 om_termcount set_length(om_termcount qlen);
00187
00193 OmTermIterator get_terms_begin() const;
00194
00198 OmTermIterator get_terms_end() const;
00199
00201
00202 bool is_empty() const;
00203
00207 std::string get_description() const;
00208
00209 private:
00210 void add_subquery(const OmQuery & subq);
00211 void add_subquery(const OmQuery * subq);
00212 void add_subquery(const om_termname & tname);
00213 void start_construction(OmQuery::op op_);
00214 void end_construction();
00215 void abort_construction();
00216 };
00217
00218 template <class Iterator>
00219 OmQuery::OmQuery(OmQuery::op op_, Iterator qbegin, Iterator qend) : internal(0)
00220 {
00221 try {
00222 start_construction(op_);
00223
00224
00225 while (qbegin != qend) {
00226 add_subquery(*qbegin);
00227 ++qbegin;
00228 }
00229
00230 end_construction();
00231 } catch (...) {
00232 abort_construction();
00233 throw;
00234 }
00235 }
00236
00237 template <class SubQ>
00238 OmQuery::OmQuery(OmQuery::op op_, SubQ q) : internal(0)
00239 {
00240 try {
00241 start_construction(op_);
00242 add_subquery(q);
00243 end_construction();
00244 } catch (...) {
00245 abort_construction();
00246 throw;
00247 }
00248 }
00249
00250 inline
00251 OmQuery::OmQuery(OmQuery::op op_,
00252 const om_termname & left,
00253 const om_termname & right) : internal(0)
00254 {
00255 try {
00256 start_construction(op_);
00257 add_subquery(left);
00258 add_subquery(right);
00259 end_construction();
00260 } catch (...) {
00261 abort_construction();
00262 throw;
00263 }
00264 }
00265
00266 #endif
00267