ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / OpenFOAM / db / IOstreams / Tstreams / ITstream.H
blob55c04d0d94d719609ec4113c89e27073f3ba7dc9
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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
13     the Free Software Foundation, either version 3 of the License, or
14     (at your 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, see <http://www.gnu.org/licenses/>.
24 Class
25     Foam::ITstream
27 Description
28     Input token stream.
30 SourceFiles
31     ITstream.C
33 \*---------------------------------------------------------------------------*/
35 #ifndef ITstream_H
36 #define ITstream_H
38 #include "Istream.H"
39 #include "tokenList.H"
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 namespace Foam
46 /*---------------------------------------------------------------------------*\
47                            Class ITstream Declaration
48 \*---------------------------------------------------------------------------*/
50 class ITstream
52     public Istream,
53     public tokenList
55     // Private data
57         //- Name of ITstream
58         fileName name_;
60         //- Index of token currently being read
61         label tokenIndex_;
64 public:
66     // Constructors
68         //- Construct from components
69         ITstream
70         (
71             const string& name,
72             const UList<token>& tokens,
73             streamFormat format=ASCII,
74             versionNumber version=currentVersion
75         )
76         :
77             Istream(format, version),
78             tokenList(tokens),
79             name_(name),
80             tokenIndex_(0)
81         {
82             setOpened();
83             setGood();
84         }
87         //- Construct from components, transferring the tokens
88         ITstream
89         (
90             const string& name,
91             const Xfer<List<token> >& tokens,
92             streamFormat format=ASCII,
93             versionNumber version=currentVersion
94         )
95         :
96             Istream(format, version),
97             tokenList(tokens),
98             name_(name),
99             tokenIndex_(0)
100         {
101             setOpened();
102             setGood();
103         }
106         //- Construct as copy
107         ITstream(const ITstream& its)
108         :
109             Istream(ASCII, currentVersion),
110             tokenList(its),
111             name_(its.name_),
112             tokenIndex_(0)
113         {
114             setOpened();
115             setGood();
116         }
119         //- Destructor
120         virtual ~ITstream()
121         {}
124     // Member functions
126         // Inquiry
128             //- Return the name of the stream
129             const fileName& name() const
130             {
131                 return name_;
132             }
134             //- Return non-const access to the name of the stream
135             fileName& name()
136             {
137                 return name_;
138             }
140             //- Return the current token index
141             label tokenIndex() const
142             {
143                 return tokenIndex_;
144             }
146             //- Return non-const access to the current token index
147             label& tokenIndex()
148             {
149                 return tokenIndex_;
150             }
152             //- Return the number of remaining tokens
153             label nRemainingTokens() const
154             {
155                 return size() - tokenIndex_;
156             }
158             //- Return flags of output stream
159             ios_base::fmtflags flags() const
160             {
161                 return ios_base::fmtflags(0);
162             }
165         // Read functions
167             //- Return next token from stream
168             virtual Istream& read(token&);
170             //- Read a character
171             virtual Istream& read(char&);
173             //- Read a word
174             virtual Istream& read(word&);
176             // Read a string (including enclosing double-quotes)
177             virtual Istream& read(string&);
179             //- Read a label
180             virtual Istream& read(label&);
182             //- Read a floatScalar
183             virtual Istream& read(floatScalar&);
185             //- Read a doubleScalar
186             virtual Istream& read(doubleScalar&);
188             //- Read binary block
189             virtual Istream& read(char*, std::streamsize);
191             //- Rewind and return the stream so that it may be read again
192             virtual Istream& rewind();
195         // Edit
197             //- Set flags of stream
198             ios_base::fmtflags flags(const ios_base::fmtflags)
199             {
200                 return ios_base::fmtflags(0);
201             }
204         // Print
206             //- Print description of IOstream to Ostream
207             void print(Ostream&) const;
211 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
213 } // End namespace Foam
215 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 #endif
219 // ************************************************************************* //