baseIOdictionaryIO.C
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-2014 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "baseIOdictionary.H"
29 #include "Pstream.H"
30 
31 // * * * * * * * * * * * * * * * Members Functions * * * * * * * * * * * * * //
32 
34 {
35  is >> *this;
36 
37  if (writeDictionaries && Pstream::master() && !is.bad())
38  {
39  Sout<< nl
40  << "--- baseIOdictionary " << name()
41  << ' ' << objectPath() << ":" << nl;
43  writeData(Sout);
44  Sout<< "--- End of baseIOdictionary " << name() << nl << endl;
45  }
46 
47  return !is.bad();
48 }
49 
50 
52 {
53  dictionary::write(os, false);
54  return os.good();
55 }
56 
57 
58 // ************************************************************************* //
Foam::baseIOdictionary::readData
virtual bool readData(Istream &)
The readData function required by regIOobject read operation.
Definition: baseIOdictionaryIO.C:33
Foam::baseIOdictionary::writeData
virtual bool writeData(Ostream &) const
The writeData function required by regIOobject write operation.
Definition: baseIOdictionaryIO.C:51
Foam::UPstream::master
static bool master(const label communicator=worldComm)
Am I the master process.
Definition: UPstream.H:458
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
baseIOdictionary.H
Foam::baseIOdictionary::name
const word & name() const
Definition: baseIOdictionary.C:82
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::IOstream::bad
bool bad() const
Return true if stream is corrupted.
Definition: IOstream.H:242
Pstream.H
Foam::nl
constexpr char nl
Definition: Ostream.H:385
Foam::dictionary::write
void write(Ostream &os, const bool subDict=true) const
Write dictionary, normally with sub-dictionary formatting.
Definition: dictionaryIO.C:206
Foam::IOobject::writeHeader
bool writeHeader(Ostream &os) const
Write header.
Definition: IOobjectWriteHeader.C:156
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::IOstream::good
bool good() const
Return true if next operation might succeed.
Definition: IOstream.H:224
Foam::Sout
OSstream Sout
OSstream wrapped stdout (std::cout)
Foam::IOobject::objectPath
fileName objectPath() const
The complete path + object name.
Definition: IOobjectI.H:209