ifEntry.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) 2018 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::functionEntries::ifEntry
28 
29 Description
30  Conditional parsing of dictionary entries.
31 
32  E.g.
33  \verbatim
34  U_inlet 15;
35 
36  #if #calc "${U_inlet} < 10"
37  ..
38  #else
39  ..
40  #endif
41  \endverbatim
42 
43  Note:
44  - only supports single line, '\' is not supported
45  - condition should be readable as a \c Switch
46  (0,1, true, false, etc.) or a scalar (0.0, ...)
47 
48 See also
49  Foam::functionEntries::ifeqEntry
50  Foam::Switch
51 
52 SourceFiles
53  ifEntry.C
54 
55 \*---------------------------------------------------------------------------*/
56 
57 #ifndef functionEntries_ifEntry_H
58 #define functionEntries_ifEntry_H
59 
60 #include "ifeqEntry.H"
61 
62 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
63 
64 namespace Foam
65 {
66 namespace functionEntries
67 {
68 
69 /*---------------------------------------------------------------------------*\
70  Class ifEntry Declaration
71 \*---------------------------------------------------------------------------*/
72 
73 class ifEntry
74 :
75  public ifeqEntry
76 {
77  friend class ifeqEntry;
78 
79  // Private Member Functions
80 
81  //- Test first token (label, scalar, word) for true/false
82  static bool isTrue(ITstream& is);
83 
84  //- Execute the functionEntry in a sub-dict context
85  static bool execute
86  (
87  DynamicList<filePos>& stack,
88  dictionary& parentDict,
89  Istream& is
90  );
91 
92 public:
93 
94  //- Runtime type information
95  ClassName("if");
96 
97  // Member Functions
98 
99  //- Execute the functionEntry in a sub-dict context
100  static bool execute(dictionary& parentDict, Istream& is);
101 };
102 
103 
104 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
105 
106 } // End namespace functionEntries
107 } // End namespace Foam
108 
109 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
110 
111 #endif
112 
113 // ************************************************************************* //
Foam::DynamicList
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:55
Foam::functionEntries::ifeqEntry
Conditional parsing of dictionary entries.
Definition: ifeqEntry.H:89
Foam::functionEntries::ifEntry
Conditional parsing of dictionary entries.
Definition: ifEntry.H:72
Foam::ITstream
An input stream of tokens.
Definition: ITstream.H:52
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
ifeqEntry.H
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::ifEntry::ClassName
ClassName("if")
Runtime type information.
isTrue
static bool isTrue(const char *envName, bool deflt)
Definition: sigFpe.C:70