Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class 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 00078 Database(const std::string &path); 00079 00082 explicit Database(Internal *internal); 00083 00089 virtual ~Database(); 00090 00094 Database(const Database &other); 00095 00099 void operator=(const Database &other); 00100 00106 void reopen(); 00107 00112 virtual std::string get_description() const; 00113 00117 PostingIterator postlist_begin(const std::string &tname) const; 00118 00121 PostingIterator postlist_end(const std::string &tname) const; 00122 00126 TermIterator termlist_begin(Xapian::docid did) const; 00127 00130 TermIterator termlist_end(Xapian::docid did) const; 00131 00135 PositionIterator positionlist_begin(Xapian::docid did, const std::string &tname) const; 00136 00139 PositionIterator positionlist_end(Xapian::docid did, const std::string &tname) const; 00140 00143 TermIterator allterms_begin() const; 00144 00147 TermIterator allterms_end() const; 00148 00150 Xapian::doccount get_doccount() const; 00151 00153 Xapian::docid get_lastdocid() const; 00154 00156 Xapian::doclength get_avlength() const; 00157 00159 Xapian::doccount get_termfreq(const std::string & tname) const; 00160 00167 bool term_exists(const std::string & tname) const; 00168 00178 Xapian::termcount get_collection_freq(const std::string & tname) const; 00179 00182 Xapian::doclength get_doclength(Xapian::docid did) const; 00183 00187 void keep_alive(); 00188 00201 Xapian::Document get_document(Xapian::docid did) const; 00202 }; 00203 00206 class WritableDatabase : public Database { 00207 public: 00214 virtual ~WritableDatabase(); 00215 00218 WritableDatabase(); 00219 00236 WritableDatabase(const std::string &path, int action); 00237 00240 explicit WritableDatabase(Database::Internal *internal); 00241 00245 WritableDatabase(const WritableDatabase &other); 00246 00254 void operator=(const WritableDatabase &other); 00255 00295 void flush(); 00296 00316 void begin_transaction(); 00317 00344 void commit_transaction(); 00345 00364 void cancel_transaction(); 00365 00389 Xapian::docid add_document(const Xapian::Document & document); 00390 00412 void delete_document(Xapian::docid did); 00413 00431 void delete_document(const std::string & unique_term); 00432 00454 void replace_document(Xapian::docid did, 00455 const Xapian::Document & document); 00456 00488 Xapian::docid replace_document(const std::string & unique_term, 00489 const Xapian::Document & document); 00490 00495 std::string get_description() const; 00496 }; 00497 00498 const int DB_CREATE_OR_OPEN = 1; 00499 const int DB_CREATE = 2; 00500 const int DB_CREATE_OR_OVERWRITE = 3; 00501 const int DB_OPEN = 4; 00502 // Can't see any sensible use for this one 00503 // const int DB_OVERWRITE = XXX; 00504 00505 /* It's mostly harmless to provide prototypes for all the backends, even 00506 * if they may not all be built in - it means the failure will be at 00507 * link time rather than when a file is built. The main benefit is 00508 * simplicity, but this also allows us to easily split the backends into 00509 * separate libraries and link the ones we actually use in an application. 00510 */ 00511 00512 namespace Auto { 00520 inline Database open(const std::string &path) { 00521 return Database(path); 00522 } 00523 00529 inline WritableDatabase open(const std::string &path, int action) { 00530 return WritableDatabase(path, action); 00531 } 00532 00540 Database open_stub(const std::string &file); 00541 00542 } 00543 00544 namespace Quartz { 00549 Database open(const std::string &dir); 00550 00566 WritableDatabase 00567 open(const std::string &dir, int action, int block_size = 8192); 00568 00569 } 00570 00571 namespace InMemory { 00574 WritableDatabase open(); 00575 } 00576 00577 namespace Muscat36 { 00587 Database open_da(const std::string &R, const std::string &T, bool heavy_duty = true); 00588 00599 Database open_da(const std::string &R, const std::string &T, const std::string &values, bool heavy_duty = true); 00600 00609 Database open_db(const std::string &DB, size_t cache_size = 30); 00610 00620 Database open_db(const std::string &DB, const std::string &values, size_t cache_size = 30); 00621 } 00622 00623 namespace Remote { 00636 Database open(const std::string &program, const std::string &args, 00637 Xapian::timeout timeout = 10000); 00638 00655 Database 00656 open(const std::string &host, unsigned int port, 00657 Xapian::timeout timeout = 10000, Xapian::timeout connect_timeout = 0); 00658 } 00659 00660 } 00661 00662 #endif /* XAPIAN_INCLUDED_DATABASE_H */

Documentation for Xapian (version 0.8.4).
Generated on 8 Dec 2004 by Doxygen 1.3.8.