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 -------------------------------------------------------------------------------
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 Namespace
28  Foam::functionEntries
29 
30 Description
31  Namespace for containing a functionEntry.
32 
33 
34 Class
35  Foam::functionEntry
36 
37 Description
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 
43 SourceFiles
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 
57 namespace Foam
58 {
59 
60 // Forward Declarations
61 class dictionary;
62 
63 /*---------------------------------------------------------------------------*\
64  Class functionEntry Declaration
65 \*---------------------------------------------------------------------------*/
66 
67 class functionEntry
68 :
69  public primitiveEntry
70 {
71 protected:
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.
85  static bool continueReadUntilRightBrace
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 
98 public:
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
107 
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  );
128 
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 // ************************************************************************* //
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:91
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
A token holds an item read from Istream.
Definition: token.H:65
static bool continueReadUntilRightBrace(Istream &is, std::string &str, const bool stripComments=true)
Slurp a string until a closing &#39;}&#39; is found.
Definition: functionEntry.C:59
functionEntry(const functionEntry &)=delete
No copy construct.
A keyword and a list of tokens comprise a primitiveEntry. A primitiveEntry can be read...
A class for handling words, derived from Foam::string.
Definition: word.H:63
A functionEntry causes entries to be added/manipulated on the specified dictionary given an input str...
Definition: functionEntry.H:63
declareMemberFunctionSelectionTable(bool, functionEntry, execute, dictionaryIstream,(dictionary &parentDict, Istream &is),(parentDict, is))
virtual void write(Ostream &os) const
Write.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
OBJstream os(runTime.globalPath()/outputName)
virtual const dictionary & dict() const
This entry is not a dictionary, calling this function generates a FatalError.
Macros to ease declaration of member function selection tables.
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
Definition: foamGltfBase.H:103
static token readLine(const word &key, Istream &is)
Read line and return as a string token.
Definition: functionEntry.C:49
Namespace for OpenFOAM.
static List< StringType > readStringList(Istream &is)
Read a List of strings values, treating a single entry like a list of size 1.
A keyword and a list of tokens is an &#39;entry&#39;.
Definition: entry.H:63