initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / db / IOstreams / Sstreams / ISstream.H
blobfe778fa01031cccb4d0602d913ba61da3ebb6889
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::ISstream
28 Description
29     Generic input stream.
31 SourceFiles
32     ISstreamI.H
33     ISread.C
34     ISreadToken.C
36 \*---------------------------------------------------------------------------*/
38 #ifndef ISstream_H
39 #define ISstream_H
41 #include "Istream.H"
42 #include "fileName.H"
43 #include <iostream>
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 namespace Foam
50 /*---------------------------------------------------------------------------*\
51                            Class ISstream Declaration
52 \*---------------------------------------------------------------------------*/
54 class ISstream
56     public Istream
58     // Private data
60         fileName name_;
61         istream& is_;
64     // Private member functions
66         char nextValid();
69     // Private Member Functions
71         //- Disallow default bitwise assignment
72         void operator=(const ISstream&);
75 protected:
77     // Protected member functions
79         //- Return the stream reference
80         istream& stream()
81         {
82             return is_;
83         }
85         //- Return the const stream reference
86         const istream& stream() const
87         {
88             return is_;
89         }
92 public:
94     // Constructors
96         //- Construct as wrapper around istream
97         inline ISstream
98         (
99             istream& is,
100             const string& name,
101             streamFormat format=ASCII,
102             versionNumber version=currentVersion,
103             compressionType compression=UNCOMPRESSED
104         );
107     // Destructor
109         virtual ~ISstream()
110         {}
113     // Member functions
115         // Inquiry
117             //- Return the name of the stream
118             //  Useful for Fstream to return the filename
119             virtual const fileName& name() const
120             {
121                 return name_;
122             }
124             //- Return non-const access to the name of the stream
125             //  Useful to alter the stream name
126             virtual fileName& name()
127             {
128                 return name_;
129             }
131             //- Return flags of output stream
132             virtual ios_base::fmtflags flags() const;
135         // Read functions
137             //- Raw, low-level get character function.
138             inline ISstream& get(char&);
140             //- Raw, low-level getline into a string function.
141             inline ISstream& getLine(string&);
143             //- Raw, low-level putback character function.
144             inline ISstream& putback(const char&);
146             //- Return next token from stream
147             virtual Istream& read(token&);
149             //- Read a character
150             virtual Istream& read(char&);
152             //- Read a word
153             virtual Istream& read(word&);
155             //- Read a string (including enclosing double-quotes).
156             //  Backslashes are retained, except when escaping double-quotes
157             //  and an embedded newline character.
158             virtual Istream& read(string&);
160             //- Read a label
161             virtual Istream& read(label&);
163             //- Read a floatScalar
164             virtual Istream& read(floatScalar&);
166             //- Read a doubleScalar
167             virtual Istream& read(doubleScalar&);
169             //- Read binary block
170             virtual Istream& read(char*, std::streamsize);
172             //- Rewind and return the stream so that it may be read again
173             virtual Istream& rewind();
176         // Stream state functions
178             //- Set flags of output stream
179             virtual ios_base::fmtflags flags(const ios_base::fmtflags flags);
182         // Print
184             //- Print description of IOstream to Ostream
185             virtual void print(Ostream&) const;
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191 } // End namespace Foam
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195 #include "ISstreamI.H"
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199 #endif
201 // ************************************************************************* //