]> git.mxchange.org Git - simgear.git/blobdiff - simgear/misc/sgstream.cxx
hla: Use HLADataElementIndices for HLAInteractionClass.
[simgear.git] / simgear / misc / sgstream.cxx
index dec7711e508e1a2510684493243df09741bfc1e8..70da33afd1316052ebc9925a699a9fb4946392f6 100644 (file)
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 // Library General Public License for more details.
 //
-// You should have received a copy of the GNU Library General Public
-// License along with this library; if not, write to the
-// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-// Boston, MA  02111-1307, USA.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //
 // $Id$
 
+#include <simgear/compiler.h>
+#include <string>
 #include <ctype.h> // isspace()
-
-#ifdef SG_HAVE_STD_INCLUDES
-# include <cerrno>
-#else
-# include <errno.h>
-#endif
+#include <cerrno>
 
 #include "sgstream.hxx"
 
+using std::string;
+using std::istream;
+using std::ostream;
+
 sg_gzifstream::sg_gzifstream()
     : istream(&gzbuf)
 {
@@ -104,11 +104,7 @@ skipeol( istream& in )
     char c = '\0';
     // skip to end of line.
 
-#ifdef __MWERKS__
-    while ( in.get(c) && c != '\0' ) {
-#else
     while ( in.get(c) ) {
-#endif
        if ( (c == '\n') || (c == '\r') ) {
            break;
        }       
@@ -120,17 +116,9 @@ skipeol( istream& in )
 istream&
 skipws( istream& in ) {
     char c;
-#ifdef __MWERKS__
-    while ( in.get(c) && c != '\0' ) {
-#else
     while ( in.get(c) ) {
-#endif
 
-#ifdef __MWERKS__
-       if ( ! isspace( c ) && c != '\n' ) {
-#else
        if ( ! isspace( c ) ) {
-#endif
            // put pack the non-space character
            in.putback(c);
            break;
@@ -145,11 +133,7 @@ skipcomment( istream& in )
     while ( in )
     {
        // skip whitespace
-#ifdef __MWERKS__
-       in >> ::skipws;
-#else
        in >> skipws;
-#endif
 
        char c;
        if ( in.get( c ) && c != '#' )
@@ -163,3 +147,44 @@ skipcomment( istream& in )
     return in;
 }
 
+
+sg_gzofstream::sg_gzofstream()
+    : ostream(&gzbuf)
+{
+}
+
+//-----------------------------------------------------------------------------
+//
+// Open a file for gzipped writing.
+//
+sg_gzofstream::sg_gzofstream( const string& name, ios_openmode io_mode )
+    : ostream(&gzbuf)
+{
+    this->open( name, io_mode );
+}
+
+//-----------------------------------------------------------------------------
+//
+// Attach a stream to an already opened file descriptor.
+//
+sg_gzofstream::sg_gzofstream( int fd, ios_openmode io_mode )
+    : ostream(&gzbuf)
+{
+    gzbuf.attach( fd, io_mode );
+}
+
+//-----------------------------------------------------------------------------
+//
+// Open a file for gzipped writing.
+//
+void
+sg_gzofstream::open( const string& name, ios_openmode io_mode )
+{
+    gzbuf.open( name.c_str(), io_mode );
+}
+
+void
+sg_gzofstream::attach( int fd, ios_openmode io_mode )
+{
+    gzbuf.attach( fd, io_mode );
+}