ARTS  2.2.66
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 
18 
20 // File description
22 
31 #ifndef BIFSTREAM_H_INCLUDED
32 #define BIFSTREAM_H_INCLUDED
33 
34 #include <fstream>
35 
36 #include "binio.h"
37 
38 
40 
44 class bifstream : public binistream, public ifstream
45 {
46 public:
47  bifstream () : ifstream () { }
48 
49  explicit
50  bifstream (const char* name,
51  ios::openmode mode = ios::in | ios::binary)
52  : ifstream (name, mode)
53  {
54  // Set Little Endian mode, with IEEE-754 floats.
55  this->setFlag(binio::BigEndian, false); // remove flag
56  this->setFlag(binio::FloatIEEE); // set flag
57  }
58 
59 
60  virtual ~bifstream () {}
61  void seek(long spos, Offset offs);
62  streampos pos();
63 
65  void getRaw (char *c, streamsize n) { this->read (c, n); }
66 
67 };
68 
69 
70 /* Overloaded input operators */
71 bifstream& operator>> (bifstream& bif, double& n);
72 
73 bifstream& operator>> (bifstream& bif, float& n);
74 
75 bifstream& operator>> (bifstream& bif, long& n);
76 
77 bifstream& operator>> (bifstream& bif, int& n);
78 
79 #endif
unsigned char Byte
Definition: binio.h:103
void seek(long spos, Offset offs)
Definition: bifstream.cc:35
virtual ~bifstream()
Definition: bifstream.h:60
bifstream & operator>>(bifstream &bif, double &n)
Definition: bifstream.cc:68
bifstream()
Definition: bifstream.h:47
void getRaw(char *c, streamsize n)
Definition: bifstream.h:65
streampos pos()
Definition: bifstream.cc:46
Binary output file stream class.
Definition: bifstream.h:44
Offset
Definition: binio.h:84
void setFlag(Flag f, bool set=true)
Definition: binio.cc:94
bifstream(const char *name, ios::openmode mode=ios::in|ios::binary)
Definition: bifstream.h:50
bifstream::Byte getByte()
Definition: bifstream.cc:52