3 * zlib input file stream wrapper.
6 // Written by Bernie Bright, 1998
8 // Copyright (C) 1998 Bernie Bright - bbright@c031.aone.net.au
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Library General Public
12 // License as published by the Free Software Foundation; either
13 // version 2 of the License, or (at your option) any later version.
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Library General Public License for more details.
20 // You should have received a copy of the GNU General Public License
21 // along with this program; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
31 # error This library requires C++
34 #include <simgear/compiler.h>
41 #include <simgear/misc/zfstream.hxx>
44 * An envelope class for gzifstream.
46 class sg_gzifstream : private gzifstream_base, public std::istream
49 /** Default constructor */
53 * Constructor that attempt to open a file with and without
55 * @param name name of file
56 * @param io_mode file open mode(s) "or'd" together
58 sg_gzifstream( const std::string& name,
59 ios_openmode io_mode = ios_in | ios_binary );
62 * Constructor that attaches itself to an existing file descriptor.
63 * @param fd file descriptor
64 * @param io_mode file open mode(s) "or'd" together
66 sg_gzifstream( int fd, ios_openmode io_mode = ios_in|ios_binary );
69 * Attempt to open a file with and without ".gz" extension.
70 * @param name name of file
71 * @param io_mode file open mode(s) "or'd" together
73 void open( const std::string& name,
74 ios_openmode io_mode = ios_in|ios_binary );
77 * Attach to an existing file descriptor.
78 * @param fd file descriptor
79 * @param io_mode file open mode(s) "or'd" together
81 void attach( int fd, ios_openmode io_mode = ios_in|ios_binary );
86 void close() { gzbuf.close(); }
88 /** @return true if the file is successfully opened, false otherwise. */
89 bool is_open() { return gzbuf.is_open(); }
93 sg_gzifstream( const sg_gzifstream& );
94 void operator= ( const sg_gzifstream& );
98 * \relates sg_gzifstream
99 * An istream manipulator that skips to end of line.
100 * @param in input stream
102 std::istream& skipeol( std::istream& in );
105 * \relates sg_gzifstream
106 * An istream manipulator that skips over white space.
107 * @param in input stream
109 std::istream& skipws( std::istream& in );
112 * \relates sg_gzifstream
113 * An istream manipulator that skips comments and white space.
114 * Ignores comments that start with '#'.
115 * @param in input stream
117 std::istream& skipcomment( std::istream& in );
120 * An envelope class for gzofstream.
122 class sg_gzofstream : private gzofstream_base, public std::ostream
125 /** Default constructor */
129 * Constructor to open a file for writing.
130 * @param name name of file
131 * @param io_mode file open mode(s) "or'd" together
133 sg_gzofstream( const std::string& name,
134 ios_openmode io_mode = ios_out | ios_binary );
137 * Constructor that attaches itself to an existing file descriptor.
138 * @param fd file descriptor
139 * @param io_mode file open mode(s) "or'd" together
141 sg_gzofstream( int fd, ios_openmode io_mode = ios_out|ios_binary );
144 * Attempt to open a file for writing.
145 * @param name name of file
146 * @param io_mode file open mode(s) "or'd" together
148 void open( const std::string& name,
149 ios_openmode io_mode = ios_out|ios_binary );
152 * Attach to an existing file descriptor.
153 * @param fd file descriptor
154 * @param io_mode file open mode(s) "or'd" together
156 void attach( int fd, ios_openmode io_mode = ios_out|ios_binary );
161 void close() { gzbuf.close(); }
163 /** @return true if the file is successfully opened, false otherwise. */
164 bool is_open() { return gzbuf.is_open(); }
168 sg_gzofstream( const sg_gzofstream& );
169 void operator= ( const sg_gzofstream& );
172 #endif /* _SGSTREAM_HXX */