Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXGZFileStream.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * G Z F i l e S t r e a m C l a s s e s *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2002,2006 by Sander Jansen. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 *********************************************************************************
22 * $Id: FXGZFileStream.h,v 1.5.2.1 2007/09/28 16:42:19 fox Exp $ *
23 ********************************************************************************/
24 #ifdef HAVE_ZLIB_H
25 #ifndef FXGZFILESTREAM_H
26 #define FXGZFILESTREAM_H
27 
28 #ifndef FXFILESTREAM_H
29 #include "FXFileStream.h"
30 #endif
31 
32 
33 namespace FX {
34 
35 
36 struct ZBlock;
37 
38 
39 /// GZIP compressed stream
40 class FXAPI FXGZFileStream : public FXFileStream {
41 private:
42  ZBlock *z;
43  int f;
44 protected:
45  virtual FXuval writeBuffer(FXuval count);
46  virtual FXuval readBuffer(FXuval count);
47 public:
48 
49  /// Create GZIP compressed file stream
50  FXGZFileStream(const FXObject* cont=NULL);
51 
52  /// Open file stream
53  bool open(const FXString& filename,FXStreamDirection save_or_load,FXuval size=8192);
54 
55  /// Flush buffer
56  virtual bool flush();
57 
58  /// Close file stream
59  virtual bool close();
60 
61  /// Get position
62  FXlong position() const { return FXStream::position(); }
63 
64  /// Move to position
65  virtual bool position(FXlong,FXWhence){ return FALSE; }
66 
67  /// Save single items to stream
68  FXGZFileStream& operator<<(const FXuchar& v){ FXStream::operator<<(v); return *this; }
69  FXGZFileStream& operator<<(const FXchar& v){ FXStream::operator<<(v); return *this; }
70  FXGZFileStream& operator<<(const FXushort& v){ FXStream::operator<<(v); return *this; }
71  FXGZFileStream& operator<<(const FXshort& v){ FXStream::operator<<(v); return *this; }
72  FXGZFileStream& operator<<(const FXuint& v){ FXStream::operator<<(v); return *this; }
73  FXGZFileStream& operator<<(const FXint& v){ FXStream::operator<<(v); return *this; }
74  FXGZFileStream& operator<<(const FXfloat& v){ FXStream::operator<<(v); return *this; }
75  FXGZFileStream& operator<<(const FXdouble& v){ FXStream::operator<<(v); return *this; }
76  FXGZFileStream& operator<<(const FXlong& v){ FXStream::operator<<(v); return *this; }
77  FXGZFileStream& operator<<(const FXulong& v){ FXStream::operator<<(v); return *this; }
78 
79  /// Save arrays of items to stream
80  FXGZFileStream& save(const FXuchar* p,FXuval n){ FXStream::save(p,n); return *this; }
81  FXGZFileStream& save(const FXchar* p,FXuval n){ FXStream::save(p,n); return *this; }
82  FXGZFileStream& save(const FXushort* p,FXuval n){ FXStream::save(p,n); return *this; }
83  FXGZFileStream& save(const FXshort* p,FXuval n){ FXStream::save(p,n); return *this; }
84  FXGZFileStream& save(const FXuint* p,FXuval n){ FXStream::save(p,n); return *this; }
85  FXGZFileStream& save(const FXint* p,FXuval n){ FXStream::save(p,n); return *this; }
86  FXGZFileStream& save(const FXfloat* p,FXuval n){ FXStream::save(p,n); return *this; }
87  FXGZFileStream& save(const FXdouble* p,FXuval n){ FXStream::save(p,n); return *this; }
88  FXGZFileStream& save(const FXlong* p,FXuval n){ FXStream::save(p,n); return *this; }
89  FXGZFileStream& save(const FXulong* p,FXuval n){ FXStream::save(p,n); return *this; }
90 
91  /// Load single items from stream
92  FXGZFileStream& operator>>(FXuchar& v){ FXStream::operator>>(v); return *this; }
93  FXGZFileStream& operator>>(FXchar& v){ FXStream::operator>>(v); return *this; }
94  FXGZFileStream& operator>>(FXushort& v){ FXStream::operator>>(v); return *this; }
95  FXGZFileStream& operator>>(FXshort& v){ FXStream::operator>>(v); return *this; }
96  FXGZFileStream& operator>>(FXuint& v){ FXStream::operator>>(v); return *this; }
97  FXGZFileStream& operator>>(FXint& v){ FXStream::operator>>(v); return *this; }
98  FXGZFileStream& operator>>(FXfloat& v){ FXStream::operator>>(v); return *this; }
99  FXGZFileStream& operator>>(FXdouble& v){ FXStream::operator>>(v); return *this; }
100  FXGZFileStream& operator>>(FXlong& v){ FXStream::operator>>(v); return *this; }
101  FXGZFileStream& operator>>(FXulong& v){ FXStream::operator>>(v); return *this; }
102 
103  /// Load arrays of items from stream
104  FXGZFileStream& load(FXuchar* p,FXuval n){ FXStream::load(p,n); return *this; }
105  FXGZFileStream& load(FXchar* p,FXuval n){ FXStream::load(p,n); return *this; }
106  FXGZFileStream& load(FXushort* p,FXuval n){ FXStream::load(p,n); return *this; }
107  FXGZFileStream& load(FXshort* p,FXuval n){ FXStream::load(p,n); return *this; }
108  FXGZFileStream& load(FXuint* p,FXuval n){ FXStream::load(p,n); return *this; }
109  FXGZFileStream& load(FXint* p,FXuval n){ FXStream::load(p,n); return *this; }
110  FXGZFileStream& load(FXfloat* p,FXuval n){ FXStream::load(p,n); return *this; }
111  FXGZFileStream& load(FXdouble* p,FXuval n){ FXStream::load(p,n); return *this; }
112  FXGZFileStream& load(FXlong* p,FXuval n){ FXStream::load(p,n); return *this; }
113  FXGZFileStream& load(FXulong* p,FXuval n){ FXStream::load(p,n); return *this; }
114 
115  /// Save object
116  FXGZFileStream& saveObject(const FXObject* v){ FXStream::saveObject(v); return *this; }
117 
118  /// Load object
119  FXGZFileStream& loadObject(FXObject*& v){ FXStream::loadObject(v); return *this; }
120 
121  /// Clean up
122  virtual ~FXGZFileStream();
123  };
124 
125 }
126 
127 
128 #endif
129 #endif
FXStream & operator>>(FXStream &store, FXDate &d)
unsigned short FXushort
Definition: fxdefs.h:387
char FXchar
Definition: fxdefs.h:380
short FXshort
Definition: fxdefs.h:388
FXlong position() const
Get position.
Definition: FXStream.h:146
FXStream & save(const FXuchar *p, FXuval n)
Save arrays of items to stream.
unsigned int FXuint
Definition: fxdefs.h:389
#define FXAPI
Definition: fxdefs.h:122
FXStream & operator>>(FXuchar &v)
Load single items from stream.
#define NULL
Definition: fxdefs.h:41
FXStream & saveObject(const FXObject *v)
Save object.
FXWhence
Stream seeking.
Definition: FXStream.h:65
double FXdouble
Definition: fxdefs.h:392
Definition: FX4Splitter.h:31
int FXint
Definition: fxdefs.h:390
FXStream & operator<<(const FXuchar &v)
Save single items to stream.
#define FALSE
Definition: fxdefs.h:35
unsigned char FXuchar
Definition: fxdefs.h:385
float FXfloat
Definition: fxdefs.h:391
FXStreamDirection
Stream data flow direction.
Definition: FXStream.h:35
FXStream & loadObject(FXObject *&v)
Load object.
FXStream & load(FXuchar *p, FXuval n)
Load arrays of items from stream.
unsigned long FXuval
Definition: fxdefs.h:429
FXStream & operator<<(FXStream &store, const FXDate &d)

Copyright © 1997-2005 Jeroen van der Zijp