mirror of
https://git.savannah.gnu.org/git/gperf.git
synced 2025-12-02 21:19:24 +00:00
Align all member declarations.
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
2002-10-16 Bruno Haible <bruno@clisp.org>
|
||||||
|
|
||||||
|
* src/*.h: Align all member names at column 24.
|
||||||
|
|
||||||
2002-10-15 Bruno Haible <bruno@clisp.org>
|
2002-10-15 Bruno Haible <bruno@clisp.org>
|
||||||
|
|
||||||
* src/input.h: New file.
|
* src/input.h: New file.
|
||||||
|
|||||||
@@ -38,28 +38,28 @@ class Bool_Array
|
|||||||
public:
|
public:
|
||||||
/* Initializes the bit array with room for SIZE bits, numbered from
|
/* Initializes the bit array with room for SIZE bits, numbered from
|
||||||
0 to SIZE-1. */
|
0 to SIZE-1. */
|
||||||
Bool_Array (unsigned int size);
|
Bool_Array (unsigned int size);
|
||||||
|
|
||||||
/* Frees this object. */
|
/* Frees this object. */
|
||||||
~Bool_Array ();
|
~Bool_Array ();
|
||||||
|
|
||||||
/* Resets all bits to zero. */
|
/* Resets all bits to zero. */
|
||||||
void clear ();
|
void clear ();
|
||||||
|
|
||||||
/* Sets the specified bit to one. Returns its previous value (0 or 1). */
|
/* Sets the specified bit to one. Returns its previous value (0 or 1). */
|
||||||
int set_bit (unsigned int index);
|
int set_bit (unsigned int index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* Size of array. */
|
/* Size of array. */
|
||||||
unsigned int const _size;
|
unsigned int const _size;
|
||||||
|
|
||||||
/* Current iteration number. Always nonzero. Starts out as 1, and is
|
/* Current iteration number. Always nonzero. Starts out as 1, and is
|
||||||
incremented each time clear() is called. */
|
incremented each time clear() is called. */
|
||||||
unsigned int _iteration_number;
|
unsigned int _iteration_number;
|
||||||
|
|
||||||
/* For each index, we store in storage_array[index] the iteration_number at
|
/* For each index, we store in storage_array[index] the iteration_number at
|
||||||
the time set_bit(index) was last called. */
|
the time set_bit(index) was last called. */
|
||||||
unsigned int * const _storage_array;
|
unsigned int * const _storage_array;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __OPTIMIZE__ /* efficiency hack! */
|
#ifdef __OPTIMIZE__ /* efficiency hack! */
|
||||||
|
|||||||
@@ -31,21 +31,21 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
|
|||||||
class Gen_Perf : private Key_List
|
class Gen_Perf : private Key_List
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
int _max_hash_value; /* Maximum possible hash value. */
|
int _max_hash_value; /* Maximum possible hash value. */
|
||||||
int _fewest_collisions; /* Records fewest # of collisions for asso value. */
|
int _fewest_collisions; /* Records fewest # of collisions for asso value. */
|
||||||
int _num_done; /* Number of keywords processed without a collision. */
|
int _num_done; /* Number of keywords processed without a collision. */
|
||||||
Bool_Array *_collision_detector;
|
Bool_Array * _collision_detector;
|
||||||
|
|
||||||
void change (KeywordExt *prior, KeywordExt *curr);
|
void change (KeywordExt *prior, KeywordExt *curr);
|
||||||
int affects_prev (char c, KeywordExt *curr);
|
int affects_prev (char c, KeywordExt *curr);
|
||||||
static int hash (KeywordExt *key_node);
|
static int hash (KeywordExt *key_node);
|
||||||
static int compute_disjoint_union (const char *set_1, int size_1, const char *set_2, int size_2, char *set_3);
|
static int compute_disjoint_union (const char *set_1, int size_1, const char *set_2, int size_2, char *set_3);
|
||||||
static void sort_set (char *union_set, int len);
|
static void sort_set (char *union_set, int len);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Gen_Perf ();
|
Gen_Perf ();
|
||||||
~Gen_Perf ();
|
~Gen_Perf ();
|
||||||
int doit_all ();
|
int doit_all ();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -29,15 +29,15 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
|
|||||||
class Hash_Table
|
class Hash_Table
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
KeywordExt **_table; /* Vector of pointers to linked lists of keywords. */
|
KeywordExt ** _table; /* Vector of pointers to linked lists of keywords. */
|
||||||
int _size; /* Size of the vector. */
|
int _size; /* Size of the vector. */
|
||||||
int _collisions; /* Find out how well our double hashing is working! */
|
int _collisions; /* Find out how well our double hashing is working! */
|
||||||
int _ignore_length;
|
int _ignore_length;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Hash_Table (KeywordExt **t, int s, int ignore_len);
|
Hash_Table (KeywordExt **t, int s, int ignore_len);
|
||||||
~Hash_Table ();
|
~Hash_Table ();
|
||||||
KeywordExt *insert (KeywordExt *item);
|
KeywordExt * insert (KeywordExt *item);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
24
src/input.h
24
src/input.h
@@ -31,22 +31,22 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
|
|||||||
class Input : private Read_Line
|
class Input : private Read_Line
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void read_keys ();
|
void read_keys ();
|
||||||
private:
|
private:
|
||||||
#ifndef strcspn
|
#ifndef strcspn
|
||||||
static int strcspn (const char *s, const char *reject);
|
static int strcspn (const char *s, const char *reject);
|
||||||
#endif
|
#endif
|
||||||
void set_output_types ();
|
void set_output_types ();
|
||||||
const char *get_array_type ();
|
const char * get_array_type ();
|
||||||
const char *save_include_src ();
|
const char * save_include_src ();
|
||||||
const char *get_special_input (char delimiter);
|
const char * get_special_input (char delimiter);
|
||||||
public:
|
public:
|
||||||
const char *_array_type; /* Pointer to the type for word list. */
|
const char * _array_type; /* Pointer to the type for word list. */
|
||||||
const char *_return_type; /* Pointer to return type for lookup function. */
|
const char * _return_type; /* Pointer to return type for lookup function. */
|
||||||
const char *_struct_tag; /* Shorthand for user-defined struct tag type. */
|
const char * _struct_tag; /* Shorthand for user-defined struct tag type. */
|
||||||
const char *_include_src; /* C source code to be included verbatim. */
|
const char * _include_src; /* C source code to be included verbatim. */
|
||||||
int _additional_code; /* True if any additional C code is included. */
|
int _additional_code; /* True if any additional C code is included. */
|
||||||
KeywordExt_List *_head; /* Points to the head of the linked list. */
|
KeywordExt_List * _head; /* Points to the head of the linked list. */
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -36,46 +36,46 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
|
|||||||
class Key_List : public Vectors
|
class Key_List : public Vectors
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
const char *_array_type; /* Pointer to the type for word list. */
|
const char * _array_type; /* Pointer to the type for word list. */
|
||||||
const char *_return_type; /* Pointer to return type for lookup function. */
|
const char * _return_type; /* Pointer to return type for lookup function. */
|
||||||
const char *_struct_tag; /* Shorthand for user-defined struct tag type. */
|
const char * _struct_tag; /* Shorthand for user-defined struct tag type. */
|
||||||
const char *_include_src; /* C source code to be included verbatim. */
|
const char * _include_src; /* C source code to be included verbatim. */
|
||||||
int _max_key_len; /* Maximum length of the longest keyword. */
|
int _max_key_len; /* Maximum length of the longest keyword. */
|
||||||
int _min_key_len; /* Minimum length of the shortest keyword. */
|
int _min_key_len; /* Minimum length of the shortest keyword. */
|
||||||
private:
|
private:
|
||||||
int _occurrence_sort; /* True if sorting by occurrence. */
|
int _occurrence_sort; /* True if sorting by occurrence. */
|
||||||
int _hash_sort; /* True if sorting by hash value. */
|
int _hash_sort; /* True if sorting by hash value. */
|
||||||
protected:
|
protected:
|
||||||
int _additional_code; /* True if any additional C code is included. */
|
int _additional_code; /* True if any additional C code is included. */
|
||||||
private:
|
private:
|
||||||
int _list_len; /* Length of head's Key_List, not counting duplicates. */
|
int _list_len; /* Length of head's Key_List, not counting duplicates. */
|
||||||
protected:
|
protected:
|
||||||
int _total_keys; /* Total number of keys, counting duplicates. */
|
int _total_keys; /* Total number of keys, counting duplicates. */
|
||||||
int _size; /* Range of the hash table. */
|
int _size; /* Range of the hash table. */
|
||||||
private:
|
private:
|
||||||
static int _determined[MAX_ALPHA_SIZE]; /* Used in function reorder, below. */
|
static int _determined[MAX_ALPHA_SIZE]; /* Used in function reorder, below. */
|
||||||
static int get_occurrence (KeywordExt *ptr);
|
static int get_occurrence (KeywordExt *ptr);
|
||||||
static int already_determined (KeywordExt *ptr);
|
static int already_determined (KeywordExt *ptr);
|
||||||
static void set_determined (KeywordExt *ptr);
|
static void set_determined (KeywordExt *ptr);
|
||||||
void dump ();
|
void dump ();
|
||||||
KeywordExt_List *merge (KeywordExt_List *list1, KeywordExt_List *list2);
|
KeywordExt_List * merge (KeywordExt_List *list1, KeywordExt_List *list2);
|
||||||
KeywordExt_List *merge_sort (KeywordExt_List *head);
|
KeywordExt_List * merge_sort (KeywordExt_List *head);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
KeywordExt_List *_head; /* Points to the head of the linked list. */
|
KeywordExt_List * _head; /* Points to the head of the linked list. */
|
||||||
int _total_duplicates; /* Total number of duplicate hash values. */
|
int _total_duplicates; /* Total number of duplicate hash values. */
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Key_List ();
|
Key_List ();
|
||||||
~Key_List ();
|
~Key_List ();
|
||||||
int keyword_list_length ();
|
int keyword_list_length ();
|
||||||
int max_key_length ();
|
int max_key_length ();
|
||||||
void reorder ();
|
void reorder ();
|
||||||
void sort ();
|
void sort ();
|
||||||
void read_keys ();
|
void read_keys ();
|
||||||
int get_max_keysig_size ();
|
int get_max_keysig_size ();
|
||||||
void set_asso_max (int r) { _size = r; }
|
void set_asso_max (int r) { _size = r; }
|
||||||
int get_asso_max () { return _size; }
|
int get_asso_max () { return _size; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -30,15 +30,15 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
|
|||||||
class KeywordExt_List : private KeywordExt {
|
class KeywordExt_List : private KeywordExt {
|
||||||
public:
|
public:
|
||||||
/* Constructor. */
|
/* Constructor. */
|
||||||
KeywordExt_List (const char *allchars, int allchars_length, const char *rest);
|
KeywordExt_List (const char *allchars, int allchars_length, const char *rest);
|
||||||
|
|
||||||
/* Access to first element of list. */
|
/* Access to first element of list. */
|
||||||
KeywordExt* first () { return this; }
|
KeywordExt * first () { return this; }
|
||||||
/* Access to next element of list. */
|
/* Access to next element of list. */
|
||||||
KeywordExt_List *& rest () { return _cdr; }
|
KeywordExt_List *& rest () { return _cdr; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
KeywordExt_List * _cdr;
|
KeywordExt_List * _cdr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -30,51 +30,51 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
|
|||||||
struct Keyword
|
struct Keyword
|
||||||
{
|
{
|
||||||
/* Constructor. */
|
/* Constructor. */
|
||||||
Keyword (const char *allchars, int allchars_length, const char *rest);
|
Keyword (const char *allchars, int allchars_length, const char *rest);
|
||||||
|
|
||||||
/* Data members defined immediately by the input file. */
|
/* Data members defined immediately by the input file. */
|
||||||
/* The keyword as a string, possibly containing NUL bytes. */
|
/* The keyword as a string, possibly containing NUL bytes. */
|
||||||
const char *const _allchars;
|
const char *const _allchars;
|
||||||
const int _allchars_length;
|
const int _allchars_length;
|
||||||
/* Additional stuff seen on the same line of the input file. */
|
/* Additional stuff seen on the same line of the input file. */
|
||||||
const char *const _rest;
|
const char *const _rest;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* A keyword, in the context of a given keyposition list. */
|
/* A keyword, in the context of a given keyposition list. */
|
||||||
struct KeywordExt : public Keyword
|
struct KeywordExt : public Keyword
|
||||||
{
|
{
|
||||||
/* Constructor. */
|
/* Constructor. */
|
||||||
KeywordExt (const char *allchars, int allchars_length, const char *rest);
|
KeywordExt (const char *allchars, int allchars_length, const char *rest);
|
||||||
|
|
||||||
/* Data members depending on the keyposition list. */
|
/* Data members depending on the keyposition list. */
|
||||||
/* The selected characters that participate for the hash function,
|
/* The selected characters that participate for the hash function,
|
||||||
reordered according to the keyposition list. */
|
reordered according to the keyposition list. */
|
||||||
const char * _selchars;
|
const char * _selchars;
|
||||||
int _selchars_length;
|
int _selchars_length;
|
||||||
/* Chained list of keywords having the same selchars. */
|
/* Chained list of keywords having the same selchars. */
|
||||||
KeywordExt * _duplicate_link;
|
KeywordExt * _duplicate_link;
|
||||||
|
|
||||||
/* Methods depending on the keyposition list. */
|
/* Methods depending on the keyposition list. */
|
||||||
/* Initialize selchars and selchars_length, and update v->occurrences. */
|
/* Initialize selchars and selchars_length, and update v->occurrences. */
|
||||||
void init_selchars (Vectors *v);
|
void init_selchars (Vectors *v);
|
||||||
|
|
||||||
/* Data members used by the algorithm. */
|
/* Data members used by the algorithm. */
|
||||||
int _occurrence; /* A metric for frequency of key set occurrences. */
|
int _occurrence; /* A metric for frequency of key set occurrences. */
|
||||||
int _hash_value; /* Hash value for the key. */
|
int _hash_value; /* Hash value for the key. */
|
||||||
|
|
||||||
/* Data members used by the output routines. */
|
/* Data members used by the output routines. */
|
||||||
int _final_index;
|
int _final_index;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* A factory for creating Keyword instances. */
|
/* A factory for creating Keyword instances. */
|
||||||
class Keyword_Factory
|
class Keyword_Factory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Keyword_Factory ();
|
Keyword_Factory ();
|
||||||
virtual ~Keyword_Factory ();
|
virtual ~Keyword_Factory ();
|
||||||
/* Creates a new Keyword. */
|
/* Creates a new Keyword. */
|
||||||
virtual Keyword * create_keyword (const char *allchars, int allchars_length,
|
virtual Keyword * create_keyword (const char *allchars, int allchars_length,
|
||||||
const char *rest) = 0;
|
const char *rest) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -295,24 +295,24 @@ Options::print_options () const
|
|||||||
class PositionStringParser
|
class PositionStringParser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PositionStringParser (const char *str, int low_bound, int high_bound, int end_word_marker, int error_value, int end_marker);
|
PositionStringParser (const char *str, int low_bound, int high_bound, int end_word_marker, int error_value, int end_marker);
|
||||||
int nextPosition ();
|
int nextPosition ();
|
||||||
private:
|
private:
|
||||||
/* A pointer to the string provided by the user. */
|
/* A pointer to the string provided by the user. */
|
||||||
const char * _str;
|
const char * _str;
|
||||||
/* Smallest possible value, inclusive. */
|
/* Smallest possible value, inclusive. */
|
||||||
int const _low_bound;
|
int const _low_bound;
|
||||||
/* Greatest possible value, inclusive. */
|
/* Greatest possible value, inclusive. */
|
||||||
int const _high_bound;
|
int const _high_bound;
|
||||||
/* A value marking the abstract "end of word" ( usually '$'). */
|
/* A value marking the abstract "end of word" ( usually '$'). */
|
||||||
int const _end_word_marker;
|
int const _end_word_marker;
|
||||||
/* Error value returned when input is syntactically erroneous. */
|
/* Error value returned when input is syntactically erroneous. */
|
||||||
int const _error_value;
|
int const _error_value;
|
||||||
/* Value returned after last key is processed. */
|
/* Value returned after last key is processed. */
|
||||||
int const _end_marker;
|
int const _end_marker;
|
||||||
int _size;
|
int _size;
|
||||||
int _curr_value;
|
int _curr_value;
|
||||||
int _upper_bound;
|
int _upper_bound;
|
||||||
};
|
};
|
||||||
|
|
||||||
PositionStringParser::PositionStringParser (const char *str, int low_bound, int high_bound, int end_word_marker, int error_value, int end_marker)
|
PositionStringParser::PositionStringParser (const char *str, int low_bound, int high_bound, int end_word_marker, int error_value, int end_marker)
|
||||||
|
|||||||
108
src/options.h
108
src/options.h
@@ -108,34 +108,34 @@ class Positions
|
|||||||
friend class PositionIterator;
|
friend class PositionIterator;
|
||||||
public:
|
public:
|
||||||
/* Denotes the last char of a keyword, depending on the keyword's length. */
|
/* Denotes the last char of a keyword, depending on the keyword's length. */
|
||||||
static const int LASTCHAR = 0;
|
static const int LASTCHAR = 0;
|
||||||
|
|
||||||
/* Maximum size of the set. */
|
/* Maximum size of the set. */
|
||||||
static const int MAX_KEY_POS = 127;
|
static const int MAX_KEY_POS = 127;
|
||||||
|
|
||||||
/* Constructors. */
|
/* Constructors. */
|
||||||
Positions ();
|
Positions ();
|
||||||
Positions (int key1);
|
Positions (int key1);
|
||||||
Positions (int key1, int key2);
|
Positions (int key1, int key2);
|
||||||
|
|
||||||
/* Accessors. */
|
/* Accessors. */
|
||||||
int operator[] (unsigned int index) const;
|
int operator[] (unsigned int index) const;
|
||||||
unsigned int get_size () const;
|
unsigned int get_size () const;
|
||||||
|
|
||||||
/* Write access. */
|
/* Write access. */
|
||||||
unsigned char * pointer ();
|
unsigned char * pointer ();
|
||||||
void set_size (unsigned int size);
|
void set_size (unsigned int size);
|
||||||
|
|
||||||
/* Sorts the array in reverse order.
|
/* Sorts the array in reverse order.
|
||||||
Returns 1 if there are no duplicates, 0 otherwise. */
|
Returns 1 if there are no duplicates, 0 otherwise. */
|
||||||
int sort ();
|
int sort ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* Number of positions, excluding the terminating PositionIterator::EOS. */
|
/* Number of positions, excluding the terminating PositionIterator::EOS. */
|
||||||
unsigned int _size;
|
unsigned int _size;
|
||||||
/* Array of positions. 1 for the first char, 2 for the second char etc.,
|
/* Array of positions. 1 for the first char, 2 for the second char etc.,
|
||||||
LASTCHAR for the last char. PositionIterator::EOS past the end. */
|
LASTCHAR for the last char. PositionIterator::EOS past the end. */
|
||||||
unsigned char _positions[MAX_KEY_POS];
|
unsigned char _positions[MAX_KEY_POS];
|
||||||
};
|
};
|
||||||
|
|
||||||
/* This class denotes an iterator through a set of key positions. */
|
/* This class denotes an iterator through a set of key positions. */
|
||||||
@@ -144,17 +144,17 @@ class PositionIterator
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/* Initializes an iterator through POSITIONS. */
|
/* Initializes an iterator through POSITIONS. */
|
||||||
PositionIterator (Positions const& positions);
|
PositionIterator (Positions const& positions);
|
||||||
|
|
||||||
/* End of iteration marker. */
|
/* End of iteration marker. */
|
||||||
static const int EOS = Positions::MAX_KEY_POS;
|
static const int EOS = Positions::MAX_KEY_POS;
|
||||||
|
|
||||||
/* Retrieves the next position, or EOS past the end. */
|
/* Retrieves the next position, or EOS past the end. */
|
||||||
int next ();
|
int next ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Positions& _set;
|
const Positions& _set;
|
||||||
int _index;
|
int _index;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Class manager for gperf program Options. */
|
/* Class manager for gperf program Options. */
|
||||||
@@ -163,118 +163,118 @@ class Options
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/* Constructor. */
|
/* Constructor. */
|
||||||
Options ();
|
Options ();
|
||||||
|
|
||||||
/* Destructor. */
|
/* Destructor. */
|
||||||
~Options ();
|
~Options ();
|
||||||
|
|
||||||
/* Parses the options given in the command-line arguments. */
|
/* Parses the options given in the command-line arguments. */
|
||||||
void parse_options (int argc, char *argv[]);
|
void parse_options (int argc, char *argv[]);
|
||||||
|
|
||||||
/* Prints the given options. */
|
/* Prints the given options. */
|
||||||
void print_options () const;
|
void print_options () const;
|
||||||
|
|
||||||
/* Accessors. */
|
/* Accessors. */
|
||||||
|
|
||||||
/* Tests a given boolean option. Returns 1 if set, 0 otherwise. */
|
/* Tests a given boolean option. Returns 1 if set, 0 otherwise. */
|
||||||
int operator[] (Option_Type option) const;
|
int operator[] (Option_Type option) const;
|
||||||
|
|
||||||
/* Returns the iterations value. */
|
/* Returns the iterations value. */
|
||||||
int get_iterations () const;
|
int get_iterations () const;
|
||||||
|
|
||||||
/* Returns the jump value. */
|
/* Returns the jump value. */
|
||||||
int get_jump () const;
|
int get_jump () const;
|
||||||
|
|
||||||
/* Returns the initial associated character value. */
|
/* Returns the initial associated character value. */
|
||||||
int get_initial_asso_value () const;
|
int get_initial_asso_value () const;
|
||||||
|
|
||||||
/* Returns the total number of switch statements to generate. */
|
/* Returns the total number of switch statements to generate. */
|
||||||
int get_total_switches () const;
|
int get_total_switches () const;
|
||||||
|
|
||||||
/* Returns the factor by which to multiply the generated table's size. */
|
/* Returns the factor by which to multiply the generated table's size. */
|
||||||
int get_size_multiple () const;
|
int get_size_multiple () const;
|
||||||
|
|
||||||
/* Returns the generated function name. */
|
/* Returns the generated function name. */
|
||||||
const char * get_function_name () const;
|
const char * get_function_name () const;
|
||||||
|
|
||||||
/* Returns the keyword key name. */
|
/* Returns the keyword key name. */
|
||||||
const char * get_key_name () const;
|
const char * get_key_name () const;
|
||||||
|
|
||||||
/* Returns the struct initializer suffix. */
|
/* Returns the struct initializer suffix. */
|
||||||
const char * get_initializer_suffix () const;
|
const char * get_initializer_suffix () const;
|
||||||
|
|
||||||
/* Returns the generated class name. */
|
/* Returns the generated class name. */
|
||||||
const char * get_class_name () const;
|
const char * get_class_name () const;
|
||||||
|
|
||||||
/* Returns the hash function name. */
|
/* Returns the hash function name. */
|
||||||
const char * get_hash_name () const;
|
const char * get_hash_name () const;
|
||||||
|
|
||||||
/* Returns the hash table array name. */
|
/* Returns the hash table array name. */
|
||||||
const char * get_wordlist_name () const;
|
const char * get_wordlist_name () const;
|
||||||
|
|
||||||
/* Returns the string used to delimit keywords from other attributes. */
|
/* Returns the string used to delimit keywords from other attributes. */
|
||||||
const char * get_delimiter () const;
|
const char * get_delimiter () const;
|
||||||
|
|
||||||
/* Returns key positions. */
|
/* Returns key positions. */
|
||||||
const Positions& get_key_positions () const;
|
const Positions& get_key_positions () const;
|
||||||
|
|
||||||
/* Returns total distinct key positions. */
|
/* Returns total distinct key positions. */
|
||||||
int get_max_keysig_size () const;
|
int get_max_keysig_size () const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* Prints program usage to given stream. */
|
/* Prints program usage to given stream. */
|
||||||
void short_usage (FILE * stream) const;
|
void short_usage (FILE * stream) const;
|
||||||
|
|
||||||
/* Prints program usage to given stream. */
|
/* Prints program usage to given stream. */
|
||||||
void long_usage (FILE * stream) const;
|
void long_usage (FILE * stream) const;
|
||||||
|
|
||||||
/* Records count of command-line arguments. */
|
/* Records count of command-line arguments. */
|
||||||
int _argument_count;
|
int _argument_count;
|
||||||
|
|
||||||
/* Stores a pointer to command-line argument vector. */
|
/* Stores a pointer to command-line argument vector. */
|
||||||
char **_argument_vector;
|
char ** _argument_vector;
|
||||||
|
|
||||||
/* Holds the boolean options. */
|
/* Holds the boolean options. */
|
||||||
int _option_word;
|
int _option_word;
|
||||||
|
|
||||||
/* Amount to iterate when a collision occurs. */
|
/* Amount to iterate when a collision occurs. */
|
||||||
int _iterations;
|
int _iterations;
|
||||||
|
|
||||||
/* Jump length when trying alternative values. */
|
/* Jump length when trying alternative values. */
|
||||||
int _jump;
|
int _jump;
|
||||||
|
|
||||||
/* Initial value for asso_values table. */
|
/* Initial value for asso_values table. */
|
||||||
int _initial_asso_value;
|
int _initial_asso_value;
|
||||||
|
|
||||||
/* Number of switch statements to generate. */
|
/* Number of switch statements to generate. */
|
||||||
int _total_switches;
|
int _total_switches;
|
||||||
|
|
||||||
/* Factor by which to multiply the generated table's size. */
|
/* Factor by which to multiply the generated table's size. */
|
||||||
int _size_multiple;
|
int _size_multiple;
|
||||||
|
|
||||||
/* Names used for generated lookup function. */
|
/* Names used for generated lookup function. */
|
||||||
const char *_function_name;
|
const char * _function_name;
|
||||||
|
|
||||||
/* Name used for keyword key. */
|
/* Name used for keyword key. */
|
||||||
const char *_key_name;
|
const char * _key_name;
|
||||||
|
|
||||||
/* Suffix for empty struct initializers. */
|
/* Suffix for empty struct initializers. */
|
||||||
const char *_initializer_suffix;
|
const char * _initializer_suffix;
|
||||||
|
|
||||||
/* Name used for generated C++ class. */
|
/* Name used for generated C++ class. */
|
||||||
const char *_class_name;
|
const char * _class_name;
|
||||||
|
|
||||||
/* Name used for generated hash function. */
|
/* Name used for generated hash function. */
|
||||||
const char *_hash_name;
|
const char * _hash_name;
|
||||||
|
|
||||||
/* Name used for hash table array. */
|
/* Name used for hash table array. */
|
||||||
const char *_wordlist_name;
|
const char * _wordlist_name;
|
||||||
|
|
||||||
/* Separates keywords from other attributes. */
|
/* Separates keywords from other attributes. */
|
||||||
const char *_delimiters;
|
const char * _delimiters;
|
||||||
|
|
||||||
/* Contains user-specified key choices. */
|
/* Contains user-specified key choices. */
|
||||||
Positions _key_positions;
|
Positions _key_positions;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Global option coordinator for the entire program. */
|
/* Global option coordinator for the entire program. */
|
||||||
|
|||||||
50
src/output.h
50
src/output.h
@@ -34,46 +34,46 @@ struct Output_Compare;
|
|||||||
class Output
|
class Output
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Output (KeywordExt_List *head, const char *array_type, const char *return_type, const char *struct_tag, int additional_code, const char *include_src, int total_keys, int total_duplicates, int max_key_len, int min_key_len, Vectors *v);
|
Output (KeywordExt_List *head, const char *array_type, const char *return_type, const char *struct_tag, int additional_code, const char *include_src, int total_keys, int total_duplicates, int max_key_len, int min_key_len, Vectors *v);
|
||||||
void output ();
|
void output ();
|
||||||
private:
|
private:
|
||||||
void compute_min_max ();
|
void compute_min_max ();
|
||||||
int num_hash_values ();
|
int num_hash_values ();
|
||||||
void output_constants (struct Output_Constants&);
|
void output_constants (struct Output_Constants&);
|
||||||
void output_hash_function ();
|
void output_hash_function ();
|
||||||
void output_keylength_table ();
|
void output_keylength_table ();
|
||||||
void output_keyword_table ();
|
void output_keyword_table ();
|
||||||
void output_lookup_array ();
|
void output_lookup_array ();
|
||||||
void output_lookup_tables ();
|
void output_lookup_tables ();
|
||||||
void output_lookup_function_body (const struct Output_Compare&);
|
void output_lookup_function_body (const struct Output_Compare&);
|
||||||
void output_lookup_function ();
|
void output_lookup_function ();
|
||||||
|
|
||||||
/* Linked list of keywords. */
|
/* Linked list of keywords. */
|
||||||
KeywordExt_List *_head;
|
KeywordExt_List * _head;
|
||||||
|
|
||||||
/* Pointer to the type for word list. */
|
/* Pointer to the type for word list. */
|
||||||
const char *_array_type;
|
const char * _array_type;
|
||||||
/* Pointer to return type for lookup function. */
|
/* Pointer to return type for lookup function. */
|
||||||
const char *_return_type;
|
const char * _return_type;
|
||||||
/* Shorthand for user-defined struct tag type. */
|
/* Shorthand for user-defined struct tag type. */
|
||||||
const char *_struct_tag;
|
const char * _struct_tag;
|
||||||
/* True if any additional C code is included. */
|
/* True if any additional C code is included. */
|
||||||
int _additional_code;
|
int _additional_code;
|
||||||
/* C source code to be included verbatim. */
|
/* C source code to be included verbatim. */
|
||||||
const char *_include_src;
|
const char * _include_src;
|
||||||
/* Total number of keys, counting duplicates. */
|
/* Total number of keys, counting duplicates. */
|
||||||
int _total_keys;
|
int _total_keys;
|
||||||
/* Total number of duplicate hash values. */
|
/* Total number of duplicate hash values. */
|
||||||
int _total_duplicates;
|
int _total_duplicates;
|
||||||
/* Maximum length of the longest keyword. */
|
/* Maximum length of the longest keyword. */
|
||||||
int _max_key_len;
|
int _max_key_len;
|
||||||
/* Minimum length of the shortest keyword. */
|
/* Minimum length of the shortest keyword. */
|
||||||
int _min_key_len;
|
int _min_key_len;
|
||||||
/* Minimum hash value for all keywords. */
|
/* Minimum hash value for all keywords. */
|
||||||
int _min_hash_value;
|
int _min_hash_value;
|
||||||
/* Maximum hash value for all keywords. */
|
/* Maximum hash value for all keywords. */
|
||||||
int _max_hash_value;
|
int _max_hash_value;
|
||||||
Vectors * _v;
|
Vectors * _v;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -35,16 +35,16 @@ class Read_Line
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
/* Initializes the instance with a given input stream. */
|
/* Initializes the instance with a given input stream. */
|
||||||
Read_Line (FILE *stream = stdin) : _fp (stream) {}
|
Read_Line (FILE *stream = stdin) : _fp (stream) {}
|
||||||
|
|
||||||
/* Reads the next line and returns it, excluding the terminating newline,
|
/* Reads the next line and returns it, excluding the terminating newline,
|
||||||
and ignoring lines starting with '#'. Returns NULL on error or EOF.
|
and ignoring lines starting with '#'. Returns NULL on error or EOF.
|
||||||
The storage for the string is dynamically allocated and must be freed
|
The storage for the string is dynamically allocated and must be freed
|
||||||
through delete[]. */
|
through delete[]. */
|
||||||
char *read_next_line ();
|
char * read_next_line ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FILE * const _fp; /* FILE pointer to the input stream. */
|
FILE * const _fp; /* FILE pointer to the input stream. */
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __OPTIMIZE__
|
#ifdef __OPTIMIZE__
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ static const int MAX_ALPHA_SIZE = 256;
|
|||||||
|
|
||||||
struct Vectors
|
struct Vectors
|
||||||
{
|
{
|
||||||
static int ALPHA_SIZE; /* Size of alphabet. */
|
static int ALPHA_SIZE; /* Size of alphabet. */
|
||||||
static int _occurrences[MAX_ALPHA_SIZE]; /* Counts occurrences of each key set character. */
|
static int _occurrences[MAX_ALPHA_SIZE]; /* Counts occurrences of each key set character. */
|
||||||
static int _asso_values[MAX_ALPHA_SIZE]; /* Value associated with each character. */
|
static int _asso_values[MAX_ALPHA_SIZE]; /* Value associated with each character. */
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user