helpTypeNew.C
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) 2012-2015 OpenFOAM Foundation
9  Copyright (C) 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 \*---------------------------------------------------------------------------*/
28 
29 #include "helpType.H"
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
34 (
35  const word& helpTypeName
36 )
37 {
38  auto* ctorPtr = dictionaryConstructorTable(helpTypeName);
39 
40  if (!ctorPtr)
41  {
42  // special treatment for -help
43  // exit without stack trace
44  if (helpTypeName.starts_with("-help"))
45  {
47  << "Valid helpType selections:" << nl
48  << " "
49  << flatOutput(dictionaryConstructorTablePtr_->sortedToc()) << nl
50  << exit(FatalError);
51  }
52  else
53  {
55  << "Unknown helpType type '" << helpTypeName << "'" << nl << nl
56  << "Valid helpType selections:" << nl
57  << " "
58  << flatOutput(dictionaryConstructorTablePtr_->sortedToc()) << nl
59  << abort(FatalError);
60  }
61  }
62 
63  Info<< "Selecting helpType '" << helpTypeName << "'" << endl;
64 
65  return autoPtr<helpType>(ctorPtr());
66 }
67 
68 
69 // ************************************************************************* //
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:578
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:49
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:487
static autoPtr< helpType > New(const word &helpTypeName)
Selector.
errorManip< error > abort(error &err)
Definition: errorManip.H:139
messageStream Info
Information stream (stdout output on master, null elsewhere)
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
Definition: FlatOutput.H:225