]> git.mxchange.org Git - simgear.git/blob - Misc/fgstream.hxx
Added point3d.hxx to replace cheezy fgPoint3d struct.
[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 "Include/fg_stl_config.h"
38 _FG_USING_NAMESPACE(std);
39
40 #include "zfstream.hxx"
41
42 //-----------------------------------------------------------------------------
43 //
44 // Envelope class for gzifstream.
45 //
46 class fg_gzifstream
47 {
48 public:
49     //
50     fg_gzifstream();
51
52     // Attempt to open a file with and without ".gz" extension.
53     fg_gzifstream( const string& name,
54                    int io_mode = ios::in|ios::binary );
55
56     // 
57     fg_gzifstream( int fd, int io_mode = ios::in|ios::binary );
58
59     // Attempt to open a file with and without ".gz" extension.
60     void open( const string& name,
61                int io_mode = ios::in|ios::binary );
62
63     // Return the underlying stream.
64     istream& stream() { return gzstream; }
65
66     // Check stream state.
67     bool operator ! () const { return !gzstream; }
68
69     // Check for end of file.
70     bool eof() const { return gzstream.eof(); }
71
72     // Remove whitespace from stream.
73     // Whitespace is as defined by isspace().
74     istream& eat_whitespace();
75
76     // Removes comments and whitespace from stream.
77     // A comment is any line starting with '#'.
78     istream& eat_comments();
79
80     // Read one character from stream.
81     istream& get( char& c ) { return gzstream.get(c); }
82
83     // Put a character back into the input buffer.
84     istream& putback( char c ) { return gzstream.putback(c); }
85
86 private:
87     // The underlying compressed data stream.
88     gzifstream gzstream;
89
90 private:
91     // Not defined!
92     fg_gzifstream( const fg_gzifstream& );    
93 };
94
95 // istream manipulator that skips to end of line.
96 istream& skipeol( istream& in );
97
98 // istream manipulator that skips over white space.
99 istream& skipws( istream& in );
100
101 // istream manipulator that skips comments and white space.
102 // A comment starts with '#'.
103 istream& skipcomment( istream& in );
104
105 #endif /* _FGSTREAM_HXX */
106
107 // $Log$
108 // Revision 1.3  1998/10/13 00:10:06  curt
109 // More portability changes to help with windoze compilation problems.
110 //
111 // Revision 1.2  1998/09/24 15:22:18  curt
112 // Additional enhancements.
113 //
114 // Revision 1.1  1998/09/01 19:06:29  curt
115 // Initial revision.
116 //