Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

/include/xapian/database.h

Go to the documentation of this file.
00001 
00004 /* ----START-LICENCE----
00005  * Copyright 1999,2000,2001 BrightStation PLC
00006  * Copyright 2002 Ananova Ltd
00007  * Copyright 2002,2003,2004 Olly Betts
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00022  * USA
00023  * -----END-LICENCE-----
00024  */
00025 
00026 #ifndef XAPIAN_INCLUDED_DATABASE_H
00027 #define XAPIAN_INCLUDED_DATABASE_H
00028 
00029 #include <string>
00030 #include <vector>
00031 
00032 #include <xapian/base.h>
00033 #include <xapian/types.h>
00034 
00036 namespace Xapian {
00037     
00038 class Document;
00039 class PositionIterator;
00040 class PostingIterator;
00041 class TermIterator;
00042 class WritableDatabase;
00043 
00054 class Database {
00055     public:
00061         void add_database(const Database & database);
00062     
00063     public:
00064         class Internal;
00066         std::vector<Xapian::Internal::RefCntPtr<Internal> > internal;
00067 
00068     public:
00071         Database();
00072 
00075         explicit Database(Internal *internal);
00076 
00082         virtual ~Database();
00083 
00087         Database(const Database &other);
00088 
00092         void operator=(const Database &other);
00093 
00099         void reopen();
00100 
00105         virtual std::string get_description() const;
00106 
00110         PostingIterator postlist_begin(const std::string &tname) const;
00111 
00114         PostingIterator postlist_end(const std::string &tname) const;
00115 
00119         TermIterator termlist_begin(Xapian::docid did) const;
00120         
00123         TermIterator termlist_end(Xapian::docid did) const;
00124 
00128         PositionIterator positionlist_begin(Xapian::docid did, const std::string &tname) const;
00129 
00132         PositionIterator positionlist_end(Xapian::docid did, const std::string &tname) const;
00133 
00136         TermIterator allterms_begin() const;
00137 
00140         TermIterator allterms_end() const;
00141 
00143         Xapian::doccount get_doccount() const;
00144 
00146         Xapian::docid get_lastdocid() const;
00147 
00149         Xapian::doclength get_avlength() const;
00150 
00152         Xapian::doccount get_termfreq(const std::string & tname) const;
00153 
00160         bool term_exists(const std::string & tname) const;
00161 
00171         Xapian::termcount get_collection_freq(const std::string & tname) const;
00172 
00175         Xapian::doclength get_doclength(Xapian::docid did) const;
00176 
00180         void keep_alive();
00181 
00194         Xapian::Document get_document(Xapian::docid did) const;
00195 };
00196 
00199 class WritableDatabase : public Database {
00200     public:
00207         virtual ~WritableDatabase();
00208 
00211         WritableDatabase();
00212 
00215         explicit WritableDatabase(Database::Internal *internal);
00216 
00220         WritableDatabase(const WritableDatabase &other);
00221 
00229         void operator=(const WritableDatabase &other);
00230 
00270         void flush();
00271 
00291         void begin_transaction();
00292 
00319         void commit_transaction();
00320 
00339         void cancel_transaction();
00340 
00364         Xapian::docid add_document(const Xapian::Document & document);
00365 
00387         void delete_document(Xapian::docid did);
00388 
00406         void delete_document(const std::string & unique_term);
00407 
00429         void replace_document(Xapian::docid did,
00430                               const Xapian::Document & document);
00431 
00463         Xapian::docid replace_document(const std::string & unique_term,
00464                                        const Xapian::Document & document);
00465 
00470         std::string get_description() const;
00471 };
00472 
00473 const int DB_CREATE_OR_OPEN = 1;
00474 const int DB_CREATE = 2;
00475 const int DB_CREATE_OR_OVERWRITE = 3;
00476 const int DB_OPEN = 4;
00477 // Can't see any sensible use for this one
00478 // const int DB_OVERWRITE = XXX;
00479 
00480 /* It's mostly harmless to provide prototypes for all the backends, even
00481  * if they may not all be built in - it means the failure will be at
00482  * link time rather than when a file is built.  The main benefit is
00483  * simplicity, but this also allows us to easily split the backends into
00484  * separate libraries and link the ones we actually use in an application.
00485  */
00486 
00487 namespace Auto {
00493 Database open(const std::string &path);
00494 
00507 WritableDatabase open(const std::string &path, int action);
00508 
00516 Database open_stub(const std::string &file);
00517 
00518 }
00519 
00520 namespace Quartz {
00525 Database open(const std::string &dir);
00526 
00541 WritableDatabase
00542 open(const std::string &dir, int action, int block_size = 8192);
00543 
00544 }
00545 
00546 namespace InMemory {
00549 WritableDatabase open();
00550 }
00551 
00552 namespace Muscat36 {
00562 Database open_da(const std::string &R, const std::string &T, bool heavy_duty = true);
00563 
00574 Database open_da(const std::string &R, const std::string &T, const std::string &values, bool heavy_duty = true);
00575 
00584 Database open_db(const std::string &DB, size_t cache_size = 30);
00585 
00595 Database open_db(const std::string &DB, const std::string &values = "", size_t cache_size = 30);
00596 }
00597 
00598 namespace Remote {
00611 Database open(const std::string &program, const std::string &args,
00612         Xapian::timeout timeout = 10000);
00613 
00630 Database
00631 open(const std::string &host, unsigned int port,
00632         Xapian::timeout timeout = 10000, Xapian::timeout connect_timeout = 0);
00633 }
00634 
00635 }
00636 
00637 #endif /* XAPIAN_INCLUDED_DATABASE_H */

Documentation for Xapian (version 0.8.2).
Generated on 13 Sep 2004 by Doxygen 1.2.15.