OpenASIP 2.2
|
#include <CmdLineParser.hh>
Public Member Functions | |
CmdLineParser (std::string description) | |
virtual | ~CmdLineParser () |
virtual void | parse (char *argv[], int argc) |
virtual void | parse (std::vector< std::string > options) |
virtual void | storeOptions (Options &options) |
virtual int | numberOfArguments () const |
virtual std::string | argument (int index) const |
Protected Member Functions | |
void | addOption (CmdLineOptionParser *opt) |
CmdLineOptionParser * | findOption (std::string name) const |
bool | parseOption (std::string option, std::string &name, std::string &arguments, std::string &prefix, bool &hasArgument) const |
bool | readPrefix (std::string &option, std::string &prefix, bool &longOption) const |
bool | isPrefix (std::string name) const |
Protected Attributes | |
std::map< std::string, CmdLineOptionParser * > | optionLongNames_ |
Database for holding options with their long names as a key. | |
std::map< std::string, CmdLineOptionParser * > | optionShortNames_ |
Database for holding options with their short names as a key. | |
std::vector< std::string > | commandLine_ |
Command line is stored here. | |
std::vector< std::string > | arguments_ |
Command line arguments are stored here. | |
std::vector< std::string > | prefixes_ |
Legal prefixes are stored here. | |
Private Types | |
typedef std::map< std::string, CmdLineOptionParser * >::value_type | valType |
For adding new values to maps. | |
typedef std::map< std::string, CmdLineOptionParser * >::iterator | mapIter |
For traversing non-const maps. | |
typedef std::map< std::string, CmdLineOptionParser * >::const_iterator | constMapIter |
For traversing const maps. | |
Private Member Functions | |
CmdLineParser (const CmdLineParser &) | |
Copying not allowed. | |
CmdLineParser & | operator= (const CmdLineParser &) |
Assignment not allowed. | |
void | parseAll () |
Private Attributes | |
std::string | progName_ |
The name of the program. | |
std::string | description_ |
The description of usage of program. | |
Static Private Attributes | |
static const int | SHORT_FLAG = 2 |
Number of characters reserved for printing short version of commandline flag. | |
static const int | LONG_FLAG = 22 |
Number of characters reserved for printing long version of commandline flag. | |
Abstract base class for command line parsers.
Is capable of storing and parsing commmand line options.
Definition at line 53 of file CmdLineParser.hh.
|
private |
For traversing const maps.
Definition at line 97 of file CmdLineParser.hh.
|
private |
For traversing non-const maps.
Definition at line 94 of file CmdLineParser.hh.
|
private |
For adding new values to maps.
Definition at line 92 of file CmdLineParser.hh.
CmdLineParser::CmdLineParser | ( | std::string | description | ) |
Constructor.
description | Brief description of the program and how to use it. Only prefix is currently "no-". |
Definition at line 59 of file CmdLineParser.cc.
References prefixes_.
|
virtual |
Destructor.
Definition at line 68 of file CmdLineParser.cc.
References commandLine_, optionLongNames_, and optionShortNames_.
|
private |
Copying not allowed.
|
protected |
Referenced by AsmCmdLineOptions::AsmCmdLineOptions(), BEMGeneratorCmdLineOptions::BEMGeneratorCmdLineOptions(), BuildOpsetOptions::BuildOpsetOptions(), CmdLineOptions::CmdLineOptions(), DictionaryToolCmdLineOptions::DictionaryToolCmdLineOptions(), DisasmCmdLineOptions::DisasmCmdLineOptions(), EstimatorCmdLineOptions::EstimatorCmdLineOptions(), ExplorerCmdLineOptions::ExplorerCmdLineOptions(), LLVMTCECmdLineOptions::LLVMTCECmdLineOptions(), MachInfoCmdLineOptions::MachInfoCmdLineOptions(), PIGCmdLineOptions::PIGCmdLineOptions(), ProGeCmdLineOptions::ProGeCmdLineOptions(), SchedulerCmdLineOptions::SchedulerCmdLineOptions(), SimulatorCmdLineOptions::SimulatorCmdLineOptions(), TestHDBCmdLineOptions::TestHDBCmdLineOptions(), and TTAUnitTesterCmdLineOptions::TTAUnitTesterCmdLineOptions().
|
virtual |
|
protected |
Try to find a particular option.
name | The name of the option. |
IllegalCommandLine | If option is not found. |
Definition at line 160 of file CmdLineParser.cc.
References optionLongNames_, and optionShortNames_.
Referenced by ExplorerCmdLineOptions::adfFile(), ExplorerCmdLineOptions::adfFileName(), TTAUnitTesterCmdLineOptions::adfFileName(), ExplorerCmdLineOptions::adfOutFile(), ExplorerCmdLineOptions::adfOutFileName(), LLVMTCECmdLineOptions::analyzeInstructionPatterns(), ExplorerCmdLineOptions::applicationIDToRemove(), ExplorerCmdLineOptions::applicationIDToRemoveCount(), LLVMTCECmdLineOptions::assumeADFStackAlignment(), ProGeCmdLineOptions::asyncReset(), LLVMTCECmdLineOptions::backendCacheDir(), SimulatorCmdLineOptions::backendType(), PIGCmdLineOptions::bemFile(), ProGeCmdLineOptions::bemFile(), SchedulerCmdLineOptions::bypassDistance(), ProGeCmdLineOptions::clockFrequency(), ProGeCmdLineOptions::commaSeparatedList(), ExplorerCmdLineOptions::compilerOptions(), ExplorerCmdLineOptions::compilerOptionsString(), PIGCmdLineOptions::compressorParameter(), PIGCmdLineOptions::compressorParameterCount(), PIGCmdLineOptions::compressorPlugin(), ExplorerCmdLineOptions::configurationToWrite(), LLVMTCECmdLineOptions::conservativePreRAScheduler(), PIGCmdLineOptions::dataImageOutputFormat(), PIGCmdLineOptions::dataMemoryWidthInMAUs(), PIGCmdLineOptions::dataStart(), LLVMTCECmdLineOptions::dataStartAddress(), LLVMTCECmdLineOptions::debugFlag(), SimulatorCmdLineOptions::debugMode(), ProGeCmdLineOptions::deviceFamilyName(), ProGeCmdLineOptions::deviceName(), LLVMTCECmdLineOptions::disableAddressSpaceAA(), LLVMTCECmdLineOptions::disableDelaySlotFiller(), LLVMTCECmdLineOptions::disableHWLoops(), LLVMTCECmdLineOptions::disableLLVMAA(), ProGeCmdLineOptions::dmemType(), DictionaryToolCmdLineOptions::doNotPrintErrors(), LLVMTCECmdLineOptions::dumpDDGsDot(), LLVMTCECmdLineOptions::dumpDDGsXML(), SchedulerCmdLineOptions::dumpIfConversionCFGs(), SchedulerCmdLineOptions::enableOffsetAA(), SchedulerCmdLineOptions::enableStackAA(), PIGCmdLineOptions::entityName(), ProGeCmdLineOptions::entityName(), ExplorerCmdLineOptions::explorerPlugin(), ExplorerCmdLineOptions::explorerPluginParameter(), ExplorerCmdLineOptions::explorerPluginParameterCount(), DisasmCmdLineOptions::flatFile(), ProGeCmdLineOptions::forceOutputDirectory(), TestHDBCmdLineOptions::fuEntryID(), PIGCmdLineOptions::generateDataImages(), PIGCmdLineOptions::generateDecompressor(), LLVMTCECmdLineOptions::generatePluginOnly(), ProGeCmdLineOptions::generateTestbench(), LLVMTCECmdLineOptions::getLLVMargv(), ExplorerCmdLineOptions::hdbFileName(), ExplorerCmdLineOptions::hdbFileNameCount(), ExplorerCmdLineOptions::hdbFileNames(), ProGeCmdLineOptions::hdl(), ExplorerCmdLineOptions::idfFile(), ProGeCmdLineOptions::idfFile(), ExplorerCmdLineOptions::idfFileName(), SchedulerCmdLineOptions::ifConversionThreshold(), BuildOpsetOptions::ignore(), ProGeCmdLineOptions::imemType(), LLVMTCECmdLineOptions::initialStackPointerValue(), ProGeCmdLineOptions::integratorName(), LLVMTCECmdLineOptions::isDataStartAddressSet(), TestHDBCmdLineOptions::isFUEntryIDGiven(), LLVMTCECmdLineOptions::isInitialStackPointerValueSet(), SchedulerCmdLineOptions::isLoopOptDefined(), SchedulerCmdLineOptions::isMachineFileDefined(), LLVMTCECmdLineOptions::isOptLevelDefined(), SchedulerCmdLineOptions::isOutputFileDefined(), TestHDBCmdLineOptions::isRFEntryIDGiven(), LLVMTCECmdLineOptions::isStandardEmulationLibDefined(), CmdLineOptions::isVerboseSpamSwitchDefined(), LLVMTCECmdLineOptions::isVerboseSwitchDefined(), CmdLineOptions::isVerboseSwitchDefined(), LLVMTCECmdLineOptions::isWorkItemAAFileDefined(), SchedulerCmdLineOptions::killDeadResults(), TestHDBCmdLineOptions::leaveDirty(), TTAUnitTesterCmdLineOptions::leaveDirty(), DisasmCmdLineOptions::lineNumbers(), ProGeCmdLineOptions::listAvailableIntegrators(), EstimatorCmdLineOptions::longestPath(), SchedulerCmdLineOptions::lowMemModeThreshold(), SimulatorCmdLineOptions::machineFile(), SchedulerCmdLineOptions::machineFile(), SchedulerCmdLineOptions::noaliasFunctions(), SchedulerCmdLineOptions::noDreBypassDistance(), ExplorerCmdLineOptions::numberOfConfigurations(), ExplorerCmdLineOptions::numberOfConfigurationsToWrite(), SchedulerCmdLineOptions::operandShareDistance(), CmdLineOptions::optionGiven(), LLVMTCECmdLineOptions::optLevel(), ProGeCmdLineOptions::outputDirectory(), AsmCmdLineOptions::outputFile(), DisasmCmdLineOptions::outputFile(), SchedulerCmdLineOptions::outputFile(), BEMGeneratorCmdLineOptions::outputFile(), DisasmCmdLineOptions::outputFileDefined(), MachInfoCmdLineOptions::outputFileNameSuffix(), MachInfoCmdLineOptions::outputFormat(), ExplorerCmdLineOptions::paretoSetValues(), CmdLineOptions::parseAll(), parseAll(), ExplorerCmdLineOptions::pluginInfo(), ProGeCmdLineOptions::pluginParametersQuery(), ProGeCmdLineOptions::preferHDLGeneration(), LLVMTCECmdLineOptions::primaryFunctions(), ExplorerCmdLineOptions::printApplications(), DictionaryToolCmdLineOptions::printConnections(), DictionaryToolCmdLineOptions::printGlobalRegister(), CmdLineOptions::printHelp(), LLVMTCECmdLineOptions::printInlineAsmWarnings(), DictionaryToolCmdLineOptions::printMissingConnections(), ExplorerCmdLineOptions::printPlugins(), DictionaryToolCmdLineOptions::printPrimitive(), SchedulerCmdLineOptions::printResourceConstraints(), DictionaryToolCmdLineOptions::printRFConnections(), ExplorerCmdLineOptions::printSummary(), DisasmCmdLineOptions::printToStdout(), AsmCmdLineOptions::printWarnings(), PIGCmdLineOptions::progeOutputDirectory(), SimulatorCmdLineOptions::programFile(), PIGCmdLineOptions::programImageOutputFormat(), SchedulerCmdLineOptions::renameRegisters(), ProGeCmdLineOptions::resetAllRegisters(), TestHDBCmdLineOptions::rfEntryID(), EstimatorCmdLineOptions::runOnlyEstimations(), LLVMTCECmdLineOptions::saveBackendPlugin(), SchedulerCmdLineOptions::schedulingWindowSize(), SimulatorCmdLineOptions::scriptString(), ProGeCmdLineOptions::sharedOutputDirectory(), PIGCmdLineOptions::showCompressors(), ProGeCmdLineOptions::simulationRuntime(), BuildOpsetOptions::sourceDir(), LLVMTCECmdLineOptions::standardEmulationLib(), ExplorerCmdLineOptions::startConfiguration(), ExplorerCmdLineOptions::summaryOrdering(), ProGeCmdLineOptions::syncReset(), LLVMTCECmdLineOptions::tempDir(), ExplorerCmdLineOptions::testApplicationDirectory(), ExplorerCmdLineOptions::testApplicationDirectoryCount(), EstimatorCmdLineOptions::totalArea(), EstimatorCmdLineOptions::totalEnergy(), EstimatorCmdLineOptions::TPEF(), PIGCmdLineOptions::tpefFile(), PIGCmdLineOptions::tpefFileCount(), ProGeCmdLineOptions::tpefName(), EstimatorCmdLineOptions::traceDB(), ProGeCmdLineOptions::useAbsolutePaths(), LLVMTCECmdLineOptions::useBubbleFish2Scheduler(), LLVMTCECmdLineOptions::useBUScheduler(), LLVMTCECmdLineOptions::useOldBackendSources(), SchedulerCmdLineOptions::useRestrictedAliasAnalyzer(), LLVMTCECmdLineOptions::useTDScheduler(), LLVMTCECmdLineOptions::useVectorBackend(), TestHDBCmdLineOptions::verbose(), TTAUnitTesterCmdLineOptions::verbose(), TestHDBCmdLineOptions::vhdlSim(), TTAUnitTesterCmdLineOptions::vhdlSim(), LLVMTCECmdLineOptions::workItemAAFile(), DictionaryToolCmdLineOptions::writeBinary(), ExplorerCmdLineOptions::writeOutBestConfiguration(), and ExplorerCmdLineOptions::writeOutConfiguration().
|
protected |
|
virtual |
Referenced by BEMGeneratorCmdLineOptions::adfFile(), BEMViewerCmdLineOptions::bemFile(), GenerateProcessor::generateProcessor(), TestHDBCmdLineOptions::hdbFile(), TTAUnitTesterCmdLineOptions::idfFileName(), loadInputs(), main(), MachInfoCmdLineOptions::outputFileNameSuffix(), and ProGeCmdLineOptions::processorToGenerate().
|
private |
Assignment not allowed.
|
virtual |
Loads all command line arguments and parses them.
argv | Command line options. |
argc | The number of command line options. |
IllegalCommandLine | If parsing is not succesfull. |
ParserStopRequest | If help or version option is found. |
Reimplemented in CmdLineOptions.
Definition at line 109 of file CmdLineParser.cc.
References commandLine_, parseAll(), and progName_.
|
virtual |
Loads all command line arguments and parses them.
options | Command line options pre-parsed in vector. |
argc | The number of command line options. |
IllegalCommandLine | If parsing is not succesfull. |
ParserStopRequest | If help or version option is found. |
Reimplemented in CmdLineOptions.
Definition at line 129 of file CmdLineParser.cc.
References commandLine_, options, and parseAll().
|
private |
Parses all command line options.
IllegalCommandLine | If parsing fails. |
Definition at line 182 of file CmdLineParser.cc.
References arguments_, commandLine_, findOption(), parseOption(), and CmdLineOptionParser::parseValue().
Referenced by parse(), and parse().
|
protected |
Parses one option.
Each option should have name and prefix (-, –, -no, or –no). Arguments are mandatory for all except Boolean options.
option | The whole option. |
name | The name of the option. |
arguments | The arguments for option. |
prefix | The prefix of option. |
hasArgument | False if argument is part of option body (eg. -abc). |
IllegalCommandLine | If option is illegal. |
Definition at line 277 of file CmdLineParser.cc.
References readPrefix().
Referenced by CmdLineOptions::parseAll(), and parseAll().
|
protected |
Reads prefix of option.
option | The whole option as a string. |
prefix | The prefix of option. |
longOption | True if option starts with "--". |
Definition at line 327 of file CmdLineParser.cc.
References prefixes_.
Referenced by parseOption().
|
virtual |
Stores options to Options class.
options | Options-object where the options are stored. |
Definition at line 83 of file CmdLineParser.cc.
References CmdLineOptionParser::copy(), optionLongNames_, options, and optionShortNames_.
|
protected |
Command line arguments are stored here.
Definition at line 86 of file CmdLineParser.hh.
Referenced by CmdLineOptions::parseAll(), and parseAll().
|
protected |
Command line is stored here.
Definition at line 84 of file CmdLineParser.hh.
Referenced by CmdLineOptions::parse(), parse(), CmdLineOptions::parse(), CmdLineOptions::parse(), parse(), CmdLineOptions::parseAll(), parseAll(), and ~CmdLineParser().
|
private |
The description of usage of program.
Definition at line 109 of file CmdLineParser.hh.
|
staticprivate |
Number of characters reserved for printing long version of commandline flag.
Definition at line 117 of file CmdLineParser.hh.
|
protected |
Database for holding options with their long names as a key.
Definition at line 79 of file CmdLineParser.hh.
Referenced by findOption(), CmdLineOptions::printHelp(), storeOptions(), and ~CmdLineParser().
|
protected |
Database for holding options with their short names as a key.
Definition at line 81 of file CmdLineParser.hh.
Referenced by findOption(), storeOptions(), and ~CmdLineParser().
|
protected |
Legal prefixes are stored here.
Definition at line 88 of file CmdLineParser.hh.
Referenced by CmdLineParser(), and readPrefix().
|
private |
|
staticprivate |
Number of characters reserved for printing short version of commandline flag.
Definition at line 113 of file CmdLineParser.hh.