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 
00057 class XAPIAN_VISIBILITY_DEFAULT Database {
00058     public:
00059         class Internal;
00061         std::vector<Xapian::Internal::RefCntPtr<Internal> > internal;
00062 
00068         void add_database(const Database & database);
00069 
00072         Database();
00073 
00079         explicit Database(const std::string &path);
00080 
00083         explicit Database(Internal *internal);
00084 
00090         virtual ~Database();
00091 
00095         Database(const Database &other);
00096 
00100         void operator=(const Database &other);
00101 
00107         void reopen();
00108 
00113         virtual std::string get_description() const;
00114 
00123         PostingIterator postlist_begin(const std::string &tname) const;
00124 
00127         PostingIterator postlist_end(const std::string &) const {
00128             return PostingIterator(NULL);
00129         }
00130 
00134         TermIterator termlist_begin(Xapian::docid did) const;
00135 
00138         TermIterator termlist_end(Xapian::docid) const {
00139             return TermIterator(NULL);
00140         }
00141 
00143         bool has_positions() const;
00144 
00148         PositionIterator positionlist_begin(Xapian::docid did, const std::string &tname) const;
00149 
00152         PositionIterator positionlist_end(Xapian::docid, const std::string &) const {
00153             return PositionIterator(NULL);
00154         }
00155 
00158         TermIterator allterms_begin() const;
00159 
00162         TermIterator allterms_end() const {
00163             return TermIterator(NULL);
00164         }
00165 
00167         Xapian::doccount get_doccount() const;
00168 
00170         Xapian::docid get_lastdocid() const;
00171 
00173         Xapian::doclength get_avlength() const;
00174 
00176         Xapian::doccount get_termfreq(const std::string & tname) const;
00177 
00184         bool term_exists(const std::string & tname) const;
00185 
00195         Xapian::termcount get_collection_freq(const std::string & tname) const;
00196 
00199         Xapian::doclength get_doclength(Xapian::docid did) const;
00200 
00204         void keep_alive();
00205 
00218         Xapian::Document get_document(Xapian::docid did) const;
00219 };
00220 
00223 class XAPIAN_VISIBILITY_DEFAULT WritableDatabase : public Database {
00224     public:
00231         virtual ~WritableDatabase();
00232 
00235         WritableDatabase();
00236 
00253         WritableDatabase(const std::string &path, int action);
00254 
00257         explicit WritableDatabase(Database::Internal *internal);
00258 
00262         WritableDatabase(const WritableDatabase &other);
00263 
00271         void operator=(const WritableDatabase &other);
00272 
00309         void flush();
00310 
00350         void begin_transaction(bool flushed=true);
00351 
00377         void commit_transaction();
00378 
00397         void cancel_transaction();
00398 
00427         Xapian::docid add_document(const Xapian::Document & document);
00428 
00450         void delete_document(Xapian::docid did);
00451 
00469         void delete_document(const std::string & unique_term);
00470 
00502         void replace_document(Xapian::docid did,
00503                               const Xapian::Document & document);
00504 
00536         Xapian::docid replace_document(const std::string & unique_term,
00537                                        const Xapian::Document & document);
00538 
00543         std::string get_description() const;
00544 };
00545 
00547 const int DB_CREATE_OR_OPEN = 1;
00549 const int DB_CREATE = 2;
00551 const int DB_CREATE_OR_OVERWRITE = 3;
00553 const int DB_OPEN = 4;
00554 // Can't see any sensible use for this one
00555 // const int DB_OVERWRITE = XXX;
00556 
00557 }
00558 
00559 #endif /* XAPIAN_INCLUDED_DATABASE_H */

Documentation for Xapian (version 1.0.0).
Generated on 18 May 2007 by Doxygen 1.4.6.