home *** CD-ROM | disk | FTP | other *** search
/ Hackers Magazine 57 / CdHackersMagazineNr57.iso / Software / Multimedia / k3d-setup-0.7.11.0.exe / include / k3d / k3dsdk / gzstream.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-11-07  |  2.5 KB  |  95 lines

  1. #ifndef K3DSDK_GZSTREAM_H
  2. #define K3DSDK_GZSTREAM_H
  3.  
  4. // ============================================================================
  5. // gzstream, C++ iostream classes wrapping the zlib compression library.
  6. // Copyright (C) 2001  Deepak Bandyopadhyay, Lutz Kettner
  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. //
  23. // File          : gzstream.h
  24. // Revision      : $Revision: 1.3 $
  25. // Revision_date : $Date: 2007/02/17 01:35:57 $
  26. // Author(s)     : Deepak Bandyopadhyay, Lutz Kettner
  27. //
  28. // Standard streambuf implementation following Nicolai Josuttis, "The
  29. // Standard C++ Library".
  30. // ============================================================================
  31.  
  32. // Integrated into the K-3D SDK by Tim Shead, April 2006
  33.  
  34. #include <iostream>
  35.  
  36. namespace k3d
  37. {
  38.  
  39. namespace filesystem
  40. {
  41.  
  42. class gzstreambuf;
  43. class path;
  44.  
  45. class gzstreambase :
  46.     virtual public std::ios
  47. {
  48. protected:
  49.     gzstreambuf* const buf;
  50.  
  51. public:
  52.     gzstreambase();
  53.     gzstreambase(const filesystem::path& name, int open_mode);
  54.     ~gzstreambase();
  55.  
  56.     void open(const filesystem::path& name, int open_mode);
  57.     void close();
  58.     std::streambuf* rdbuf();
  59. };
  60.  
  61. /// ifstream replacement that can read files with gzip compression
  62. /** \todo Implement this using boost::iostreams */
  63. class igzstream :
  64.     public gzstreambase,
  65.     public std::istream
  66. {
  67. public:
  68.     igzstream();
  69.     igzstream(const filesystem::path& name);
  70.  
  71.     std::streambuf* rdbuf();
  72.     void open(const filesystem::path& name);
  73. };
  74.  
  75. /// ofstream replacement that writes files with gzip compression
  76. /** \todo Implement this using boost::iostreams */
  77. class ogzstream :
  78.     public gzstreambase,
  79.     public std::ostream
  80. {
  81. public:
  82.     ogzstream();
  83.     ogzstream(const filesystem::path& name);
  84.  
  85.     std::streambuf* rdbuf();
  86.     void open(const filesystem::path& name);
  87. };
  88.  
  89. } // namespace filesystem
  90.  
  91. } // namespace k3d
  92.  
  93. #endif // !K3DSDK_GZSTREAM_H
  94.  
  95.