home *** CD-ROM | disk | FTP | other *** search
/ Aminet 10 / aminetcdnumber101996.iso / Aminet / util / gnu / groff_src.lha / groff-1.10src / include / search.h < prev    next >
C/C++ Source or Header  |  1995-06-22  |  3KB  |  97 lines

  1. // -*- C++ -*-
  2. /* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
  3.      Written by James Clark (jjc@jclark.com)
  4.  
  5. This file is part of groff.
  6.  
  7. groff 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.
  11.  
  12. groff 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.
  16.  
  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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  20.  
  21. struct search_item;
  22. struct search_item_iterator;
  23.  
  24. class search_list {
  25. public:
  26.   search_list();
  27.   ~search_list();
  28.   void add_file(const char *fn, int silent = 0);
  29.   int nfiles() const;
  30. private:
  31.   search_item *list;
  32.   int niterators;
  33.   int next_fid;
  34.   friend class search_list_iterator;
  35. };
  36.  
  37. struct bmpattern;
  38.  
  39. class 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;
  50. public:
  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.  
  58. class search_list_iterator {
  59.   search_list *list;
  60.   search_item *ptr;
  61.   search_item_iterator *iter;
  62.   char *query;
  63.   linear_searcher searcher;
  64. public:
  65.   search_list_iterator(search_list *, const char *query);
  66.   ~search_list_iterator();
  67.   int next(const char **, int *, reference_id * = 0);
  68. };
  69.  
  70. class search_item {
  71. protected:
  72.   char *name;
  73.   int filename_id;
  74. public:
  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.  
  83. class search_item_iterator {
  84.   char shut_g_plus_plus_up;
  85. public:
  86.   virtual ~search_item_iterator();
  87.   virtual int next(const linear_searcher &, const char **ptr, int *lenp,
  88.            reference_id *) = 0;
  89. };
  90.  
  91. search_item *make_index_search_item(const char *filename, int fid);
  92. search_item *make_linear_search_item(int fd, const char *filename, int fid);
  93.  
  94. extern int linear_truncate_len;
  95. extern const char *linear_ignore_fields;
  96. extern int verify_flag;
  97.