inputSyntaxEntry.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2019 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "inputSyntaxEntry.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 const Foam::word Foam::functionEntries::inputSyntaxEntry::typeName
32 (
33  Foam::functionEntries::inputSyntaxEntry::typeName_()
34 );
35 
36 // Don't lookup the debug switch here as the debug switch dictionary
37 // might include inputSyntax entries
38 int Foam::functionEntries::inputSyntaxEntry::debug(0);
39 
40 // Read the default dictionary syntax from etc/controlDict if specified
41 Foam::functionEntries::inputSyntaxEntry::inputSyntax
42  Foam::functionEntries::inputSyntaxEntry::defaultSyntax_
43 (
45  ? Foam::functionEntries::inputSyntaxEntry::syntax
46  (
48  (
49  "inputSyntax"
50  )
51  )
52  : DOT
53 );
54 
55 // Initialise the current dictionary syntax to the default
56 Foam::functionEntries::inputSyntaxEntry::inputSyntax
57  Foam::functionEntries::inputSyntaxEntry::syntax_
58 (
59  Foam::functionEntries::inputSyntaxEntry::defaultSyntax_
60 );
61 
62 
63 namespace Foam
64 {
65 namespace functionEntries
66 {
68  (
69  functionEntry,
70  inputSyntaxEntry,
71  execute,
72  dictionaryIstream
73  );
74 }
75 }
76 
77 
78 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
79 
80 Foam::functionEntries::inputSyntaxEntry::inputSyntax
81 Foam::functionEntries::inputSyntaxEntry::syntax
82 (
83  Istream& is
84 )
85 {
86  word syntax(is);
87  if (syntax == "slash")
88  {
89  return SLASH;
90  }
91  else if (syntax == "dot")
92  {
93  return DOT;
94  }
95  else
96  {
98  << "unsupported input syntax'" << syntax
99  << ", setting to default"
100  << endl;
101 
102  return defaultSyntax_;
103  }
104 }
105 
106 
107 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
108 
110 (
111  dictionary& parentDict,
112  Istream& is
113 )
114 {
115  syntax_ = syntax(is);
116  return true;
117 }
118 
119 
121 {
122  syntax_ = defaultSyntax_;
123 }
124 
125 
127 {
128  return syntax_ == SLASH;
129 }
130 
131 
133 {
134  return syntax_ == DOT;
135 }
136 
137 
139 {
140  return syntax_ == SLASH ? '/' : '.';
141 }
142 
143 
144 // ************************************************************************* //
static bool slash()
Return true if the inputSyntax is slash.
static bool execute(dictionary &parentDict, Istream &)
Execute the functionEntry in a sub-dict context.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
static bool dot()
Return true if the inputSyntax is dot.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
addToMemberFunctionSelectionTable(functionEntry, calcEntry, execute, dictionaryIstream)
stressControl lookup("compactNormalStress") >> compactNormalStress
A class for handling words, derived from string.
Definition: word.H:59
static char scopeChar()
Return true if the inputSyntax is slash.
static void clear()
Reset the inputSyntax to the default specified in etc/controlDict.
#define WarningInFunction
Report a warning using Foam::Warning.
Macros for easy insertion into member function selection tables.
dictionary & optimisationSwitches()
The OptimisationSwitches sub-dictionary in the central controlDict.
Definition: debug.C:172
bool found
Namespace for OpenFOAM.