IFstream.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011 OpenFOAM Foundation
9 Copyright (C) 2017-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::IFstream
29
30Description
31 Input from file stream, using an ISstream
32
33SourceFiles
34 IFstream.C
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef IFstream_H
39#define IFstream_H
40
41#include "ISstream.H"
42#include "className.H"
43#include "fstreamPointer.H"
44
45// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46
47namespace Foam
48{
49
50/*---------------------------------------------------------------------------*\
51 Class IFstream Declaration
52\*---------------------------------------------------------------------------*/
54class IFstream
55:
57 public ISstream
58{
59public:
60
61 //- Declare type-name (with debug switch)
62 ClassName("IFstream");
63
64
65 // Constructors
66
67 //- Construct from pathname
68 explicit IFstream
69 (
70 const fileName& pathname,
71 IOstreamOption streamOpt = IOstreamOption()
72 );
73
74 //- Construct from pathname, format (version)
76 (
77 const fileName& pathname,
80 )
81 :
82 IFstream(pathname, IOstreamOption(fmt, ver))
83 {}
84
85
86 //- Destructor
87 ~IFstream() = default;
88
89
90 // Member Functions
91
92 //- Get character(s)
93 using ISstream::get;
94
95 //- Read/write access to the name of the stream
96 using ISstream::name;
97
98
99 // STL stream
100
101 //- Access to underlying std::istream
102 virtual std::istream& stdStream();
103
104 //- Const access to underlying std::istream
105 virtual const std::istream& stdStream() const;
106
107 //- Rewind the stream so that it may be read again.
108 // Includes special handling for compressed streams.
109 virtual void rewind();
110
111
112 // Print
113
114 //- Print stream description
115 virtual void print(Ostream& os) const;
116
117
118 // Member Operators
119
120 //- Return a non-const reference to const IFstream
121 // Needed for read-constructors where the stream argument is temporary:
122 // e.g. thing thisThing(IFstream("fileName")());
123 IFstream& operator()() const;
124};
125
126
127// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
128
129} // End namespace Foam
130
131// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
132
133#endif
134
135// ************************************************************************* //
Input from file stream, using an ISstream.
Definition: IFstream.H:57
IFstream & operator()() const
Return a non-const reference to const IFstream.
Definition: IFstream.C:148
~IFstream()=default
Destructor.
virtual std::istream & stdStream()
Access to underlying std::istream.
Definition: IFstream.C:94
virtual void print(Ostream &os) const
Print stream description.
Definition: IFstream.C:139
IFstream(const fileName &pathname, IOstreamOption::streamFormat fmt, IOstreamOption::versionNumber ver=IOstreamOption::currentVersion)
Construct from pathname, format (version)
Definition: IFstream.H:75
virtual void rewind()
Rewind the stream so that it may be read again.
Definition: IFstream.C:124
ClassName("IFstream")
Declare type-name (with debug switch)
Representation of a major/minor version number.
The IOstreamOption is a simple container for options an IOstream can normally have.
streamFormat
Data format (ascii | binary)
static const versionNumber currentVersion
The current version number (2.0)
Generic input stream using a standard (STL) stream.
Definition: ISstream.H:58
virtual const fileName & name() const
Return the name of the stream.
Definition: ISstream.H:113
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
unsigned int get() const
Get value as unsigned, no range-checking.
Definition: PackedListI.H:302
A class for handling file names.
Definition: fileName.H:76
A wrapped std::ifstream with possible compression handling (igzstream) that behaves much like a std::...
Macro definitions for declaring ClassName(), NamespaceName(), etc.
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
Definition: className.H:67
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.