]> git.mxchange.org Git - simgear.git/blob - Misc/fgstream.hxx
Miscellaneous fixes under Steve's direction.
[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     // 
54     fg_gzifstream( int fd, int io_mode = ios::in|ios::binary );
55
56     // Attempt to open a file with and without ".gz" extension.
57     void open( const string& name,
58                int io_mode = ios::in|ios::binary );
59
60     // Return the underlying stream.
61     istream& stream() { return gzstream; }
62
63     // Check stream state.
64     bool operator ! () const { return !gzstream; }
65
66     // Check for end of file.
67     bool eof() const { return gzstream.eof(); }
68
69     // Remove whitespace from stream.
70     // Whitespace is as defined by isspace().
71     istream& eat_whitespace();
72
73     // Removes comments and whitespace from stream.
74     // A comment is any line starting with '#'.
75     istream& eat_comments();
76
77     // Read one character from stream.
78     istream& get( char& c ) { return gzstream.get(c); }
79
80     // Put a character back into the input buffer.
81     istream& putback( char c ) { return gzstream.putback(c); }
82
83 private:
84     // The underlying compressed data stream.
85     gzifstream gzstream;
86
87 private:
88     // Not defined!
89     fg_gzifstream( const fg_gzifstream& );    
90 };
91
92 // istream manipulator that skips to end of line.
93 istream& skipeol( istream& in );
94
95 // istream manipulator that skips over white space.
96 istream& skipws( istream& in );
97
98 // istream manipulator that skips comments and white space.
99 // A comment starts with '#'.
100 istream& skipcomment( istream& in );
101
102 #endif /* _FGSTREAM_HXX */
103
104 // $Log$
105 // Revision 1.2  1998/09/24 15:22:18  curt
106 // Additional enhancements.
107 //
108 // Revision 1.1  1998/09/01 19:06:29  curt
109 // Initial revision.
110 //