ARTS  2.3.1285(git:92a29ea9-dirty)
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
unsigned char Byte
Definition: binio.h:99
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.
virtual ~bifstream()
Definition: bifstream.h:54
bifstream & operator>>(bifstream &bif, double &n)
Definition: bifstream.cc:75
bifstream()
Definition: bifstream.h:44
streampos pos() override final
Definition: bifstream.cc:53
void getRaw(char *c, streamsize n) override final
Definition: bifstream.h:59
Binary output file stream class.
Definition: bifstream.h:42
bifstream::Byte getByte() override final
Definition: bifstream.cc:61
void seek(long spos, Offset offs) override final
Definition: bifstream.cc:34
Offset
Definition: binio.h:80
void setFlag(Flag f, bool set=true)
Definition: binio.cc:84
bifstream(const char *name, ios::openmode mode=ios::in|ios::binary)
Definition: bifstream.h:46