]> git.mxchange.org Git - simgear.git/blobdiff - simgear/misc/sgstream.cxx
cppbind: automatic conversion of SGReferenced derived pointers.
[simgear.git] / simgear / misc / sgstream.cxx
index 6d5352c86ae2a6f1cefa845cd3d6cfb6df648318..c2ed93b5869e8bfe43708d9f0f07409220062f11 100644 (file)
@@ -29,6 +29,7 @@
 
 using std::string;
 using std::istream;
+using std::ostream;
 
 sg_gzifstream::sg_gzifstream()
     : istream(&gzbuf)
@@ -101,14 +102,17 @@ istream&
 skipeol( istream& in )
 {
     char c = '\0';
-    // skip to end of line.
 
+    // make sure we detect LF, CR and CR/LF
     while ( in.get(c) ) {
-       if ( (c == '\n') || (c == '\r') ) {
-           break;
-       }       
+        if (c == '\n')
+            break;
+        else if (c == '\r') {
+            if (in.peek() == '\n')
+                in.get(c);
+            break;
+        }
     }
-
     return in;
 }
 
@@ -146,3 +150,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 );
+}