Loading...
Searching...
No Matches
exprDriverIO.C
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) 2019-2022 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
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\*---------------------------------------------------------------------------*/
27
28#include "exprDriver.H"
29#include "exprTools.H"
30#include "stringOps.H"
31
32// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
33
34namespace Foam
35{
36
38// Write list as single or multiple entries - see exprTools::getList()
39static void writeList
40(
41 Ostream& os,
43)
44{
45 if (list.size() == 1)
46 {
47 os << list[0];
48 }
49 else
50 {
52
53 if (!list.empty())
54 {
55 os << nl;
56
57 for (const expressions::exprString& str : list)
58 {
59 os << str << nl;
60 }
61 }
63 }
64}
65
68} // End namespace Foam
69
70
71// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
72
75(
76 const word& name,
77 const dictionary& dict
86(
87 const word& name
97 const dictionary& dict,
98 const word& keyword,
99 bool mandatory
100)
101{
102 return exprTools::getList(keyword, dict, mandatory);
103}
104
105
107(
108 const dictionary& dict,
109 bool mandatory
110)
112 variableStrings_ = readVariableStrings(dict, "variables", mandatory);
113
114 return variableStrings_.size();
115}
116
117
119(
120 Ostream& os,
121 const word& keyword
122) const
123{
124 if (keyword.size())
125 {
126 os.writeKeyword(keyword);
127 }
128
129 writeList(os, variableStrings_);
130
131 if (keyword.size())
132 {
133 os.endEntry();
134 }
135
136 return os;
137}
138
139
140// ************************************************************************* //
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition UList.H:89
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Ostream & writeVariableStrings(Ostream &os, const word &keyword="") const
Write "variables".
static expressions::exprString readExpression(const word &name, const dictionary &dict)
Read an expression string and do substitutions.
label setVariableStrings(const dictionary &dict, bool mandatory=false)
Read "variables" and assigns to the list of expression strings.
List< expressions::exprString > variableStrings_
Variable definitions, as read from a dictionary.
Definition exprDriver.H:206
static List< expressions::exprString > readVariableStrings(const dictionary &dict, const word &name="variables", bool mandatory=false)
Read the list of variable strings.
const dictionary & dict() const noexcept
The dictionary with all input data/specification.
Definition exprDriver.H:455
A variant of Foam::string with expansion of dictionary variables into a comma-separated form.
Definition exprString.H:58
@ BEGIN_LIST
Begin list [isseparator].
Definition token.H:174
@ END_LIST
End list [isseparator].
Definition token.H:175
A class for handling words, derived from Foam::string.
Definition word.H:66
OBJstream os(runTime.globalPath()/outputName)
List< expressions::exprString > getList(const word &keyword, const dictionary &dict, bool mandatory=true, label recursionDepth=0)
Get an expression string list from a dictionary.
Definition exprTools.C:116
void writeList(vtk::formatter &fmt, const UList< uint8_t > &values)
Write a list of uint8_t values.
Namespace for OpenFOAM.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
dictionary dict