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,2007 Olly Betts
00007  * Copyright 2006 Richard Boulton
00008  *
00009  * This program is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU General Public License as
00011  * published by the Free Software Foundation; either version 2 of the
00012  * License, or (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
00022  * USA
00023  */
00024 
00025 #ifndef XAPIAN_INCLUDED_DATABASE_H
00026 #define XAPIAN_INCLUDED_DATABASE_H
00027 
00028 #include <string>
00029 #include <vector>
00030 
00031 #include <xapian/base.h>
00032 #include <xapian/types.h>
00033 #include <xapian/positioniterator.h>
00034 #include <xapian/postingiterator.h>
00035 #include <xapian/termiterator.h>
00036 #include <xapian/visibility.h>
00037 
00039 namespace Xapian {
00040 
00041 class Document;
00042 
00053 class XAPIAN_VISIBILITY_DEFAULT Database {
00054     public:
00055         class Internal;
00057         std::vector<Xapian::Internal::RefCntPtr<Internal> > internal;
00058 
00064         void add_database(const Database & database);
00065 
00068         Database();
00069 
00075         explicit 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 
00119         PostingIterator postlist_begin(const std::string &tname) const;
00120 
00123         PostingIterator postlist_end(const std::string &) const {
00124             return PostingIterator(NULL);
00125         }
00126 
00130         TermIterator termlist_begin(Xapian::docid did) const;
00131 
00134         TermIterator termlist_end(Xapian::docid) const {
00135             return TermIterator(NULL);
00136         }
00137 
00139         bool has_positions() const;
00140 
00144         PositionIterator positionlist_begin(Xapian::docid did, const std::string &tname) const;
00145 
00148         PositionIterator positionlist_end(Xapian::docid, const std::string &) const {
00149             return PositionIterator(NULL);
00150         }
00151 
00154         TermIterator allterms_begin() const;
00155 
00158         TermIterator allterms_end() const {
00159             return TermIterator(NULL);
00160         }
00161 
00163         Xapian::doccount get_doccount() const;
00164 
00166         Xapian::docid get_lastdocid() const;
00167 
00169         Xapian::doclength get_avlength() const;
00170 
00172         Xapian::doccount get_termfreq(const std::string & tname) const;
00173 
00180         bool term_exists(const std::string & tname) const;
00181 
00191         Xapian::termcount get_collection_freq(const std::string & tname) const;
00192 
00195         Xapian::doclength get_doclength(Xapian::docid did) const;
00196 
00200         void keep_alive();
00201 
00214         Xapian::Document get_document(Xapian::docid did) const;
00215 };
00216 
00219 class XAPIAN_VISIBILITY_DEFAULT WritableDatabase : public Database {
00220     public:
00227         virtual ~WritableDatabase();
00228 
00231         WritableDatabase();
00232 
00249         WritableDatabase(const std::string &path, int action);
00250 
00253         explicit WritableDatabase(Database::Internal *internal);
00254 
00258         WritableDatabase(const WritableDatabase &other);
00259 
00267         void operator=(const WritableDatabase &other);
00268 
00305         void flush();
00306 
00346         void begin_transaction(bool flushed=true);
00347 
00373         void commit_transaction();
00374 
00393         void cancel_transaction();
00394 
00423         Xapian::docid add_document(const Xapian::Document & document);
00424 
00446         void delete_document(Xapian::docid did);
00447 
00465         void delete_document(const std::string & unique_term);
00466 
00490         void replace_document(Xapian::docid did,
00491                               const Xapian::Document & document);
00492 
00524         Xapian::docid replace_document(const std::string & unique_term,
00525                                        const Xapian::Document & document);
00526 
00531         std::string get_description() const;
00532 };
00533 
00535 const int DB_CREATE_OR_OPEN = 1;
00537 const int DB_CREATE = 2;
00539 const int DB_CREATE_OR_OVERWRITE = 3;
00541 const int DB_OPEN = 4;
00542 // Can't see any sensible use for this one
00543 // const int DB_OVERWRITE = XXX;
00544 
00545 }
00546 
00547 #endif /* XAPIAN_INCLUDED_DATABASE_H */

Documentation for Xapian (version 0.9.10_svn8391).
Generated on 26 Apr 2007 by Doxygen 1.4.6.