OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

dictionaryEntryIO.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Description
00026     DictionaryEntry constructor from Istream and Ostream output operator.
00027 
00028 \*---------------------------------------------------------------------------*/
00029 
00030 #include "keyType.H"
00031 #include "dictionaryEntry.H"
00032 #include "IOstreams.H"
00033 
00034 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00035 
00036 Foam::dictionaryEntry::dictionaryEntry
00037 (
00038     const dictionary& parentDict,
00039     Istream& is
00040 )
00041 :
00042     entry(is),
00043     dictionary(parentDict, is)
00044 {
00045     is.fatalCheck
00046     (
00047         "dictionaryEntry::dictionaryEntry"
00048         "(const dictionary& parentDict, Istream&)"
00049     );
00050 }
00051 
00052 
00053 Foam::dictionaryEntry::dictionaryEntry
00054 (
00055     const keyType& key,
00056     const dictionary& parentDict,
00057     Istream& is
00058 )
00059 :
00060     entry(key),
00061     dictionary(parentDict, is)
00062 {
00063     name() += "::" + key;
00064 
00065     is.fatalCheck
00066     (
00067         "dictionaryEntry::dictionaryEntry"
00068         "(const keyType&, const dictionary& parentDict, Istream&)"
00069     );
00070 }
00071 
00072 
00073 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00074 
00075 void Foam::dictionaryEntry::write(Ostream& os) const
00076 {
00077     // write keyword with indent but without trailing spaces
00078     os.indent();
00079     os.write(keyword());
00080     dictionary::write(os);
00081 }
00082 
00083 
00084 // * * * * * * * * * * * * * Ostream operator  * * * * * * * * * * * * * * * //
00085 
00086 Foam::Ostream& Foam::operator<<(Ostream& os, const dictionaryEntry& de)
00087 {
00088     de.write(os);
00089     return os;
00090 }
00091 
00092 
00093 #if defined (__GNUC__)
00094 template<>
00095 #endif
00096 Foam::Ostream& Foam::operator<<
00097 (
00098     Ostream& os,
00099     const InfoProxy<dictionaryEntry>& ip
00100 )
00101 {
00102     const dictionaryEntry& e = ip.t_;
00103 
00104     os  << "    dictionaryEntry '" << e.keyword() << "'" << endl;
00105 
00106     return os;
00107 }
00108 
00109 
00110 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd