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-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 "keyType.H"
27 #include "dictionaryEntry.H"
28 #include "IOstreams.H"
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
32 Foam::dictionaryEntry::dictionaryEntry
33 (
34  const dictionary& parentDict,
35  Istream& is
36 )
37 :
38  entry(keyType(is)),
39  dictionary(parentDict, is)
40 {
41  is.fatalCheck
42  (
43  "dictionaryEntry::dictionaryEntry"
44  "(const dictionary& parentDict, Istream&)"
45  );
46 }
47 
48 
49 Foam::dictionaryEntry::dictionaryEntry
50 (
51  const keyType& key,
52  const dictionary& parentDict,
53  Istream& is
54 )
55 :
56  entry(key),
57  dictionary(key, parentDict, is)
58 {
59  is.fatalCheck
60  (
61  "dictionaryEntry::dictionaryEntry"
62  "(const keyType&, const dictionary& parentDict, Istream&)"
63  );
64 }
65 
66 
67 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
68 
70 {
71  // write keyword with indent but without trailing spaces
72  os.indent();
73  os << keyword();
75 }
76 
77 
78 // * * * * * * * * * * * * * * Ostream operator * * * * * * * * * * * * * * //
79 
81 {
82  de.write(os);
83  return os;
84 }
85 
86 
87 template<>
88 Foam::Ostream& Foam::operator<<
89 (
90  Ostream& os,
92 )
93 {
94  const dictionaryEntry& e = ip.t_;
95 
96  os << " dictionaryEntry '" << e.keyword() << "'" << endl;
97 
98  return os;
99 }
100 
101 
102 // ************************************************************************* //
void write(Ostream &, const bool subDict=true) const
Write dictionary, normally with sub-dictionary formatting.
Definition: dictionaryIO.C:207
A class for handling keywords in dictionaries.
Definition: keyType.H:66
const keyType & keyword() const
Return keyword.
Definition: entry.H:123
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
A keyword and a list of tokens is a &#39;dictionaryEntry&#39;.
void write(Ostream &) const
Write.
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
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
A helper class for outputting values to Ostream.
Definition: InfoProxy.H:45
Ostream & operator<<(Ostream &, const ensightPart &)
const doubleScalar e
Elementary charge.
Definition: doubleScalar.H:105
virtual void indent()=0
Add indentation characters.
A keyword and a list of tokens is an &#39;entry&#39;.
Definition: entry.H:65