1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 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
29 An Istream is an abstract base class for all input systems
30 (streams, files, token lists etc). The basic operations
31 are construct, close, read token, read primitive and read binary
34 In addition, version control and line number counting is incorporated.
35 Usually one would use the read primitive member functions, but if one
36 were reading a stream on unknown data sequence one can read token by
37 token, and then analyse.
42 \*---------------------------------------------------------------------------*/
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 /*---------------------------------------------------------------------------*\
56 Class Istream Declaration
57 \*---------------------------------------------------------------------------*/
65 //- Has a token been put back on the stream
68 //- The last token put back on the stream
79 streamFormat format=ASCII,
80 versionNumber version=currentVersion,
81 compressionType compression=UNCOMPRESSED
84 IOstream(format, version, compression),
100 void putBack(const token&);
102 //- Get the put back token
103 bool getBack(token&);
105 //- Return next token from stream
106 virtual Istream& read(token&) = 0;
109 virtual Istream& read(char&) = 0;
112 virtual Istream& read(word&) = 0;
114 // Read a string (including enclosing double-quotes)
115 virtual Istream& read(string&) = 0;
118 virtual Istream& read(label&) = 0;
120 //- Read a floatScalar
121 virtual Istream& read(floatScalar&) = 0;
123 //- Read a doubleScalar
124 virtual Istream& read(doubleScalar&) = 0;
126 //- Read binary block
127 virtual Istream& read(char*, std::streamsize) = 0;
129 //- Rewind and return the stream so that it may be read again
130 virtual Istream& rewind() = 0;
133 // Read List punctuation tokens
135 Istream& readBegin(const char* funcName);
136 Istream& readEnd(const char* funcName);
137 Istream& readEndBegin(const char* funcName);
139 char readBeginList(const char* funcName);
140 char readEndList(const char* funcName);
145 //- Return a non-const reference to const Istream
146 // Needed for read-constructors where the stream argument is temporary:
147 // e.g. thing thisThing(IFstream("thingFileName")());
148 Istream& operator()() const;
152 // --------------------------------------------------------------------
153 // ------ Manipulators (not taking arguments)
154 // --------------------------------------------------------------------
156 typedef Istream& (*IstreamManip)(Istream&);
158 //- operator>> handling for manipulators without arguments
159 inline Istream& operator>>(Istream& is, IstreamManip f)
164 //- operator>> handling for manipulators without arguments
165 inline Istream& operator>>(Istream& is, IOstreamManip f)
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 } // End namespace Foam
176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 # include "HashTable.C"
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
186 // ************************************************************************* //