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

FXGZFileStream.h
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,2024 by Sander Jansen. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (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 *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifdef HAVE_ZLIB_H
22 #ifndef FXGZFILESTREAM_H
23 #define FXGZFILESTREAM_H
24 
25 #ifndef FXFILESTREAM_H
26 #include "FXFileStream.h"
27 #endif
28 
29 namespace FX {
30 
31 
32 struct ZBlock;
33 
34 
36 class FXAPI FXGZFileStream : public FXFileStream {
37 private:
38  ZBlock *gz;
39  int ac;
40 protected:
41  virtual FXuval writeBuffer(FXuval count);
42  virtual FXuval readBuffer(FXuval count);
43 private:
44  FXGZFileStream(const FXGZFileStream&);
45  FXGZFileStream& operator=(const FXGZFileStream&);
46 public:
47 
49  FXGZFileStream(const FXObject* cont=nullptr);
50 
52  FXGZFileStream(const FXString& filename,FXStreamDirection save_or_load=FXStreamLoad,FXuval size=8192UL);
53 
55  FXbool open(const FXString& filename,FXStreamDirection save_or_load=FXStreamLoad,FXuval size=8192UL);
56 
58  virtual FXbool flush();
59 
61  virtual FXbool close();
62 
64  FXlong position() const { return FXStream::position(); }
65 
67  virtual FXbool position(FXlong,FXWhence){ return false; }
68 
70  FXGZFileStream& operator<<(const FXuchar& v){ FXStream::operator<<(v); return *this; }
71  FXGZFileStream& operator<<(const FXchar& v){ FXStream::operator<<(v); return *this; }
72  FXGZFileStream& operator<<(const FXbool& v){ FXStream::operator<<(v); return *this; }
73  FXGZFileStream& operator<<(const FXushort& v){ FXStream::operator<<(v); return *this; }
74  FXGZFileStream& operator<<(const FXshort& v){ FXStream::operator<<(v); return *this; }
75  FXGZFileStream& operator<<(const FXuint& v){ FXStream::operator<<(v); return *this; }
76  FXGZFileStream& operator<<(const FXint& v){ FXStream::operator<<(v); return *this; }
77  FXGZFileStream& operator<<(const FXfloat& v){ FXStream::operator<<(v); return *this; }
78  FXGZFileStream& operator<<(const FXdouble& v){ FXStream::operator<<(v); return *this; }
79  FXGZFileStream& operator<<(const FXlong& v){ FXStream::operator<<(v); return *this; }
80  FXGZFileStream& operator<<(const FXulong& v){ FXStream::operator<<(v); return *this; }
81 
83  FXGZFileStream& save(const FXuchar* p,FXuval n){ FXStream::save(p,n); return *this; }
84  FXGZFileStream& save(const FXchar* p,FXuval n){ FXStream::save(p,n); return *this; }
85  FXGZFileStream& save(const FXbool* p,FXuval n){ FXStream::save(p,n); return *this; }
86  FXGZFileStream& save(const FXushort* p,FXuval n){ FXStream::save(p,n); return *this; }
87  FXGZFileStream& save(const FXshort* p,FXuval n){ FXStream::save(p,n); return *this; }
88  FXGZFileStream& save(const FXuint* p,FXuval n){ FXStream::save(p,n); return *this; }
89  FXGZFileStream& save(const FXint* p,FXuval n){ FXStream::save(p,n); return *this; }
90  FXGZFileStream& save(const FXfloat* p,FXuval n){ FXStream::save(p,n); return *this; }
91  FXGZFileStream& save(const FXdouble* p,FXuval n){ FXStream::save(p,n); return *this; }
92  FXGZFileStream& save(const FXlong* p,FXuval n){ FXStream::save(p,n); return *this; }
93  FXGZFileStream& save(const FXulong* p,FXuval n){ FXStream::save(p,n); return *this; }
94 
96  FXGZFileStream& operator>>(FXuchar& v){ FXStream::operator>>(v); return *this; }
97  FXGZFileStream& operator>>(FXchar& v){ FXStream::operator>>(v); return *this; }
98  FXGZFileStream& operator>>(FXbool& v){ FXStream::operator>>(v); return *this; }
99  FXGZFileStream& operator>>(FXushort& v){ FXStream::operator>>(v); return *this; }
100  FXGZFileStream& operator>>(FXshort& v){ FXStream::operator>>(v); return *this; }
101  FXGZFileStream& operator>>(FXuint& v){ FXStream::operator>>(v); return *this; }
102  FXGZFileStream& operator>>(FXint& v){ FXStream::operator>>(v); return *this; }
103  FXGZFileStream& operator>>(FXfloat& v){ FXStream::operator>>(v); return *this; }
104  FXGZFileStream& operator>>(FXdouble& v){ FXStream::operator>>(v); return *this; }
105  FXGZFileStream& operator>>(FXlong& v){ FXStream::operator>>(v); return *this; }
106  FXGZFileStream& operator>>(FXulong& v){ FXStream::operator>>(v); return *this; }
107 
109  FXGZFileStream& load(FXuchar* p,FXuval n){ FXStream::load(p,n); return *this; }
110  FXGZFileStream& load(FXchar* p,FXuval n){ FXStream::load(p,n); return *this; }
111  FXGZFileStream& load(FXbool* p,FXuval n){ FXStream::load(p,n); return *this; }
112  FXGZFileStream& load(FXushort* p,FXuval n){ FXStream::load(p,n); return *this; }
113  FXGZFileStream& load(FXshort* p,FXuval n){ FXStream::load(p,n); return *this; }
114  FXGZFileStream& load(FXuint* p,FXuval n){ FXStream::load(p,n); return *this; }
115  FXGZFileStream& load(FXint* p,FXuval n){ FXStream::load(p,n); return *this; }
116  FXGZFileStream& load(FXfloat* p,FXuval n){ FXStream::load(p,n); return *this; }
117  FXGZFileStream& load(FXdouble* p,FXuval n){ FXStream::load(p,n); return *this; }
118  FXGZFileStream& load(FXlong* p,FXuval n){ FXStream::load(p,n); return *this; }
119  FXGZFileStream& load(FXulong* p,FXuval n){ FXStream::load(p,n); return *this; }
120 
122  FXGZFileStream& saveObject(const FXObject* v){ FXStream::saveObject(v); return *this; }
123 
125  FXGZFileStream& loadObject(FXObject*& v){ FXStream::loadObject(v); return *this; }
126 
128  template<class TYPE>
129  FXGZFileStream& operator>>(TYPE*& obj){ return loadObject(reinterpret_cast<FXObject*&>(obj)); }
130 
132  template<class TYPE>
133  FXGZFileStream& operator<<(const TYPE* obj){ return saveObject(static_cast<const FXObject*>(obj)); }
134 
136  virtual ~FXGZFileStream();
137  };
138 
139 }
140 
141 
142 #endif
143 #endif
FXStream & save(const FXuchar *p, FXuval n)
Save arrays of items to stream.
FXStream & operator>>(FXuchar &v)
Load single items from stream.
FXStream & saveObject(const FXObject *v)
Save object.
Definition: FX4Splitter.h:28
FXStream & operator<<(const FXuchar &v)
Save single items to stream.
FXStream & loadObject(FXObject *&v)
Load object.
FXStream & load(FXuchar *p, FXuval n)
Load arrays of items from stream.
FXlong position() const
Get position.
Definition: FXStream.h:164

Copyright © 1997-2022 Jeroen van der Zijp