]> git.mxchange.org Git - simgear.git/blob - Misc/fgstream.hxx
Temporary destructor patch until Steve can release next version of PUI.
[simgear.git] / Misc / fgstream.hxx
1 // zlib input file stream wrapper.
2 //
3 // Written by Bernie Bright, 1998
4 //
5 // Copyright (C) 1998  Bernie Bright - bbright@c031.aone.net.au
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22 // (Log is kept at end of this file)
23
24 #ifndef _FGSTREAM_HXX
25 #define _FGSTREAM_HXX
26
27 #ifndef __cplusplus                                                          
28 # error This library requires C++
29 #endif                                   
30
31 #ifdef HAVE_CONFIG_H
32 #  include "config.h"
33 #endif
34
35 #include <string>
36
37 #include "zfstream.hxx"
38
39 //-----------------------------------------------------------------------------
40 //
41 // Envelope class for gzifstream.
42 //
43 class fg_gzifstream
44 {
45 public:
46     //
47     fg_gzifstream();
48
49     // Attempt to open a file with and without ".gz" extension.
50     fg_gzifstream( const string& name,
51                    int io_mode = ios::in|ios::binary );
52
53     // Attempt to open a file with and without ".gz" extension.
54     void open( const string& name,
55                int io_mode = ios::in|ios::binary );
56
57     // Return the underlying stream.
58     istream& stream() { return gzstream; }
59
60     // Check stream state.
61     bool operator ! () const { return !gzstream; }
62
63     // Check for end of file.
64     bool eof() const { return gzstream.eof(); }
65
66     // Remove whitespace from stream.
67     // Whitespace is as defined by isspace().
68     istream& eat_whitespace();
69
70     // Removes comments and whitespace from stream.
71     // A comment is any line starting with '#'.
72     istream& eat_comments();
73
74     // Read one character from stream.
75     istream& get( char& c ) { return gzstream.get(c); }
76
77     // Put a character back into the input buffer.
78     istream& putback( char c ) { return gzstream.putback(c); }
79
80 private:
81     // The underlying compressed data stream.
82     gzifstream gzstream;
83
84 private:
85     // Not defined!
86     fg_gzifstream( const fg_gzifstream& );    
87 };
88
89 #endif /* _FGSTREAM_HXX */
90
91 // $Log$
92 // Revision 1.1  1998/09/01 19:06:29  curt
93 // Initial revision.
94 //