coan  6.0.1
A C/C++ Configuration Analyzer
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
options Struct Reference

Manages coan's commandline arguments. More...

#include <options.h>

Inheritance diagram for options:

Static Public Member Functions

static command_code get_command ()
 Get the operative coan command code.
 
static std::string const & exec_path ()
 Get our executable's full pathname, argv[0]
 
static std::string const & prog_name ()
 Get the program's name.
 
static std::string const & backup_suffix ()
 Get the file backup name suffix.
 
static bool got_opts ()
 Have we got all the options?
 
static bool replace ()
 Do we replace input files with output files?
 
static bool list_location ()
 Do we report file and line numbers for listed items?
 
static bool list_only_once ()
 Do we report only the first occurrence of listed items?
 
static bool list_once_per_file ()
 Do we report the listed items just once per input file?
 
static bool list_only_active ()
 Do we list items only from operative directives?
 
static bool list_only_inactive ()
 Do we list items only from inoperative directives?
 
static bool list_symbols_in_ifs ()
 Do we list items only from inoperative directives?
 
static bool list_symbols_in_defs ()
 Do we list symbols in #define directives?
 
static bool list_symbols_in_undefs ()
 Do we list symbols in #undef directives?
 
static bool list_symbols_in_includes ()
 Do we list symbols in #include directives?
 
static bool list_symbols_in_lines ()
 Do we list symbols in #line directives?
 
static bool list_system_includes ()
 Do we list system #include directives?
 
static bool list_local_includes ()
 Do we list local #include directives?
 
static bool complement ()
 Are we to output lines instead of dropping them and vice versa?
 
static bool eval_wip ()
 Do we evaluate constants in truth-functional contexts or treat them as unknowns.
 
static bool expand_references ()
 Do we report the expansions reported symbols?
 
static discard_policyget_discard_policy ()
 Get the policy for discarding lines.
 
static bool line_directives ()
 Do we output #line directives?
 
static bool plaintext ()
 Are we to omit parsing for C/C++ comments?
 
static bool recurse ()
 Do we recurse into directories?
 
static bool keep_going ()
 Shall we continue to process input files after errors?
 
static bool implicit ()
 Do we implicitly --undef all unconfigured symbols?
 
static bool no_transients ()
 
static bool explain_references ()
 Do we report the progressive expansion of symbol references?
 
static bool selected_symbols ()
 Is symbol reporting restricted to a selected set?
 
static unsigned & max_expansion ()
 Is symbol reporting restricted to a selected set?
 
static bool have_source_output ()
 Say whether the current comment generates source code.
 
static bool list_at_most_once_per_file ()
 Say whether items are reportable at most once per file.
 
static void parse_executable (char **argv)
 Parse the full and short names of the executable. More...
 
static void parse (int argc, char *argv[])
 Parse the commandline. More...
 
static bool diagnostic_gagged (unsigned reason)
 Say whether a diagnostic reason code is gagged.
 
static void finish ()
 Analyse the class global state after parsing the commandline. More...
 

Private Types

enum  option_codes {
  OPT_FILE = 'f', OPT_REPLACE = 'r', OPT_BACKUP = 'b', OPT_DEF = 'D',
  OPT_UNDEF = 'U', OPT_CONFLICT = 'x', OPT_GAG = 'g', OPT_VERBOSE = 'V',
  OPT_COMPLEMENT = 'c', OPT_EVALWIP = 'E', OPT_DISCARD = 'k', OPT_LINE = 1,
  OPT_POD = 'P', OPT_RECURSE = 'R', OPT_FILTER = 'F', OPT_KEEPGOING = 'K',
  OPT_IFS = 'i', OPT_DEFS = 'd', OPT_UNDEFS = 'u', OPT_INCLUDES = 2,
  OPT_LOCATE = 'L', OPT_ONCE = 'o', OPT_SYSTEM = 's', OPT_LOCAL = 'l',
  OPT_ACTIVE = 'A', OPT_INACTIVE = 'I', OPT_EXPAND = 3, OPT_IMPLICIT = 'm',
  OPT_DIR = 4, OPT_PREFIX = 'p', OPT_NO_TRANSIENTS = 5, OPT_EXPLAIN = 6,
  OPT_SELECT = 7, OPT_LNS = 8, OPT_EXPAND_MAX = 9, OPT_ONCE_PER_FILE = 10
}
 Symbolic constants for the options of all coan commands. More...
 

