functionEntry.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2026 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 Namespace
25  Foam::functionEntries
26 
27 Description
28  Namespace for containing a functionEntry.
29 
30 
31 Class
32  Foam::functionEntry
33 
34 Description
35  A functionEntry causes entries to be added/manipulated on the specified
36  dictionary given an input stream.
37 
38  In dictionaries, a \c '\#' sigil is typically used for a functionEntry.
39 
40 SourceFiles
41  functionEntry.C
42  functionEntryIO.C
43 
44 \*---------------------------------------------------------------------------*/
45 
46 #ifndef functionEntry_H
47 #define functionEntry_H
48 
49 #include "primitiveEntry.H"
51 
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 
54 namespace Foam
55 {
56 
57 class dictionary;
58 class OTstream;
59 
60 /*---------------------------------------------------------------------------*\
61  Class functionEntry Declaration
62 \*---------------------------------------------------------------------------*/
63 
64 class functionEntry
65 :
66  public primitiveEntry
67 {
68  // Private Member Functions
69 
70  //- Read the rest of the argument list following the part attached
71  // to the function name
72  void readRestOfArgs(string& fNameArgs, Istream& is) const;
73 
74 
75 protected:
76 
77  // Constructors
78 
79  //- Construct from function type and parent dictionary
81  (
82  const functionName&,
83  const label lineNumber,
84  const dictionary&
85  );
86 
87  //- Construct from function type, parent dictionary and a token
89  (
90  const functionName&,
91  const label lineNumber,
92  const dictionary&,
93  const Istream& is,
94  const token&
95  );
96 
97  //- Construct from function type, parent dictionary and tokenList
99  (
100  const functionName&,
101  const label lineNumber,
102  const dictionary&,
103  const Istream& is,
104  const tokenList&
105  );
106 
107  //- Copy construct
108  functionEntry(const functionEntry&) = default;
109 
110  //- Clone
111  virtual autoPtr<entry> clone(const dictionary&) const = 0;
112 
113 
114  // Protected Member Functions
115 
117  (
118  const functionName& functionType,
119  Istream& is,
120  const bool optional = false
121  ) const;
122 
123  //- Read the function name and optional argument list
124  // The argument list can be on one or more lines.
126  (
127  const functionName& functionType,
128  Istream& is
129  ) const;
130 
131  //- Read the filen name and optional argument list
132  // The argument list can be on one or more lines.
134  (
135  const functionName& functionType,
136  Istream& is
137  ) const;
138 
139  //- Read a single argument or list
141  (
142  const functionName& functionType,
143  Istream& is
144  ) const;
145 
146  //- Read entry starting from token t and insert into contextDict
147  static bool insert
148  (
149  const dictionary& parentDict,
150  dictionary& contextDict,
151  const token& t,
152  Istream& is
153  );
154 
155  //- Insert token t into contextEntry, expanding as required
156  // which may read subsequent tokens from Istream
157  static bool insert
158  (
159  const dictionary& parentDict,
160  primitiveEntry& contextEntry,
161  const token& t,
162  Istream& is
163  );
164 
165  //- Read entry from the given OTstream and insert into contextDict
166  static bool insert
167  (
168  dictionary& contextDict,
169  const OTstream&
170  );
171 
172  //- Read tokens from the given OTstream and insert into contextEntry
173  static bool insert
174  (
175  const dictionary& parentDict,
176  primitiveEntry& contextEntry,
177  const OTstream&
178  );
179 
180  //- Read entry from the given string and insert into contextDict
181  static bool insert
182  (
183  dictionary& contextDict,
184  const string&
185  );
186 
187  //- Read tokens from the given string and insert into contextEntry
188  static bool insert
189  (
190  const dictionary& parentDict,
191  primitiveEntry& contextEntry,
192  const string&
193  );
194 
195 
196 public:
197 
198  FunctionTypeName("functionEntry");
199 
200  // Declare run-time constructor selection tables
201 
203  (
204  autoPtr,
206  dictionary,
207  (
208  const label lineNumber,
209  const dictionary& parentDict,
210  Istream& is
211  ),
212  (lineNumber, parentDict, is)
213  );
214 
215 
216  // Selectors
217 
218  //- Construct from Istream and insert into dictionary
220  (
221  const keyType& functionName,
222  const dictionary& parentDict,
223  Istream& is
224  );
225 
226 
227  // Member Function Selectors
228 
229  //- Expand the functionEntry into the contextDict
230  virtual bool execute(dictionary& contextDict, Istream& is) = 0;
231 
233  (
234  bool,
236  execute,
237  primitiveEntryIstream,
238  (
239  const dictionary& contextDict,
240  primitiveEntry& contextEntry,
241  Istream& is
242  ),
243  (contextDict, entry, is)
244  );
245 
246  //- Expand the functionEntry into the contextEntry
247  static bool execute
248  (
249  const word& functionName,
250  const dictionary& contextDict,
251  primitiveEntry& contextEntry,
252  Istream&
253  );
254 
255  //- Write
256  virtual void write(Ostream&) const;
257 
258 
259  // Member Operators
260 
261  //- Disallow default bitwise assignment
262  void operator=(const functionEntry&) = delete;
263 };
264 
265 
266 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
267 
268 } // End namespace Foam
269 
270 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
271 
272 #endif
273 
274 // ************************************************************************* //
label lineNumber() const
Return current stream line number.
Definition: IOstream.H:450
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:91
Output token stream.
Definition: OTstream.H:56
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:68
virtual autoPtr< entry > clone() const
Construct on freestore as copy.
Definition: entry.C:56
A functionEntry causes entries to be added/manipulated on the specified dictionary given an input str...
Definition: functionEntry.H:66
tokenList readArgOrList(const functionName &functionType, Istream &is) const
Read a single argument or list.
declareMemberFunctionSelectionTable(bool, functionEntry, execute, primitiveEntryIstream,(const dictionary &contextDict, primitiveEntry &contextEntry, Istream &is),(contextDict, entry, is))
virtual void write(Ostream &) const
Write.
virtual bool execute(dictionary &contextDict, Istream &is)=0
Expand the functionEntry into the contextDict.
static bool insert(const dictionary &parentDict, dictionary &contextDict, const token &t, Istream &is)
Read entry starting from token t and insert into contextDict.
tokenList readFuncNameArgList(const functionName &functionType, Istream &is) const
Read the function name and optional argument list.
FunctionTypeName("functionEntry")
tokenList readArgList(const functionName &functionType, Istream &is, const bool optional=false) const
tokenList readFileNameArgList(const functionName &functionType, Istream &is) const
Read the filen name and optional argument list.
void operator=(const functionEntry &)=delete
Disallow default bitwise assignment.
static autoPtr< functionEntry > New(const keyType &functionName, const dictionary &parentDict, Istream &is)
Construct from Istream and insert into dictionary.
declareRunTimeSelectionTable(autoPtr, functionEntry, dictionary,(const label lineNumber, const dictionary &parentDict, Istream &is),(lineNumber, parentDict, is))
A functionName is a word starting with '#'.
Definition: functionName.H:60
A class for handling keywords in dictionaries.
Definition: keyType.H:69
A keyword and a list of tokens is a 'primitiveEntry'. An primitiveEntry can be read,...
friend class functionEntry
A token holds items read from Istream.
Definition: token.H:74
A class for handling words, derived from string.
Definition: word.H:63
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59