From: curt Date: Sun, 25 Mar 2001 12:07:55 +0000 (+0000) Subject: renamed to sgstream.[ch]xx X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=778149818158ab2a2978e62f0b58c5896edc116a;p=simgear.git renamed to sgstream.[ch]xx --- diff --git a/simgear/misc/fgstream.cxx b/simgear/misc/fgstream.cxx deleted file mode 100644 index d3a58f0d..00000000 --- a/simgear/misc/fgstream.cxx +++ /dev/null @@ -1,165 +0,0 @@ -// zlib input file stream wrapper. -// -// Written by Bernie Bright, 1998 -// -// Copyright (C) 1998 Bernie Bright - bbright@c031.aone.net.au -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// 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. -// -// $Id$ - -#include // isspace() - -#ifdef SG_HAVE_STD_INCLUDES -# include -#else -# include -#endif - -#include "fgstream.hxx" - -fg_gzifstream::fg_gzifstream() - : istream(&gzbuf) -{ -} - -//----------------------------------------------------------------------------- -// -// Open a possibly gzipped file for reading. -// -fg_gzifstream::fg_gzifstream( const string& name, ios_openmode io_mode ) - : istream(&gzbuf) -{ - this->open( name, io_mode ); -} - -//----------------------------------------------------------------------------- -// -// Attach a stream to an already opened file descriptor. -// -fg_gzifstream::fg_gzifstream( int fd, ios_openmode io_mode ) - : istream(&gzbuf) -{ - gzbuf.attach( fd, io_mode ); -} - -//----------------------------------------------------------------------------- -// -// Open a possibly gzipped file for reading. -// If the initial open fails and the filename has a ".gz" extension then -// remove the extension and try again. -// If the initial open fails and the filename doesn't have a ".gz" extension -// then append ".gz" and try again. -// -void -fg_gzifstream::open( const string& name, ios_openmode io_mode ) -{ - gzbuf.open( name.c_str(), io_mode ); - if ( ! gzbuf.is_open() ) - { - string s = name; - if ( s.substr( s.length() - 3, 3 ) == ".gz" ) - { - // remove ".gz" suffix - s.replace( s.length() - 3, 3, "" ); -// s.erase( s.length() - 3, 3 ); - } - else - { - // Append ".gz" suffix - s += ".gz"; - } - - // Try again. - gzbuf.open( s.c_str(), io_mode ); - } -} - -void -fg_gzifstream::attach( int fd, ios_openmode io_mode ) -{ - gzbuf.attach( fd, io_mode ); -} - -// -// Manipulators -// - -istream& -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; - } - } - - return 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; - } - } - return in; -} - -istream& -skipcomment( istream& in ) -{ - while ( in ) - { - // skip whitespace -#ifdef __MWERKS__ - in >> ::skipws; -#else - in >> skipws; -#endif - - char c; - if ( in.get( c ) && c != '#' ) - { - // not a comment - in.putback(c); - break; - } - in >> skipeol; - } - return in; -} - diff --git a/simgear/misc/fgstream.hxx b/simgear/misc/fgstream.hxx deleted file mode 100644 index a7385fc7..00000000 --- a/simgear/misc/fgstream.hxx +++ /dev/null @@ -1,103 +0,0 @@ -// zlib input file stream wrapper. -// -// Written by Bernie Bright, 1998 -// -// Copyright (C) 1998 Bernie Bright - bbright@c031.aone.net.au -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// 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. -// -// $Id$ - -#ifndef _FGSTREAM_HXX -#define _FGSTREAM_HXX - -#ifndef __cplusplus -# error This library requires C++ -#endif - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include - -#if defined( SG_HAVE_STD_INCLUDES ) -# include -#elif defined ( SG_HAVE_NATIVE_SGI_COMPILERS ) -# include -#elif defined ( __BORLANDC__ ) -# include -#else -# include -#endif - -#include STL_STRING - -#include - -SG_USING_STD(string); - -#ifndef SG_HAVE_NATIVE_SGI_COMPILERS -SG_USING_STD(istream); -#endif - - -//----------------------------------------------------------------------------- -// -// Envelope class for gzifstream. -// -class fg_gzifstream : private gzifstream_base, public istream -{ -public: - // - fg_gzifstream(); - - // Attempt to open a file with and without ".gz" extension. - fg_gzifstream( const string& name, - ios_openmode io_mode = ios_in | ios_binary ); - - // - fg_gzifstream( int fd, ios_openmode io_mode = ios_in|ios_binary ); - - // Attempt to open a file with and without ".gz" extension. - void open( const string& name, - ios_openmode io_mode = ios_in|ios_binary ); - - void attach( int fd, ios_openmode io_mode = ios_in|ios_binary ); - - void close() { gzbuf.close(); } - - bool is_open() { return gzbuf.is_open(); } - -private: - // Not defined! - fg_gzifstream( const fg_gzifstream& ); - void operator= ( const fg_gzifstream& ); -}; - -// istream manipulator that skips to end of line. -istream& skipeol( istream& in ); - -// istream manipulator that skips over white space. -istream& skipws( istream& in ); - -// istream manipulator that skips comments and white space. -// A comment starts with '#'. -istream& skipcomment( istream& in ); - - -#endif /* _FGSTREAM_HXX */ -