xapian-core  1.4.26
dbfactory.h
Go to the documentation of this file.
1 
4 /* Copyright (C) 2005,2006,2007,2008,2009,2011,2013,2014,2016 Olly Betts
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of the
9  * License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
19  * USA
20  */
21 
22 #ifndef XAPIAN_INCLUDED_DBFACTORY_H
23 #define XAPIAN_INCLUDED_DBFACTORY_H
24 
25 #if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD
26 # error Never use <xapian/dbfactory.h> directly; include <xapian.h> instead.
27 #endif
28 
29 #ifndef _MSC_VER
30 # include <sys/types.h>
31 #endif
32 
33 #include <string>
34 
35 #include <xapian/constants.h>
36 #include <xapian/database.h>
37 #include <xapian/deprecated.h>
38 #include <xapian/types.h>
39 #include <xapian/version.h>
40 #include <xapian/visibility.h>
41 
42 namespace Xapian {
43 
44 #ifdef _MSC_VER
45 typedef unsigned useconds_t;
46 #endif
47 
49 namespace Auto {
50 
58 XAPIAN_DEPRECATED(Database open_stub(const std::string &file));
59 
60 inline Database
61 open_stub(const std::string &file)
62 {
63  return Database(file, DB_BACKEND_STUB);
64 }
65 
82 XAPIAN_DEPRECATED(WritableDatabase open_stub(const std::string &file, int action));
83 
84 inline WritableDatabase
85 open_stub(const std::string &file, int action)
86 {
87  return WritableDatabase(file, action|DB_BACKEND_STUB);
88 }
89 
90 }
91 
92 #ifdef XAPIAN_HAS_INMEMORY_BACKEND
93 namespace InMemory {
95 
102 
103 inline WritableDatabase
105 {
106  return WritableDatabase(std::string(), DB_BACKEND_INMEMORY);
107 }
108 
109 }
110 #endif
111 
112 #ifdef XAPIAN_HAS_CHERT_BACKEND
113 namespace Chert {
115 
120 XAPIAN_DEPRECATED(Database open(const std::string &dir));
121 
122 inline Database
123 open(const std::string &dir)
124 {
125  return Database(dir, DB_BACKEND_CHERT);
126 }
127 
146 XAPIAN_DEPRECATED(WritableDatabase open(const std::string &dir, int action, int block_size = 0));
147 
148 inline WritableDatabase
149 open(const std::string &dir, int action, int block_size)
150 {
151  return WritableDatabase(dir, action|DB_BACKEND_CHERT, block_size);
152 }
153 
154 }
155 #endif
156 
157 #ifdef XAPIAN_HAS_REMOTE_BACKEND
158 namespace Remote {
160 
161 #if defined __GNUC__ && defined __MINGW32__
162 // Avoid deprecation warnings about useconds_t on mingw.
163 # pragma GCC diagnostic push
164 # pragma GCC diagnostic ignored "-Wdeprecated-declarations"
165 #endif
166 
187 Database open(const std::string &host, unsigned int port, useconds_t timeout = 10000, useconds_t connect_timeout = 10000);
188 
209 WritableDatabase open_writable(const std::string &host, unsigned int port, useconds_t timeout = 0, useconds_t connect_timeout = 10000, int flags = 0);
210 
226 Database open(const std::string &program, const std::string &args, useconds_t timeout = 10000);
227 
243 WritableDatabase open_writable(const std::string &program, const std::string &args, useconds_t timeout = 0, int flags = 0);
244 
245 #if defined __GNUC__ && defined __MINGW32__
246 # pragma GCC diagnostic pop
247 #endif
248 
249 }
250 #endif
251 
252 }
253 
254 #endif /* XAPIAN_INCLUDED_DBFACTORY_H */
const int DB_BACKEND_INMEMORY
Use the "in memory" backend.
Definition: constants.h:195
The Xapian namespace contains public interfaces for the Xapian library.
Definition: compactor.cc:80
typedefs for Xapian
This class is used to access a database, or a group of databases.
Definition: database.h:68
unsigned timeout
A timeout value in milliseconds.
Definition: types.h:100
Constants in the Xapian namespace.
Define XAPIAN_DEPRECATED() and related macros.
#define XAPIAN_DEPRECATED(X)
#define XAPIAN_VISIBILITY_DEFAULT
Definition: visibility.h:28
This class provides read/write access to a database.
Definition: database.h:789
WritableDatabase open_writable(const std::string &program, const std::string &args, useconds_t timeout=0, int flags=0)
Construct a WritableDatabase object for update access to a remote database accessed via a program...
Define XAPIAN_VISIBILITY_* macros.
API for working with Xapian databases.
Define preprocessor symbols for the library version.
const int DB_BACKEND_STUB
Open a stub database file.
Definition: constants.h:179
Database open_stub(const std::string &file)
Construct a Database object for a stub database file.
Definition: dbfactory.h:61
Database open(const std::string &program, const std::string &args, useconds_t timeout=10000)
Construct a Database object for read-only access to a remote database accessed via a program...
const int DB_BACKEND_CHERT
Use the chert backend.
Definition: constants.h:170