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