OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

argList Class Reference

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

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 >
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< stringvalidArgs
 A list of valid (mandatory) arguments.
static HashTable< stringvalidOptions
 A list of valid options.
static HashTable< stringvalidParOptions
 A list of valid parallel options.

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 89 of file argList.H.


Constructor & Destructor Documentation

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 181 of file argList.C.

~argList (  )  [virtual]

Definition at line 566 of file argList.C.

References Foam::Info, and IOobject::writeDivider().

Here is the call graph for this function:


Member Function Documentation

const word& executable (  )  const [inline]

Name of executable.

Definition at line 170 of file argList.H.

Referenced by if().

Here is the caller graph for this function:

const fileName& rootPath (  )  const [inline]

Return root path.

Definition at line 176 of file argList.H.

Referenced by argList::path().

Here is the caller graph for this function:

const fileName& globalCaseName (  )  const [inline]

Return case name.

Definition at line 182 of file argList.H.

const fileName& caseName (  )  const [inline]

Return case name (parallel run) or global case (serial run).

Definition at line 188 of file argList.H.

Referenced by argList::path().

Here is the caller graph for this function:

fileName path (  )  const [inline]

Return the path.

Definition at line 194 of file argList.H.

References argList::caseName(), and argList::rootPath().

Here is the call graph for this function:

const stringList& args (  )  const [inline]

Return arguments.

Definition at line 200 of file argList.H.

Foam::stringList::subList additionalArgs (  )  const

Return additionl arguments,.

i.e. those additional to the executable itself

Definition at line 172 of file argList.C.

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

Return options.

Definition at line 212 of file argList.H.

const string& option ( const word opt  )  const [inline]

Return the argument string associated with the named option.

Definition at line 218 of file argList.H.

References HashTable< T, Key, Hash >::operator.

Referenced by addSubtract::calc(), if(), and argList::optionLookup().

Here is the caller graph for this function:

bool optionFound ( const word opt  )  const [inline]

Return true if the named option is found.

Definition at line 224 of file argList.H.

References HashTable< T, Key, Hash >::found().

Here is the call graph for this function:

IStringStream optionLookup ( const word opt  )  const [inline]

Return an IStringStream to the named option.

Definition at line 230 of file argList.H.

References argList::option().

Referenced by argList::optionRead(), and argList::optionReadIfPresent().

Here is the call graph for this function:

Here is the caller graph for this function:

T optionRead ( const word opt  )  const [inline]

Read a value from the named option.

Definition at line 237 of file argList.H.

References argList::optionLookup(), and Foam::T().

Referenced by if().

Here is the call graph for this function:

Here is the caller graph for this function:

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 249 of file argList.H.

References argList::optionLookup().

Here is the call graph for this function:

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

Read a List of values from the named option.

Definition at line 264 of file argList.H.

void noBanner (  )  [static]

Disable emitting the banner information.

Definition at line 574 of file argList.C.

References Foam::jobInfo.

void noParallel (  )  [static]

Remove the parallel options.

Definition at line 580 of file argList.C.

void printUsage (  )  const

Print usage.

Definition at line 586 of file argList.C.

Referenced by argList::checkRootCase().

Here is the caller graph for this function:

void displayDoc ( bool  source = false  )  const

Display documentation in browser.

Optionally display the application source code

Definition at line 624 of file argList.C.

bool check ( bool  checkArgs = true,
bool  checkOpts = true 
) const

Check argument list.

Definition at line 679 of file argList.C.

References Foam::Info, and Foam::nl.

bool checkRootCase (  )  const

Check root path and case path.

Definition at line 720 of file argList.C.

References argList::printUsage().

Here is the call graph for this function:


Member Data Documentation

A list of valid (mandatory) arguments.

Definition at line 127 of file argList.H.

Referenced by magGrad::preCalc(), mag::preCalc(), magSqr::preCalc(), components::preCalc(), randomise::preCalc(), interpolate::preCalc(), and div::preCalc().

A list of valid options.

Definition at line 130 of file argList.H.

A list of valid parallel options.

Definition at line 133 of file argList.H.


The documentation for this class was generated from the following files:
Copyright © 2000-2009 OpenCFD Ltd