initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / db / IOstreams / IOstreams / Istream.H
blob701c674b14f5a6df33da9c6f4ce86e40663e6d62
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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
25 Class
26     Foam::Istream
28 Description
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
32     block.
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.
39 SourceFiles
40     Istream.C
42 \*---------------------------------------------------------------------------*/
44 #ifndef Istream_H
45 #define Istream_H
47 #include "IOstream.H"
48 #include "token.H"
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 namespace Foam
55 /*---------------------------------------------------------------------------*\
56                            Class Istream Declaration
57 \*---------------------------------------------------------------------------*/
59 class Istream
61     public IOstream
63     // Private data
65         //- Has a token been put back on the stream
66         bool putBack_;
68         //- The last token put back on the stream
69         token putBackToken_;
72 public:
74     // Constructors
76         //- Set stream status
77         Istream
78         (
79             streamFormat format=ASCII,
80             versionNumber version=currentVersion,
81             compressionType compression=UNCOMPRESSED
82         )
83         :
84             IOstream(format, version, compression),
85             putBack_(false)
86         {}
89     // Destructor
91         virtual ~Istream()
92         {}
95     // Member functions
97         // Read functions
99             //- Put back token
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;
108             //- Read a character
109             virtual Istream& read(char&) = 0;
111             //- Read a word
112             virtual Istream& read(word&) = 0;
114             // Read a string (including enclosing double-quotes)
115             virtual Istream& read(string&) = 0;
117             //- Read a label
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);
143     // Member operators
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)
161     return f(is);
164 //- operator>> handling for manipulators without arguments
165 inline Istream& operator>>(Istream& is, IOstreamManip f)
167     f(is);
168     return is;
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 } // End namespace Foam
176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178 #ifdef NoRepository
179 #   include "HashTable.C"
180 #endif
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 #endif
186 // ************************************************************************* //