aboutsummaryrefslogtreecommitdiff
path: root/src/gzstream.h
diff options
context:
space:
mode:
authorPjotr Prins2017-08-02 08:46:58 +0000
committerPjotr Prins2017-08-02 08:46:58 +0000
commit3935ba39d30666dd7d4a831155631847c77b70c4 (patch)
treec45fc682b473618a219e324d5c85b5e1f9361d0c /src/gzstream.h
parent84360c191f418bf8682b35e0c8235fcc3bd19a06 (diff)
downloadpangemma-3935ba39d30666dd7d4a831155631847c77b70c4.tar.gz
Massive patch using LLVM coding style. It was generated with:
clang-format -style=LLVM -i *.cpp *.h Please set your editor to replace tabs with spaces and use indentation of 2 spaces.
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