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

ITstream.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::ITstream
00026 
00027 Description
00028     Input token stream.
00029 
00030 SourceFiles
00031     ITstream.C
00032 
00033 \*---------------------------------------------------------------------------*/
00034 
00035 #ifndef ITstream_H
00036 #define ITstream_H
00037 
00038 #include <OpenFOAM/Istream.H>
00039 #include <OpenFOAM/tokenList.H>
00040 
00041 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00042 
00043 namespace Foam
00044 {
00045 
00046 /*---------------------------------------------------------------------------*\
00047                            Class ITstream Declaration
00048 \*---------------------------------------------------------------------------*/
00049 
00050 class ITstream
00051 :
00052     public Istream,
00053     public tokenList
00054 {
00055     // Private data
00056 
00057         //- Name of ITstream
00058         fileName name_;
00059 
00060         //- Index of token currently being read
00061         label tokenIndex_;
00062 
00063 
00064 public:
00065 
00066     // Constructors
00067 
00068         //- Construct from components
00069         ITstream
00070         (
00071             const string& name,
00072             const tokenList& tokens,
00073             streamFormat format=ASCII,
00074             versionNumber version=currentVersion
00075         )
00076         :
00077             Istream(format, version),
00078             tokenList(tokens),
00079             name_(name),
00080             tokenIndex_(0)
00081         {
00082             setOpened();
00083             setGood();
00084         }
00085 
00086 
00087         //- Construct as copy
00088         ITstream(const ITstream& its)
00089         :
00090             Istream(ASCII, currentVersion),
00091             tokenList(its),
00092             name_(its.name_),
00093             tokenIndex_(0)
00094         {
00095             setOpened();
00096             setGood();
00097         }
00098 
00099 
00100     // Destructor
00101 
00102         virtual ~ITstream()
00103         {}
00104 
00105 
00106     // Member functions
00107 
00108         // Inquiry
00109 
00110             //- Return the name of the stream
00111             const fileName& name() const
00112             {
00113                 return name_;
00114             }
00115 
00116             //- Return non-const access to the name of the stream
00117             fileName& name()
00118             {
00119                 return name_;
00120             }
00121 
00122             //- Return the current token index
00123             label tokenIndex() const
00124             {
00125                 return tokenIndex_;
00126             }
00127 
00128             //- Return non-const access to the current token index
00129             label& tokenIndex()
00130             {
00131                 return tokenIndex_;
00132             }
00133 
00134             //- Return the number of remaining tokens
00135             label nRemainingTokens() const
00136             {
00137                 return size() - tokenIndex_;
00138             }
00139 
00140             //- Return flags of output stream
00141             ios_base::fmtflags flags() const
00142             {
00143                 return ios_base::fmtflags(0);
00144             }
00145 
00146 
00147         // Read functions
00148 
00149             //- Return next token from stream
00150             virtual Istream& read(token&);
00151 
00152             //- Read a character
00153             virtual Istream& read(char&);
00154 
00155             //- Read a word
00156             virtual Istream& read(word&);
00157 
00158             // Read a string (including enclosing double-quotes)
00159             virtual Istream& read(string&);
00160 
00161             //- Read a label
00162             virtual Istream& read(label&);
00163 
00164             //- Read a floatScalar
00165             virtual Istream& read(floatScalar&);
00166 
00167             //- Read a doubleScalar
00168             virtual Istream& read(doubleScalar&);
00169 
00170             //- Read binary block
00171             virtual Istream& read(char*, std::streamsize);
00172 
00173             //- Rewind and return the stream so that it may be read again
00174             virtual Istream& rewind();
00175 
00176 
00177         // Edit
00178 
00179             //- Set flags of stream
00180             ios_base::fmtflags flags(const ios_base::fmtflags)
00181             {
00182                 return ios_base::fmtflags(0);
00183             }
00184 
00185 
00186         // Print
00187 
00188             //- Print description of IOstream to Ostream
00189             void print(Ostream&) const;
00190 };
00191 
00192 
00193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00194 
00195 } // End namespace Foam
00196 
00197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00198 
00199 #endif
00200 
00201 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines