functionEntry.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) 2021 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
27Namespace
28 Foam::functionEntries
29
30Description
31 Namespace for containing a functionEntry.
32
33
34Class
35 Foam::functionEntry
36
37Description
38 A functionEntry causes entries to be added/manipulated on the specified
39 dictionary given an input stream.
40
41 In dictionaries, a \c '\#' sigil is typically used for a functionEntry.
42
43SourceFiles
44 functionEntry.C
45 functionEntryIO.C
46
47\*---------------------------------------------------------------------------*/
48
49#ifndef functionEntry_H
50#define functionEntry_H
51
52#include "primitiveEntry.H"
54
55// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56
57namespace Foam
58{
59
60// Forward Declarations
61class dictionary;
62
63/*---------------------------------------------------------------------------*\
64 Class functionEntry Declaration
65\*---------------------------------------------------------------------------*/
67class functionEntry
68:
69 public primitiveEntry
70{
71protected:
72
73 // Protected Member Functions
74
75 //- Read line and return as a string token
76 static token readLine(const word& key, Istream& is);
77
78 //- Read a List of strings values, treating a single entry like a
79 //- list of size 1.
80 template<class StringType>
82
83 //- Slurp a string until a closing '}' is found.
84 // Track balanced bracket/brace pairs, with max stack depth of 60.
86 (
87 Istream& is,
88 std::string& str,
89 const bool stripComments = true
90 );
91
92 //- No copy construct
93 functionEntry(const functionEntry&) = delete;
94
95 //- No copy assignment
96 void operator=(const functionEntry&) = delete;
97
98public:
99
100 // Constructors
101
102 //- Construct from keyword, parent dictionary and Istream
103 functionEntry(const word& key, const dictionary& dict, Istream& is);
104
105
106 // Member Function Selectors
109 (
110 bool,
112 execute,
113 dictionaryIstream,
114 (
115 dictionary& parentDict,
116 Istream& is
117 ),
118 (parentDict, is)
119 );
120
121 //- Execute the functionEntry in a sub-dict context
122 static bool execute
123 (
124 const word& functionName,
125 dictionary& parentDict,
126 Istream& is
127 );
130 (
131 bool,
133 execute,
134 primitiveEntryIstream,
135 (
136 const dictionary& parentDict,
138 Istream& is
139 ),
140 (parentDict, entry, is)
141 );
142
143 //- Execute the functionEntry in a primitiveEntry context
144 static bool execute
145 (
146 const word& functionName,
147 const dictionary& parentDict,
149 Istream& is
150 );
151
152 //- Write
153 virtual void write(Ostream& os) const;
154};
155
156
157// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158
159} // End namespace Foam
160
161// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162
163#ifdef NoRepository
164 #include "functionEntryTemplates.C"
165#endif
166
167// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168
169#endif
170
171// ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
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 functionEntry causes entries to be added/manipulated on the specified dictionary given an input str...
Definition: functionEntry.H:69
static List< StringType > readStringList(Istream &is)
declareMemberFunctionSelectionTable(bool, functionEntry, execute, dictionaryIstream,(dictionary &parentDict, Istream &is),(parentDict, is))
static bool continueReadUntilRightBrace(Istream &is, std::string &str, const bool stripComments=true)
Slurp a string until a closing '}' is found.
Definition: functionEntry.C:66
declareMemberFunctionSelectionTable(bool, functionEntry, execute, primitiveEntryIstream,(const dictionary &parentDict, primitiveEntry &entry, Istream &is),(parentDict, entry, is))
functionEntry(const functionEntry &)=delete
No copy construct.
static token readLine(const word &key, Istream &is)
Read line and return as a string token.
Definition: functionEntry.C:56
void operator=(const functionEntry &)=delete
No copy assignment.
static bool execute(const word &functionName, dictionary &parentDict, Istream &is)
Execute the functionEntry in a sub-dict context.
Definition: functionEntry.C:98
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,.
A token holds an item read from Istream.
Definition: token.H:69
A class for handling words, derived from Foam::string.
Definition: word.H:68
OBJstream os(runTime.globalPath()/outputName)
Macros to ease declaration of member function selection tables.
#define declareMemberFunctionSelectionTable(returnType, baseType, funcName, argNames, argList, parListUnused)
Declare a run-time member-function selection (variables and adder classes)
Namespace for OpenFOAM.
runTime write()