# include/xapian/dbfactory.h File Reference

Factory functions for constructing Database and WritableDatabase objects. More...

`#include <string>`
`#include <xapian/types.h>`
`#include <xapian/database.h>`
`#include <xapian/version.h>`

Include dependency graph for dbfactory.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Namespaces

namespace | Xapian
namespace | Xapian::Auto
namespace | Xapian::InMemory
namespace | Xapian::Quartz
namespace | Xapian::Flint
namespace | Xapian::Remote

## Functions

Database | open_stub (const std::string &file)
| Construct a Database object for a stub database file.
Database | open (const std::string &path)
| Construct a Database object for read-only access to a Flint database.
WritableDatabase | open (const std::string &path, int action)
| Construct a WritableDatabase object for update access to a database.
WritableDatabase | open ()
| Construct a Database object for update access to an InMemory database.
Database | open (const std::string &dir)
| Construct a Database object for read-only access to a Quartz database.
WritableDatabase | open (const std::string &dir, int action, int block_size=8192)
| Construct a Database object for update access to a Quartz database.
Database | open (const std::string &dir)
| Construct a Database object for read-only access to a Flint database.
WritableDatabase | open (const std::string &dir, int action, int block_size=8192)
| Construct a Database object for update access to a Flint database.
Database | open (const std::string &host, unsigned int port, Xapian::timeout timeout=10000, Xapian::timeout connect_timeout=0)
| Construct a Database object for read-only access to a remote database accessed via a TCP connection.
Database | open (const std::string &program, const std::string &args, Xapian::timeout timeout=10000)
| Construct a Database object for read-only access to a remote database accessed via a program.

## Detailed Description

Factory functions for constructing Database and WritableDatabase objects.

## Function Documentation

Database open | ( | const std::string & | program,
|  | const std::string & | args,
|  | Xapian::timeout | timeout = `10000`
| ) |

Construct a Database object for read-only access to a remote database accessed via a program.

Access to the remote database is done by running an external program and communicating with it on stdin/stdout.

Parameters:

  | program | the external program to run.
  | arguments | space-separated list of arguments to pass to program.
  | timeout | timeout in milliseconds. If this timeout is exceeded for any individual operation on the remote database then Xapian::NetworkTimeoutError is thrown (default is 10000ms, which is 10 seconds).

Database open | ( | const std::string & | host,
|  | unsigned int | port,
|  | Xapian::timeout | timeout = `10000`,
|  | Xapian::timeout | connect_timeout = `0`
| ) |

Construct a Database object for read-only access to a remote database accessed via a TCP connection.

Access to the remote database is via a TCP connection to the specified host and port.

Parameters:

  | host | hostname to connect to.
  | port | port number to connect to.
  | timeout | timeout in milliseconds. If this timeout is exceeded for any individual operation on the remote database then Xapian::NetworkTimeoutError is thrown. (Default is 10000ms, which is 10 seconds).
  | connect_timeout | timeout to use when connecting to the server. If this timeout is exceeded then Xapian::NetworkTimeoutError is throw. (Default is to be the same as timeout).

WritableDatabase open | ( | const std::string & | dir,
|  | int | action,
|  | int | block_size = `8192`
| ) |

Construct a Database object for update access to a Flint database.

Parameters:

  | dir | pathname of the directory containing the database.

  action

  determines handling of existing/non-existing database:
  - Xapian::DB_CREATE fail if database already exist, otherwise create new database.
  - Xapian::DB_CREATE_OR_OPEN open existing database, or create new database if none exists.
  - Xapian::DB_CREATE_OR_OVERWRITE overwrite existing database, or create new database if none exists.
  - Xapian::DB_OPEN open existing database, failing if none exists.

  | block_size | the Btree blocksize to use (in bytes), which must be a power of two between 2048 and 65536 (inclusive). The default (also used if an invalid value if passed) is 8192 bytes. This parameter is ignored when opening an existing database.

Database open | ( | const std::string & | path | ) | `[inline]`

Construct a Database object for read-only access to a Flint database.

The appropriate database backend is chosen automatically.

Deprecated:
  This function is deprecated - use the Xapian::Database(path) constructor instead.

Parameters:

  | path | pathname of the file or directory containing the database.

WritableDatabase open | ( | const std::string & | dir,
|  | int | action,
|  | int | block_size = `8192`
| ) |

Construct a Database object for update access to a Quartz database.

Parameters:

  | dir | pathname of the directory containing the database.

  action

  determines handling of existing/non-existing database:
  - Xapian::DB_CREATE fail if database already exist, otherwise create new database.
  - Xapian::DB_CREATE_OR_OPEN open existing database, or create new database if none exists.
  - Xapian::DB_CREATE_OR_OVERWRITE overwrite existing database, or create new database if none exists.
  - Xapian::DB_OPEN open existing database, failing if none exists.

  | block_size | the Btree blocksize to use (in bytes), which must be a power of two between 2048 and 65536 (inclusive). The default (also used if an invalid value if passed) is 8192 bytes. This parameter is ignored when opening an existing database.

Database open | ( | const std::string & | path | ) | `[inline]`

Construct a Database object for read-only access to a Quartz database.

The appropriate database backend is chosen automatically.

Deprecated:
  This function is deprecated - use the Xapian::Database(path) constructor instead.

Parameters:

  | path | pathname of the file or directory containing the database.

WritableDatabase open | ( |  | ) |

| Construct a Database object for update access to an InMemory database. A new, empty database is created for each call.

WritableDatabase open | ( | const std::string & | path,
|  | int | action
| ) | `[inline]`

Construct a WritableDatabase object for update access to a database.

The appropriate database backend is chosen automatically.

Deprecated:
  This function is deprecated - use the Xapian::WritableDatabase(path, action) constructor instead.

Parameters:

  | path | pathname of the file or directory containing the database.

Database open | ( | const std::string & | path | ) | `[inline]`

Construct a Database object for read-only access to a Flint database.

The appropriate database backend is chosen automatically.

Deprecated:
  This function is deprecated - use the Xapian::Database(path) constructor instead.

Parameters:

  | path | pathname of the file or directory containing the database.

Database open_stub | ( | const std::string & | file | ) |

Construct a Database object for a stub database file.

The stub database file contains serialised parameters for one or more databases.

Parameters:

  | file | pathname of the stub database file.