ARTS  2.2.66
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 
18 
20 // File description
22 
31 #ifndef BOFSTREAM_H_INCLUDED
32 #define BOFSTREAM_H_INCLUDED
33 
34 #include <fstream>
35 
36 #include "binio.h"
37 
38 
40 
44 class bofstream : public binostream, public ofstream
45 {
46 public:
47  bofstream () : ofstream () { }
48 
49  explicit
50  bofstream (const char* name,
51  ios::openmode mode = ios::out | ios::trunc | ios::binary)
52  : ofstream (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  virtual ~bofstream () {}
60  void seek(long spos, Offset offs);
61  streampos pos();
62 
63  void putByte (bofstream::Byte b);
64  void putRaw (const char *c, streamsize n) { this->write (c, n); }
65 };
66 
67 
68 /* Overloaded output operators */
69 bofstream& operator<< (bofstream& bof, double n);
70 
71 bofstream& operator<< (bofstream& bof, float n);
72 
73 bofstream& operator<< (bofstream& bof, long n);
74 
75 bofstream& operator<< (bofstream& bof, int n);
76 
77 #endif
binio::BigEndian
@ BigEndian
Definition: binio.h:70
binio::FloatIEEE
@ FloatIEEE
Definition: binio.h:71
bofstream::bofstream
bofstream()
Definition: bofstream.h:47
binio.h
bofstream::putRaw
void putRaw(const char *c, streamsize n)
Definition: bofstream.h:64
binostream
Definition: binio.h:151
bofstream::pos
streampos pos()
Definition: bofstream.cc:46
bofstream::putByte
void putByte(bofstream::Byte b)
Definition: bofstream.cc:52
bofstream::bofstream
bofstream(const char *name, ios::openmode mode=ios::out|ios::trunc|ios::binary)
Definition: bofstream.h:50
binio::Offset
Offset
Definition: binio.h:84
operator<<
bofstream & operator<<(bofstream &bof, double n)
Definition: bofstream.cc:70
bofstream::~bofstream
virtual ~bofstream()
Definition: bofstream.h:59
binio::setFlag
void setFlag(Flag f, bool set=true)
Definition: binio.cc:94
bofstream::seek
void seek(long spos, Offset offs)
Definition: bofstream.cc:35
binio::Byte
unsigned char Byte
Definition: binio.h:103
bofstream
Binary output file stream class.
Definition: bofstream.h:45