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

Istream.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::Istream
00026 
00027 Description
00028     An Istream is an abstract base class for all input systems
00029     (streams, files, token lists etc).  The basic operations
00030     are construct, close, read token, read primitive and read binary
00031     block.
00032 
00033     In addition, version control and line number counting is incorporated.
00034     Usually one would use the read primitive member functions, but if one
00035     were reading a stream on unknown data sequence one can read token by
00036     token, and then analyse.
00037 
00038 SourceFiles
00039     Istream.C
00040 
00041 \*---------------------------------------------------------------------------*/
00042 
00043 #ifndef Istream_H
00044 #define Istream_H
00045 
00046 #include "IOstream.H"
00047 #include <OpenFOAM/token.H>
00048 
00049 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00050 
00051 namespace Foam
00052 {
00053 
00054 /*---------------------------------------------------------------------------*\
00055                            Class Istream Declaration
00056 \*---------------------------------------------------------------------------*/
00057 
00058 class Istream
00059 :
00060     public IOstream
00061 {
00062     // Private data
00063 
00064         //- Has a token been put back on the stream
00065         bool putBack_;
00066 
00067         //- The last token put back on the stream
00068         token putBackToken_;
00069 
00070 
00071 public:
00072 
00073     // Constructors
00074 
00075         //- Set stream status
00076         Istream
00077         (
00078             streamFormat format=ASCII,
00079             versionNumber version=currentVersion,
00080             compressionType compression=UNCOMPRESSED
00081         )
00082         :
00083             IOstream(format, version, compression),
00084             putBack_(false)
00085         {}
00086 
00087 
00088     // Destructor
00089 
00090         virtual ~Istream()
00091         {}
00092 
00093 
00094     // Member functions
00095 
00096         // Read functions
00097 
00098             //- Put back token
00099             void putBack(const token&);
00100 
00101             //- Get the put back token
00102             bool getBack(token&);
00103 
00104              //- Return next token from stream
00105             virtual Istream& read(token&) = 0;
00106 
00107             //- Read a character
00108             virtual Istream& read(char&) = 0;
00109 
00110             //- Read a word
00111             virtual Istream& read(word&) = 0;
00112 
00113             // Read a string (including enclosing double-quotes)
00114             virtual Istream& read(string&) = 0;
00115 
00116             //- Read a label
00117             virtual Istream& read(label&) = 0;
00118 
00119             //- Read a floatScalar
00120             virtual Istream& read(floatScalar&) = 0;
00121 
00122             //- Read a doubleScalar
00123             virtual Istream& read(doubleScalar&) = 0;
00124 
00125             //- Read binary block
00126             virtual Istream& read(char*, std::streamsize) = 0;
00127 
00128             //- Rewind and return the stream so that it may be read again
00129             virtual Istream& rewind() = 0;
00130 
00131 
00132         // Read List punctuation tokens
00133 
00134             Istream& readBegin(const char* funcName);
00135             Istream& readEnd(const char* funcName);
00136             Istream& readEndBegin(const char* funcName);
00137 
00138             char readBeginList(const char* funcName);
00139             char readEndList(const char* funcName);
00140 
00141 
00142     // Member operators
00143 
00144         //- Return a non-const reference to const Istream
00145         //  Needed for read-constructors where the stream argument is temporary:
00146         //  e.g. thing thisThing(IFstream("thingFileName")());
00147         Istream& operator()() const;
00148 };
00149 
00150 
00151 // --------------------------------------------------------------------
00152 // ------ Manipulators (not taking arguments)
00153 // --------------------------------------------------------------------
00154 
00155 typedef Istream& (*IstreamManip)(Istream&);
00156 
00157 //- operator>> handling for manipulators without arguments
00158 inline Istream& operator>>(Istream& is, IstreamManip f)
00159 {
00160     return f(is);
00161 }
00162 
00163 //- operator>> handling for manipulators without arguments
00164 inline Istream& operator>>(Istream& is, IOstreamManip f)
00165 {
00166     f(is);
00167     return is;
00168 }
00169 
00170 
00171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00172 
00173 } // End namespace Foam
00174 
00175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00176 
00177 #ifdef NoRepository
00178 #   include <OpenFOAM/HashTable.C>
00179 #endif
00180 
00181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00182 
00183 #endif
00184 
00185 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines