00001
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef OM_HGUARD_OMQUERY_H
00026 #define OM_HGUARD_OMQUERY_H
00027
00028 #ifndef OM_HGUARD_OMTYPES_H
00029 #include "om/omtypes.h"
00030 #endif
00031 #ifndef OM_HGUARD_OMTERMLISTITERATOR_H
00032 #include "om/omtermlistiterator.h"
00033 #endif
00034
00038 class OmQuery {
00039 public:
00041 class Internal;
00043 Internal *internal;
00044
00046 typedef enum {
00048 OP_AND,
00049
00051 OP_OR,
00052
00054 OP_AND_NOT,
00055
00057 OP_XOR,
00058
00060 OP_AND_MAYBE,
00061
00063 OP_FILTER,
00064
00073 OP_NEAR,
00074
00083 OP_PHRASE,
00084
00091 OP_WEIGHT_CUTOFF,
00092
00096 OP_ELITE_SET
00097 } op;
00098
00100 OmQuery(const OmQuery & copyme);
00101
00103 OmQuery & operator=(const OmQuery & copyme);
00104
00113 OmQuery();
00114
00116 ~OmQuery();
00117
00119 OmQuery(const om_termname & tname_,
00120 om_termcount wqf_ = 1,
00121 om_termpos term_pos_ = 0);
00122
00124 OmQuery(OmQuery::op op_, const OmQuery & left, const OmQuery & right);
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00136 OmQuery(OmQuery::op op_,
00137 const om_termname & left, const om_termname & right);
00138
00149 template <class Iterator>
00150 OmQuery(OmQuery::op op_, Iterator qbegin, Iterator qend);
00151
00157 template <class SubQ>
00158 OmQuery(OmQuery::op op_, SubQ q);
00159
00162 void set_window(om_termpos window);
00163
00166 void set_cutoff(om_weight cutoff);
00167
00169 void set_elite_set_size(om_termcount size);
00170
00175 om_termcount get_length() const;
00176
00182 om_termcount set_length(om_termcount qlen);
00183
00189 OmTermIterator get_terms_begin() const;
00190
00194 OmTermIterator get_terms_end() const;
00195
00197
00198 bool is_empty() const;
00199
00203 std::string get_description() const;
00204
00205 private:
00206 void add_subquery(const OmQuery & subq);
00207 void add_subquery(const OmQuery * subq);
00208 void add_subquery(const om_termname & tname);
00209 void start_construction(OmQuery::op op_);
00210 void end_construction();
00211 void abort_construction();
00212 };
00213
00214 template <class Iterator>
00215 OmQuery::OmQuery(OmQuery::op op_, Iterator qbegin, Iterator qend) : internal(0)
00216 {
00217 try {
00218 start_construction(op_);
00219
00220
00221 while (qbegin != qend) {
00222 add_subquery(*qbegin);
00223 ++qbegin;
00224 }
00225
00226 end_construction();
00227 } catch (...) {
00228 abort_construction();
00229 throw;
00230 }
00231 }
00232
00233 template <class SubQ>
00234 OmQuery::OmQuery(OmQuery::op op_, SubQ q) : internal(0)
00235 {
00236 try {
00237 start_construction(op_);
00238 add_subquery(q);
00239 end_construction();
00240 } catch (...) {
00241 abort_construction();
00242 throw;
00243 }
00244 }
00245
00246 inline
00247 OmQuery::OmQuery(OmQuery::op op_,
00248 const om_termname & left,
00249 const om_termname & right) : internal(0)
00250 {
00251 try {
00252 start_construction(op_);
00253 add_subquery(left);
00254 add_subquery(right);
00255 end_construction();
00256 } catch (...) {
00257 abort_construction();
00258 throw;
00259 }
00260 }
00261
00262 #endif