includeEtcEntry.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) 2015-2016 OpenFOAM Foundation
9  Copyright (C) 2018-2019 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::functionEntries::includeEtcEntry
29 
30 Description
31  A dictionary directive for including a file found using the
32  Foam::findEtcFile() mechanism.
33 
34  Specify an etc file to include when reading dictionaries, expects a
35  single string to follow.
36 
37  An example of the \c \#includeEtc directive:
38  \verbatim
39  #includeEtc "etcFile"
40  \endverbatim
41 
42  The usual expansion of environment variables and other constructs is
43  retained.
44 
45 See also
46  findEtcFile, fileName, string::expand()
47 
48 SourceFiles
49  includeEtcEntry.C
50 
51 \*---------------------------------------------------------------------------*/
52 
53 #ifndef functionEntries_includeEtcEntry_H
54 #define functionEntries_includeEtcEntry_H
55 
56 #include "functionEntry.H"
57 
58 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
59 
60 namespace Foam
61 {
62 namespace functionEntries
63 {
64 
65 /*---------------------------------------------------------------------------*\
66  Class includeEtcEntry Declaration
67 \*---------------------------------------------------------------------------*/
68 
69 class includeEtcEntry
70 :
71  public functionEntry
72 {
73 protected:
74 
75  // Protected Member Functions
76 
77  //- Expand include fileName and search etc directories for the file
79  (
80  const fileName& f,
81  const dictionary& dict
82  );
83 
84  //- Include file in a sub-dict context
85  static bool execute
86  (
87  const bool mandatory,
88  dictionary& parentDict,
89  Istream& is
90  );
91 
92  //- Include file in a primitiveEntry context
93  static bool execute
94  (
95  const bool mandatory,
96  const dictionary& parentDict,
98  Istream& is
99  );
100 
101 public:
102 
103  // Static Data Members
104 
105  //- Report to stdout which file is included
106  static bool log;
107 
108 
109  // Member Functions
110 
111  //- Include etc file in a sub-dict context
112  static bool execute(dictionary& parentDict, Istream& is);
113 
114  //- Include etc file in a primitiveEntry context
115  static bool execute
116  (
117  const dictionary& parentDict,
119  Istream& is
120  );
121 };
122 
123 
124 /*---------------------------------------------------------------------------*\
125  Class sincludeEtcEntry Declaration
126 \*---------------------------------------------------------------------------*/
127 
128 //- A dictionary directive for conditionally including an etc file,
129 //- expects a single string to follow.
130 //
131 // The \c \#sincludeEtc directive is identically to the
132 // \c \#includeEtc directive, but does not generate an error
133 // if the file does not exist.
134 class sincludeEtcEntry
135 :
136  public includeEtcEntry
137 {
138 public:
139 
140  //- Include etc file (if it exists) in a sub-dict context
141  static bool execute(dictionary& parentDict, Istream& is);
142 
143  //- Include etc file (if it exists) in a primitiveEntry context
144  static bool execute
145  (
146  const dictionary& parentDict,
148  Istream& is
149  );
150 };
151 
152 
153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154 
155 } // End namespace functionEntries
156 } // End namespace Foam
157 
158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159 
160 #endif
161 
162 // ************************************************************************* //
Foam::entry
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:67
Foam::primitiveEntry
A keyword and a list of tokens comprise a primitiveEntry. A primitiveEntry can be read,...
Definition: primitiveEntry.H:63
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
Foam::functionEntries::sincludeEtcEntry
Definition: includeEtcEntry.H:133
Foam::functionEntries::sincludeEtcEntry::execute
static bool execute(dictionary &parentDict, Istream &is)
Include etc file (if it exists) in a sub-dict context.
Definition: includeEtcEntry.C:212
functionEntry.H
Foam::primitiveEntry::dict
virtual const dictionary & dict() const
This entry is not a dictionary,.
Definition: primitiveEntry.C:299
Foam::functionEntries::includeEtcEntry::resolveEtcFile
static fileName resolveEtcFile(const fileName &f, const dictionary &dict)
Expand include fileName and search etc directories for the file.
Definition: includeEtcEntry.C:88
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionEntries::includeEtcEntry::log
static bool log
Report to stdout which file is included.
Definition: includeEtcEntry.H:105
Foam::functionEntry
A functionEntry causes entries to be added/manipulated on the specified dictionary given an input str...
Definition: functionEntry.H:66
Foam::functionEntries::includeEtcEntry::execute
static bool execute(const bool mandatory, dictionary &parentDict, Istream &is)
Include file in a sub-dict context.
Definition: includeEtcEntry.C:110
f
labelList f(nPoints)
Foam::functionEntries::includeEtcEntry
A dictionary directive for including a file found using the Foam::findEtcFile() mechanism.
Definition: includeEtcEntry.H:68