FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

ISstream.H

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 Class
00025     Foam::ISstream
00026 
00027 Description
00028     Generic input stream.
00029 
00030 SourceFiles
00031     ISstreamI.H
00032     ISread.C
00033     ISreadToken.C
00034 
00035 \*---------------------------------------------------------------------------*/
00036 
00037 #ifndef ISstream_H
00038 #define ISstream_H
00039 
00040 #include <OpenFOAM/Istream.H>
00041 #include <OpenFOAM/fileName.H>
00042 #include <iostream>
00043 
00044 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00045 
00046 namespace Foam
00047 {
00048 
00049 /*---------------------------------------------------------------------------*\
00050                            Class ISstream Declaration
00051 \*---------------------------------------------------------------------------*/
00052 
00053 class ISstream
00054 :
00055     public Istream
00056 {
00057     // Private data
00058 
00059         fileName name_;
00060         istream& is_;
00061 
00062 
00063     // Private member functions
00064 
00065         char nextValid();
00066 
00067 
00068     // Private Member Functions
00069 
00070         //- Disallow default bitwise assignment
00071         void operator=(const ISstream&);
00072 
00073 
00074 protected:
00075 
00076     // Protected member functions
00077 
00078         //- Return the stream reference
00079         istream& stream()
00080         {
00081             return is_;
00082         }
00083 
00084         //- Return the const stream reference
00085         const istream& stream() const
00086         {
00087             return is_;
00088         }
00089 
00090 
00091 public:
00092 
00093     // Constructors
00094 
00095         //- Construct as wrapper around istream
00096         inline ISstream
00097         (
00098             istream& is,
00099             const string& name,
00100             streamFormat format=ASCII,
00101             versionNumber version=currentVersion,
00102             compressionType compression=UNCOMPRESSED
00103         );
00104 
00105 
00106     // Destructor
00107 
00108         virtual ~ISstream()
00109         {}
00110 
00111 
00112     // Member functions
00113 
00114         // Inquiry
00115 
00116             //- Return the name of the stream
00117             //  Useful for Fstream to return the filename
00118             virtual const fileName& name() const
00119             {
00120                 return name_;
00121             }
00122 
00123             //- Return non-const access to the name of the stream
00124             //  Useful to alter the stream name
00125             virtual fileName& name()
00126             {
00127                 return name_;
00128             }
00129 
00130             //- Return flags of output stream
00131             virtual ios_base::fmtflags flags() const;
00132 
00133 
00134         // Read functions
00135 
00136             //- Raw, low-level get character function.
00137             inline ISstream& get(char&);
00138 
00139             //- Raw, low-level getline into a string function.
00140             inline ISstream& getLine(string&);
00141 
00142             //- Raw, low-level putback character function.
00143             inline ISstream& putback(const char&);
00144 
00145             //- Return next token from stream
00146             virtual Istream& read(token&);
00147 
00148             //- Read a character
00149             virtual Istream& read(char&);
00150 
00151             //- Read a word
00152             virtual Istream& read(word&);
00153 
00154             //- Read a string (including enclosing double-quotes).
00155             //  Backslashes are retained, except when escaping double-quotes
00156             //  and an embedded newline character.
00157             virtual Istream& read(string&);
00158 
00159             //- Read a label
00160             virtual Istream& read(label&);
00161 
00162             //- Read a floatScalar
00163             virtual Istream& read(floatScalar&);
00164 
00165             //- Read a doubleScalar
00166             virtual Istream& read(doubleScalar&);
00167 
00168             //- Read binary block
00169             virtual Istream& read(char*, std::streamsize);
00170 
00171             //- Rewind and return the stream so that it may be read again
00172             virtual Istream& rewind();
00173 
00174 
00175         // Stream state functions
00176 
00177             //- Set flags of output stream
00178             virtual ios_base::fmtflags flags(const ios_base::fmtflags flags);
00179 
00180 
00181         // Print
00182 
00183             //- Print description of IOstream to Ostream
00184             virtual void print(Ostream&) const;
00185 };
00186 
00187 
00188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00189 
00190 } // End namespace Foam
00191 
00192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00193 
00194 #include <OpenFOAM/ISstreamI.H>
00195 
00196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00197 
00198 #endif
00199 
00200 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines