expressionEntryI.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) 2014-2018 Bernhard Gschaider
9  Copyright (C) 2019 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 \*---------------------------------------------------------------------------*/
28 
29 #include "OStringStream.H"
30 
31 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
32 
33 inline Foam::string
35 {
36  return e.stream().toString();
37 }
38 
39 
40 template<class Type>
41 inline Foam::string
43 {
44  OStringStream buf;
45 
46  buf << pTraits<Type>::typeName << '(';
47  for (direction cmpt=0; cmpt < pTraits<Type>::nComponents; ++cmpt)
48  {
49  if (cmpt) buf << ',';
50  buf << component(data, cmpt);
51  }
52  buf << ')';
53 
54  return buf.str();
55 }
56 
57 
58 template<class Type>
59 inline Foam::string
61 {
62  Type data(Zero);
63  is >> data;
64 
65  return toExprStr<Type>(data);
66 }
67 
68 
69 // ************************************************************************* //
Foam::entry
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:67
Foam::exprTools::expressionEntry::evaluate
static string evaluate(const entry &e)
Generic concatenate tokens to space-separated string.
Definition: expressionEntryI.H:34
Foam::component
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
Definition: FieldFieldFunctions.C:44
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::exprTools::expressionEntry::toExprStr
static string toExprStr(const Type &data)
Foam::string
A class for handling character strings derived from std::string.
Definition: string.H:76
Foam::ITstream
An input stream of tokens.
Definition: ITstream.H:52
OStringStream.H
Foam::Detail::StringStreamAllocator::str
Foam::string str() const
Get the string - as Foam::string rather than std::string.
Definition: StringStream.H:88
Foam::OStringStream
Output to string buffer, using a OSstream. Always UNCOMPRESSED.
Definition: StringStream.H:227
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
Foam::direction
uint8_t direction
Definition: direction.H:52
Foam::data
Database for solution data, solver performance and other reduced data.
Definition: data.H:55