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