PageRenderTime 56ms CodeModel.GetById 46ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 1ms

/contrib/groff/src/include/search.h

https://bitbucket.org/freebsd/freebsd-head/
C++ Header | 96 lines | 68 code | 9 blank | 19 comment | 0 complexity | 26d78a57c18a09f880cd140ba4cd2787 MD5 | raw file
 1// -*- C++ -*-
 2/* Copyright (C) 1989, 1990, 1991, 1992, 2004 Free Software Foundation, Inc.
 3     Written by James Clark (jjc@jclark.com)
 4
 5This file is part of groff.
 6
 7groff is free software; you can redistribute it and/or modify it under
 8the terms of the GNU General Public License as published by the Free
 9Software Foundation; either version 2, or (at your option) any later
10version.
11
12groff is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15for more details.
16
17You should have received a copy of the GNU General Public License along
18with groff; see the file COPYING.  If not, write to the Free Software
19Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
20
21class search_item;
22class search_item_iterator;
23
24class search_list {
25public:
26  search_list();
27  ~search_list();
28  void add_file(const char *fn, int silent = 0);
29  int nfiles() const;
30private:
31  search_item *list;
32  int niterators;
33  int next_fid;
34  friend class search_list_iterator;
35};
36
37class bmpattern;
38
39class linear_searcher {
40  const char *ignore_fields;
41  int truncate_len;
42  bmpattern **keys;
43  int nkeys;
44  const char *search_and_check(const bmpattern *key, const char *buf,
45			       const char *bufend, const char **start = 0)
46    const;
47  int check_match(const char *buf, const char *bufend, const char *match,
48		  int matchlen, const char **cont, const char **start)
49    const;
50public:
51  linear_searcher(const char *query, int query_len,
52		  const char *ign, int trunc);
53  ~linear_searcher();
54  int search(const char *buf, const char *bufend,
55	     const char **startp, int *lengthp) const;
56};
57
58class search_list_iterator {
59  search_list *list;
60  search_item *ptr;
61  search_item_iterator *iter;
62  char *query;
63  linear_searcher searcher;
64public:
65  search_list_iterator(search_list *, const char *query);
66  ~search_list_iterator();
67  int next(const char **, int *, reference_id * = 0);
68};
69
70class search_item {
71protected:
72  char *name;
73  int filename_id;
74public:
75  search_item *next;
76  search_item(const char *nm, int fid);
77  virtual search_item_iterator *make_search_item_iterator(const char *) = 0;
78  virtual ~search_item();
79  int is_named(const char *) const;
80  virtual int next_filename_id() const;
81};
82
83class search_item_iterator {
84  char shut_g_plus_plus_up;
85public:
86  virtual ~search_item_iterator();
87  virtual int next(const linear_searcher &, const char **ptr, int *lenp,
88		   reference_id *) = 0;
89};
90
91search_item *make_index_search_item(const char *filename, int fid);
92search_item *make_linear_search_item(int fd, const char *filename, int fid);
93
94extern int linear_truncate_len;
95extern const char *linear_ignore_fields;
96extern int verify_flag;