calcEntry.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-2013 OpenFOAM Foundation
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
27Class
28 Foam::functionEntries::calcEntry
29
30Description
31 Uses dynamic compilation to provide calculating functionality
32 for entering dictionary entries.
33
34 E.g.
35
36 \verbatim
37 a 1.0;
38 b 3;
39 c \#calc "$a/$b";
40 \endverbatim
41
42 Note the explicit trailing 0 ('1.0') to force a to be read (and written)
43 as a floating point number.
44
45Note
46 Internally this is just a wrapper around codeStream functionality - the
47 \#calc string gets used to construct a dictionary for codeStream.
48
49SourceFiles
50 calcEntry.C
51
52\*---------------------------------------------------------------------------*/
53
54#ifndef functionEntries_calcEntry_H
55#define functionEntries_calcEntry_H
56
57#include "codeStream.H"
58
59// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
60
61namespace Foam
62{
63namespace functionEntries
64{
65
66/*---------------------------------------------------------------------------*\
67 Class calcEntry Declaration
68\*---------------------------------------------------------------------------*/
70class calcEntry
71:
72 public codeStream
73{
74 // Private Member Functions
75
76 //- Evaluate dynamically compiled code, returning result as string
77 static string evaluate(const dictionary& parentDict, Istream& is);
78
79
80public:
81
82 //- Execute in a primitiveEntry context
83 static bool execute
84 (
85 const dictionary& parentDict,
87 Istream& is
88 );
89
90 //- Execute in a sub-dict context
91 static bool execute(dictionary& parentDict, Istream& is);
92};
93
94
95// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
96
97} // End namespace functionEntries
98} // End namespace Foam
99
100// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
101
102#endif
103
104// ************************************************************************* //
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
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:70
Uses dynamic compilation to provide calculating functionality for entering dictionary entries.
Definition: calcEntry.H:72
static bool execute(const dictionary &parentDict, primitiveEntry &entry, Istream &is)
Execute in a primitiveEntry context.
Definition: calcEntry.C:103
Dictionary entry that contains C++ OpenFOAM code that is compiled to generate the entry itself....
Definition: codeStream.H:119
A keyword and a list of tokens comprise a primitiveEntry. A primitiveEntry can be read,...
Namespace for OpenFOAM.