?? options.cc
字號:
"\tfor this option indicates ``how many times larger or smaller'' the associated\n" "\tvalue range should be, in relationship to the number of keys, e.g. a value of 3\n" "\tmeans ``allow the maximum associated value to be about 3 times larger than the\n" "\tnumber of input keys.'' Conversely, a value of -3 means ``make the maximum\n" "\tassociated value about 3 times smaller than the number of input keys.\n" "\tA larger table should decrease the time required for an unsuccessful search,\n" "\tat the expense of extra table space. Default value is 1.\n" "-S\tCauses the generated C code to use a switch statement scheme, rather\n" "\tthan an array lookup table. This can lead to a reduction in both\n" "\ttime and space requirements for some keyfiles. The argument to\n" "\tthis option determines how many switch statements are generated.\n" "\tA value of 1 generates 1 switch containing all the elements, a value of 2\n" "\tgenerates 2 tables with 1/2 the elements in each table, etc. This\n" "\tis useful since many C compilers cannot correctly generate code for\n" "\tlarge switch statements.\n" "-t\tAllows the user to include a structured type declaration for \n" "\tgenerated code. Any text before %%%% is consider part of the type\n" "\tdeclaration. Key words and additional fields may follow this, one\n" "\tgroup of fields per line.\n" "-T\tPrevents the transfer of the type declaration to the output file.\n" "\tUse this option if the type is already defined elsewhere.\n" "-v\tPrints out the current version number\n" "-Z\tAllow user to specify name of generated C++ class. Default\n" "\tname is `Perfect_Hash.'\n%e%a", DEFAULT_JUMP_VALUE, (MAX_KEY_POS - 1), usage, 1); } case 'H': /* Sets the name for the hash function */ { hash_name = getopt.optarg; break; } case 'i': /* Sets the initial value for the associated values array. */ { if ((initial_asso_value = atoi (getopt.optarg)) < 0) report_error ("Initial value %d should be non-zero, ignoring and continuing.\n", initial_asso_value); if (option[RANDOM]) report_error ("warning, -r option superceeds -i, ignoring -i option and continuing\n"); break; } case 'j': /* Sets the jump value, must be odd for later algorithms. */ { if ((jump = atoi (getopt.optarg)) < 0) report_error ("Jump value %d must be a positive number.\n%e%a", jump, usage, 1); else if (jump && even (jump)) report_error ("Jump value %d should be odd, adding 1 and continuing...\n", jump++); break; } case 'k': /* Sets key positions used for hash function. */ { const int BAD_VALUE = -1; int value; Iterator expand (getopt.optarg, 1, MAX_KEY_POS - 1, WORD_END, BAD_VALUE, EOS); if (*getopt.optarg == '*') /* Use all the characters for hashing!!!! */ option_word = (option_word & ~DEFAULTCHARS) | ALLCHARS; else { char *key_pos; for (key_pos = key_positions; (value = expand ()) != EOS; key_pos++) if (value == BAD_VALUE) report_error ("Illegal key value or range, use 1,2,3-%d,'$' or '*'.\n%e%a", MAX_KEY_POS - 1, usage, 1); else *key_pos = value;; *key_pos = EOS; if (! (total_keysig_size = (key_pos - key_positions))) report_error ("No keys selected.\n%e%a", usage, 1); else if (! key_sort (key_positions, total_keysig_size)) report_error ("Duplicate keys selected\n%e%a", usage, 1); if (total_keysig_size != 2 || (key_positions[0] != 1 || key_positions[1] != WORD_END)) option_word &= ~DEFAULTCHARS; } break; } case 'K': /* Make this the keyname for the keyword component field. */ { key_name = getopt.optarg; break; } case 'l': /* Create length table to avoid extra string compares. */ { option_word |= LENTABLE; break; } case 'L': /* Deal with different generated languages. */ { option_word &= ~C; if (!strcmp (getopt.optarg, "C++")) option_word |= (CPLUSPLUS | ANSI); else if (!strcmp (getopt.optarg, "C")) option_word |= C; else { report_error ("unsupported language option %s, defaulting to C\n", getopt.optarg); option_word |= C; } break; } case 'n': /* Don't include the length when computing hash function. */ { option_word |= NOLENGTH; break; } case 'N': /* Make generated lookup function name be optarg */ { function_name = getopt.optarg; break; } case 'o': /* Order input by frequency of key set occurrence. */ { option_word |= ORDER; break; } case 'p': /* Generated lookup function now a pointer instead of int. */ { option_word |= POINTER; break; } case 'r': /* Utilize randomness to initialize the associated values table. */ { option_word |= RANDOM; if (option.initial_asso_value != 0) report_error ("warning, -r option superceeds -i, disabling -i option and continuing\n"); break; } case 's': /* Range of associated values, determines size of final table. */ { if (abs (size = atoi (getopt.optarg)) > 50) report_error ("%d is excessive, did you really mean this?! (type %n -h for help)\n", size); break; } case 'S': /* Generate switch statement output, rather than lookup table. */ { option_word |= SWITCH; if ((option.total_switches = atoi (getopt.optarg)) <= 0) report_error ("number of switches %s must be a positive number\n%e%a", getopt.optarg, usage, 1); break; } case 't': /* Enable the TYPE mode, allowing arbitrary user structures. */ { option_word |= TYPE; break; } case 'T': /* Don't print structure definition. */ { option_word |= NOTYPE; break; } case 'v': /* Print out the version and quit. */ report_error ("%n: version %s\n%e\n%a", version_string, usage, 1); case 'Z': /* Set the class name. */ { class_name = getopt.optarg; break; } default: report_error ("%e%a", usage, 1); } } if (argv[getopt.optind] && ! freopen (argv[getopt.optind], "r", stdin)) report_error ("Cannot open keyword file %p\n%e%a", argv[getopt.optind], usage, 1); if (++getopt.optind < argc) report_error ("Extra trailing arguments to %n.\n%e%a", usage, 1);}#ifndef __OPTIMIZE__/* TRUE if option enable, else FALSE. */int Options::operator[] (Option_Type option) { T (Trace t ("Options::operator[]");) return option_word & option;}/* Enables option OPT. */voidOptions::operator= (enum Option_Type opt) { T (Trace t ("Options::operator=");) option_word |= opt;}/* Disables option OPT. */voidOptions::operator!= (enum Option_Type opt) { T (Trace t ("Options::operator!=");) option_word &= ~opt;}/* Initializes the key Iterator. */void Options::reset (void) { T (Trace t ("Options::reset");) key_pos = 0;}/* Returns current key_position and advances index. */int Options::get (void) { T (Trace t ("Options::get");) return key_positions[key_pos++];}/* Sets the size of the table size. */void Options::set_asso_max (int r) { T (Trace t ("Options::set_asso_max");) size = r;}/* Returns the size of the table size. */int Options::get_asso_max (void) { T (Trace t ("Options::get_asso_max");) return size;}/* Returns total distinct key positions. */int Options::get_max_keysig_size (void) { T (Trace t ("Options::get_max_keysig_size");) return total_keysig_size;}/* Sets total distinct key positions. */voidOptions::set_keysig_size (int size) { T (Trace t ("Options::set_keysig_size");) total_keysig_size = size;}/* Returns the jump value. */int Options::get_jump (void) { T (Trace t ("Options::get_jump");) return jump;}/* Returns the lookup function name. */const char *Options::get_function_name (void) { T (Trace t ("Options::get_function_name");) return function_name;}/* Returns the keyword key name. */const char *Options::get_key_name (void) { T (Trace t ("Options::get_key_name");) return key_name;}/* Returns the hash function name. */const char *Options::get_hash_name (void) { T (Trace t ("Options::get_hash_name");) return hash_name;}/* Returns the generated class name. */const char *Options::get_class_name (void){ T (Trace t ("Options::get_class_name");) return class_name;}/* Returns the initial associated character value. */int Options::initial_value (void) { T (Trace t ("Options::initial_value");) return initial_asso_value;}/* Returns the iterations value. */int Options::get_iterations (void) { T (Trace t ("Options::get_iterations");) return iterations;}/* Returns the string used to delimit keywords from other attributes. */const char *Options::get_delimiter () { T (Trace t ("Options::get_delimiter");) return delimiters;}/* Gets the total number of switch statements to generate. */intOptions::get_total_switches () { T (Trace t ("Options::get_total_switches");) return total_switches;}#endif /* not defined __OPTIMIZE__ */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -