common/document.h

Go to the documentation of this file.
00001 /* document.h: class with document data
00002  *
00003  * Copyright 1999,2000,2001 BrightStation PLC
00004  * Copyright 2002 Ananova Ltd
00005  * Copyright 2003,2004,2005,2007 Olly Betts
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License as
00009  * published by the Free Software Foundation; either version 2 of the
00010  * License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
00020  * USA
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 
00037 class Xapian::Document::Internal : public Xapian::Internal::RefCntBase {
00038     friend class Xapian::ValueIterator;
00039     public:
00041         typedef map<Xapian::valueno, string> document_values;
00042 
00044         typedef map<string, OmDocumentTerm> document_terms;
00045 
00046     private:
00047         // Prevent copying
00048         Internal(const Internal &);
00049         Internal & operator=(const Internal &);
00050 
00052         const Xapian::Database::Internal *database;
00053 
00054         bool data_here;
00055         mutable bool values_here; // FIXME mutable is a hack
00056         mutable bool terms_here;
00057 
00059         string data;
00060 
00062         mutable document_values values; // FIXME mutable is a hack
00063 
00065         mutable vector<Xapian::valueno> value_nos; // FIXME mutable is a hack
00066 
00068         mutable document_terms terms;
00069 
00070     protected:
00076         Xapian::docid did;
00077 
00078     private:
00079         // Functions for backend to implement
00080         virtual string do_get_value(Xapian::valueno /*valueno*/) const { return ""; }
00081         virtual map<Xapian::valueno, string> do_get_all_values() const {
00082             map<Xapian::valueno, string> none;
00083             return none;
00084         }
00085         virtual string do_get_data() const { return ""; }
00086 
00087     public:
00104         string get_value(Xapian::valueno valueid) const;
00105 
00106         Xapian::valueno values_count() const;
00107         void add_value(Xapian::valueno, const string &);
00108         void remove_value(Xapian::valueno);
00109         void clear_values();
00110         void add_posting(const string &, Xapian::termpos, Xapian::termcount);
00111         void add_term(const string &, Xapian::termcount);
00112         void remove_posting(const string &, Xapian::termpos, Xapian::termcount);
00113         void remove_term(const string &);
00114         void clear_terms();
00115         Xapian::termcount termlist_count() const;
00116 
00130         string get_data() const;        
00131 
00132         void set_data(const string &);
00133 
00142         TermList * open_term_list() const;
00143 
00144         void need_values() const;
00145         void need_terms() const;
00146 
00156         Xapian::docid get_docid() const { return did; }
00157 
00159         string get_description() const;
00160 
00166         Internal(const Xapian::Database::Internal *database_, Xapian::docid did_)
00167             : database(database_), data_here(false), values_here(false),
00168               terms_here(false), did(did_) { }
00169 
00170         Internal()
00171             : database(0), data_here(false), values_here(false),
00172               terms_here(false) { }
00173 
00179         virtual ~Internal() { }
00180 };
00181 
00182 #endif  // OM_HGUARD_DOCUMENT_H

Documentation for Xapian (version 1.0.10).
Generated on 24 Dec 2008 by Doxygen 1.5.2.