Extract command arguments and options from the supplied argc and argv parameters. More...
#include <OpenFOAM/argList.H>
Extract command arguments and options from the supplied argc and argv parameters.
Sequences with "(" ... ")" are transformed into a stringList. For example,
program -listFiles \( *.txt \)
would create a stringList:
( "file1.txt" "file2.txt" ... "fileN.txt" )
The backslash-escaping has been used to avoid shell expansions.
-case | <dir> select an case directory instead of the current working directory |
-parallel | specify case as a parallel job |
-doc | display the documentation in browser |
-srcDoc | display the source documentation in browser |
-help | print the usage |
The environment variable FOAM_CASE is set to the path of the global case (same for serial and parallel jobs). The environment variable FOAM_CASENAME is set to the name of the global case.
Definition at line 94 of file argList.H.
Public Member Functions | |
ignoreDocumentation | argList (int &argc, char **&argv, bool checkArgs=true, bool checkOpts=true) |
virtual | ~argList () |
const word & | executable () const |
Name of executable.
| |
const fileName & | rootPath () const |
Return root path.
| |
const fileName & | globalCaseName () const |
Return case name.
| |
const fileName & | caseName () const |
Return case name (parallel run) or global case (serial run)
| |
fileName | path () const |
Return the path.
| |
const stringList & | args () const |
Return arguments.
| |
stringList::subList | additionalArgs () const |
Return additionl arguments,.
| |
const Foam::HashTable< string > & | options () const |
Return options.
| |
const string & | option (const word &opt) const |
Return the argument string associated with the named option.
| |
bool | optionFound (const word &opt) const |
Return true if the named option is found.
| |
IStringStream | optionLookup (const word &opt) const |
Return an IStringStream to the named option.
| |
template<class T > | |
T | optionRead (const word &opt) const |
Read a value from the named option.
| |
template<class T > | |
bool | optionReadIfPresent (const word &opt, T &val) const |
Read a value from the named option if present.
| |
template<class T > | |
List< T > | optionReadList (const word &opt) const |
Read a List of values from the named option.
| |
void | printUsage () const |
Print usage.
| |
void | displayDoc (bool source=false) const |
Display documentation in browser.
| |
bool | check (bool checkArgs=true, bool checkOpts=true) const |
Check argument list.
| |
bool | checkRootCase () const |
Check root path and case path.
| |
Static Public Member Functions | |
static void | noBanner () |
Disable emitting the banner information.
| |
static void | noParallel () |
Remove the parallel options.
| |
Static Public Attributes | |
static SLList< string > | validArgs |
A list of valid (mandatory) arguments.
| |
static HashTable< string > | validOptions |
A list of valid options.
| |
static HashTable< string > | validParOptions |
A list of valid parallel options.
|
argList | ( | int & | argc, |
char **& | argv, | ||
bool | checkArgs = true ,
|
||
bool | checkOpts = true
|
||
) |
Construct from argc and argv
checking the arguments and options as requested
Definition at line 190 of file argList.C.
References dictionary::add(), clock::clockTime(), Pstream::commsTypeNames, Foam::cwd(), clock::date(), Pstream::defaultCommsType, Foam::endl(), error::exit(), Foam::exit(), Foam::FatalError, Pstream::firstSlave(), Pstream::floatTransfer, Foam::FOAMbuild, Foam::FOAMfullVersion, Foam::FOAMupstreamVersion, IOstream::good(), Foam::hostName(), Foam::Info, Foam::isDir(), Foam::jobInfo, Pstream::lastSlave(), dictionary::lookup(), dictionary::lookupOrDefault(), Pstream::master(), Pstream::masterNo(), Pstream::myProcNo(), Foam::name(), IFstream::name(), fileName::name(), Foam::nl, Pstream::nProcs(), Pstream::nProcsSimpleSum, Foam::pgid(), Foam::pid(), Foam::ppid(), PstreamBase::scheduled, List< T >::setSize(), List< T >::size(), Foam::userName(), IOobject::writeBanner(), and IOobject::writeDivider().
~argList | ( | ) | [virtual]
|
Definition at line 576 of file argList.C.
References Foam::jobInfo.
const word& executable | ( | ) | const [inline]
|
Name of executable.
Definition at line 171 of file argList.H.
Referenced by if(), and timeSelector::select0().
const fileName& rootPath | ( | ) | const [inline]
|
const fileName& globalCaseName | ( | ) | const [inline]
|
const fileName& caseName | ( | ) | const [inline]
|
Return case name (parallel run) or global case (serial run)
Definition at line 189 of file argList.H.
Referenced by argList::path().
fileName path | ( | ) | const [inline]
|
Return the path.
Definition at line 195 of file argList.H.
References argList::caseName(), and argList::rootPath().
const stringList& args | ( | ) | const [inline]
|
Foam::stringList::subList additionalArgs | ( | ) | const |
Return additionl arguments,.
i.e. those additional to the executable itself
Definition at line 181 of file argList.C.
Referenced by randomise::calc(), magSqr::calc(), magGrad::calc(), mag::calc(), interpolate::calc(), div::calc(), components::calc(), and addSubtract::preCalc().
const Foam::HashTable<string>& options | ( | ) | const [inline]
|
Return the argument string associated with the named option.
Definition at line 217 of file argList.H.
References HashTable< T, Key, Hash >::operator.
Referenced by if(), argList::optionLookup(), and addSubtract::preCalc().
bool optionFound | ( | const word & | opt ) | const [inline]
|
Return true if the named option is found.
Definition at line 223 of file argList.H.
References HashTable< T, Key, Hash >::found().
Referenced by argList::optionReadIfPresent(), addSubtract::preCalc(), and timeSelector::select().
IStringStream optionLookup | ( | const word & | opt ) | const [inline]
|
Return an IStringStream to the named option.
Definition at line 229 of file argList.H.
References argList::option().
Referenced by argList::optionRead(), argList::optionReadIfPresent(), argList::optionReadList(), and timeSelector::select().
T optionRead | ( | const word & | opt ) | const [inline]
|
Read a value from the named option.
Definition at line 236 of file argList.H.
References argList::optionLookup(), and Foam::T().
Referenced by if().
bool optionReadIfPresent | ( | const word & | opt, |
T & | val | ||
) | const [inline]
|
Read a value from the named option if present.
Return true if the named option was found.
Definition at line 246 of file argList.H.
References argList::optionFound(), and argList::optionLookup().
Read a List of values from the named option.
Definition at line 261 of file argList.H.
References argList::optionLookup().
void noBanner | ( | ) | [static]
|
void printUsage | ( | ) | const |
Print usage.
Definition at line 596 of file argList.C.
References HashTable< T, Key, Hash >::begin(), SLListBase::begin(), Foam::endl(), Foam::Info, and Foam::nl.
void displayDoc | ( | bool | source = false
) |
const |
Display documentation in browser.
Optionally display the application source code
Definition at line 634 of file argList.C.
References Foam::debug::controlDict(), Foam::endl(), forAll, dictionary::found(), IOstream::good(), Foam::Info, dictionary::lookup(), Foam::nl, dictionary::subDict(), Foam::system(), and WarningIn.
bool check | ( | bool | checkArgs = true ,
|
bool | checkOpts = true
|
||
) | const |
Check argument list.
Definition at line 708 of file argList.C.
References Foam::endl(), Foam::FatalError, forAllConstIter, and Pstream::master().
bool checkRootCase | ( | ) | const |
Check root path and case path.
Definition at line 749 of file argList.C.
References Foam::endl(), Foam::FatalError, Foam::isDir(), and Pstream::master().
Foam::SLList< Foam::string > validArgs [static]
|
A list of valid (mandatory) arguments.
Definition at line 130 of file argList.H.
Referenced by randomise::init(), magSqr::init(), magGrad::init(), mag::init(), interpolate::init(), div::init(), components::init(), and addSubtract::init().
Foam::HashTable< Foam::string > validOptions [static]
|
A list of valid options.
Definition at line 133 of file argList.H.
Referenced by timeSelector::addOptions(), addSubtract::init(), main(), and timeSelector::select().
Foam::HashTable< Foam::string > validParOptions [static]
|