]> git.mxchange.org Git - simgear.git/blob - simgear/misc/fgstream.hxx
Updates from David Megginson:
[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 library is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU Library General Public
9 // License as published by the Free Software Foundation; either
10 // version 2 of the License, or (at your option) any later version.
11 //
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // Library General Public License for more details.
16 //
17 // You should have received a copy of the GNU Library General Public
18 // License along with this library; if not, write to the
19 // Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 // Boston, MA  02111-1307, USA.
21 //
22 // $Id$
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 <simgear/compiler.h>
36
37 #if defined( FG_HAVE_STD_INCLUDES )
38 #  include <istream>
39 #elif defined ( FG_HAVE_NATIVE_SGI_COMPILERS )
40 #  include <CC/stream.h>
41 #elif defined ( __BORLANDC__ )
42 #  include <iostream>
43 #else
44 #  include <istream.h>
45 #endif
46
47 #include STL_STRING
48
49 #include <simgear/misc/zfstream.hxx>
50
51 FG_USING_STD(string);
52
53 #ifndef FG_HAVE_NATIVE_SGI_COMPILERS
54 FG_USING_STD(istream);
55 #endif
56
57
58 //-----------------------------------------------------------------------------
59 //
60 // Envelope class for gzifstream.
61 //
62 class fg_gzifstream : private gzifstream_base, public istream
63 {
64 public:
65     //
66     fg_gzifstream();
67
68     // Attempt to open a file with and without ".gz" extension.
69     fg_gzifstream( const string& name,
70                    ios_openmode io_mode = ios_in | ios_binary );
71
72     // 
73     fg_gzifstream( int fd, ios_openmode io_mode = ios_in|ios_binary );
74
75     // Attempt to open a file with and without ".gz" extension.
76     void open( const string& name,
77                ios_openmode io_mode = ios_in|ios_binary );
78
79     void attach( int fd, ios_openmode io_mode = ios_in|ios_binary );
80
81     void close() { gzbuf.close(); }
82
83     bool is_open() { return gzbuf.is_open(); }
84
85 private:
86     // Not defined!
87     fg_gzifstream( const fg_gzifstream& );    
88     void operator= ( const fg_gzifstream& );    
89 };
90
91 // istream manipulator that skips to end of line.
92 istream& skipeol( istream& in );
93
94 // istream manipulator that skips over white space.
95 istream& skipws( istream& in );
96
97 // istream manipulator that skips comments and white space.
98 // A comment starts with '#'.
99 istream& skipcomment( istream& in );
100
101
102 #endif /* _FGSTREAM_HXX */
103