includeIfPresentEntry.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-2016 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 \*---------------------------------------------------------------------------*/
25 
26 #include "includeIfPresentEntry.H"
27 #include "dictionary.H"
28 #include "IFstream.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 const Foam::word Foam::functionEntries::includeIfPresentEntry::typeName
34 (
35  Foam::functionEntries::includeIfPresentEntry::typeName_()
36 );
37 
38 // Don't lookup the debug switch here as the debug switch dictionary
39 // might include includeIfPresentEntry
40 int Foam::functionEntries::includeIfPresentEntry::debug(0);
41 
42 namespace Foam
43 {
44 namespace functionEntries
45 {
47  (
48  functionEntry,
49  includeIfPresentEntry,
50  execute,
51  dictionaryIstream
52  );
53 
55  (
56  functionEntry,
57  includeIfPresentEntry,
58  execute,
59  primitiveEntryIstream
60  );
61 }
62 }
63 
64 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
65 
67 (
68  dictionary& parentDict,
69  Istream& is
70 )
71 {
72  const fileName fName(includeFileName(is, parentDict));
73  IFstream ifs(fName);
74 
75  if (ifs)
76  {
78  {
79  Info<< fName << endl;
80  }
81  parentDict.read(ifs);
82  }
83 
84  return true;
85 }
86 
87 
89 (
90  const dictionary& parentDict,
91  primitiveEntry& entry,
92  Istream& is
93 )
94 {
95  const fileName fName(includeFileName(is, parentDict));
96  IFstream ifs(fName);
97 
98  if (ifs)
99  {
101  {
102  Info<< fName << endl;
103  }
104  entry.read(parentDict, ifs);
105  }
106 
107  return true;
108 }
109 
110 // ************************************************************************* //
bool read(Istream &)
Read dictionary from Istream.
Definition: dictionaryIO.C:126
static bool execute(dictionary &parentDict, Istream &)
Execute the functionEntry in a sub-dict context.
A class for handling file names.
Definition: fileName.H:69
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
addToMemberFunctionSelectionTable(functionEntry, calcEntry, execute, dictionaryIstream)
A keyword and a list of tokens is a &#39;primitiveEntry&#39;. An primitiveEntry can be read, written and printed, and the types and values of its tokens analysed.
A class for handling words, derived from string.
Definition: word.H:59
Input from file stream.
Definition: IFstream.H:81
Macros for easy insertion into member function selection tables.
messageStream Info
virtual bool read(const dictionary &, Istream &)
Read tokens from the given stream.
static bool log
Report which file is included to stdout.
Definition: includeEntry.H:94
Namespace for OpenFOAM.