]> git.mxchange.org Git - simgear.git/blob - simgear/misc/sgstream.hxx
Add a function to calculate the normalmap from a regular texture.
[simgear.git] / simgear / misc / sgstream.hxx
1 /**
2  * \file sgstream.hxx
3  * zlib input file stream wrapper.
4  */
5
6 // Written by Bernie Bright, 1998
7 //
8 // Copyright (C) 1998  Bernie Bright - bbright@c031.aone.net.au
9 //
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.
14 //
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.
19 //
20 // You should have received a copy of the GNU Library General Public
21 // License along with this library; if not, write to the
22 // Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 // Boston, MA  02111-1307, USA.
24 //
25 // $Id$
26
27
28 #ifndef _SGSTREAM_HXX
29 #define _SGSTREAM_HXX
30
31 #ifndef __cplusplus                                                          
32 # error This library requires C++
33 #endif                                   
34
35 #include <simgear/compiler.h>
36
37 #if defined( SG_HAVE_STD_INCLUDES )
38 #  include <istream>
39 #elif defined ( __BORLANDC__ )
40 #  include <iostream>
41 #else
42 #  include <istream.h>
43 #endif
44
45 #include STL_STRING
46
47 #include <simgear/misc/zfstream.hxx>
48
49 SG_USING_STD(string);
50 SG_USING_STD(istream);
51
52
53 /**
54  * An envelope class for gzifstream.
55  */
56 class sg_gzifstream : private gzifstream_base, public istream
57 {
58 public:
59     /** Default constructor */
60     sg_gzifstream();
61
62     /**
63      * Constructor that attempt to open a file with and without
64      * ".gz" extension.
65      * @param name name of file
66      * @param io_mode file open mode(s) "or'd" together
67      */
68     sg_gzifstream( const string& name,
69                    ios_openmode io_mode = ios_in | ios_binary );
70
71     /**
72      * Constructor that attaches itself to an existing file descriptor.
73      * @param fd file descriptor
74      * @param io_mode file open mode(s) "or'd" together
75      */
76     sg_gzifstream( int fd, ios_openmode io_mode = ios_in|ios_binary );
77
78     /**
79      * Attempt to open a file with and without ".gz" extension.
80      * @param name name of file
81      * @param io_mode file open mode(s) "or'd" together
82      */
83     void open( const string& name,
84                ios_openmode io_mode = ios_in|ios_binary );
85
86     /**
87      * Attach to an existing file descriptor.
88      * @param fd file descriptor
89      * @param io_mode file open mode(s) "or'd" together
90      */
91     void attach( int fd, ios_openmode io_mode = ios_in|ios_binary );
92
93     /**
94      * Close the stream.
95      */
96     void close() { gzbuf.close(); }
97
98     /** @return true if the file is successfully opened, false otherwise. */
99     bool is_open() { return gzbuf.is_open(); }
100
101 private:
102     // Not defined!
103     sg_gzifstream( const sg_gzifstream& );    
104     void operator= ( const sg_gzifstream& );    
105 };
106
107 /**
108  * \relates sg_gzifstream
109  * An istream manipulator that skips to end of line.
110  * @param in input stream
111  */
112 istream& skipeol( istream& in );
113
114 /**
115  * \relates sg_gzifstream
116  * An istream manipulator that skips over white space.
117  * @param in input stream
118  */
119 istream& skipws( istream& in );
120
121 /**
122  * \relates sg_gzifstream
123  * An istream manipulator that skips comments and white space.
124  * Ignores comments that start with '#'.
125  * @param in input stream
126  */
127 istream& skipcomment( istream& in );
128
129
130 #endif /* _SGSTREAM_HXX */
131