dictionaryEntryIO.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) 2011-2025 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 "keyType.H"
27 #include "dictionaryEntry.H"
28 #include "IOstreams.H"
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
33 (
34  const dictionary& parentDict,
35  Istream& is
36 )
37 :
38  entry(keyType(is), is.lineNumber()),
39  dictionary(parentDict, is)
40 {
41  is.fatalCheck
42  (
43  "dictionaryEntry::dictionaryEntry"
44  "(const dictionary& parentDict, Istream&)"
45  );
46 }
47 
48 
50 (
51  const keyType& key,
52  const label lineNumber,
53  const dictionary& parentDict,
54  Istream& is
55 )
56 :
57  entry(key, lineNumber),
58  dictionary(fileName(key), parentDict, is)
59 {
60  is.fatalCheck
61  (
62  "dictionaryEntry::dictionaryEntry"
63  "(const keyType&, const dictionary& parentDict, Istream&)"
64  );
65 }
66 
67 
69 (
70  const keyType& key,
71  const dictionary& parentDict,
72  Istream& is
73 )
74 :
75  dictionaryEntry(key, is.lineNumber(), parentDict, is)
76 {}
77 
78 
79 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
80 
82 {
83  // write keyword with indent but without trailing spaces
84  os.indent();
85  os << keyword();
87 }
88 
89 
90 // * * * * * * * * * * * * * * Ostream operator * * * * * * * * * * * * * * //
91 
93 {
94  de.write(os);
95  return os;
96 }
97 
98 
99 template<>
100 Foam::Ostream& Foam::operator<<
101 (
102  Ostream& os,
104 )
105 {
106  const dictionaryEntry& e = ip.t_;
107 
108  os << " dictionaryEntry '" << e.keyword() << "'" << endl;
109 
110  return os;
111 }
112 
113 
114 // ************************************************************************* //
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
void fatalCheck(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:105
A helper class for outputting values to Ostream.
Definition: InfoProxy.H:50
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
virtual void indent()=0
Add indentation characters.
A keyword and a list of tokens is a 'dictionaryEntry'.
dictionaryEntry(const dictionary &parentDict, Istream &)
Construct from the parent dictionary and Istream.
void write(Ostream &) const
Write.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
void write(Ostream &, const bool subDict=true) const
Write dictionary, normally with sub-dictionary formatting.
Definition: dictionaryIO.C:226
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:68
A class for handling file names.
Definition: fileName.H:82
A class for handling keywords in dictionaries.
Definition: keyType.H:69
const doubleScalar e
Definition: doubleScalar.H:106
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:258
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)