Static Private Member Functions

static void make_opts_list ()
 Assemble the shortopts arguments for getopts_long(). More...
 
static void config_diagnostics (std::string const &arg)
 Configure diagnostic output. More...
 
static void finalise_diagnostics ()
 Configure the final state of diagnostic output filtering. More...
 
static void error_invalid_opt (struct cmd_option const *cmd, int bad_opt)
 Raise a usage error when an option is invalid for the active command. More...
 
static void add_files (std::string const &path)
 Add files to the input dataset. More...
 
static void parse_file (std::string const &argsfile)
 Parse commandline options from a file. More...
 
static void parse_command_args (int argc, char *argv[])
 Parse the options to the active coan command. More...
 
static bool progress_gagged ()
 Say whether progress messages are suppressed.
 

Static Private Attributes

static struct option long_options []
 Array of structures specifying the valid options for all coan commands.
 
static char opts []
 Array in which we will assemble the shortopts arguments for getopts_long() More...
 
static struct cmd_option commands []
 Array of structures specifying the valid coan commands.
 
static int const source_cmd_exclusions []
 Excluded options for the source command. More...
 
static int const symbols_cmd_exclusions []
 Excluded options for the symbols command. More...
 
static int const includes_cmd_exclusions []
 Excluded options for the includes command. More...
 
static int const directives_cmd_exclusions []
 Excluded options for the directives command. More...
 
static int const defs_cmd_exclusions []
 Excluded options for the defs command. More...
 
static int const pragmas_cmd_exclusions []
 Excluded options for the pragmas command. More...
 
static int const errors_cmd_exclusions []
 Excluded options for the errors command. More...
 
static int const lines_cmd_exclusions []
 Excluded options for the lines command. More...
 
static int const spin_cmd_exclusions []
 Excluded options for the spin command. More...
 
static struct exclusion_list const cmd_exclusion_lists []
 Array of exclusion lists for the coan commands, indexed by command code.
 
static struct cmd_option_command_ = nullptr
 Pointer to the details of the operative coan command.
 
static std::string _exec_path_
 argv[0]
 
static std::string _prog_name_
 Filename element of exec_path
 
static std::string _backup_suffix_
 Suffix for backup files.
 
static bool _got_opts_ = false
 Have we got all commandline options?
 
static bool _replace_ = false
 Do we replace input files with output files?
 
static bool _list_locate_ = false
 Do we report file and line numbers for listed items?
 
static bool _list_only_once_ = false
 Do we report only the first occurrence of listed items?
 
static bool _list_once_per_file_ = false
 Do we report only the first occurrence per file of listed items?
 
static bool _list_only_active_ = false
 Do we list items only from kept lines?
 
static bool _list_only_inactive_ = false
 Do list items only from dropped lines?
 
