FG_ to SG_ namespace changes.

Doxygenifing.
This commit is contained in:
curt
2001-03-25 12:06:09 +00:00
parent 75911b6c64
commit b8ce139b8a
22 changed files with 472 additions and 141 deletions

View File

@@ -31,7 +31,7 @@
#include <math.h>
#include <simgear/misc/fgpath.hxx>
#include <simgear/misc/sg_path.hxx>
#include "newbucket.hxx"
@@ -180,7 +180,7 @@ string SGBucket::gen_base_path() const {
hem, top_lon, pole, top_lat,
hem, main_lon, pole, main_lat);
FGPath path( raw_path );
SGPath path( raw_path );
return path.str();
}

View File

@@ -37,7 +37,7 @@ SGEphemeris::SGEphemeris( const string &path ) {
saturn = new Saturn;
uranus = new Uranus;
neptune = new Neptune;
stars = new SGStarData( FGPath(path) );
stars = new SGStarData( SGPath(path) );
}

View File

@@ -27,7 +27,6 @@
#include <string.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/misc/fgpath.hxx>
#ifdef __BORLANDC__
# define exception c_exception

View File

@@ -23,7 +23,7 @@
#include <simgear/debug/logstream.hxx>
#include <simgear/misc/fgstream.hxx>
#include <simgear/misc/sgstream.hxx>
#include "stardata.hxx"
@@ -35,8 +35,8 @@
SGStarData::SGStarData() {
}
SGStarData::SGStarData( FGPath path ) {
data_path = FGPath( path );
SGStarData::SGStarData( SGPath path ) {
data_path = SGPath( path );
load();
}
@@ -56,7 +56,7 @@ bool SGStarData::load() {
data_path.append( "stars" );
SG_LOG( SG_ASTRO, SG_INFO, " Loading stars from " << data_path.str() );
fg_gzifstream in( data_path.str() );
sg_gzifstream in( data_path.str() );
if ( ! in.is_open() ) {
SG_LOG( SG_ASTRO, SG_ALERT, "Cannot open star file: "
<< data_path.str() );

View File

@@ -28,7 +28,7 @@
#include <plib/sg.h>
#include <simgear/misc/fgpath.hxx>
#include <simgear/misc/sg_path.hxx>
#define SG_MAX_STARS 850
@@ -39,13 +39,13 @@ class SGStarData {
int nstars;
sgdVec3 *stars;
FGPath data_path;
SGPath data_path;
public:
// Constructor
SGStarData();
SGStarData( FGPath path );
SGStarData( SGPath path );
// Destructor
~SGStarData();

View File

@@ -27,7 +27,6 @@
#include <math.h>
#include <simgear/misc/fgpath.hxx>
#include <simgear/magvar/magvar.hxx>
#include "coremag.hxx"

View File

@@ -32,7 +32,7 @@
// depricated - #include <simgear/sg_zlib.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/misc/fgstream.hxx>
#include <simgear/misc/sgstream.hxx>
#include "interpolater.hxx"
@@ -44,7 +44,7 @@ SG_USING_STD(string);
SGInterpTable::SGInterpTable( const string& file ) {
SG_LOG( SG_MATH, SG_INFO, "Initializing Interpolator for " << file );
fg_gzifstream in( file );
sg_gzifstream in( file );
if ( !in.is_open() ) {
SG_LOG( SG_GENERAL, SG_ALERT, "Cannot open file: " << file );
exit(-1);

View File

@@ -8,8 +8,6 @@
#include "MetarStation.h"
#include <algorithm>
#include <simgear/misc/fgpath.hxx>
#if !defined (SG_HAVE_NATIVE_SGI_COMPILERS)
SG_USING_STD(ostream);
SG_USING_STD(cout);

View File

@@ -9,19 +9,19 @@ endif
lib_LIBRARIES = libsgmisc.a
include_HEADERS = \
fgpath.hxx \
fgstream.hxx \
props.hxx \
sg_path.hxx \
sgstream.hxx \
stopwatch.hxx \
strutils.hxx \
texcoord.hxx \
zfstream.hxx
libsgmisc_a_SOURCES = \
fgpath.cxx \
fgstream.cxx \
props.cxx \
props_io.cxx \
sg_path.cxx \
sgstream.cxx \
strutils.cxx \
texcoord.cxx \
zfstream.cxx

View File

@@ -1,89 +0,0 @@
//
// fgpath.hxx -- routines to abstract out path separator differences
// between MacOS and the rest of the world
//
// Written by Curtis L. Olson, started April 1999.
//
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
//
// 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 _FGPATH_HXX
#define _FGPATH_HXX
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <simgear/compiler.h>
#include STL_STRING
SG_USING_STD(string);
#ifdef macintosh
# define FG_PATH_SEP ':'
# define FG_BAD_PATH_SEP '/'
#else
# define FG_PATH_SEP '/'
# define FG_BAD_PATH_SEP ':'
#endif
class FGPath {
private:
string path;
public:
// default constructor
FGPath();
// create a path based on "path"
FGPath( const string p );
// destructor
~FGPath();
// set path
void set( const string p );
// append another piece to the existing path
void append( const string p );
// concatenate a string to the end of the path without inserting a
// path separator
void concat( const string p );
// get the directory part of the path
string dir();
// get the path string
inline string str() const { return path; }
inline const char *c_str() { return path.c_str(); }
};
#endif // _FGPATH_HXX

View File

@@ -10,7 +10,7 @@
#include <simgear/debug/logstream.hxx>
#include <simgear/xml/easyxml.hxx>
#include "fgpath.hxx"
#include "sg_path.hxx"
#include "props.hxx"
#include STL_IOSTREAM
@@ -143,9 +143,9 @@ PropsVisitor::startElement (const char * name, const XMLAttributes &atts)
// Check for an include.
const char * att_include = atts.getValue("include");
if (att_include != 0) {
FGPath path(FGPath(_base).dir());
SGPath path(SGPath(_base).dir());
cerr << "Base is " << _base << endl;
cerr << "Dir is " << FGPath(_base).dir() << endl;
cerr << "Dir is " << SGPath(_base).dir() << endl;
path.append(att_include);
if (!readProperties(path.str(), node)) {
SG_LOG(SG_INPUT, SG_ALERT, "Failed to read include file "

View File

@@ -1,5 +1,4 @@
//
// fgpath.cxx -- routines to abstract out path separator differences
// sg_path.cxx -- routines to abstract out path separator differences
// between MacOS and the rest of the world
//
// Written by Curtis L. Olson, started April 1999.
@@ -24,7 +23,7 @@
// $Id$
#include "fgpath.hxx"
#include "sg_path.hxx"
// If Unix, replace all ":" with "/". If MacOS, replace all "/" with
@@ -42,8 +41,8 @@ static string fix_path( const string path ) {
continue;
}
#endif
if ( result[i] == FG_BAD_PATH_SEP ) {
result[i] = FG_PATH_SEP;
if ( result[i] == SG_BAD_PATH_SEP ) {
result[i] = SG_PATH_SEP;
}
}
@@ -52,37 +51,37 @@ static string fix_path( const string path ) {
// default constructor
FGPath::FGPath() {
SGPath::SGPath() {
path = "";
}
// create a path based on "path"
FGPath::FGPath( const string p ) {
SGPath::SGPath( const string p ) {
set( p );
}
// destructor
FGPath::~FGPath() {
SGPath::~SGPath() {
}
// set path
void FGPath::set( const string p ) {
void SGPath::set( const string p ) {
path = fix_path( p );
}
// append another piece to the existing path
void FGPath::append( const string p ) {
void SGPath::append( const string p ) {
string part = fix_path( p );
if ( path.size() == 0 ) {
path = part;
} else {
if ( part[0] != FG_PATH_SEP ) {
path += FG_PATH_SEP;
if ( part[0] != SG_PATH_SEP ) {
path += SG_PATH_SEP;
}
path += part;
}
@@ -91,7 +90,7 @@ void FGPath::append( const string p ) {
// concatenate a string to the end of the path without inserting a
// path separator
void FGPath::concat( const string p ) {
void SGPath::concat( const string p ) {
string part = fix_path( p );
if ( path.size() == 0 ) {
@@ -103,8 +102,8 @@ void FGPath::concat( const string p ) {
// get the directory part of the path.
string FGPath::dir() {
int index = path.rfind(FG_PATH_SEP);
string SGPath::dir() {
int index = path.rfind(SG_PATH_SEP);
if (index >= 0) {
return path.substr(0, index);
} else {

120
simgear/misc/sg_path.hxx Normal file
View File

@@ -0,0 +1,120 @@
/**
* \file sg_path.hxx
* Routines to abstract out path separator differences between MacOS
* and the rest of the world.
*/
// Written by Curtis L. Olson, started April 1999.
//
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
//
// 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 _SG_PATH_HXX
#define _SG_PATH_HXX
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <simgear/compiler.h>
#include STL_STRING
SG_USING_STD(string);
#ifdef macintosh
# define SG_PATH_SEP ':'
# define SG_BAD_PATH_SEP '/'
#else
# define SG_PATH_SEP '/'
# define SG_BAD_PATH_SEP ':'
#endif
/**
* A class to hide path separator difference across platforms and assist
* in managing file system path names.
*
* Paths can be input in any platform format and will be converted
* automatically to the proper format.
*/
class SGPath {
private:
string path;
public:
/** Default constructor */
SGPath();
/**
* Construct a path based on the starting path provided.
* @param p initial path
*/
SGPath( const string p );
/** Destructor */
~SGPath();
/**
* Set path to a new value
* @param p new path
*/
void set( const string p );
/**
* Append another piece to the existing path. Inserts a path
* separator between the existing component and the new component.
* @param p additional path component */
void append( const string p );
/**
* Concatenate a string to the end of the path without inserting a
* path separator.
* @param p addtional path suffix
*/
void concat( const string p );
/**
* Get the directory part of the path.
* @return directory string
*/
string dir();
/** Get the path string
* @return path string
*/
inline string str() const { return path; }
/** Get the path string
* @return path in "C" string (ptr to char array) form.
*/
inline const char *c_str() { return path.c_str(); }
};
#endif // _SG_PATH_HXX

165
simgear/misc/sgstream.cxx Normal file
View File

@@ -0,0 +1,165 @@
// 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 <ctype.h> // isspace()
#ifdef SG_HAVE_STD_INCLUDES
# include <cerrno>
#else
# include <errno.h>
#endif
#include "sgstream.hxx"
sg_gzifstream::sg_gzifstream()
: istream(&gzbuf)
{
}
//-----------------------------------------------------------------------------
//
// Open a possibly gzipped file for reading.
//
sg_gzifstream::sg_gzifstream( const string& name, ios_openmode io_mode )
: istream(&gzbuf)
{
this->open( name, io_mode );
}
//-----------------------------------------------------------------------------
//
// Attach a stream to an already opened file descriptor.
//
sg_gzifstream::sg_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
sg_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
sg_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;
}

140
simgear/misc/sgstream.hxx Normal file
View File

@@ -0,0 +1,140 @@
/**
* \file sgstream.hxx
* 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 _SGSTREAM_HXX
#define _SGSTREAM_HXX
#ifndef __cplusplus
# error This library requires C++
#endif
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <simgear/compiler.h>
#if defined( SG_HAVE_STD_INCLUDES )
# include <istream>
#elif defined ( SG_HAVE_NATIVE_SGI_COMPILERS )
# include <CC/stream.h>
#elif defined ( __BORLANDC__ )
# include <iostream>
#else
# include <istream.h>
#endif
#include STL_STRING
#include <simgear/misc/zfstream.hxx>
SG_USING_STD(string);
#ifndef SG_HAVE_NATIVE_SGI_COMPILERS
SG_USING_STD(istream);
#endif
/**
* An envelope class for gzifstream.
*/
class sg_gzifstream : private gzifstream_base, public istream
{
public:
/** Default constructor */
sg_gzifstream();
/**
* Constructor that attempt to open a file with and without
* ".gz" extension.
* @param name name of file
* @param io_mode file open mode(s) "or'd" together
*/
sg_gzifstream( const string& name,
ios_openmode io_mode = ios_in | ios_binary );
/**
* Constructor that attaches itself to an existing file descriptor.
* @param fd file descriptor
* @param io_mode file open mode(s) "or'd" together
*/
sg_gzifstream( int fd, ios_openmode io_mode = ios_in|ios_binary );
/**
* Attempt to open a file with and without ".gz" extension.
* @param name name of file
* @param io_mode file open mode(s) "or'd" together
*/
void open( const string& name,
ios_openmode io_mode = ios_in|ios_binary );
/**
* Attach to an existing file descriptor.
* @param fd file descriptor
* @param io_mode file open mode(s) "or'd" together
*/
void attach( int fd, ios_openmode io_mode = ios_in|ios_binary );
/**
* Close the stream.
*/
void close() { gzbuf.close(); }
/** @return true if the file is successfully opened, false otherwise. */
bool is_open() { return gzbuf.is_open(); }
private:
// Not defined!
sg_gzifstream( const sg_gzifstream& );
void operator= ( const sg_gzifstream& );
};
/**
* \relates sg_gzifstream
* An istream manipulator that skips to end of line.
* @param in input stream
*/
istream& skipeol( istream& in );
/**
* \relates sg_gzifstream
* An istream manipulator that skips over white space.
* @param in input stream
*/
istream& skipws( istream& in );
/**
* \relates sg_gzifstream
* An istream manipulator that skips comments and white space.
* Ignores comments that start with '#'.
* @param in input stream
*/
istream& skipcomment( istream& in );
#endif /* _SGSTREAM_HXX */

View File

@@ -124,7 +124,7 @@ SGMoon::~SGMoon( void ) {
// build the moon object
ssgBranch * SGMoon::build( FGPath path, double moon_size ) {
ssgBranch * SGMoon::build( SGPath path, double moon_size ) {
// set up the orb state
path.append( "moon.rgba" );

View File

@@ -32,7 +32,7 @@
#include <plib/ssg.h>
#include <simgear/misc/fgpath.hxx>
#include <simgear/misc/sg_path.hxx>
class SGMoon {
@@ -55,7 +55,7 @@ public:
~SGMoon( void );
// build the moon object
ssgBranch *build( FGPath path, double moon_size );
ssgBranch *build( SGPath path, double moon_size );
// repaint the moon colors based on current value of moon_anglein
// degrees relative to verticle

View File

@@ -222,7 +222,7 @@ void my_glWritePPMFile(const char *filename, GLubyte *buffer, int win_width, int
// initialize the sun object and connect it into our scene graph root
ssgBranch * SGSun::build( FGPath path, double sun_size ) {
ssgBranch * SGSun::build( SGPath path, double sun_size ) {
// set up the orb state
orb_state = new ssgSimpleState();

View File

@@ -32,7 +32,7 @@
#include <plib/ssg.h>
#include <simgear/misc/fgpath.hxx>
#include <simgear/misc/sg_path.hxx>
class SGSun {
@@ -58,7 +58,7 @@ public:
~SGSun( void );
// return the sun object
ssgBranch *build( FGPath path, double sun_size );
ssgBranch *build( SGPath path, double sun_size );
// repaint the sun colors based on current value of sun_anglein
// degrees relative to verticle

View File

@@ -98,7 +98,7 @@ void SGSky::build( double sun_size, double moon_size,
post_root->addKid( post_selector );
// add the cloud ssgStates to the material lib
FGPath cloud_path;
SGPath cloud_path;
cloud_path.set( tex_path.str() );
cloud_path.append( "overcast.rgb" );

View File

@@ -35,7 +35,7 @@
#include <plib/ssg.h> // plib include
#include <simgear/compiler.h>
#include <simgear/misc/fgpath.hxx>
#include <simgear/misc/sg_path.hxx>
#include <vector>
@@ -71,7 +71,7 @@ private:
ssgSelector *pre_selector, *post_selector;
ssgTransform *pre_transform, *post_transform;
FGPath tex_path;
SGPath tex_path;
// visibility
float visibility;
@@ -137,7 +137,7 @@ public:
// specify the texture path (optional, defaults to current directory)
inline void texture_path( const string& path ) {
tex_path = FGPath( path );
tex_path = SGPath( path );
}
// enable the sky

View File

@@ -54,7 +54,7 @@
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/misc/fgpath.hxx>
#include <simgear/misc/sg_path.hxx>
#include "sg_time.hxx"
#include "timezone.h"
@@ -83,7 +83,7 @@ SGTime::SGTime( double lon, double lat, const string& root )
// << asctime(localtime(&cur_time)) << endl;
if ( root != (string)"" ) {
FGPath zone( root );
SGPath zone( root );
zone.append( "zone.tab" );
SG_LOG( SG_EVENT, SG_DEBUG, "Reading timezone info from: "
<< zone.str() );
@@ -92,7 +92,7 @@ SGTime::SGTime( double lon, double lat, const string& root )
GeoCoord location( SGD_RADIANS_TO_DEGREES * lat, SGD_RADIANS_TO_DEGREES * lon );
GeoCoord* nearestTz = tzContainer->getNearest(location);
FGPath name( root );
SGPath name( root );
name.append( nearestTz->getDescription() );
zonename = strdup( name.c_str() );
// cout << "Using zonename = " << zonename << endl;
@@ -254,7 +254,7 @@ void SGTime::updateLocal( double lon, double lat, const string& root )
time_t aircraftLocalTime;
GeoCoord location( SGD_RADIANS_TO_DEGREES * lat, SGD_RADIANS_TO_DEGREES * lon );
GeoCoord* nearestTz = tzContainer->getNearest(location);
FGPath zone( root );
SGPath zone( root );
zone.append ( nearestTz->getDescription() );
if ( zonename ) {
delete zonename;