exprStringI.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 Original code Copyright (C) 2012-2018 Bernhard Gschaider
9 Copyright (C) 2019 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
27\*---------------------------------------------------------------------------*/
28
29#include "error.H"
30
31// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32
34(
35 const std::string& s,
36 bool doValidate
37)
38:
39 string(s)
40{
41 #ifdef FULLDEBUG
42 if (doValidate)
43 {
44 (void)valid();
45 }
46 #endif
47}
48
49
51(
52 std::string&& s,
53 bool doValidate
54)
55:
56 string(std::move(s))
57{
58 #ifdef FULLDEBUG
59 if (doValidate)
60 {
61 (void)valid();
62 }
63 #endif
64}
65
66
68(
69 const char* s,
70 bool doValidate
71)
72:
73 string(s)
74{
75 #ifdef FULLDEBUG
76 if (doValidate)
77 {
78 (void)valid();
79 }
80 #endif
81}
82
83
85(
86 const std::string& str,
87 const dictionary& dict,
88 const bool removeComments
89)
90:
91 string(str)
92{
93 expand(dict, removeComments);
94}
95
96
98(
99 std::string&& str,
100 const dictionary& dict,
101 const bool removeComments
102)
103:
104 string(std::move(str))
105{
106 expand(dict, removeComments);
107}
108
109
111(
112 Istream& is,
113 const dictionary& dict,
114 const bool removeComments
115)
116:
117 string(is)
118{
119 expand(dict, removeComments);
120}
121
122
123// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
124
126{
127 const bool ok = (std::string::npos == find('$'));
128
129 #ifdef FULLDEBUG
130 if (!ok)
131 {
133 << "Unexpanded '$' in " << *this << nl
134 << exit(FatalError);
135 }
136 #endif
137
138 return ok;
139}
140
141
144{
145 exprString expr;
146
147 expr.string::operator=(str);
148
149 return expr;
150}
151
152
155{
156 exprString expr;
157
158 expr.string::operator=(std::move(str));
159
160 return expr;
161}
162
163
164// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
165
168{
170
171 #ifdef FULLDEBUG
172 (void)valid();
173 #endif
174
175 return *this;
176}
177
178
181{
183
184 #ifdef FULLDEBUG
185 (void)valid();
186 #endif
187
188 return *this;
189}
190
191
194{
195 string::operator=(std::move(str));
196
197 #ifdef FULLDEBUG
198 (void)valid();
199 #endif
200
201 return *this;
202}
203
204
205// ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
bool valid() const
Check for unexpanded '$' entries. Fatal if any exist.
Definition: exprStringI.H:125
exprString()=default
Default construct.
void expand(const dictionary &dict, const bool stripComments=true)
Definition: exprString.C:83
exprString & operator=(const exprString &str)=default
Copy assign.
static exprString toExpr(const std::string &str)
Copy convert string to exprString.
Definition: exprStringI.H:143
void operator=(const ObukhovLength &)=delete
No copy assignment.
A class for handling character strings derived from std::string.
Definition: string.H:79
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
A variant of Foam::string with expansion of dictionary variables into a comma-separated form.
error FatalError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
dictionary dict