2 * @brief Extract text and metadata using an external library.
4 /* Copyright (C) 2011,2022,2023 Olly Betts
5 * Copyright (C) 2019 Bruno Baruffaldi
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
23 #ifndef OMEGA_INCLUDED_HANDLER_H
24 #define OMEGA_INCLUDED_HANDLER_H
29 /** Called exactly once during helper start-up.
31 * This will be called before any calls to extract().
33 * Should return true if initialisation succeeds, false (or throw a C++
34 * exception) if it fails.
39 /** Extract information from the @a filename and store it in the
40 * corresponding variable.
42 * @param filename Path to the file.
43 * @param mimetype Mimetype of the file.
45 * Note: This function should only be used by an assistant process.
47 * See Worker::extract() for more details.
50 extract(const std::string
& filename
,
51 const std::string
& mimetype
);
69 /** Respond with extracted data.
71 * @param field FIELD_* code
72 * @param data pointer to field content
73 * @param len length of field content in bytes
76 send_field(Field field
, const char* data
, size_t len
);
78 /** Respond with extracted data.
80 * @param field FIELD_* code
81 * @param data pointer to nul-terminated field content
84 send_field(Field field
, const char* data
) {
85 if (data
) send_field(field
, data
, std::strlen(data
));
88 /** Respond with extracted data.
90 * @param field FIELD_* code
91 * @param data field content as std::string
94 send_field(Field field
, const std::string
& s
) {
95 send_field(field
, s
.data(), s
.size());
98 void send_field_page_count(int value
);
100 void send_field_created_date(time_t value
);
102 #endif // OMEGA_INCLUDED_HANDLER_H