ARTS  2.4.0(git:4fb77825)
bofstream.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 BOFSTREAM_H_INCLUDED
31 #define BOFSTREAM_H_INCLUDED
32 
33 #include <fstream>
34 
35 #include "binio.h"
36 
38 
42 class bofstream : public binostream, public ofstream {
43  public:
44  bofstream() : ofstream() {}
45 
46  explicit bofstream(const char* name,
47  ios::openmode mode = ios::out | ios::trunc | ios::binary)
48  : ofstream(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 ~bofstream() {}
55  void seek(long spos, Offset offs) override final;
56  streampos pos() override final;
57 
58  void putByte(bofstream::Byte b) override final;
59  void putRaw(const char* c, streamsize n) override final { this->write(c, n); }
60 };
61 
62 /* Overloaded output operators */
63 bofstream& operator<<(bofstream& bof, double n);
64 
65 bofstream& operator<<(bofstream& bof, float n);
66 
67 bofstream& operator<<(bofstream& bof, long n);
68 
69 bofstream& operator<<(bofstream& bof, int n);
70 
71 #endif
binio::BigEndian
@ BigEndian
Definition: binio.h:68
binio::FloatIEEE
@ FloatIEEE
Definition: binio.h:68
bofstream::bofstream
bofstream()
Definition: bofstream.h:44
binio.h
bofstream::seek
void seek(long spos, Offset offs) override final
Definition: bofstream.cc:34
binostream
Definition: binio.h:145
bofstream::putRaw
void putRaw(const char *c, streamsize n) override final
Definition: bofstream.h:59
bofstream::bofstream
bofstream(const char *name, ios::openmode mode=ios::out|ios::trunc|ios::binary)
Definition: bofstream.h:46
bofstream::pos
streampos pos() override final
Definition: bofstream.cc:53
binio::Offset
Offset
Definition: binio.h:80
operator<<
bofstream & operator<<(bofstream &bof, double n)
Definition: bofstream.cc:76
bofstream::~bofstream
virtual ~bofstream()
Definition: bofstream.h:54
binio::setFlag
void setFlag(Flag f, bool set=true)
Definition: binio.cc:84
bofstream::putByte
void putByte(bofstream::Byte b) override final
Definition: bofstream.cc:61
binio::Byte
unsigned char Byte
Definition: binio.h:99
bofstream
Binary output file stream class.
Definition: bofstream.h:42