00001
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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::doclength get_avlength() const;
00147
00149 Xapian::doccount get_termfreq(const std::string & tname) const;
00150
00157 bool term_exists(const std::string & tname) const;
00158
00168 Xapian::termcount get_collection_freq(const std::string & tname) const;
00169
00172 Xapian::doclength get_doclength(Xapian::docid did) const;
00173
00177 void keep_alive();
00178
00191 Xapian::Document get_document(Xapian::docid did) const;
00192 };
00193
00196 class WritableDatabase : public Database {
00197 public:
00204 virtual ~WritableDatabase();
00205
00208 WritableDatabase();
00209
00212 explicit WritableDatabase(Database::Internal *internal);
00213
00217 WritableDatabase(const WritableDatabase &other);
00218
00226 void operator=(const WritableDatabase &other);
00227
00269 void flush();
00270
00293 void begin_transaction();
00294
00321 void commit_transaction();
00322
00341 void cancel_transaction();
00342
00372 Xapian::docid add_document(const Xapian::Document & document);
00373
00376
00377 void delete_document(Xapian::docid did);
00378
00381
00382 void replace_document(Xapian::docid did, const Xapian::Document & document);
00383
00388 std::string get_description() const;
00389 };
00390
00391 const int DB_CREATE_OR_OPEN = 1;
00392 const int DB_CREATE = 2;
00393 const int DB_CREATE_OR_OVERWRITE = 3;
00394 const int DB_OPEN = 4;
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405 namespace Auto {
00411 Database open(const std::string &path);
00412
00425 WritableDatabase open(const std::string &path, int action);
00426
00434 Database open_stub(const std::string &file);
00435
00436 }
00437
00438 namespace Quartz {
00443 Database open(const std::string &dir);
00444
00459 WritableDatabase
00460 open(const std::string &dir, int action, int block_size = 8192);
00461
00462 }
00463
00464 namespace InMemory {
00467 WritableDatabase open();
00468 }
00469
00470 namespace Muscat36 {
00480 Database open_da(const std::string &R, const std::string &T, bool heavy_duty = true);
00481
00492 Database open_da(const std::string &R, const std::string &T, const std::string &values, bool heavy_duty = true);
00493
00502 Database open_db(const std::string &DB, size_t cache_size = 30);
00503
00513 Database open_db(const std::string &DB, const std::string &values = "", size_t cache_size = 30);
00514 }
00515
00516 namespace Remote {
00529 Database open(const std::string &program, const std::string &args,
00530 Xapian::timeout timeout = 10000);
00531
00548 Database
00549 open(const std::string &host, unsigned int port,
00550 Xapian::timeout timeout = 10000, Xapian::timeout connect_timeout = 0);
00551 }
00552
00553 }
00554
00555 #endif