argList.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2016-2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::argList
29 
30 Description
31  Extract command arguments and options from the supplied
32  \a argc and \a argv parameters.
33 
34  Sequences with "(" ... ")" are transformed into a stringList.
35  For example,
36  \verbatim
37  program -listFiles \( *.txt \)
38  \endverbatim
39  would create a stringList:
40  \verbatim
41  ( "file1.txt" "file2.txt" ... "fileN.txt" )
42  \endverbatim
43  The backslash-escaping is required to avoid interpretation by the shell.
44 
45  Default command-line options:
46  - \par -case <dir>
47  Select a case directory instead of the current working directory
48  - \par -decomposeParDict <file>
49  Read decomposePar dictionary from specified location
50  - \par -parallel
51  Specify case as a parallel job
52  - \par -doc
53  Display the documentation in browser
54  - \par -srcDoc
55  Display the source documentation in browser
56  - \par -help
57  Print the usage
58 
59  Additionally, the \b -noFunctionObjects and \b -postProcess options
60  may be present for some solvers or utilities.
61 
62  Environment variables set by argList or by Time:
63  - \par FOAM_API
64  The value of foamVersion::api
65  - \par FOAM_CASE
66  The path of the global case.
67  It is the same for serial and parallel jobs.
68  - \par FOAM_CASENAME
69  The name of the global case.
70  - \par FOAM_EXECUTABLE
71  If not already present in the calling environment,
72  it is set to the \a name portion of the calling executable.
73  - \par FOAM_APPLICATION
74  If not already present in the calling environment,
75  it is set to the value of the \c application entry
76  (from \c controlDict) if that entry is present.
77 
78  The value of the \b FOAM_APPLICATION may be inconsistent if the value of
79  the \c application entry is adjusted during runtime.
80 
81 Note
82  - The document browser used is defined by the \b FOAM_DOC_BROWSER
83  environment variable or the <tt>Documentation/docBrowser</tt> entry
84  in the <tt><etc>/controlDict</tt> file.
85  The \%f token is used as a placeholder for the file name.
86  - The valid (mandatory) arguments can be adjusted
87  via the addArgument static method instead of directly
88  manipulating the argList::validArgs static member.
89  - The valid options can be adjusted
90  via the addOption/removeOption static methods instead of directly
91  manipulating the argList::validOptions static member.
92 
93 SourceFiles
94  argList.C
95  argListI.H
96 
97 \*---------------------------------------------------------------------------*/
98 
99 #ifndef argList_H
100 #define argList_H
101 
102 #include "stringList.H"
103 #include "SLList.H"
104 #include "HashSet.H"
105 #include "fileName.H"
106 #include "parRun.H"
107 #include "ITstream.H"
108 #include "dlLibraryTable.H"
109 #include "OSspecific.H"
110 #include <utility>
111 
112 // Transitional features - older style access (including 1712 release)
113 #define Foam_argList_1712
114 
115 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
116 
117 namespace Foam
118 {
119 
120 /*---------------------------------------------------------------------------*\
121  Class argList Declaration
122 \*---------------------------------------------------------------------------*/
123 
124 class argList
125 {
126  // Private Data
127 
128  //- Track if command arguments are mandatory/optional
129  static bool argsMandatory_;
130 
131  //- Track enabled/disabled checking of processor directories state
132  static bool checkProcessorDirectories_;
133 
134  //- Switch on/off parallel mode.
135  // Construct first so destructor is done last.
136  ParRunControl parRunControl_;
137 
138  //- The arguments after removing known options
139  stringList args_;
140 
141  //- The extracted options
142  HashTable<string> options_;
143 
144  //- Additional libraries
145  dlLibraryTable libs_;
146 
147  word executable_;
148  fileName rootPath_;
149  fileName globalCase_;
150  fileName case_;
151 
152  //- The command line options and arguments concatenated as a string
153  string commandLine_;
154 
155 
156  // Private Member Functions
157 
158  //- Helper for resolving aliases for -options within validOptionsCompat
159  static word optionCompat(const word& optName);
160 
161  //- Helper for resolving ignored options
162  static int optionIgnore(const word& optName);
163 
164  //- Check after reading if the input token stream has unconsumed
165  //- tokens remaining or if there were no tokens in the first place.
166  // Emits Warning
167  static void checkITstream(const ITstream& is, const label index);
168 
169  //- Check after reading if the input token stream has unconsumed
170  //- tokens remaining or if there were no tokens in the first place.
171  // Emits Warning
172  static void checkITstream(const ITstream& is, const word& optName);
173 
174  //- Read a List of values from ITstream,
175  //- treating a single entry like a list of size 1.
176  template<class T>
177  static inline void readList(ITstream& is, List<T>& list);
178 
179  //- Set rootPath_, globalCase_, case_ from one of the following forms
180  // * [-case dir]
181  // * cwd
182  //
183  // Also export FOAM_CASE and FOAM_CASENAME environment variables
184  // so they can be used immediately (eg, in decomposeParDict), as well
185  // as the FOAM_EXECUTABLE environment.
186  void setCasePaths();
187 
188  //- Transcribe argv into internal args_.
189  // Transform sequences with "(" ... ")" into string lists
190  // return true if any "(" ... ")" sequences were captured
191  bool regroupArgv(int& argc, char**& argv);
192 
193  //- Print option compatibility
194  void printManCompat() const;
195 
196 
197 public:
198 
199  // Static Data Members
200 
201  //- A list of valid (mandatory) arguments
202  static SLList<string> validArgs;
203 
204  //- The "advanced" options are shown with -help-full (not with --help)
206 
207  //- A list of valid options
209 
210  //- A list of valid parallel options
212 
213  //- A list of aliases for options.
214  // Stored as (alias = canonical, version)
216 
217  //- A list of options to ignore.
218  // Stored as (option = bool, version)
220 
221  //- Short description for program arguments
223 
224  //- Short description for validOptions
226 
227  //- General usage notes
228  static SLList<string> notes;
229 
230  //- Min indentation when displaying usage (default: 20)
232 
233  //- Max screen width when displaying usage (default: 80)
235 
236  //- Standard name for the post-processing option
238 
240  // The constructor populates the standard options
241  struct initValidTables
242  {
243  initValidTables();
244  };
246 
247 
248  // Constructors
249 
250  //- Construct from argc and argv
251  //- checking the arguments and options as requested.
252  //
253  // By default, the argument check respects the value of
254  // argsMandatory() to decide if the arguments should be checked
255  // (when they are mandatory) or not (when they are optional)
256  argList
257  (
258  int& argc,
259  char**& argv,
260  bool checkArgs = argList::argsMandatory(),
261  bool checkOpts = true,
262  bool initialise = true
263  );
264 
265  //- Construct copy with new options
266  argList
267  (
268  const argList& args,
269  const HashTable<string>& options,
270  bool checkArgs = true,
271  bool checkOpts = true,
272  bool initialise = true
273  );
274 
275 
276  //- Destructor
277  virtual ~argList();
278 
279 
280  // Member Functions
281 
282  // Environment
283 
284  //- Global case (directory) from environment variable
285  //
286  // Returns the contents of the \c FOAM_CASE variable,
287  // which has previously been set by argList or by Time.
288  //
289  // This will normally be identical to the value of globalPath(),
290  // but obtained via the environment.
291  static fileName envGlobalPath();
292 
293 
294  // Low-level
295 
296  //- Scan for -help, -doc options etc prior to checking the validity
297  //- of other args/opts and finally initialising.
298  void parse(bool checkArgs, bool checkOpts, bool initialise);
299 
300 
301  // Access
302 
303  //- Name of executable without the path
304  inline const word& executable() const;
305 
306  //- The command line options and arguments concatenated as a string
307  inline const string& commandLine() const;
308 
309  //- Return root path
310  inline const fileName& rootPath() const;
311 
312  //- Return case name (parallel run) or global case (serial run)
313  inline const fileName& caseName() const;
314 
315  //- Return global case name
316  inline const fileName& globalCaseName() const;
317 
318  //- Return the full path to the (processor local) case
319  // \note This is guaranteed to be an absolute path
320  inline fileName path() const;
321 
322  //- Return the full path to the global case
323  // \note This is guaranteed to be an absolute path
324  inline fileName globalPath() const;
325 
326  //- Return the input relative to the globalPath by stripping off
327  //- a leading value of the globalPath
328  //
329  // \param input the directory or filename to make case-relative
330  // \param caseTag replace globalPath with <case> for later
331  // use with expand(), or prefix <case> if the file name was
332  // not an absolute location
333  inline fileName relativePath
334  (
335  const fileName& input,
336  const bool caseTag = false
337  ) const;
338 
339  //- Return distributed flag
340  //- (i.e. are rootPaths different on different machines)
341  inline bool distributed() const;
342 
343  //- Return the ParRunControl
344  inline const ParRunControl& parRunControl() const;
345 
346  //- Access to the loaded libraries
347  inline const dlLibraryTable& libs() const;
348 
349  //- Access to the loaded libraries
350  inline dlLibraryTable& libs();
351 
352  //- The number of arguments
353  inline label size() const noexcept;
354 
355  //- Return arguments
356  inline const stringList& args() const;
357 
358  //- Non-const access to the command arguments (non-options)
359  inline stringList& args();
360 
361  //- Return options
362  inline const HashTable<string>& options() const;
363 
364  //- Return non-const access to the command options
365  inline HashTable<string>& options();
366 
367  //- Return true if the named option is found
368  inline bool found(const word& optName) const;
369 
370  //- Return how many of the specified options were used
371  label count(const UList<word>& optionNames) const;
372 
373  //- Return how many of the specified options were used
374  label count(std::initializer_list<word> optionNames) const;
375 
376  //- Return an input stream from the named option
377  inline ITstream lookup(const word& optName) const;
378 
379  //- Get a value from the argument at index.
380  // Index 1 is the first (non-option) argument.
381  template<class T>
382  inline T get(const label index) const;
383 
384  //- Get a List of values from the argument at index.
385  // Index 1 is the first (non-option) argument.
386  template<class T>
387  inline List<T> getList(const label index) const;
388 
389  //- Get a value from the named option
390  // The default template parameter is string (ie, no conversion).
391  template<class T=string>
392  inline T get(const word& optName) const;
393 
394  //- Get a value from the named option if present, or return default.
395  // Identical to getOrDefault().
396  template<class T>
397  inline T get(const word& optName, const T& deflt) const;
398 
399  //- Read a value from the named option if present.
400  // \return true if the named option was found.
401  template<class T>
402  inline bool readIfPresent(const word& optName, T& val) const;
403 
404  //- Read a value from the named option if present.
405  // \return true if the named option was found, otherwise
406  // use the supplied default and return false.
407  template<class T>
408  inline bool readIfPresent
409  (
410  const word& optName,
411  T& val,
412  const T& deflt
413  ) const;
414 
415  //- Get a value from the named option if present, or return default.
416  template<class T>
417  inline T getOrDefault(const word& optName, const T& deflt) const;
418 
419  //- Get a List of values from the named option,
420  //- treating a single entry like a list of size 1.
421  // \param optName the option name to read from
422  // \param mandatory if the option is non-mandatory, the behaviour
423  // is similar to readListIfPresent().
424  template<class T>
425  inline List<T> getList(const word& optName, bool mandatory=true) const;
426 
427  //- If named option is present, get a List of values
428  //- treating a single entry like a list of size 1.
429  // \return true if the named option was found.
430  template<class T>
431  inline bool readListIfPresent(const word& optName, List<T>& list) const;
432 
433 
434  //- Alternative name for option get(const word& optName)
435  template<class T=string>
436  T opt(const word& optName) const
437  {
438  return this->get<T>(optName);
439  }
440 
441  //- Alternative name for option get(const word& optName, ...)
442  template<class T>
443  T opt(const word& optName, const T& deflt) const
444  {
445  return this->get<T>(optName, deflt);
446  }
447 
448 
449  // Edit
450 
451  //- Append a (mandatory) argument to validArgs
452  static void addArgument
453  (
454  const string& argName,
455  const string& usage = ""
456  );
457 
458  //- Add a bool option to validOptions with usage information
459  static void addBoolOption
460  (
461  const word& optName,
462  const string& usage = "",
463  bool advanced = false
464  );
465 
466  //- Add an option to validOptions with usage information
467  // An option with an empty param is a bool option
468  static void addOption
469  (
470  const word& optName,
471  const string& param = "",
472  const string& usage = "",
473  bool advanced = false
474  );
475 
476  //- Set an existing option as being 'advanced' or normal
477  static void setAdvanced(const word& optName, bool advanced = true);
478 
479  //- Specify an alias for the option name.
480  //
481  // \param optName the currently used option name
482  // \param compat alias name and the last OpenFOAM version (YYMM)
483  // when the alias was not needed.
484  // Setting a zero or negative version suppresses warnings about
485  // the alias.
486  static void addOptionCompat
487  (
488  const word& optName,
489  std::pair<const char*, int> compat
490  );
491 
492  //- Specify an option to be ignored.
493  //
494  // \param compat optName and the last OpenFOAM version (YYMM)
495  // when the option was directly supported.
496  // Setting a zero or negative version suppresses warnings about
497  // the alias.
498  // \param expectArg the option is non-bool
499  static void ignoreOptionCompat
500  (
501  std::pair<const char*,int> compat,
502  bool expectArg
503  );
504 
505  //- Add option usage information to optionUsage
506  static void addUsage
507  (
508  const word& optName,
509  const string& usage
510  );
511 
512  //- Add extra notes for the usage information
513  // This string is used "as-is" without additional formatting
514  static void addNote(const string& note);
515 
516  //- Remove option from validOptions and from optionUsage
517  static void removeOption(const word& optName);
518 
519  //- Flag command arguments as being optional (non-mandatory)
520  static void noMandatoryArgs();
521 
522  //- Command arguments type (optional/mandatory).
523  static bool argsMandatory();
524 
525  //- Disable emitting the banner information.
526  // Adjusts the Foam::infoDetailLevel flag.
527  static void noBanner();
528 
529  //- Banner status (enabled/disabled).
530  // Queries the Foam::infoDetailLevel flag.
531  static bool bannerEnabled();
532 
533  //- Remove '-noFunctionObjects' option and ignore any occurances.
534  // Optionally add a '-withFunctionObjects' option instead
535  static void noFunctionObjects(bool addWithOption = false);
536 
537  //- Suppress JobInfo, overriding controlDict setting
538  static void noJobInfo();
539 
540  //- Add the '-no-libs' command line option
541  static void noLibs();
542 
543  //- Remove the parallel options
544  static void noParallel();
545 
546  //- Remove checking of processor directories
547  static void noCheckProcessorDirectories();
548 
549  //- Return true if the post-processing option is specified
550  static bool postProcess(int argc, char *argv[]);
551 
552  //- Set option directly (use with caution)
553  // An option with an empty param is a bool option.
554  // Not all valid options can also be set: eg, -case, -roots, ...
555  // Return true if the existing option value needed changing,
556  // or if the option did not previously exist.
557  bool setOption(const word& optName, const string& param = "");
558 
559  //- Unset option directly (use with caution)
560  // Not all valid options can also be unset: eg, -case, -roots ...
561  // Return true if the option existed before being unset.
562  bool unsetOption(const word& optName);
563 
564 
565  // Print
566 
567  //- Print option compatibility
568  void printCompat() const;
569 
570  //- Print notes (if any)
571  void printNotes() const;
572 
573  //- Print usage
574  void printUsage(bool full=true) const;
575 
576  //- Print usage as nroff-man format (Experimental)
577  void printMan() const;
578 
579  //- Display documentation in browser
580  // Optionally display the application source code
581  void displayDoc(bool source=false) const;
582 
583 
584  // Check
585 
586  //- Check the parsed command-line for mandatory arguments and
587  //- that all the options are correct.
588  //
589  // By default, the argument check respects the value of
590  // argsMandatory() to decide if the arguments should be checked
591  // (when they are mandatory) or not (when they are optional)
592  bool check
593  (
594  bool checkArgs = argList::argsMandatory(),
595  bool checkOpts = true
596  ) const;
597 
598  //- Check root path and case path
599  bool checkRootCase() const;
600 
601 
602  // Member Operators
603 
604  //- The string corresponding to the argument index.
605  // Index 0 is the executable.
606  // Index 1 is the first (non-option) argument.
607  inline const string& operator[](const label index) const;
608 
609  //- The string associated with the named option
610  inline const string& operator[](const word& optName) const;
611 
612 
613  // Housekeeping
614 
615  //- Get a value from the named option if present, or return default.
616  template<class T>
617  T lookupOrDefault(const word& optName, const T& deflt) const
618  {
619  return getOrDefault<T>(optName, deflt);
620  }
621 
622 
623  // Older style access (including 1712 release)
624 
625  #ifdef Foam_argList_1712
626 
627  //- Deprecated(2018-08) read a value from the argument at index.
628  // Index 1 is the first (non-option) argument.
629  // \deprecated(2018-08) - use get() method
630  template<class T>
631  T FOAM_DEPRECATED_FOR(2018-08, "get() method")
632  read(const label index) const
633  {
634  return this->get<T>(index);
635  }
636 
637  //- Deprecated(2018-01) read a value from the argument at index.
638  // Index 1 is the first (non-option) argument.
639  // \deprecated(2018-01) - use get() method
640  template<class T>
641  T FOAM_DEPRECATED_FOR(2018-01, "get() method")
642  argRead(const label index) const
643  {
644  return this->get<T>(index);
645  }
646 
647  //- Deprecated(2018-01) return true if the named option is found
648  // \deprecated(2018-01) - use found() method
649  bool FOAM_DEPRECATED_FOR(2018-01, "found() method")
650  optionFound(const word& optName) const
651  {
652  return found(optName);
653  }
654 
655  //- Deprecated(2018-01) return an input stream from the named option
656  // \deprecated(2018-01) - use lookup() method
657  ITstream FOAM_DEPRECATED_FOR(2018-01, "lookup() method")
658  optionLookup(const word& optName) const
659  {
660  return lookup(optName);
661  }
662 
663  //- Deprecated(2018-01) read a value from the named option
664  // \deprecated(2018-01) - use get() method
665  template<class T>
666  T FOAM_DEPRECATED_FOR(2018-01, "get() method")
667  optionRead(const word& optName) const
668  {
669  return get<T>(optName);
670  }
671 
672  //- Deprecated(2018-01) read a value from the named option if present.
673  // Return true if the named option was found.
674  // \deprecated(2018-01) - use readIfPresent() method
675  template<class T>
676  bool FOAM_DEPRECATED_FOR(2018-01, "readIfPresent() method")
677  optionReadIfPresent
678  (
679  const word& optName,
680  T& val
681  ) const
682  {
683  return readIfPresent<T>(optName, val);
684  }
685 
686  //- Deprecated(2018-01) read a value from the named option if present.
687  // Return true if the named option was found, otherwise
688  // use the supplied default and return false.
689  // \deprecated(2018-01) - use readIfPresent() method
690  template<class T>
691  bool FOAM_DEPRECATED_FOR(2018-01, "readIfPresent() method")
692  optionReadIfPresent
693  (
694  const word& optName,
695  T& val,
696  const T& deflt
697  ) const
698  {
699  return readIfPresent<T>(optName, val, deflt);
700  }
701 
702  //- Deprecated(2018-01) read a value from the named option if present.
703  // Return supplied default otherwise.
704  // \deprecated(2018-01) - use getOrDefault() method
705  template<class T>
706  T FOAM_DEPRECATED_FOR(2018-01, "getOrDefault() method")
707  optionLookupOrDefault
708  (
709  const word& optName,
710  const T& deflt
711  ) const
712  {
713  return getOrDefault<T>(optName, deflt);
714  }
715 
716  //- Deprecated(2018-01) read a List of values from the named option
717  // \deprecated(2018-01) - use getList() method
718  template<class T>
719  List<T> FOAM_DEPRECATED_FOR(2018-01, "getList() method")
720  optionReadList(const word& optName) const
721  {
722  return this->getList<T>(optName);
723  }
724 
725  #endif /* Foam_argList_1712 */
726 };
727 
728 
729 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
730 
731 } // End namespace Foam
732 
733 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
734 
735 #include "argListI.H"
736 
737 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
738 
739 #endif
740 
741 // ************************************************************************* //
Foam::argList::validArgs
static SLList< string > validArgs
A list of valid (mandatory) arguments.
Definition: argList.H:201
Foam::argList::count
label count(const UList< word > &optionNames) const
Return how many of the specified options were used.
Definition: argList.C:1559
Foam::argList::noBanner
static void noBanner()
Disable emitting the banner information.
Definition: argList.C:432
parRun.H
Foam::argList::printMan
void printMan() const
Print usage as nroff-man format (Experimental)
Definition: argListHelp.C:169
Foam::argList::usageMin
static std::string::size_type usageMin
Min indentation when displaying usage (default: 20)
Definition: argList.H:230
Foam::argList::FOAM_DEPRECATED_FOR
T FOAM_DEPRECATED_FOR(2018-08, "get() method") read(const label index) const
Deprecated(2018-08) read a value from the argument at index.
Definition: argList.H:630
OSspecific.H
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
Foam::dlLibraryTable
A table of dynamically loaded libraries.
Definition: dlLibraryTable.H:51
Foam::argList::addUsage
static void addUsage(const word &optName, const string &usage)
Add option usage information to optionUsage.
Definition: argList.C:387
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::argList::val
bool T &const val
Definition: argList.H:681
Foam::argList::usageMax
static std::string::size_type usageMax
Max screen width when displaying usage (default: 80)
Definition: argList.H:233
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::argList::validOptionsCompat
static HashTable< std::pair< word, int > > validOptionsCompat
A list of aliases for options.
Definition: argList.H:214
ITstream.H
Foam::argList::envGlobalPath
static fileName envGlobalPath()
Global case (directory) from environment variable.
Definition: argList.C:513
Foam::argList::getOrDefault
T getOrDefault(const word &optName, const T &deflt) const
Get a value from the named option if present, or return default.
Definition: argListI.H:333
Foam::argList::optionUsage
static HashTable< string > optionUsage
Short description for validOptions.
Definition: argList.H:224
Foam::read
bool read(const char *buf, int32_t &val)
Same as readInt32.
Definition: int32.H:108
Foam::argList::addNote
static void addNote(const string &note)
Add extra notes for the usage information.
Definition: argList.C:403
Foam::argList::options
const HashTable< string > & options() const
Return options.
Definition: argListI.H:145
Foam::argList::args
const stringList & args() const
Return arguments.
Definition: argListI.H:133
Foam::argList::addOptionCompat
static void addOptionCompat(const word &optName, std::pair< const char *, int > compat)
Specify an alias for the option name.
Definition: argList.C:359
Foam::argList
Extract command arguments and options from the supplied argc and argv parameters.
Definition: argList.H:123
Foam::argList::readListIfPresent
bool readListIfPresent(const word &optName, List< T > &list) const
Definition: argListI.H:385
Foam::argList::FOAM_DEPRECATED_FOR
T FOAM_DEPRECATED_FOR(2018-01, "get() method") argRead(const label index) const
Deprecated(2018-01) read a value from the argument at index.
Definition: argList.H:640
Foam::HashSet
A HashTable with keys but without contents that is similar to std::unordered_set.
Definition: HashSet.H:84
Foam::argList::get
T get(const label index) const
Get a value from the argument at index.
Definition: argListI.H:257
Foam::argList::printCompat
void printCompat() const
Print option compatibility.
Definition: argListHelp.C:514
Foam::argList::readIfPresent
bool readIfPresent(const word &optName, T &val) const
Read a value from the named option if present.
Definition: argListI.H:298
Foam::argList::noMandatoryArgs
static void noMandatoryArgs()
Flag command arguments as being optional (non-mandatory)
Definition: argList.C:420
Foam::argList::opt
T opt(const word &optName) const
Alternative name for option get(const word& optName)
Definition: argList.H:435
Foam::argList::libs
const dlLibraryTable & libs() const
Access to the loaded libraries.
Definition: argListI.H:115
Foam::argList::rootPath
const fileName & rootPath() const
Return root path.
Definition: argListI.H:63
Foam::argList::argList
argList(int &argc, char **&argv, bool checkArgs=argList::argsMandatory(), bool checkOpts=true, bool initialise=true)
Definition: argList.C:735
Foam::argList::ignoreOptionCompat
static void ignoreOptionCompat(std::pair< const char *, int > compat, bool expectArg)
Specify an option to be ignored.
Definition: argList.C:373
Foam::argList::parRunControl
const ParRunControl & parRunControl() const
Return the ParRunControl.
Definition: argListI.H:109
Foam::argList::addArgument
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
Definition: argList.C:292
Foam::LList
Template class for non-intrusive linked lists.
Definition: LList.H:54
Foam::argList::validParOptions
static HashTable< string > validParOptions
A list of valid parallel options.
Definition: argList.H:210
Foam::argList::printNotes
void printNotes() const
Print notes (if any)
Definition: argListHelp.C:436
Foam::argList::parse
void parse(bool checkArgs, bool checkOpts, bool initialise)
Definition: argList.C:930
Foam::argList::noLibs
static void noLibs()
Add the '-no-libs' command line option.
Definition: argList.C:470
Foam::argList::noFunctionObjects
static void noFunctionObjects(bool addWithOption=false)
Remove '-noFunctionObjects' option and ignore any occurances.
Definition: argList.C:444
Foam::argList::lookup
ITstream lookup(const word &optName) const
Return an input stream from the named option.
Definition: argListI.H:163
Foam::argList::executable
const word & executable() const
Name of executable without the path.
Definition: argListI.H:51
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:62
Foam::argList::FOAM_DEPRECATED_FOR
T FOAM_DEPRECATED_FOR(2018-01, "get() method") optionRead(const word &optName) const
Deprecated(2018-01) read a value from the named option.
Definition: argList.H:665
Foam::ITstream
An input stream of tokens.
Definition: ITstream.H:55
Foam::argList::setOption
bool setOption(const word &optName, const string &param="")
Set option directly (use with caution)
Definition: argList.C:1590
Foam::argList::noJobInfo
static void noJobInfo()
Suppress JobInfo, overriding controlDict setting.
Definition: argList.C:464
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:58
fileName.H
Foam::argList::postProcessOptionName
static word postProcessOptionName
Standard name for the post-processing option.
Definition: argList.H:236
size_type
graph_traits< Graph >::vertices_size_type size_type
Definition: SloanRenumber.C:75
Foam::argList::setAdvanced
static void setAdvanced(const word &optName, bool advanced=true)
Set an existing option as being 'advanced' or normal.
Definition: argList.C:345
Foam::radiation::lookup
Lookup type of boundary radiation properties.
Definition: lookup.H:63
argListI.H
Foam::argList::noCheckProcessorDirectories
static void noCheckProcessorDirectories()
Remove checking of processor directories.
Definition: argList.C:491
HashSet.H
Foam::argList::path
fileName path() const
Return the full path to the (processor local) case.
Definition: argListI.H:81
Foam::argList::validOptions
static HashTable< string > validOptions
A list of valid options.
Definition: argList.H:207
Foam::argList::lookupOrDefault
T lookupOrDefault(const word &optName, const T &deflt) const
Get a value from the named option if present, or return default.
Definition: argList.H:616
Foam::argList::postProcess
static bool postProcess(int argc, char *argv[])
Return true if the post-processing option is specified.
Definition: argList.C:497
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::argList::unsetOption
bool unsetOption(const word &optName)
Unset option directly (use with caution)
Definition: argList.C:1616
Foam::HashTable
A HashTable similar to std::unordered_map.
Definition: HashTable.H:105
Foam::argList::addBoolOption
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
Definition: argList.C:315
Foam::argList::advancedOptions
static HashSet< string > advancedOptions
The "advanced" options are shown with -help-full (not with –help)
Definition: argList.H:204
Foam::argList::size
label size() const noexcept
The number of arguments.
Definition: argListI.H:127
Foam::argList::opt
T opt(const word &optName, const T &deflt) const
Alternative name for option get(const word& optName, ...)
Definition: argList.H:442
Foam::argList::argsMandatory
static bool argsMandatory()
Command arguments type (optional/mandatory).
Definition: argList.C:426
SLList.H
Non-intrusive singly-linked list.
Foam::List< string >
dlLibraryTable.H
Foam::UList
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:103
Foam::argList::deflt
bool T const T &const deflt
Definition: argList.H:697
Foam::argList::globalPath
fileName globalPath() const
Return the full path to the global case.
Definition: argListI.H:87
Foam::argList::FOAM_DEPRECATED_FOR
List< T > FOAM_DEPRECATED_FOR(2018-01, "getList() method") optionReadList(const word &optName) const
Deprecated(2018-01) read a List of values from the named option.
Definition: argList.H:718
Foam::argList::notes
static SLList< string > notes
General usage notes.
Definition: argList.H:227
Foam::argList::checkRootCase
bool checkRootCase() const
Check root path and case path.
Definition: argList.C:1758
Foam::argList::commandLine
const string & commandLine() const
The command line options and arguments concatenated as a string.
Definition: argListI.H:57
Foam::argList::getList
List< T > getList(const label index) const
Get a List of values from the argument at index.
Foam::ParRunControl
Helper class for initializing parallel jobs from the command arguments.
Definition: parRun.H:52
Foam::argList::caseName
const fileName & caseName() const
Return case name (parallel run) or global case (serial run)
Definition: argListI.H:69
Foam::argList::ignoreOptionsCompat
static HashTable< std::pair< bool, int > > ignoreOptionsCompat
A list of options to ignore.
Definition: argList.H:218
Foam::argList::argUsage
static HashTable< string, label, Hash< label > > argUsage
Short description for program arguments.
Definition: argList.H:221
Foam::argList::check
bool check(bool checkArgs=argList::argsMandatory(), bool checkOpts=true) const
Definition: argList.C:1712
Foam::argList::noParallel
static void noParallel()
Remove the parallel options.
Definition: argList.C:481
Foam::argList::bannerEnabled
static bool bannerEnabled()
Banner status (enabled/disabled).
Definition: argList.C:438
Foam::argList::addOption
static void addOption(const word &optName, const string &param="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
Definition: argList.C:326
Foam::argList::distributed
bool distributed() const
Definition: argListI.H:103
Foam::argList::operator[]
const string & operator[](const label index) const
The string corresponding to the argument index.
Definition: argListI.H:407
stringList.H
Foam::argList::printUsage
void printUsage(bool full=true) const
Print usage.
Definition: argListHelp.C:335
Foam::argList::globalCaseName
const fileName & globalCaseName() const
Return global case name.
Definition: argListI.H:75
Foam::argList::relativePath
fileName relativePath(const fileName &input, const bool caseTag=false) const
Definition: argListI.H:94
Foam::argList::~argList
virtual ~argList()
Destructor.
Definition: argList.C:1547
Foam::argList::displayDoc
void displayDoc(bool source=false) const
Display documentation in browser.
Definition: argList.C:1638
Foam::argList::removeOption
static void removeOption(const word &optName)
Remove option from validOptions and from optionUsage.
Definition: argList.C:412
Foam::argList::found
bool found(const word &optName) const
Return true if the named option is found.
Definition: argListI.H:157