23 #ifndef XAPIAN_INCLUDED_DATABASEHELPERS_H 24 #define XAPIAN_INCLUDED_DATABASEHELPERS_H 50 const std::string& path,
68 A4 action_remote_prog,
79 std::ifstream stub(file.c_str());
81 std::string msg =
"Couldn't open stub database file: ";
86 unsigned int line_no = 0;
87 while (std::getline(stub, line)) {
89 if (line.empty() || line[0] ==
'#')
91 std::string::size_type space = line.find(
' ');
92 if (space == std::string::npos) space = line.size();
94 std::string type(line, 0, space);
95 line.erase(0, space + 1);
103 if (type ==
"chert") {
104 #ifdef XAPIAN_HAS_CHERT_BACKEND 114 if (type ==
"glass") {
115 #ifdef XAPIAN_HAS_GLASS_BACKEND 125 if (type ==
"remote" && !line.empty()) {
126 #ifdef XAPIAN_HAS_REMOTE_BACKEND 127 if (line[0] ==
':') {
131 space = line.find(
' ');
133 if (space != std::string::npos) {
134 args.assign(line, space + 1, std::string::npos);
135 line.assign(line, 1, space - 1);
139 action_remote_prog(line, args);
142 std::string::size_type colon = line.rfind(
':');
143 if (colon != std::string::npos) {
149 if (!(line[0] ==
'[' && line.back() ==
']')) {
150 unsigned int port = std::atoi(line.c_str() + colon + 1);
152 if (line[0] ==
'[' && line.back() ==
']') {
153 line.erase(line.size() - 1, 1);
156 action_remote_tcp(line, port);
161 (void)action_remote_prog;
162 (void)action_remote_tcp;
167 if (type ==
"inmemory" && line.empty()) {
168 #ifdef XAPIAN_HAS_INMEMORY_BACKEND 172 (void)action_inmemory;
177 if (type ==
"flint") {
178 auto msg =
"Flint backend no longer supported";
187 std::string msg = file;
DatabaseOpeningError indicates failure to open a database.
Convert types to std::string.
include <sys/stat.h> with portability enhancements
int test_if_single_file_db(const struct stat &sb, const std::string &path, int *fd_ptr)
Probe if a path is a single-file database.
Hierarchy of classes which Xapian can throw as exceptions.
Indicates an attempt to use a feature which is unavailable.
string str(int value)
Convert int to std::string.
Indicates an attempt to access a database not present.
void read_stub_file(const std::string &file, A1 action_auto, A2 action_chert, A3 action_glass, A4 action_remote_prog, A5 action_remote_tcp, A6 action_inmemory)
Open, read and process a stub database file.
void resolve_relative_path(string &path, const string &base)
Resolve path relative to base.
<unistd.h>, but with compat.
File and path manipulation routines.