turns printfs back on
[freebsd-src/fkvm-freebsd.git] / contrib / gperf / src / key-list.h
blob98b8fa5e0c849777cbc11a8763ed8fd6c8dc9a33
1 /* This may look like C code, but it is really -*- C++ -*- */
3 /* Data and function member declarations for the keyword list class.
5 Copyright (C) 1989-1998 Free Software Foundation, Inc.
6 written by Douglas C. Schmidt (schmidt@ics.uci.edu)
8 This file is part of GNU GPERF.
10 GNU GPERF is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 1, or (at your option)
13 any later version.
15 GNU GPERF is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with GNU GPERF; see the file COPYING. If not, write to the Free
22 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
24 /* The key word list is a useful abstraction that keeps track of
25 various pieces of information that enable that fast generation
26 of the Gen_Perf.hash function. A Key_List is a singly-linked
27 list of List_Nodes. */
29 #ifndef key_list_h
30 #define key_list_h 1
32 #include "list-node.h"
33 #include "vectors.h"
34 #include "read-line.h"
36 /* OSF/1 cxx needs these forward declarations. */
37 struct Output_Constants;
38 struct Output_Compare;
40 class Key_List : private Read_Line, public Vectors
42 private:
43 const char *array_type; /* Pointer to the type for word list. */
44 const char *return_type; /* Pointer to return type for lookup function. */
45 const char *struct_tag; /* Shorthand for user-defined struct tag type. */
46 const char *include_src; /* C source code to be included verbatim. */
47 int max_key_len; /* Maximum length of the longest keyword. */
48 int min_key_len; /* Minimum length of the shortest keyword. */
49 int min_hash_value; /* Minimum hash value for all keywords. */
50 int max_hash_value; /* Maximum hash value for all keywords. */
51 int occurrence_sort; /* True if sorting by occurrence. */
52 int hash_sort; /* True if sorting by hash value. */
53 int additional_code; /* True if any additional C code is included. */
54 int list_len; /* Length of head's Key_List, not counting duplicates. */
55 int total_keys; /* Total number of keys, counting duplicates. */
56 static int determined[MAX_ALPHA_SIZE]; /* Used in function reorder, below. */
57 static int get_occurrence (List_Node *ptr);
58 #ifndef strcspn
59 static int strcspn (const char *s, const char *reject);
60 #endif
61 static int already_determined (List_Node *ptr);
62 static void set_determined (List_Node *ptr);
63 void compute_min_max (void);
64 int num_hash_values (void);
65 void output_constants (struct Output_Constants&);
66 void output_hash_function (void);
67 void output_keylength_table (void);
68 void output_keyword_table (void);
69 void output_lookup_array (void);
70 void output_lookup_tables (void);
71 void output_lookup_function_body (const struct Output_Compare&);
72 void output_lookup_function (void);
73 void set_output_types (void);
74 void dump (void);
75 const char *get_array_type (void);
76 const char *save_include_src (void);
77 const char *get_special_input (char delimiter);
78 List_Node *merge (List_Node *list1, List_Node *list2);
79 List_Node *merge_sort (List_Node *head);
81 protected:
82 List_Node *head; /* Points to the head of the linked list. */
83 int total_duplicates; /* Total number of duplicate hash values. */
85 public:
86 Key_List (void);
87 ~Key_List (void);
88 int keyword_list_length (void);
89 int max_key_length (void);
90 void reorder (void);
91 void sort (void);
92 void read_keys (void);
93 void output (void);
96 #endif