FreeFOAM The Cross-Platform CFD Toolkit
argList Class Reference

Extract command arguments and options from the supplied argc and argv parameters. More...

#include <OpenFOAM/argList.H>


Detailed Description

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.

Default command-line options
Parameters:
-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.

Note:
  • Adjustment of the valid (mandatory) arguments by directly manipulating the static member argList::validArgs.
  • Adjustment of the valid options by directly manipulating the static member argList::validOptions.
Source files

Definition at line 94 of file argList.H.

+ Collaboration diagram for argList:

List of all members.

Public Member Functions

ignoreDocumentation argList (int &argc, char **&argv, bool checkArgs=true, bool checkOpts=true)
virtual ~argList ()
const wordexecutable () const
 Name of executable.
const fileNamerootPath () const
 Return root path.
const fileNameglobalCaseName () const
 Return case name.
const fileNamecaseName () const
 Return case name (parallel run) or global case (serial run)
fileName path () const
 Return the path.
const stringListargs () const
 Return arguments.
stringList::subList additionalArgs () const
 Return additionl arguments,.
const Foam::HashTable< string > & options () const
 Return options.
const stringoption (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< ToptionReadList (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< stringvalidArgs
 A list of valid (mandatory) arguments.
static HashTable< stringvalidOptions
 A list of valid options.
static HashTable< stringvalidParOptions
 A list of valid parallel options.

Constructor & Destructor Documentation

~argList ( )
virtual

Definition at line 576 of file argList.C.

References Foam::jobInfo.


Member Function Documentation

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

Return root path.

Definition at line 177 of file argList.H.

Referenced by argList::path().

const fileName& globalCaseName ( ) const
inline

Return case name.

Definition at line 183 of file argList.H.

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

Return arguments.

Definition at line 201 of file argList.H.

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 interpolate::calc(), mag::calc(), magSqr::calc(), magGrad::calc(), components::calc(), randomise::calc(), div::calc(), and addSubtract::preCalc().

const Foam::HashTable<string>& options ( ) const
inline

Return options.

Definition at line 211 of file argList.H.

const string& option ( const word opt) 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().

List<T> optionReadList ( const word opt) const
inline

Read a List of values from the named option.

Definition at line 261 of file argList.H.

References argList::optionLookup().

void noBanner ( )
static

Disable emitting the banner information.

Definition at line 584 of file argList.C.

noParallel ( )
static

Remove the parallel options.

Definition at line 590 of file argList.C.

void printUsage ( ) const

Print usage.

Definition at line 596 of file argList.C.

References SLListBase::begin(), HashTable< T, Key, Hash >::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().


Member Data Documentation

Foam::SLList< Foam::string > validArgs
static

A list of valid (mandatory) arguments.

Definition at line 130 of file argList.H.

Referenced by interpolate::init(), mag::init(), magSqr::init(), magGrad::init(), components::init(), randomise::init(), div::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

A list of valid parallel options.

Definition at line 136 of file argList.H.


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