include/xapian/database.h

Go to the documentation of this file.
00001 
00004 /* Copyright 1999,2000,2001 BrightStation PLC
00005  * Copyright 2002 Ananova Ltd
00006  * Copyright 2002,2003,2004,2005,2006 Olly Betts
00007  *
00008  * This program is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU General Public License as
00010  * published by the Free Software Foundation; either version 2 of the
00011  * License, or (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
00021  * USA
00022  */
00023 
00024 #ifndef XAPIAN_INCLUDED_DATABASE_H
00025 #define XAPIAN_INCLUDED_DATABASE_H
00026 
00027 #include <string>
00028 #include <vector>
00029 
00030 #include <xapian/base.h>
00031 #include <xapian/types.h>
00032 #include <xapian/positioniterator.h>
00033 #include <xapian/postingiterator.h>
00034 #include <xapian/termiterator.h>
00035 
00037 namespace Xapian {
00038 
00039 class Document;
00040 
00051 class Database {
00052     public:
00058         void add_database(const Database & database);
00059 
00060     public:
00061         class Internal;
00063         std::vector<Xapian::Internal::RefCntPtr<Internal> > internal;
00064 
00065     public:
00068         Database();
00069 
00075         Database(const std::string &path);
00076 
00079         explicit Database(Internal *internal);
00080 
00086         virtual ~Database();
00087 
00091         Database(const Database &other);
00092 
00096         void operator=(const Database &other);
00097 
00103         void reopen();
00104 
00109         virtual std::string get_description() const;
00110 
00114         PostingIterator postlist_begin(const std::string &tname) const;
00115 
00118         PostingIterator postlist_end(const std::string &) const {
00119             return PostingIterator(NULL);
00120         }
00121 
00125         TermIterator termlist_begin(Xapian::docid did) const;
00126 
00129         TermIterator termlist_end(Xapian::docid) const {
00130             return TermIterator(NULL);
00131         }
00132 
00136         PositionIterator positionlist_begin(Xapian::docid did, const std::string &tname) const;
00137 
00140         PositionIterator positionlist_end(Xapian::docid, const std::string &) const {
00141             return PositionIterator(NULL);
00142         }
00143 
00146         TermIterator allterms_begin() const;
00147 
00150         TermIterator allterms_end() const {
00151             return TermIterator(NULL);
00152         }
00153 
00155         Xapian::doccount get_doccount() const;
00156 
00158         Xapian::docid get_lastdocid() const;
00159 
00161         Xapian::doclength get_avlength() const;
00162 
00164         Xapian::doccount get_termfreq(const std::string & tname) const;
00165 
00172         bool term_exists(const std::string & tname) const;
00173 
00183         Xapian::termcount get_collection_freq(const std::string & tname) const;
00184 
00187         Xapian::doclength get_doclength(Xapian::docid did) const;
00188 
00192         void keep_alive();
00193 
00206         Xapian::Document get_document(Xapian::docid did) const;
00207 };
00208 
00211 class WritableDatabase : public Database {
00212     public:
00219         virtual ~WritableDatabase();
00220 
00223         WritableDatabase();
00224 
00241         WritableDatabase(const std::string &path, int action);
00242 
00245         explicit WritableDatabase(Database::Internal *internal);
00246 
00250         WritableDatabase(const WritableDatabase &other);
00251 
00259         void operator=(const WritableDatabase &other);
00260 
00300         void flush();
00301 
00321         void begin_transaction();
00322 
00349         void commit_transaction();
00350 
00369         void cancel_transaction();
00370 
00394         Xapian::docid add_document(const Xapian::Document & document);
00395 
00417         void delete_document(Xapian::docid did);
00418 
00436         void delete_document(const std::string & unique_term);
00437 
00459         void replace_document(Xapian::docid did,
00460                               const Xapian::Document & document);
00461 
00493         Xapian::docid replace_document(const std::string & unique_term,
00494                                        const Xapian::Document & document);
00495 
00500         std::string get_description() const;
00501 };
00502 
00503 const int DB_CREATE_OR_OPEN = 1;
00504 const int DB_CREATE = 2;
00505 const int DB_CREATE_OR_OVERWRITE = 3;
00506 const int DB_OPEN = 4;
00507 // Can't see any sensible use for this one
00508 // const int DB_OVERWRITE = XXX;
00509 
00510 }
00511 
00512 #endif /* XAPIAN_INCLUDED_DATABASE_H */

Documentation for Xapian (version 0.9.6).
Generated on 15 May 2006 by Doxygen 1.4.6.