SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GZstream.h
Go to the documentation of this file.
1 /*
2  For more information, please see: http://software.sci.utah.edu
3 
4  The MIT License
5 
6  Copyright (c) 2009 Scientific Computing and Imaging Institute,
7  University of Utah.
8 
9 
10  Permission is hereby granted, free of charge, to any person obtaining a
11  copy of this software and associated documentation files (the "Software"),
12  to deal in the Software without restriction, including without limitation
13  the rights to use, copy, modify, merge, publish, distribute, sublicense,
14  and/or sell copies of the Software, and to permit persons to whom the
15  Software is furnished to do so, subject to the following conditions:
16 
17  The above copyright notice and this permission notice shall be included
18  in all copies or substantial portions of the Software.
19 
20  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26  DEALINGS IN THE SOFTWARE.
27 */
28 
29 ///
30 ///@file Pstream.h
31 ///@brief reading/writing persistent objects
32 ///
33 ///@author
34 /// Michael Callahan
35 /// Department of Computer Science
36 /// University of Utah
37 ///@date June 2007
38 ///
39 
40 #ifndef SCI_project_GZstream_h
41 #define SCI_project_GZstream_h 1
42 
44 #include <stdio.h>
45 
46 #include <zlib.h>
47 
48 
49 #include <iosfwd>
50 
51 
52 #include <Core/Persistent/share.h>
53 
54 namespace SCIRun {
55 
56 
57 class SCISHARE GZPiostream : public Piostream {
58 protected:
59  gzFile fp_;
60 
61  virtual const char *endianness();
62  virtual void reset_post_header();
63 private:
64  template <class T> void gen_io(T&, const char *);
65 
66 public:
67  GZPiostream(const std::string& filename, Direction dir,
68  const int& v = -1, ProgressReporter *pr = 0);
69  GZPiostream(int fd, Direction dir, const int& v = -1,
70  ProgressReporter *pr = 0);
71  virtual ~GZPiostream();
72 
73  virtual void io(char&);
74  virtual void io(signed char&);
75  virtual void io(unsigned char&);
76  virtual void io(short&);
77  virtual void io(unsigned short&);
78  virtual void io(int&);
79  virtual void io(unsigned int&);
80  virtual void io(long&);
81  virtual void io(unsigned long&);
82  virtual void io(long long&);
83  virtual void io(unsigned long long&);
84  virtual void io(double&);
85  virtual void io(float&);
86  virtual void io(std::string& str);
87 
88  virtual bool supports_block_io() { return (version() > 1); }
89  virtual bool block_io(void*, size_t, size_t);
90 };
91 
92 
94 protected:
95  virtual const char *endianness();
96 private:
97  template <class T> void gen_io(T&, const char *);
98 
99 public:
100  GZSwapPiostream(const std::string& filename, Direction d,
101  const int& v = -1, ProgressReporter *pr = 0);
102  GZSwapPiostream(int fd, Direction dir, const int& v = -1,
103  ProgressReporter *pr = 0);
104  virtual ~GZSwapPiostream();
105 
106  virtual void io(short&);
107  virtual void io(unsigned short&);
108  virtual void io(int&);
109  virtual void io(unsigned int&);
110  virtual void io(long&);
111  virtual void io(unsigned long&);
112  virtual void io(long long&);
113  virtual void io(unsigned long long&);
114  virtual void io(double&);
115  virtual void io(float&);
116 
117  virtual bool supports_block_io() { return false; }
118  virtual bool block_io(void*, size_t, size_t) { return false; }
119 };
120 
121 
122 
124 auto_gzistream(const std::string& filename, ProgressReporter *pr);
125 
126 
127 } // End namespace SCIRun
128 
129 
130 #endif
Definition: Persistent.h:89
virtual bool supports_block_io()
Definition: GZstream.h:88
Direction
Definition: Persistent.h:95
#define SCISHARE
Definition: share.h:39
string dir
Definition: eab.py:5
Base class for persistent objects...
boost::shared_ptr< Piostream > PiostreamPtr
Definition: Persistent.h:80
Definition: GZstream.h:93
v
Definition: readAllFields.py:42
gzFile fp_
Definition: GZstream.h:59
Definition: GZstream.h:57
std::string endianness()
Definition: Endian.cc:80
virtual bool block_io(void *, size_t, size_t)
Definition: GZstream.h:118
PiostreamPtr auto_gzistream(const std::string &filename, ProgressReporter *pr)
Definition: GZstream.cc:782
virtual bool supports_block_io()
Definition: GZstream.h:117