]> git.mxchange.org Git - flightgear.git/blob - Lib/Misc/fgstream.hxx
Merge FG_Lib as subdirectory
[flightgear.git] / Lib / 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 "Include/config.h"
33 #endif
34
35 #include <Include/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 #else
42 #  include <istream.h>
43 #endif
44
45 #include STL_STRING
46
47 #include "zfstream.hxx"
48
49 FG_USING_STD(string);
50
51 #ifndef FG_HAVE_NATIVE_SGI_COMPILERS
52 FG_USING_STD(istream);
53 #endif
54
55
56 //-----------------------------------------------------------------------------
57 //
58 // Envelope class for gzifstream.
59 //
60 class fg_gzifstream : private gzifstream_base, public istream
61 {
62 public:
63     //
64     fg_gzifstream();
65
66     // Attempt to open a file with and without ".gz" extension.
67     fg_gzifstream( const string& name,
68                    ios_openmode io_mode = ios_in | ios_binary );
69
70     // 
71     fg_gzifstream( int fd, ios_openmode io_mode = ios_in|ios_binary );
72
73     // Attempt to open a file with and without ".gz" extension.
74     void open( const string& name,
75                ios_openmode io_mode = ios_in|ios_binary );
76
77     void attach( int fd, ios_openmode io_mode = ios_in|ios_binary );
78
79     void close() { gzbuf.close(); }
80
81     bool is_open() { return gzbuf.is_open(); }
82
83 private:
84     // Not defined!
85     fg_gzifstream( const fg_gzifstream& );    
86     void operator= ( const fg_gzifstream& );    
87 };
88
89 // istream manipulator that skips to end of line.
90 istream& skipeol( istream& in );
91
92 // istream manipulator that skips over white space.
93 istream& skipws( istream& in );
94
95 // istream manipulator that skips comments and white space.
96 // A comment starts with '#'.
97 istream& skipcomment( istream& in );
98
99
100 #endif /* _FGSTREAM_HXX */
101
102 // $Log$
103 // Revision 1.9  1999/03/27 14:04:25  curt
104 // Added is_open() so we can check if the open() succeeded.
105 //
106 // Revision 1.8  1999/03/02 01:01:55  curt
107 // Tweaks for compiling with native SGI compilers.
108 //
109 // Revision 1.7  1999/02/26 22:08:08  curt
110 // Added initial support for native SGI compilers.
111 //
112 // Revision 1.6  1999/01/19 20:41:46  curt
113 // Portability updates contributed by Bernie Bright.
114 //
115 // Revision 1.5  1998/11/06 14:05:13  curt
116 // More portability improvements by Bernie Bright.
117 //
118 // Revision 1.4  1998/10/16 00:50:56  curt
119 // Remove leading _ from a couple defines.
120 //
121 // Revision 1.3  1998/10/13 00:10:06  curt
122 // More portability changes to help with windoze compilation problems.
123 //
124 // Revision 1.2  1998/09/24 15:22:18  curt
125 // Additional enhancements.
126 //
127 // Revision 1.1  1998/09/01 19:06:29  curt
128 // Initial revision.
129 //