Test-codeStream.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 | Copyright (C) 2011 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Application
25  Test-codeStream
26 
27 Description
28 
29 \*---------------------------------------------------------------------------*/
30 
31 #include "argList.H"
32 #include "IOstreams.H"
33 #include "IOobject.H"
34 #include "IFstream.H"
35 #include "dictionary.H"
36 
37 using namespace Foam;
38 
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 // Main program:
41 
42 int main(int argc, char *argv[])
43 {
45  argList::validArgs.insert("dict .. dictN");
46  argList args(argc, argv, false, true);
47 
48  Info<< nl
49  << "FOAM_CASE=" << getEnv("FOAM_CASE") << nl
50  << "FOAM_CASENAME=" << getEnv("FOAM_CASENAME") << nl
51  << endl;
52 
53  if (args.size() <= 1)
54  {
55  Info<<"specify dictionaries to test\n";
56  }
57  else
58  {
60  for (label argI=1; argI < args.size(); ++argI)
61  {
62  const string& dictFile = args[argI];
63  IFstream is(dictFile);
64 
65  dictionary dict(is);
66 
67  Info<< dict << endl;
68  }
69  }
70 
71  return 0;
72 }
73 
74 
75 // ************************************************************************* //
Foam::argList::validArgs
static SLList< string > validArgs
A list of valid (mandatory) arguments.
Definition: argList.H:143
IOstreams.H
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
main
int main(int argc, char *argv[])
Definition: Test-codeStream.C:39
Foam::IFstream
Input from file stream.
Definition: IFstream.H:81
Foam::argList::size
label size() const
Return the number of arguments.
Definition: argListI.H:84
Foam::argList
Extract command arguments and options from the supplied argc and argv parameters.
Definition: argList.H:97
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::getEnv
string getEnv(const word &)
Return environment variable of given name.
Definition: POSIX.C:101
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:59
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
argList.H
IFstream.H
dict
dictionary dict
Definition: searchingEngine.H:14
IOobject.H
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::IOobject::writeDivider
static Stream & writeDivider(Stream &os)
Write the standard file section divider.
Definition: IOobjectI.H:108
dictionary.H
Foam::argList::noParallel
static void noParallel()
Remove the parallel options.
Definition: argList.C:161
args
Foam::argList args(argc, argv)