static bool _list_symbols_in_ifs_ = false
 Do we list symbols in `#if/else/endif directives?
 
static bool _list_symbols_in_defs_ = false
 Do we list symbols in #define directives?
 
static bool _list_symbols_in_undefs_ = false
 Do we list symbols in #undef directives?
 
static bool _list_symbols_in_includes_ = false
 Do we list symbols in #include directives?
 
static bool _list_symbols_in_lines_ = false
 Do we list symbols in #line directives?
 
static bool _list_system_includes_ = false
 Do we list system #include directives?
 
static bool _list_local_includes_ = false
 Do we list local #include directives?
 
static bool _complement_ = false
 Are to output lines instead of dropping tem and vice versa?
 
static bool _eval_wip_ = false
 Do we evaluate constants in truth-functional contexts or treat them as unknowns?
 
static bool _expand_references_ = false
 Do we report the expansions of symbol references?
 
static discard_policy _discard_policy_
 Policy for discarding lines.
 
static bool _line_directives_ = false
 Do we output #line directives?
 
static bool _plaintext_ = false
 Are we to omit parsing for comments?
 
static bool _recurse_ = false
 Recurse into directories?
 
static bool _keepgoing_ = false
 Continue to process input files after errors.
 
static bool _implicit_ = false
 Do we implicitly --undef all unconfigured symbols?
 
static bool _no_transients_ = false
 
static bool _explain_references_ = false
 Do we report the derivation of symbol resolutions?
 
static bool _selected_symbols_ = false
 Is symbol reporting restricted to a selected set?
 
static unsigned _max_expansion_ = 4096
 Limit size for reported macro expansions.
 
static int _diagnostic_filter_ = 0
 Bitmask of diagnostic filters.
 
static std::vector< std::string > _argfile_argv_
 Array of options read from --file ARGFILE
 
static std::string _memfile_
 Read whole ARGFILE into this storage.
 
static int _cmd_line_files_ = 0
 The number of input files/dirs specified on the commandline.
 
static bool _parsing_file_ = false
 Are we parsing an argsfile ?
 

Detailed Description

Manages coan's commandline arguments.

Definition at line 98 of file options.cpp.

Member Enumeration Documentation

enum options::option_codes
private

Symbolic constants for the options of all coan commands.

Enumerator
OPT_FILE 

The --file option.

OPT_REPLACE 

The --replace option.

OPT_BACKUP 

The --backup option.

OPT_DEF 

The --define option.

OPT_UNDEF 

The --undefine option.

OPT_CONFLICT 

The --conflict option.

OPT_GAG 

The --gag option.

OPT_VERBOSE 

The --verbose option.

OPT_COMPLEMENT 

The --complement option.

OPT_EVALWIP 

The --eval-wip option.

OPT_DISCARD 

The --discard option.

OPT_LINE 

The --line option.

OPT_POD 

The --pod option.

OPT_RECURSE 

The --recurse option.

OPT_FILTER 

The --filter option.

OPT_KEEPGOING 

The --keepgoing option.

OPT_IFS 

The --ifs option.

OPT_DEFS 

The --defs option.

OPT_UNDEFS 

The --undefs option.

OPT_INCLUDES 

The --includes option.

OPT_LOCATE 

The --locate option.

OPT_ONCE 

The --once-only option.

OPT_SYSTEM 

The --system option.

OPT_LOCAL 

The --local option.

OPT_ACTIVE 

The --active option.

OPT_INACTIVE 

The --inactive option.

OPT_EXPAND 

The --expand option.

OPT_IMPLICIT 

The --implicit option.

OPT_DIR 

The --dir option.

OPT_PREFIX 

The --prefix option.

OPT_NO_TRANSIENTS 

The --no-transients option.

OPT_EXPLAIN 

The --explain option.

OPT_SELECT 

The --select option.

OPT_LNS 

The --lns option.

OPT_EXPAND_MAX 

The --max-expansion option.

OPT_ONCE_PER_FILE 

The --once-per-file option.

Definition at line 259 of file options.h.

Member Function Documentation

void options::add_files ( std::string const &  path)
staticprivate

Add files to the input dataset.

Parameters
pathFile or directory to be included in the input dataset.

If path is a file that satisfies any --filter option it is added to the input dataset.

If path is a directory and --recurse is in force then files recursively beneath it that satisfy any --filter option are added to the input dataset.

If path is a directory and --recurse is not in force then the directory is ignored.

Definition at line 350 of file options.cpp.

void options::config_diagnostics ( std::string const &  arg)
staticprivate

Configure diagnostic output.

Configure diagnostic outputs in response to a --gag or --verbose option.

Parameters
argEither "verbose" or an argument to the --gag option

Definition at line 275 of file options.cpp.

void options::error_invalid_opt ( struct cmd_option const *  cmd,
int  bad_opt 
)
staticprivate

Raise a usage error when an option is invalid for the active command.

Parameters
cmdPointer to details of the active coan command.
bad_optThe code of the invalid option.

Definition at line 340 of file options.cpp.

void options::finalise_diagnostics ( )
staticprivate

Configure the final state of diagnostic output filtering.

If no --gag or --verbose option has been seen, default to --gag info --gag summary.

Definition at line 326 of file options.cpp.

void options::finish ( )
static

Analyse the class global state after parsing the commandline.

Diagnose any errors and draw final conclusions.

Definition at line 731 of file options.cpp.

void options::make_opts_list ( )
staticprivate

Assemble the shortopts arguments for getopts_long().

The string is constructed by scanning the long_options array to avoid the need for manually maintaining agreement between that structure and the shortopts string..

Definition at line 252 of file options.cpp.

static bool options::no_transients ( )
inlinestatic

Do we suppress transient symbol configurations for in-source #define and #undef directives?

Definition at line 201 of file options.h.

void options::parse ( int  argc,
char *  argv[] 
)
static

Parse the commandline.

Parameters
argcThe number of commandline arguments.
argvArray of commandline arguments.

Definition at line 705 of file options.cpp.

void options::parse_command_args ( int  argc,
char *  argv[] 
)
staticprivate

Parse the options to the active coan command.

Parameters
argcThe number of arguments to be parsed.
argvThe array of arguments to be parsed.

Definition at line 382 of file options.cpp.

void options::parse_executable ( char **  argv)
static

Parse the full and short names of the executable.

Element 0 of argv is parsed to store the pathname and filename of our executable.

Parameters
argvThe array of commandline arguments.

Definition at line 694 of file options.cpp.

void options::parse_file ( std::string const &  argsfile)
staticprivate

Parse commandline options from a file.

Parse commandline options specified with the --file option.

Parameters
argsfileName of the file from which to read options.

Options are separated by whitespace in the file.

Definition at line 669 of file options.cpp.

Member Data Documentation

bool options::_no_transients_ = false
staticprivate

Do we suppress transient symbol configurations for in-source #define and #undef directives?

Definition at line 478 of file options.h.

int const options::defs_cmd_exclusions
staticprivate
Initial value:

Excluded options for the defs command.

Definition at line 327 of file options.h.

int const options::directives_cmd_exclusions
staticprivate
Initial value:

Excluded options for the directives command.

Definition at line 324 of file options.h.

int const options::errors_cmd_exclusions
staticprivate
Initial value:

Excluded options for the errors command.

Definition at line 333 of file options.h.

int const options::includes_cmd_exclusions
staticprivate
Initial value:

Excluded options for the includes command.

Definition at line 321 of file options.h.

int const options::lines_cmd_exclusions
staticprivate
Initial value:

Excluded options for the lines command.

Definition at line 336 of file options.h.

char options::opts
staticprivate

Array in which we will assemble the shortopts arguments for getopts_long()

We allow 3 bytes per short option, i,e, the short option code possibly followed by up to 2 colons.

Definition at line 309 of file options.h.

int const options::pragmas_cmd_exclusions
staticprivate
Initial value:

Excluded options for the pragmas command.

Definition at line 330 of file options.h.

int const options::source_cmd_exclusions
staticprivate
Initial value:

Excluded options for the source command.

Definition at line 315 of file options.h.

int const options::spin_cmd_exclusions
staticprivate
Initial value:

Excluded options for the spin command.

Definition at line 339 of file options.h.

int const options::symbols_cmd_exclusions
staticprivate
Initial value:

Excluded options for the symbols command.

Definition at line 318 of file options.h.


The documentation for this struct was generated from the following files: