xref: /netbsd-src/external/gpl2/gettext/dist/gettext-tools/src/msgl-fsearch.h (revision 946379e7b37692fc43f68eb0d1c10daa0a7f3b6c)
1 /* Fast fuzzy searching among messages.
2    Copyright (C) 2006 Free Software Foundation, Inc.
3    Written by Bruno Haible <bruno@clisp.org>, 2006.
4 
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 2, or (at your option)
8    any later version.
9 
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14 
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software Foundation,
17    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
18 
19 #ifndef _MSGL_FSEARCH_H
20 #define _MSGL_FSEARCH_H 1
21 
22 #include "message.h"
23 
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 /* A fuzzy index is a data structure that corresponds to a set of messages,
31    allowing for fuzzy searching of a message.  It is optimized for large sets
32    of messages.  */
33 typedef struct message_fuzzy_index_ty message_fuzzy_index_ty;
34 
35 /* Allocate a fuzzy index corresponding to a given list of messages.
36    The list of messages and the msgctxt and msgid fields of the messages
37    inside it must not be modified while the returned fuzzy index is in use.  */
38 extern message_fuzzy_index_ty *
39        message_fuzzy_index_alloc (const message_list_ty *mlp,
40 				  const char *canon_charset);
41 
42 /* Find a good match for the given msgctxt and msgid in the given fuzzy index.
43    The match does not need to be optimal.  */
44 extern message_ty *
45        message_fuzzy_index_search (message_fuzzy_index_ty *findex,
46 				   const char *msgctxt, const char *msgid);
47 
48 /* Free a fuzzy index.  */
49 extern void
50        message_fuzzy_index_free (message_fuzzy_index_ty *findex);
51 
52 
53 #ifdef __cplusplus
54 }
55 #endif
56 
57 #endif /* _MSGL_FSEARCH_H */
58