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-2020 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  mutable 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  //- Trigger FatalError for given option
180  void raiseBadInput(const word& optName) const;
181 
182  //- Set rootPath_, globalCase_, case_ from one of the following forms
183  // * [-case dir]
184  // * cwd
185  //
186  // Also export FOAM_CASE and FOAM_CASENAME environment variables
187  // so they can be used immediately (eg, in decomposeParDict), as well
188  // as the FOAM_EXECUTABLE environment.
189  void setCasePaths();
190 
191  //- Transcribe argv into internal args_.
192  // Transform sequences with "(" ... ")" into string lists
193  // return true if any "(" ... ")" sequences were captured
194  bool regroupArgv(int& argc, char**& argv);
195 
196  //- Print option compatibility
197  void printManCompat() const;
198 
199 
200 public:
201 
202  // Static Data Members
203 
204  //- A list of valid (mandatory) arguments
205  static SLList<string> validArgs;
206 
207  //- The "advanced" options are shown with -help-full (not with --help)
209 
210  //- A list of valid options
212 
213  //- A list of valid parallel options
215 
216  //- A list of aliases for options.
217  // Stored as (alias = canonical, version)
219 
220  //- A list of options to ignore.
221  // Stored as (option = bool, version)
223 
224  //- Short description for program arguments
226 
227  //- Short description for validOptions
229 
230  //- General usage notes
231  static SLList<string> notes;
232 
233  //- Min indentation when displaying usage (default: 20)
235 
236  //- Max screen width when displaying usage (default: 80)
238 
239  //- Standard name for the post-processing option
241 
243  // The constructor populates the standard options
244  struct initValidTables
245  {
246  initValidTables();
247  };
249 
250 
251  // Constructors
252 
253  //- Construct from argc and argv
254  //- checking the arguments and options as requested.
255  //
256  // By default, the argument check respects the value of
257  // argsMandatory() to decide if the arguments should be checked
258  // (when they are mandatory) or not (when they are optional)
259  argList
260  (
261  int& argc,
262  char**& argv,
263  bool checkArgs = argList::argsMandatory(),
264  bool checkOpts = true,
265  bool initialise = true
266  );
267 
268  //- Construct copy with new options
269  argList
270  (
271  const argList& args,
272  const HashTable<string>& options,
273  bool checkArgs = true,
274  bool checkOpts = true,
275  bool initialise = true
276  );
277 
278 
279  //- Destructor
280  virtual ~argList();
281 
282 
283  // Member Functions
284 
285  // Environment
286 
287  //- Global case (directory) from environment variable
288  //
289  // Returns the contents of the \c FOAM_CASE variable,
290  // which has previously been set by argList or by Time.
291  //
292  // This will normally be identical to the value of globalPath(),
293  // but obtained via the environment.
294  static fileName envGlobalPath();
295 
296 
297  // Low-level
298 
299  //- Scan for -help, -doc options etc prior to checking the validity
300  //- of other args/opts and finally initialising.
301  void parse(bool checkArgs, bool checkOpts, bool initialise);
302 
303 
304  // Access
305 
306  //- Name of executable without the path
307  inline const word& executable() const;
308 
309  //- The command line options and arguments concatenated as a string
310  inline const string& commandLine() const;
311 
312  //- Return root path
313  inline const fileName& rootPath() const;
314 
315  //- Return case name (parallel run) or global case (serial run)
316  inline const fileName& caseName() const;
317 
318  //- Return global case name
319  inline const fileName& globalCaseName() const;
320 
321  //- Return the full path to the (processor local) case
322  // \note This is guaranteed to be an absolute path
323  inline fileName path() const;
324 
325  //- Return the full path to the global case
326  // \note This is guaranteed to be an absolute path
327  inline fileName globalPath() const;
328 
329  //- Return the input relative to the globalPath by stripping off
330  //- a leading value of the globalPath
331  //
332  // \param input the directory or filename to make case-relative
333  // \param caseTag replace globalPath with <case> for later
334  // use with expand(), or prefix <case> if the file name was
335  // not an absolute location
336  inline fileName relativePath
337  (
338  const fileName& input,
339  const bool caseTag = false
340  ) const;
341 
342  //- Return distributed flag
343  //- (i.e. are rootPaths different on different machines)
344  inline bool distributed() const;
345 
346  //- Return the ParRunControl
347  inline const ParRunControl& parRunControl() const;
348 
349  //- Mutable access to the loaded dynamic libraries
350  inline dlLibraryTable& libs() const;
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  template<class T>
396  inline T getOrDefault(const word& optName, const T& deflt) const;
397 
398  //- Get a List of values from the named option,
399  //- treating a single entry like a list of size 1.
400  // \param optName the option name to read from
401  // \param mandatory if the option is non-mandatory, the behaviour
402  // is similar to readListIfPresent().
403  template<class T>
404  inline List<T> getList(const word& optName, bool mandatory=true) const;
405 
406  //- Read a value from the named option if present.
407  // \return true if the named option was found.
408  template<class T>
409  inline bool readIfPresent(const word& optName, T& val) const;
410 
411  //- Read a value from the named option if present.
412  // \return true if the named option was found, otherwise
413  // use the supplied default and return false.
414  template<class T>
415  inline bool readIfPresent
416  (
417  const word& optName,
418  T& val,
419  const T& deflt
420  ) const;
421 
422  //- If named option is present, get a List of values
423  //- treating a single entry like a list of size 1.
424  // \return true if the named option was found.
425  template<class T>
426  inline bool readListIfPresent(const word& optName, List<T>& list) const;
427 
428  //- Read the named option and check its validity.
429  // FatalError if mandatory and not found, or if the predicate check
430  // failed.
431  //
432  // \param optName the option name
433  // \param val the value to read into
434  // \param pred the value check predicate
435  //
436  // \return true if the entry was found.
437  template<class T, class Predicate>
438  inline bool readCheck
439  (
440  const word& optName,
441  T& val,
442  const Predicate& pred,
443  bool mandatory = true
444  ) const;
445 
446  //- Read the named option if present and check its validity.
447  // FatalError if found and the predicate check failed.
448  //
449  // \param optName the option name
450  // \param val the value to read into
451  // \param pred the value check predicate
452  //
453  // \return true if the entry was found.
454  template<class T, class Predicate>
455  inline bool readCheckIfPresent
456  (
457  const word& optName,
458  T& val,
459  const Predicate& pred
460  ) const;
461 
462  //- Get a value from the named option with additional checking.
463  // FatalError if the predicate check failed.
464  //
465  // \param optName the option name
466  // \param pred the value check predicate
467  template<class T, class Predicate>
468  T getCheck
469  (
470  const word& optName,
471  const Predicate& pred
472  ) const;
473 
474  //- Get a value from the named option with additional checking
475  //- (if present), or return default.
476  // FatalError if the predicate check on the retrieved value failed.
477  //
478  // \param optName the option name
479  // \param deflt the default return value
480  // \param pred the value check predicate
481  template<class T, class Predicate>
483  (
484  const word& optName,
485  const T& deflt,
486  const Predicate& pred
487  ) const;
488 
489 
490  // Edit
491 
492  //- Append a (mandatory) argument to validArgs
493  static void addArgument
494  (
495  const string& argName,
496  const string& usage = ""
497  );
498 
499  //- Add a bool option to validOptions with usage information
500  static void addBoolOption
501  (
502  const word& optName,
503  const string& usage = "",
504  bool advanced = false
505  );
506 
507  //- Add an option to validOptions with usage information
508  // An option with an empty param is a bool option
509  static void addOption
510  (
511  const word& optName,
512  const string& param = "",
513  const string& usage = "",
514  bool advanced = false
515  );
516 
517  //- Set an existing option as being 'advanced' or normal
518  static void setAdvanced(const word& optName, bool advanced = true);
519 
520  //- Specify an alias for the option name.
521  //
522  // \param optName the currently used option name
523  // \param compat alias name and the last OpenFOAM version (YYMM)
524  // when the alias was not needed.
525  // Setting a zero or negative version suppresses warnings about
526  // the alias.
527  static void addOptionCompat
528  (
529  const word& optName,
530  std::pair<const char*, int> compat
531  );
532 
533  //- Specify an option to be ignored.
534  //
535  // \param compat optName and the last OpenFOAM version (YYMM)
536  // when the option was directly supported.
537  // Setting a zero or negative version suppresses warnings about
538  // the alias.
539  // \param expectArg the option is non-bool
540  static void ignoreOptionCompat
541  (
542  std::pair<const char*,int> compat,
543  bool expectArg
544  );
545 
546  //- Add option usage information to optionUsage
547  static void addUsage
548  (
549  const word& optName,
550  const string& usage
551  );
552 
553  //- Add extra notes for the usage information
554  // This string is used "as-is" without additional formatting
555  static void addNote(const string& note);
556 
557  //- Remove option from validOptions and from optionUsage
558  static void removeOption(const word& optName);
559 
560  //- Flag command arguments as being optional (non-mandatory)
561  static void noMandatoryArgs();
562 
563  //- Command arguments type (optional/mandatory).
564  static bool argsMandatory();
565 
566  //- Disable emitting the banner information.
567  // Adjusts the Foam::infoDetailLevel flag.
568  static void noBanner();
569 
570  //- Banner status (enabled/disabled).
571  // Queries the Foam::infoDetailLevel flag.
572  static bool bannerEnabled();
573 
574  //- Remove '-noFunctionObjects' option and ignore any occurrences.
575  // Optionally add a '-withFunctionObjects' option instead
576  static void noFunctionObjects(bool addWithOption = false);
577 
578  //- Suppress JobInfo, overriding controlDict setting
579  static void noJobInfo();
580 
581  //- Add the '-no-libs' command line option
582  static void noLibs();
583 
584  //- Remove the parallel options
585  static void noParallel();
586 
587  //- Remove checking of processor directories
588  static void noCheckProcessorDirectories();
589 
590  //- Return true if the post-processing option is specified
591  static bool postProcess(int argc, char *argv[]);
592 
593  //- Set option directly (use with caution)
594  // An option with an empty param is a bool option.
595  // Not all valid options can also be set: eg, -case, -roots, ...
596  // Return true if the existing option value needed changing,
597  // or if the option did not previously exist.
598  bool setOption(const word& optName, const string& param = "");
599 
600  //- Unset option directly (use with caution)
601  // Not all valid options can also be unset: eg, -case, -roots ...
602  // Return true if the option existed before being unset.
603  bool unsetOption(const word& optName);
604 
605 
606  // Print
607 
608  //- Print option compatibility
609  void printCompat() const;
610 
611  //- Print notes (if any)
612  void printNotes() const;
613 
614  //- Print usage
615  void printUsage(bool full=true) const;
616 
617  //- Print usage as nroff-man format (Experimental)
618  void printMan() const;
619 
620  //- Display documentation in browser
621  // Optionally display the application source code
622  void displayDoc(bool source=false) const;
623 
624 
625  // Check
626 
627  //- Check the parsed command-line for mandatory arguments and
628  //- that all the options are correct.
629  //
630  // By default, the argument check respects the value of
631  // argsMandatory() to decide if the arguments should be checked
632  // (when they are mandatory) or not (when they are optional)
633  bool check
634  (
635  bool checkArgs = argList::argsMandatory(),
636  bool checkOpts = true
637  ) const;
638 
639  //- Check root path and case path
640  bool checkRootCase() const;
641 
642 
643  // Member Operators
644 
645  //- The string corresponding to the argument index.
646  // Index 0 is the executable.
647  // Index 1 is the first (non-option) argument.
648  inline const string& operator[](const label index) const;
649 
650  //- The string associated with the named option
651  inline const string& operator[](const word& optName) const;
652 
653 
654  // Housekeeping
655 
656  //- Deprecated(2020-05) identical to get(const word& optName)
657  // \deprecated(2020-05) - use get() method
658  template<class T=string>
659  T opt(const word& optName) const
660  {
661  return this->get<T>(optName);
662  }
663 
664  //- Deprecated(2020-05) identical to getOrDefault(...)
665  // \deprecated(2020-05) - use getOrDefault() method
666  template<class T>
667  T opt(const word& optName, const T& deflt) const
668  {
669  return this->getOrDefault<T>(optName, deflt);
670  }
671 
672  //- Deprecated(2020-05) identical to getOrDefault(...)
673  // \deprecated(2020-05) - use getOrDefault() method
674  template<class T>
675  T get(const word& optName, const T& deflt) const
676  {
677  return this->getOrDefault<T>(optName, deflt);
678  }
679 
680  //- Deprecated(2020-05) identical to getOrDefault(...)
681  // \deprecated(2020-05) - use getOrDefault() method
682  template<class T>
683  T lookupOrDefault(const word& optName, const T& deflt) const
684  {
685  return this->getOrDefault<T>(optName, deflt);
686  }
687 
688 
689  // Older style access (including 1712 release)
690 
691  #ifdef Foam_argList_1712
692 
693  //- Deprecated(2018-08) read a value from the argument at index.
694  // Index 1 is the first (non-option) argument.
695  // \deprecated(2018-08) - use get() method
696  template<class T>
697  FOAM_DEPRECATED_FOR(2018-08, "get() method")
698  T read(const label index) const
699  {
700  return this->get<T>(index);
701  }
702 
703  //- Deprecated(2018-01) read a value from the argument at index.
704  // Index 1 is the first (non-option) argument.
705  // \deprecated(2018-01) - use get() method
706  template<class T>
707  FOAM_DEPRECATED_FOR(2018-01, "get() method")
708  T argRead(const label index) const
709  {
710  return this->get<T>(index);
711  }
712 
713  //- Deprecated(2018-01) return true if the named option is found
714  // \deprecated(2018-01) - use found() method
715  FOAM_DEPRECATED_FOR(2018-01, "found() method")
716  bool optionFound(const word& optName) const
717  {
718  return found(optName);
719  }
720 
721  //- Deprecated(2018-01) return an input stream from the named option
722  // \deprecated(2018-01) - use lookup() method
723  FOAM_DEPRECATED_FOR(2018-01, "lookup() method")
724  ITstream optionLookup(const word& optName) const
725  {
726  return lookup(optName);
727  }
728 
729  //- Deprecated(2018-01) read a value from the named option
730  // \deprecated(2018-01) - use get() method
731  template<class T>
732  FOAM_DEPRECATED_FOR(2018-01, "get() method")
733  T optionRead(const word& optName) const
734  {
735  return get<T>(optName);
736  }
737 
738  //- Deprecated(2018-01) read a value from the named option if present.
739  // Return true if the named option was found.
740  // \deprecated(2018-01) - use readIfPresent() method
741  template<class T>
742  FOAM_DEPRECATED_FOR(2018-01, "readIfPresent() method")
744  (
745  const word& optName,
746  T& val
747  ) const
748  {
749  return readIfPresent<T>(optName, val);
750  }
751 
752  //- Deprecated(2018-01) read a value from the named option if present.
753  // Return true if the named option was found, otherwise
754  // use the supplied default and return false.
755  // \deprecated(2018-01) - use readIfPresent() method
756  template<class T>
757  FOAM_DEPRECATED_FOR(2018-01, "readIfPresent() method")
759  (
760  const word& optName,
761  T& val,
762  const T& deflt
763  ) const
764  {
765  return readIfPresent<T>(optName, val, deflt);
766  }
767 
768  //- Deprecated(2018-01) read a value from the named option if present.
769  // Return supplied default otherwise.
770  // \deprecated(2018-01) - use getOrDefault() method
771  template<class T>
772  FOAM_DEPRECATED_FOR(2018-01, "getOrDefault() method")
774  (
775  const word& optName,
776  const T& deflt
777  ) const
778  {
779  return getOrDefault<T>(optName, deflt);
780  }
781 
782  //- Deprecated(2018-01) read a List of values from the named option
783  // \deprecated(2018-01) - use getList() method
784  template<class T>
785  FOAM_DEPRECATED_FOR(2018-01, "getList() method")
786  List<T> optionReadList(const word& optName) const
787  {
788  return this->getList<T>(optName);
789  }
790 
791  #endif /* Foam_argList_1712 */
792 };
793 
794 
795 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
796 
797 } // End namespace Foam
798 
799 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
800 
801 #include "argListI.H"
802 
803 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
804 
805 #endif
806 
807 // ************************************************************************* //
Foam::argList::validArgs
static SLList< string > validArgs
A list of valid (mandatory) arguments.
Definition: argList.H:204
Foam::argList::count
label count(const UList< word > &optionNames) const
Return how many of the specified options were used.
Definition: argList.C:1613
Foam::argList::noBanner
static void noBanner()
Disable emitting the banner information.
Definition: argList.C:455
parRun.H
Foam::argList::printMan
void printMan() const
Print usage as nroff-man format (Experimental)
Definition: argListHelp.C:200
Foam::argList::usageMin
static std::string::size_type usageMin
Min indentation when displaying usage (default: 20)
Definition: argList.H:233
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:63
Foam::argList::addUsage
static void addUsage(const word &optName, const string &usage)
Add option usage information to optionUsage.
Definition: argList.C:410
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::argList::usageMax
static std::string::size_type usageMax
Max screen width when displaying usage (default: 80)
Definition: argList.H:236
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:217
ITstream.H
Foam::argList::envGlobalPath
static fileName envGlobalPath()
Global case (directory) from environment variable.
Definition: argList.C:537
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:280
Foam::argList::optionUsage
static HashTable< string > optionUsage
Short description for validOptions.
Definition: argList.H:227
Foam::argList::optionRead
T optionRead(const word &optName) const
Deprecated(2018-01) read a value from the named option.
Definition: argList.H:732
Foam::argList::addNote
static void addNote(const string &note)
Add extra notes for the usage information.
Definition: argList.C:426
Foam::argList::options
const HashTable< string > & options() const
Return options.
Definition: argListI.H:139
Foam::argList::optionFound
bool optionFound(const word &optName) const
Deprecated(2018-01) return true if the named option is found.
Definition: argList.H:715
Foam::argList::args
const stringList & args() const
Return arguments.
Definition: argListI.H:127
Foam::argList::optionLookup
ITstream optionLookup(const word &optName) const
Deprecated(2018-01) return an input stream from the named option.
Definition: argList.H:723
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:382
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:367
Foam::argList::optionReadIfPresent
bool optionReadIfPresent(const word &optName, T &val) const
Deprecated(2018-01) read a value from the named option if present.
Definition: argList.H:743
Foam::HashSet
A HashTable with keys but without contents that is similar to std::unordered_set.
Definition: HashSet.H:83
Foam::argList::get
T get(const label index) const
Get a value from the argument at index.
Definition: argListI.H:251
Foam::argList::printCompat
void printCompat() const
Print option compatibility.
Definition: argListHelp.C:540
Foam::argList::readIfPresent
bool readIfPresent(const word &optName, T &val) const
Read a value from the named option if present.
Definition: argListI.H:296
Foam::argList::noMandatoryArgs
static void noMandatoryArgs()
Flag command arguments as being optional (non-mandatory)
Definition: argList.C:443
Foam::argList::read
T read(const label index) const
Deprecated(2018-08) read a value from the argument at index.
Definition: argList.H:697
Foam::argList::opt
T opt(const word &optName) const
Deprecated(2020-05) identical to get(const word& optName)
Definition: argList.H:658
Foam::argList::rootPath
const fileName & rootPath() const
Return root path.
Definition: argListI.H:63
Foam::argList::optionReadList
List< T > optionReadList(const word &optName) const
Deprecated(2018-01) read a List of values from the named option.
Definition: argList.H:785
Foam::argList::optionLookupOrDefault
T optionLookupOrDefault(const word &optName, const T &deflt) const
Deprecated(2018-01) read a value from the named option if present.
Definition: argList.H:773
Foam::argList::argList
argList(int &argc, char **&argv, bool checkArgs=argList::argsMandatory(), bool checkOpts=true, bool initialise=true)
Definition: argList.C:760
Foam::argList::ignoreOptionCompat
static void ignoreOptionCompat(std::pair< const char *, int > compat, bool expectArg)
Specify an option to be ignored.
Definition: argList.C:396
Foam::argList::readCheck
bool readCheck(const word &optName, T &val, const Predicate &pred, bool mandatory=true) const
Read the named option and check its validity.
Definition: argListI.H:389
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:315
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:213
Foam::argList::printNotes
void printNotes() const
Print notes (if any)
Definition: argListHelp.C:462
Foam::argList::parse
void parse(bool checkArgs, bool checkOpts, bool initialise)
Definition: argList.C:955
Foam::argList::noLibs
static void noLibs()
Add the '-no-libs' command line option.
Definition: argList.C:493
Foam::argList::noFunctionObjects
static void noFunctionObjects(bool addWithOption=false)
Remove '-noFunctionObjects' option and ignore any occurrences.
Definition: argList.C:467
Foam::argList::lookup
ITstream lookup(const word &optName) const
Return an input stream from the named option.
Definition: argListI.H:157
Foam::argList::executable
const word & executable() const
Name of executable without the path.
Definition: argListI.H:51
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:1644
Foam::argList::noJobInfo
static void noJobInfo()
Suppress JobInfo, overriding controlDict setting.
Definition: argList.C:487
Foam::argList::get
T get(const word &optName, const T &deflt) const
Deprecated(2020-05) identical to getOrDefault(...)
Definition: argList.H:674
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:239
size_type
graph_traits< Graph >::vertices_size_type size_type
Definition: SloanRenumber.C:76
Foam::argList::setAdvanced
static void setAdvanced(const word &optName, bool advanced=true)
Set an existing option as being 'advanced' or normal.
Definition: argList.C:368
Foam::argList::readCheckIfPresent
bool readCheckIfPresent(const word &optName, T &val, const Predicate &pred) const
Read the named option if present and check its validity.
Definition: argListI.H:418
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:515
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:210
Foam::argList::lookupOrDefault
T lookupOrDefault(const word &optName, const T &deflt) const
Deprecated(2020-05) identical to getOrDefault(...)
Definition: argList.H:682
Foam::argList::postProcess
static bool postProcess(int argc, char *argv[])
Return true if the post-processing option is specified.
Definition: argList.C:521
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::argList::getCheck
T getCheck(const word &optName, const Predicate &pred) const
Get a value from the named option with additional checking.
Definition: argListI.H:430
Foam::argList::unsetOption
bool unsetOption(const word &optName)
Unset option directly (use with caution)
Definition: argList.C:1670
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:338
Foam::argList::advancedOptions
static HashSet< string > advancedOptions
The "advanced" options are shown with -help-full (not with –help)
Definition: argList.H:207
Foam::argList::size
label size() const noexcept
The number of arguments.
Definition: argListI.H:121
Foam::argList::opt
T opt(const word &optName, const T &deflt) const
Deprecated(2020-05) identical to getOrDefault(...)
Definition: argList.H:666
Foam::argList::argsMandatory
static bool argsMandatory()
Command arguments type (optional/mandatory).
Definition: argList.C:449
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::globalPath
fileName globalPath() const
Return the full path to the global case.
Definition: argListI.H:87
bool
bool
Definition: EEqn.H:20
Foam::argList::notes
static SLList< string > notes
General usage notes.
Definition: argList.H:230
Foam::input
static Istream & input(Istream &is, IntRange< T > &range)
Definition: IntRanges.C:55
Foam::argList::checkRootCase
bool checkRootCase() const
Check root path and case path.
Definition: argList.C:1812
Foam::FOAM_DEPRECATED_FOR
class FOAM_DEPRECATED_FOR(2017-05, "Foam::Enum") NamedEnum
Definition: NamedEnum.H:69
Foam::argList::libs
dlLibraryTable & libs() const
Mutable access to the loaded dynamic libraries.
Definition: argListI.H:115
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. Also handles cleanup of paral...
Definition: parRun.H:50
Foam::argList::argRead
T argRead(const label index) const
Deprecated(2018-01) read a value from the argument at index.
Definition: argList.H:707
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:221
Foam::argList::argUsage
static HashTable< string, label, Hash< label > > argUsage
Short description for program arguments.
Definition: argList.H:224
Foam::argList::check
bool check(bool checkArgs=argList::argsMandatory(), bool checkOpts=true) const
Definition: argList.C:1766
Foam::argList::noParallel
static void noParallel()
Remove the parallel options.
Definition: argList.C:504
Foam::argList::bannerEnabled
static bool bannerEnabled()
Banner status (enabled/disabled).
Definition: argList.C:461
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:349
Foam::argList::distributed
bool distributed() const
Definition: argListI.H:103
stringList.H
Foam::argList::printUsage
void printUsage(bool full=true) const
Print usage.
Definition: argListHelp.C:366
Foam::argList::getCheckOrDefault
T getCheckOrDefault(const word &optName, const T &deflt, const Predicate &pred) const
Definition: argListI.H:443
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:1602
Foam::argList::displayDoc
void displayDoc(bool source=false) const
Display documentation in browser.
Definition: argList.C:1692
Foam::argList::removeOption
static void removeOption(const word &optName)
Remove option from validOptions and from optionUsage.
Definition: argList.C:435
Foam::argList::found
bool found(const word &optName) const
Return true if the named option is found.
Definition: argListI.H:151