aboutsummaryrefslogtreecommitdiff
path: root/src/gzstream.h
diff options
context:
space:
mode:
authorPeter Carbonetto2017-08-02 13:07:23 -0500
committerGitHub2017-08-02 13:07:23 -0500
commitadaf9557f776ca274b51e921af0542ef1b84eb61 (patch)
tree8f7581bec20eb815848d02f926cb949ed038008b /src/gzstream.h
parent84360c191f418bf8682b35e0c8235fcc3bd19a06 (diff)
parent1e49e7a27d0f4b811a87c64db1e875779766f6b0 (diff)
downloadpangemma-adaf9557f776ca274b51e921af0542ef1b84eb61.tar.gz
Merge pull request #62 from genenetwork/spacing
Spacing and coding style.
Diffstat (limited to 'src/gzstream.h')
-rw-r--r--src/gzstream.h90
1 files changed, 46 insertions, 44 deletions
diff --git a/src/gzstream.h b/src/gzstream.h
index 241ff76..f760138 100644
--- a/src/gzstream.h
+++ b/src/gzstream.h
@@ -30,8 +30,8 @@
#define GZSTREAM_H 1
// Standard C++ with new header file names and std::namespace.
-#include <iostream>
#include <fstream>
+#include <iostream>
#include <zlib.h>
#ifdef GZSTREAM_NAMESPACE
@@ -44,43 +44,45 @@ namespace GZSTREAM_NAMESPACE {
class gzstreambuf : public std::streambuf {
private:
- static const int bufferSize = 47+256; // size of data buff
- // totals 512 bytes under g++ for igzstream at the end.
+ static const int bufferSize = 47 + 256; // size of data buff
+ // totals 512 bytes under g++ for igzstream at the end.
+
+ gzFile file; // file handle for compressed file
+ char buffer[bufferSize]; // data buffer
+ char opened; // open/close state of stream
+ int mode; // I/O mode
- gzFile file; // file handle for compressed file
- char buffer[bufferSize]; // data buffer
- char opened; // open/close state of stream
- int mode; // I/O mode
+ int flush_buffer();
- int flush_buffer();
public:
- gzstreambuf() : opened(0) {
- setp( buffer, buffer + (bufferSize-1));
- setg( buffer + 4, // beginning of putback area
- buffer + 4, // read position
- buffer + 4); // end position
- // ASSERT: both input & output capabilities will not be used together
- }
- int is_open() { return opened; }
- gzstreambuf* open( const char* name, int open_mode);
- gzstreambuf* close();
- ~gzstreambuf() { close(); }
-
- virtual int overflow( int c = EOF);
- virtual int underflow();
- virtual int sync();
+ gzstreambuf() : opened(0) {
+ setp(buffer, buffer + (bufferSize - 1));
+ setg(buffer + 4, // beginning of putback area
+ buffer + 4, // read position
+ buffer + 4); // end position
+ // ASSERT: both input & output capabilities will not be used together
+ }
+ int is_open() { return opened; }
+ gzstreambuf *open(const char *name, int open_mode);
+ gzstreambuf *close();
+ ~gzstreambuf() { close(); }
+
+ virtual int overflow(int c = EOF);
+ virtual int underflow();
+ virtual int sync();
};
class gzstreambase : virtual public std::ios {
protected:
- gzstreambuf buf;
+ gzstreambuf buf;
+
public:
- gzstreambase() { init(&buf); }
- gzstreambase( const char* name, int open_mode);
- ~gzstreambase();
- void open( const char* name, int open_mode);
- void close();
- gzstreambuf* rdbuf() { return &buf; }
+ gzstreambase() { init(&buf); }
+ gzstreambase(const char *name, int open_mode);
+ ~gzstreambase();
+ void open(const char *name, int open_mode);
+ void close();
+ gzstreambuf *rdbuf() { return &buf; }
};
// ----------------------------------------------------------------------------
@@ -91,24 +93,24 @@ public:
class igzstream : public gzstreambase, public std::istream {
public:
- igzstream() : std::istream( &buf) {}
- igzstream( const char* name, int open_mode = std::ios::in)
- : gzstreambase( name, open_mode), std::istream( &buf) {}
- gzstreambuf* rdbuf() { return gzstreambase::rdbuf(); }
- void open( const char* name, int open_mode = std::ios::in) {
- gzstreambase::open( name, open_mode);
- }
+ igzstream() : std::istream(&buf) {}
+ igzstream(const char *name, int open_mode = std::ios::in)
+ : gzstreambase(name, open_mode), std::istream(&buf) {}
+ gzstreambuf *rdbuf() { return gzstreambase::rdbuf(); }
+ void open(const char *name, int open_mode = std::ios::in) {
+ gzstreambase::open(name, open_mode);
+ }
};
class ogzstream : public gzstreambase, public std::ostream {
public:
- ogzstream() : std::ostream( &buf) {}
- ogzstream( const char* name, int mode = std::ios::out)
- : gzstreambase( name, mode), std::ostream( &buf) {}
- gzstreambuf* rdbuf() { return gzstreambase::rdbuf(); }
- void open( const char* name, int open_mode = std::ios::out) {
- gzstreambase::open( name, open_mode);
- }
+ ogzstream() : std::ostream(&buf) {}
+ ogzstream(const char *name, int mode = std::ios::out)
+ : gzstreambase(name, mode), std::ostream(&buf) {}
+ gzstreambuf *rdbuf() { return gzstreambase::rdbuf(); }
+ void open(const char *name, int open_mode = std::ios::out) {
+ gzstreambase::open(name, open_mode);
+ }
};
#ifdef GZSTREAM_NAMESPACE