ARTS  2.4.0(git:4fb77825)
bifstream.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2012 Oliver Lemke <olemke@core-dump.info>
2 
3  This program is free software; you can redistribute it and/or modify it
4  under the terms of the GNU General Public License as published by the
5  Free Software Foundation; either version 2, or (at your option) any
6  later version.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16  USA. */
17 
19 // File description
21 
30 #ifndef BIFSTREAM_H_INCLUDED
31 #define BIFSTREAM_H_INCLUDED
32 
33 #include <fstream>
34 
35 #include "binio.h"
36 
38 
42 class bifstream : public binistream, public ifstream {
43  public:
44  bifstream() : ifstream() {}
45 
46  explicit bifstream(const char* name,
47  ios::openmode mode = ios::in | ios::binary)
48  : ifstream(name, mode) {
49  // Set Little Endian mode, with IEEE-754 floats.
50  this->setFlag(binio::BigEndian, false); // remove flag
51  this->setFlag(binio::FloatIEEE); // set flag
52  }
53 
54  virtual ~bifstream() {}
55  void seek(long spos, Offset offs) override final;
56  streampos pos() override final;
57 
58  bifstream::Byte getByte() override final;
59  void getRaw(char* c, streamsize n) override final { this->read(c, n); }
60 };
61 
62 /* Overloaded input operators */
63 bifstream& operator>>(bifstream& bif, double& n);
64 
65 bifstream& operator>>(bifstream& bif, float& n);
66 
67 bifstream& operator>>(bifstream& bif, long& n);
68 
69 bifstream& operator>>(bifstream& bif, int& n);
70 
71 #endif
binio::BigEndian
@ BigEndian
Definition: binio.h:68
operator>>
bifstream & operator>>(bifstream &bif, double &n)
Definition: bifstream.cc:75
binio::FloatIEEE
@ FloatIEEE
Definition: binio.h:68
bifstream::getRaw
void getRaw(char *c, streamsize n) override final
Definition: bifstream.h:59
binio.h
lm_hitran_2017::read
void read(HitranRelaxationMatrixData &hitran, ArrayOfAbsorptionLines &bands, const String &basedir, const Numeric linemixinglimit, const Numeric fmin, const Numeric fmax, const Numeric stot, const ModeOfLineMixing mode)
Read from HITRAN online line mixing file.
Definition: linemixing_hitran.cc:1940
bifstream::seek
void seek(long spos, Offset offs) override final
Definition: bifstream.cc:34
bifstream::~bifstream
virtual ~bifstream()
Definition: bifstream.h:54
bifstream
Binary output file stream class.
Definition: bifstream.h:42
binio::Offset
Offset
Definition: binio.h:80
bifstream::bifstream
bifstream()
Definition: bifstream.h:44
binistream
Definition: binio.h:117
bifstream::pos
streampos pos() override final
Definition: bifstream.cc:53
binio::setFlag
void setFlag(Flag f, bool set=true)
Definition: binio.cc:84
bifstream::bifstream
bifstream(const char *name, ios::openmode mode=ios::in|ios::binary)
Definition: bifstream.h:46
binio::Byte
unsigned char Byte
Definition: binio.h:99
bifstream::getByte
bifstream::Byte getByte() override final
Definition: bifstream.cc:61