ensightReadFile.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) 2016-2021 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::ensightReadFile
28 
29 Description
30  Ensight output with specialized read() for strings, integers and floats.
31  Correctly handles binary read as well.
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef ensightReadFile_H
36 #define ensightReadFile_H
37 
38 #include "IFstream.H"
39 #include "IOstream.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 /*---------------------------------------------------------------------------*\
47  Class ensightReadFile Declaration
48 \*---------------------------------------------------------------------------*/
49 
50 class ensightReadFile
51 :
52  public IFstream
53 {
54  // Private Member Functions
55 
56  //- No copy construct
57  ensightReadFile(const ensightReadFile&) = delete;
58 
59  //- No copy assignment
60  void operator=(const ensightReadFile&) = delete;
61 
62 
63 public:
64 
65  // Constructors
66 
67  //- Construct from pathname. Default format is binary.
68  explicit ensightReadFile
69  (
70  const fileName& pathname,
72  );
73 
74 
75  //- Destructor
76  ~ensightReadFile() = default;
77 
78 
79  // Output
80 
81  //- Inherit read from Istream
82  using Istream::read;
83 
84  //- Binary read
85  virtual Istream& read(char* buf, std::streamsize count);
86 
87  //- Read string as "%80s" or as binary
88  Istream& read(string& value);
89 
90  //- Read integer as "%10d" or as binary
91  Istream& read(label& value);
92 
93  //- Read float as "%12.5e" or as binary
94  Istream& read(scalar& value);
95 
96  //- Read element keyword
97  virtual Istream& readKeyword(string& key);
98 
99  //- Read "C Binary" for binary files (eg, geometry/measured)
101 };
102 
103 
104 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
105 
106 } // End namespace Foam
107 
108 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
109 
110 #endif
111 
112 // ************************************************************************* //
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
Foam::IFstream
Input from file stream, using an ISstream.
Definition: IFstream.H:53
Foam::glTF::key
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
Definition: foamGltfBase.H:108
Foam::ensightReadFile
Ensight output with specialized read() for strings, integers and floats. Correctly handles binary rea...
Definition: ensightReadFile.H:49
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
IOstream.H
IFstream.H
Foam::IOstreamOption::streamFormat
streamFormat
Data format (ascii | binary)
Definition: IOstreamOption.H:70
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::ensightReadFile::readBinaryHeader
Istream & readBinaryHeader()
Read "C Binary" for binary files (eg, geometry/measured)
Definition: ensightReadFile.C:152
Foam::IOstreamOption::BINARY
"binary"
Definition: IOstreamOption.H:73
Foam::BitOps::count
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
Definition: BitOps.H:77
Foam::ensightReadFile::~ensightReadFile
~ensightReadFile()=default
Destructor.
Foam::ensightReadFile::readKeyword
virtual Istream & readKeyword(string &key)
Read element keyword.
Definition: ensightReadFile.C:145
Foam::ensightReadFile::read
virtual Istream & read(char *buf, std::streamsize count)
Binary read.
Definition: ensightReadFile.C:45
Foam::Istream::read
virtual Istream & read(token &)=0
Return next token from stream.