srecord
1.65.0
|
The arglex class is used to implement a lexical analizer for command line arguments. More...
#include <arglex.h>
Classes | |
struct | table_ty |
The table_ty struct is used to repesent a row of a commandline option table, used to match option names with their corresponding tokens. More... | |
struct | value_ty |
The value_ty struct is used to represent the value of a command line argument. More... | |
Public Types | |
enum | { token_eoln , token_help , token_license , token_number , token_option , token_page_width , token_page_length , token_stdio , token_string , token_tracing , token_verbose , token_version , token_MAX } |
The "normal" command line tokens common to all programs. More... | |
Public Member Functions | |
virtual | ~arglex () |
The destructor. More... | |
void | fatal_error (const char *fmt,...) FORMAT_PRINTF(2 |
The fatal_error method may be used to print a fatal error message, and then exit via the usage() method. More... | |
void | test_ambiguous (void) const |
The test_ambiguous method is for debugging. More... | |
arglex () | |
The default constructor. More... | |
arglex (arglex &) | |
The copy constructor. More... | |
arglex (int argc, char **argv) | |
The normal constructor. More... | |
int | token_cur () const |
The token_cur method is used to get the type of the current token. More... | |
int | token_next (void) |
The token_next method is used to advance to the next command line option and determine what type of token it is. More... | |
int | token_first (void) |
The token_first method is used to fetch the fisrt command like token (rather than use the token_next method). More... | |
const std::string & | value_string () const |
The value_string method is used to get the string value of the current token. More... | |
long | value_number () const |
The value_number method is used to get the numeric value of the current token. More... | |
const char * | token_name (int tok) const |
The token_name method is used to turn a token type number into an equivalent string. More... | |
const char * | token_name () const |
The token_name method is used to obtain the name of the current token. More... | |
void | usage () const |
The usage method is used to print a usage summary. More... | |
void | help (const char *=0) const |
The help method is used to print a help message. More... | |
void | version () const |
The version method is used to print a version message. More... | |
void | license () const |
The license method is used to print the license conditions of the program. More... | |
void | bad_argument () const |
The bad_argument method is used to print an error message when the current token is inappropriate, then it calls usage, which exits. More... | |
void | usage_tail_set (const char *) |
The usage_tail_set method is used to set the end of the command line to be printed as part of the usage method. More... | |
virtual void | default_command_line_processing (void) |
The default_command_line_processing method is used to process command line arguments not handled by the derived class. More... | |
Static Public Member Functions | |
void static bool | compare (const char *formal, const char *actual) |
The compare class method is used to compare a command line string with a formal spec of the option, to see if they compare equal. More... | |
static std::string | abbreviate (const char *text) |
The abbreviate class method is used to take an option's long name, and turn it into the minimum possible string for that option. More... | |
Protected Member Functions | |
void | table_set (const table_ty *) |
The table_set method is used to append more command line token tables to the list of tables to be scanned. More... | |
void | deprecated_option (const std::string &formal_name) |
The deprecated_option method is used to nominate option patterns that are deprected. More... | |
The arglex class is used to implement a lexical analizer for command line arguments.
Each comamnd line argument is analized to determine if it is a number, a string (file name) or an option.
anonymous enum |
|
virtual |
The destructor.
srecord::arglex::arglex | ( | ) |
The default constructor.
srecord::arglex::arglex | ( | arglex & | ) |
The copy constructor.
srecord::arglex::arglex | ( | int | argc, |
char ** | argv | ||
) |
The normal constructor.
The argv and argv should be those passed to main(). Not manipulation is required.
void srecord::arglex::fatal_error | ( | const char * | fmt, |
... | |||
) |
The fatal_error method may be used to print a fatal error message, and then exit via the usage() method.
fmt | The format of the string - it controls the rest of the arguments. See printf(3) for more information. |
|
static |
The compare class method is used to compare a command line string with a formal spec of the option, to see if they compare equal.
The actual is case-insensitive. Uppercase in the formal means a mandatory character, while lower case means optional. Any number of consecutive optional characters may be supplied by actual, but none may be skipped, unless all are skipped to the next non-lower-case letter.
The underscore (_) is like a lower-case minus, it matches "", "-" and "_".
The "*" in a pattern matches everything to the end of the line, anything after the "*" is ignored. The rest of the line is pointed to by the "partial" variable as a side-effect (else it will be 0). This rather ugly feature is to support "-I./dir" type options.
A backslash in a pattern nominates an exact match required, case must matche excatly here. This rather ugly feature is to support "-I./dir" type options.
For example: "-project" and "-P" both match "-Project", as does "-proJ", but "-prj" does not.
For example: "-devDir" and "-d_d" both match "-Development_Directory", but "-dvlpmnt_drctry" does not.
For example: to match include path specifications, use a pattern such as "-\\I*", and the partial global variable will have the path in it on return.
|
static |
The abbreviate class method is used to take an option's long name, and turn it into the minimum possible string for that option.
void srecord::arglex::test_ambiguous | ( | void | ) | const |
The test_ambiguous method is for debugging.
It verifies that all of the option names are unique.
|
protected |
The table_set method is used to append more command line token tables to the list of tables to be scanned.
Usually one per derived class.
|
inline |
The token_cur method is used to get the type of the current token.
Definition at line 238 of file arglex.h.
Referenced by token_name().
int srecord::arglex::token_next | ( | void | ) |
The token_next method is used to advance to the next command line option and determine what type of token it is.
It returns the type of the token; this value may also be fetched using the token_cur method.
int srecord::arglex::token_first | ( | void | ) |
The token_first method is used to fetch the fisrt command like token (rather than use the token_next method).
This does standard "help" and "version" options.
|
inline |
|
inline |
const char* srecord::arglex::token_name | ( | int | tok | ) | const |
The token_name method is used to turn a token type number into an equivalent string.
Useful for some error messages.
tok | The ID of the token to be named. |
|
inline |
The token_name method is used to obtain the name of the current token.
Definition at line 280 of file arglex.h.
References token_cur(), and token_name().
Referenced by token_name().
void srecord::arglex::usage | ( | ) | const |
The usage method is used to print a usage summary.
This is a fatal error; this method does not return.
void srecord::arglex::help | ( | const char * | = 0 | ) | const |
The help method is used to print a help message.
void srecord::arglex::version | ( | ) | const |
The version method is used to print a version message.
void srecord::arglex::license | ( | ) | const |
The license method is used to print the license conditions of the program.
void srecord::arglex::bad_argument | ( | ) | const |
The bad_argument method is used to print an error message when the current token is inappropriate, then it calls usage, which exits.
This method does not return.
void srecord::arglex::usage_tail_set | ( | const char * | ) |
The usage_tail_set method is used to set the end of the command line to be printed as part of the usage method.
|
virtual |
The default_command_line_processing method is used to process command line arguments not handled by the derived class.
Reimplemented in srecord::arglex_tool.
|
protected |
The deprecated_option method is used to nominate option patterns that are deprected.
formal_name | The pattern that is deprected. Must be an entry in one of the tables, otherwise users are going to be VERY confused. |