]> git.mxchange.org Git - simgear.git/blob - simgear/misc/fgstream.hxx
Ed Williams: Added some bulletproofing at the poles.
[simgear.git] / simgear / 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
23 #ifndef _FGSTREAM_HXX
24 #define _FGSTREAM_HXX
25
26 #ifndef __cplusplus                                                          
27 # error This library requires C++
28 #endif                                   
29
30 #ifdef HAVE_CONFIG_H
31 #  include <config.h>
32 #endif
33
34 #include <simgear/compiler.h>
35
36 #if defined( FG_HAVE_STD_INCLUDES )
37 #  include <istream>
38 #elif defined ( FG_HAVE_NATIVE_SGI_COMPILERS )
39 #  include <CC/stream.h>
40 #elif defined ( __BORLANDC__ )
41 #  include <iostream>
42 #else
43 #  include <istream.h>
44 #endif
45
46 #include STL_STRING
47
48 #include <simgear/misc/zfstream.hxx>
49
50 FG_USING_STD(string);
51
52 #ifndef FG_HAVE_NATIVE_SGI_COMPILERS
53 FG_USING_STD(istream);
54 #endif
55
56
57 //-----------------------------------------------------------------------------
58 //
59 // Envelope class for gzifstream.
60 //
61 class fg_gzifstream : private gzifstream_base, public istream
62 {
63 public:
64     //
65     fg_gzifstream();
66
67     // Attempt to open a file with and without ".gz" extension.
68     fg_gzifstream( const string& name,
69                    ios_openmode io_mode = ios_in | ios_binary );
70
71     // 
72     fg_gzifstream( int fd, ios_openmode io_mode = ios_in|ios_binary );
73
74     // Attempt to open a file with and without ".gz" extension.
75     void open( const string& name,
76                ios_openmode io_mode = ios_in|ios_binary );
77
78     void attach( int fd, ios_openmode io_mode = ios_in|ios_binary );
79
80     void close() { gzbuf.close(); }
81
82     bool is_open() { return gzbuf.is_open(); }
83
84 private:
85     // Not defined!
86     fg_gzifstream( const fg_gzifstream& );    
87     void operator= ( const fg_gzifstream& );    
88 };
89
90 // istream manipulator that skips to end of line.
91 istream& skipeol( istream& in );
92
93 // istream manipulator that skips over white space.
94 istream& skipws( istream& in );
95
96 // istream manipulator that skips comments and white space.
97 // A comment starts with '#'.
98 istream& skipcomment( istream& in );
99
100
101 #endif /* _FGSTREAM_HXX */
102