man/l_roff-char.7.in: sprinkle *** (Dave Kemper)...
[s-roff.git] / include / search.h
blobbb69c47c28352f79645353eac7fc9db7d59f76cf
1 /*@
2 * Copyright (c) 2014 - 2017 Steffen (Daode) Nurpmeso <steffen@sdaoden.eu>.
4 * Copyright (C) 1989 - 1992, 2004 Free Software Foundation, Inc.
5 * Written by James Clark (jjc@jclark.com)
7 * This is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License as published by the Free
9 * Software Foundation; either version 2, or (at your option) any later
10 * version.
12 * This is distributed in the hope that it will be useful, but WITHOUT ANY
13 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with groff; see the file COPYING. If not, write to the Free Software
19 * Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA.
21 #ifndef _SEARCH_H
22 #define _SEARCH_H
24 #include "config.h"
26 class search_item;
27 class search_item_iterator;
29 class search_list
31 friend class search_list_iterator;
33 search_item *list;
34 int niterators;
35 int next_fid;
37 public:
38 search_list();
39 ~search_list();
40 void add_file(const char *fn, int silent = 0);
41 int nfiles() const;
44 class bmpattern;
46 class linear_searcher
48 const char *ignore_fields;
49 int truncate_len;
50 bmpattern **keys;
51 int nkeys;
53 const char *search_and_check(const bmpattern *key, const char *buf,
54 const char *bufend, const char **start = 0)
55 const;
56 int check_match(const char *buf, const char *bufend, const char *match,
57 int matchlen, const char **cont, const char **start)
58 const;
60 public:
61 linear_searcher(const char *query, int query_len,
62 const char *ign, int trunc);
63 ~linear_searcher();
64 int search(const char *buf, const char *bufend,
65 const char **startp, int *lengthp) const;
68 class search_list_iterator
70 search_list *list;
71 search_item *ptr;
72 search_item_iterator *iter;
73 char *query;
74 linear_searcher searcher;
76 public:
77 search_list_iterator(search_list *, const char *query);
78 ~search_list_iterator();
79 int next(const char **, int *, reference_id * = 0);
82 class search_item
84 protected:
85 char *name;
86 int filename_id;
88 public:
89 search_item *next;
90 search_item(const char *nm, int fid);
91 virtual search_item_iterator *make_search_item_iterator(const char *) = 0;
92 virtual ~search_item();
93 int is_named(const char *) const;
94 virtual int next_filename_id() const;
97 class search_item_iterator
99 char shut_g_plus_plus_up;
101 public:
102 virtual ~search_item_iterator();
103 virtual int next(const linear_searcher &, const char **ptr, int *lenp,
104 reference_id *) = 0;
107 search_item *make_index_search_item(const char *filename, int fid);
108 search_item *make_linear_search_item(int fd, const char *filename, int fid);
110 extern int linear_truncate_len;
111 extern const char *linear_ignore_fields;
112 extern int verify_flag;
114 #endif // _SEARCH_H
115 // s-it2-mode