00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef OM_HGUARD_DOCUMENT_H
00024 #define OM_HGUARD_DOCUMENT_H
00025
00026 #include <xapian/base.h>
00027 #include <xapian/types.h>
00028 #include "termlist.h"
00029 #include "database.h"
00030 #include "documentterm.h"
00031 #include <map>
00032 #include <string>
00033
00034 using namespace std;
00035
00036 class DocumentValueList;
00037 class ValueStreamDocument;
00038
00040 class Xapian::Document::Internal : public Xapian::Internal::RefCntBase {
00041 friend class ::DocumentValueList;
00042 friend class ::ValueStreamDocument;
00043 public:
00045 typedef map<Xapian::valueno, string> document_values;
00046
00048 typedef map<string, OmDocumentTerm> document_terms;
00049
00050 protected:
00052 Xapian::Internal::RefCntPtr<const Xapian::Database::Internal> database;
00053
00054 private:
00055
00056 Internal(const Internal &);
00057 Internal & operator=(const Internal &);
00058
00059 bool data_here;
00060 mutable bool values_here;
00061 mutable bool terms_here;
00062 mutable bool positions_modified;
00063
00065 string data;
00066
00068 mutable document_values values;
00069
00071 mutable document_terms terms;
00072
00073 protected:
00079 Xapian::docid did;
00080
00081 private:
00082
00083 virtual string do_get_value(Xapian::valueno ) const { return string(); }
00084 virtual void do_get_all_values(map<Xapian::valueno, string> & values_) const {
00085 values_.clear();
00086 }
00087 virtual string do_get_data() const { return string(); }
00088
00089 public:
00106 string get_value(Xapian::valueno slot) const;
00107
00113 void set_all_values(map<Xapian::valueno, string> & values_) {
00114
00115 swap(values, values_);
00116 values_here = true;
00117 }
00118
00119 Xapian::valueno values_count() const;
00120 void add_value(Xapian::valueno, const string &);
00121 void remove_value(Xapian::valueno);
00122 void clear_values();
00123 void add_posting(const string &, Xapian::termpos, Xapian::termcount);
00124 void add_term(const string &, Xapian::termcount);
00125 void remove_posting(const string &, Xapian::termpos, Xapian::termcount);
00126 void remove_term(const string &);
00127 void clear_terms();
00128 Xapian::termcount termlist_count() const;
00129
00143 string get_data() const;
00144
00145 void set_data(const string &);
00146
00155 TermList * open_term_list() const;
00156
00157 void need_values() const;
00158 void need_terms() const;
00159
00162 bool data_modified() const {
00163 return data_here;
00164 }
00165
00168 bool values_modified() const {
00169 return values_here;
00170 }
00171
00174 bool terms_modified() const {
00175 return terms_here;
00176 }
00177
00179 bool term_positions_modified() const {
00180 return positions_modified;
00181 }
00182
00184 bool modified() const {
00185 return terms_here || values_here || data_here;
00186 }
00187
00197 Xapian::docid get_docid() const { return did; }
00198
00200 string get_description() const;
00201
00207 Internal(Xapian::Internal::RefCntPtr<const Xapian::Database::Internal> database_,
00208 Xapian::docid did_)
00209 : database(database_), data_here(false), values_here(false),
00210 terms_here(false), positions_modified(false), did(did_) { }
00211
00212 Internal()
00213 : database(0), data_here(false), values_here(false),
00214 terms_here(false), positions_modified(false), did(0) { }
00215
00221 virtual ~Internal();
00222 };
00223
00224 #endif // OM_HGUARD_DOCUMENT_H