1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Implementation of parser: test the state of either an istream or an
27 ostream. Report an error if there is one.
29 \*---------------------------------------------------------------------------*/
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 // Print state of ostream.
44 void state(ostream& to, const string& s)
46 state_value osState = state_value(to.rdstate());
50 case _good: // Do not anything 'unusual'.
55 << "Output stream: premature end of stream", s << endl;
59 SeriousErrorIn("state(ostream& to, const string& s)")
60 << "Output stream failure (bad format?)", s << endl;
64 SeriousErrorIn("state(ostream& to, const string& s)")
65 << "Output stream failure and end of stream", s << endl;
69 SeriousErrorIn("state(ostream& to, const string& s)")
70 << "Serious output stream failure", s << endl;
74 SeriousErrorIn("state(ostream& to, const string& s)")
75 << "Output stream failure of unknown type", s << endl
76 << "Stream state value = ", osState << endl;
84 // Print state of istream.
85 void state(istream& from, const string& s)
87 state_value isState = state_value(from.rdstate());
91 case _good: // Do not anything 'unusual'.
96 << "Input stream: premature end of stream", s << endl;
97 Info<< "If all else well, possibly a quote mark missing" << endl;
101 SeriousErrorIn("state(istream& from, const string& s)")
102 << "Input stream failure (bad format?)", s << endl;
103 Info<< "If all else well, possibly a quote mark missing" << endl;
106 case (_fail + _eof) :
107 SeriousErrorIn("state(istream& from, const string& s)")
108 << "Input stream failure and end of stream", s << endl;
109 Info<< "If all else well, possibly a quote mark missing" << endl;
113 SeriousErrorIn("state(istream& from, const string& s)")
114 << "Serious input stream failure", s << endl;
118 SeriousErrorIn("state(istream& from, const string& s)")
119 << "Input stream failure of unknown type", s << endl;
120 SeriousErrorIn("state(istream& from, const string& s)")
121 << "Stream state value = ", isState << endl;
129 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
131 } // End namespace Foam
133 // ************************************************************************* //