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