Don't include <iostream> and "using" declarations in header files
<iostream> sucks in expensive initialization of the standard streams and isn't appropriate in a header file. Use <istream> and <ostream> instead. using declarations should never appear at global scope in a header file; source files get to decide what they want to use in their namespace.
This commit is contained in:
parent
1a498348ee
commit
d219c5c4c6
@ -33,29 +33,10 @@
|
|||||||
#include <simgear/constants.h>
|
#include <simgear/constants.h>
|
||||||
#include <simgear/math/SGMath.hxx>
|
#include <simgear/math/SGMath.hxx>
|
||||||
|
|
||||||
#ifdef SG_HAVE_STD_INCLUDES
|
#include <cmath>
|
||||||
# include <cmath>
|
#include <cstdio> // sprintf()
|
||||||
# include <cstdio> // sprintf()
|
#include <ostream>
|
||||||
#else
|
#include <string>
|
||||||
# include <math.h>
|
|
||||||
# include <stdio.h> // sprintf()
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include STL_IOSTREAM
|
|
||||||
|
|
||||||
// I don't understand ... <math.h> or <cmath> should be included
|
|
||||||
// already depending on how you defined SG_HAVE_STD_INCLUDES, but I
|
|
||||||
// can go ahead and add this -- CLO
|
|
||||||
#ifdef __MWERKS__
|
|
||||||
SG_USING_STD(sprintf);
|
|
||||||
SG_USING_STD(fabs);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include STL_STRING
|
|
||||||
|
|
||||||
SG_USING_STD(string);
|
|
||||||
SG_USING_STD(ostream);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* standard size of a bucket in degrees (1/8 of a degree)
|
* standard size of a bucket in degrees (1/8 of a degree)
|
||||||
@ -210,18 +191,19 @@ public:
|
|||||||
* string form.
|
* string form.
|
||||||
* @return tile index in string form
|
* @return tile index in string form
|
||||||
*/
|
*/
|
||||||
inline string gen_index_str() const {
|
inline std::string gen_index_str() const {
|
||||||
char tmp[20];
|
char tmp[20];
|
||||||
sprintf(tmp, "%ld",
|
std::sprintf(tmp, "%ld",
|
||||||
(((long)lon + 180) << 14) + ((lat + 90) << 6) + (y << 3) + x);
|
(((long)lon + 180) << 14) + ((lat + 90) << 6)
|
||||||
return (string)tmp;
|
+ (y << 3) + x);
|
||||||
|
return (std::string)tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build the base path name for this bucket.
|
* Build the base path name for this bucket.
|
||||||
* @return base path in string form
|
* @return base path in string form
|
||||||
*/
|
*/
|
||||||
string gen_base_path() const;
|
std::string gen_base_path() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the center lon of a tile.
|
* @return the center lon of a tile.
|
||||||
@ -306,7 +288,7 @@ public:
|
|||||||
|
|
||||||
// friends
|
// friends
|
||||||
|
|
||||||
friend ostream& operator<< ( ostream&, const SGBucket& );
|
friend std::ostream& operator<< ( std::ostream&, const SGBucket& );
|
||||||
friend bool operator== ( const SGBucket&, const SGBucket& );
|
friend bool operator== ( const SGBucket&, const SGBucket& );
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -345,8 +327,8 @@ void sgBucketDiff( const SGBucket& b1, const SGBucket& b2, int *dx, int *dy );
|
|||||||
* @param out output stream
|
* @param out output stream
|
||||||
* @param b bucket
|
* @param b bucket
|
||||||
*/
|
*/
|
||||||
inline ostream&
|
inline std::ostream&
|
||||||
operator<< ( ostream& out, const SGBucket& b )
|
operator<< ( std::ostream& out, const SGBucket& b )
|
||||||
{
|
{
|
||||||
return out << b.lon << ":" << b.x << ", " << b.lat << ":" << b.y;
|
return out << b.lon << ":" << b.x << ", " << b.lat << ":" << b.y;
|
||||||
}
|
}
|
||||||
|
@ -20,9 +20,11 @@
|
|||||||
//
|
//
|
||||||
// $Id$
|
// $Id$
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include "logstream.hxx"
|
#include "logstream.hxx"
|
||||||
|
|
||||||
logstream *global_logstream = NULL;
|
logstream *logstream::global_logstream = 0;
|
||||||
|
|
||||||
bool logbuf::logging_enabled = true;
|
bool logbuf::logging_enabled = true;
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
@ -90,3 +92,22 @@ logstream::setLogLevels( sgDebugClass c, sgDebugPriority p )
|
|||||||
logbuf::set_log_level( c, p );
|
logbuf::set_log_level( c, p );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
logstream::initGlobalLogstream()
|
||||||
|
{
|
||||||
|
// Force initialization of cerr.
|
||||||
|
static std::ios_base::Init initializer;
|
||||||
|
// XXX Is the following still necessary?
|
||||||
|
#ifdef __APPLE__
|
||||||
|
/**
|
||||||
|
* There appears to be a bug in the C++ runtime in Mac OS X that
|
||||||
|
* will crash if certain funtions are called (in this case
|
||||||
|
* cerr.rdbuf()) during static initialization of a class. This
|
||||||
|
* print statement is hack to kick the library in the pants so it
|
||||||
|
* won't crash when cerr.rdbuf() is first called -DW
|
||||||
|
**/
|
||||||
|
std::cout << "Using Mac OS X hack for initializing C++ stdio..."
|
||||||
|
<< std::endl;
|
||||||
|
#endif
|
||||||
|
global_logstream = new logstream(std::cerr);
|
||||||
|
}
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
#ifdef SG_HAVE_STD_INCLUDES
|
#ifdef SG_HAVE_STD_INCLUDES
|
||||||
# include <streambuf>
|
# include <streambuf>
|
||||||
# include <iostream>
|
# include <ostream>
|
||||||
#else
|
#else
|
||||||
# include <iostream.h>
|
# include <iostream.h>
|
||||||
# include <simgear/sg_traits.hxx>
|
# include <simgear/sg_traits.hxx>
|
||||||
@ -43,9 +43,6 @@
|
|||||||
|
|
||||||
SG_USING_STD(streambuf);
|
SG_USING_STD(streambuf);
|
||||||
SG_USING_STD(ostream);
|
SG_USING_STD(ostream);
|
||||||
SG_USING_STD(cout);
|
|
||||||
SG_USING_STD(cerr);
|
|
||||||
SG_USING_STD(endl);
|
|
||||||
|
|
||||||
#ifdef __MWERKS__
|
#ifdef __MWERKS__
|
||||||
SG_USING_STD(iostream);
|
SG_USING_STD(iostream);
|
||||||
@ -67,7 +64,7 @@ SG_USING_STD(iostream);
|
|||||||
#ifdef SG_NEED_STREAMBUF_HACK
|
#ifdef SG_NEED_STREAMBUF_HACK
|
||||||
class logbuf : public __streambuf
|
class logbuf : public __streambuf
|
||||||
#else
|
#else
|
||||||
class logbuf : public streambuf
|
class logbuf : public std::streambuf
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -137,7 +134,7 @@ public:
|
|||||||
* Set the stream buffer
|
* Set the stream buffer
|
||||||
* @param sb stream buffer
|
* @param sb stream buffer
|
||||||
*/
|
*/
|
||||||
void set_sb( streambuf* sb );
|
void set_sb( std::streambuf* sb );
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
static void has_no_console() { has_console = false; }
|
static void has_no_console() { has_console = false; }
|
||||||
@ -155,7 +152,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
// The streambuf used for actual output. Defaults to cerr.rdbuf().
|
// The streambuf used for actual output. Defaults to cerr.rdbuf().
|
||||||
static streambuf* sbuf;
|
static std::streambuf* sbuf;
|
||||||
|
|
||||||
static bool logging_enabled;
|
static bool logging_enabled;
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
@ -238,23 +235,23 @@ struct logstream_base
|
|||||||
/**
|
/**
|
||||||
* Class to manage the debug logging stream.
|
* Class to manage the debug logging stream.
|
||||||
*/
|
*/
|
||||||
class logstream : private logstream_base, public ostream
|
class logstream : private logstream_base, public std::ostream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* The default is to send messages to cerr.
|
* The default is to send messages to cerr.
|
||||||
* @param out output stream
|
* @param out output stream
|
||||||
*/
|
*/
|
||||||
logstream( ostream& out )
|
logstream( std::ostream& out )
|
||||||
// : logstream_base(out.rdbuf()),
|
// : logstream_base(out.rdbuf()),
|
||||||
: logstream_base(),
|
: logstream_base(),
|
||||||
ostream(&lbuf) { lbuf.set_sb(out.rdbuf());}
|
std::ostream(&lbuf) { lbuf.set_sb(out.rdbuf());}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the output stream
|
* Set the output stream
|
||||||
* @param out output stream
|
* @param out output stream
|
||||||
*/
|
*/
|
||||||
void set_output( ostream& out ) { lbuf.set_sb( out.rdbuf() ); }
|
void set_output( std::ostream& out ) { lbuf.set_sb( out.rdbuf() ); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the global log class and priority level.
|
* Set the global log class and priority level.
|
||||||
@ -267,18 +264,20 @@ public:
|
|||||||
* Output operator to capture the debug level and priority of a message.
|
* Output operator to capture the debug level and priority of a message.
|
||||||
* @param l log level
|
* @param l log level
|
||||||
*/
|
*/
|
||||||
inline ostream& operator<< ( const loglevel& l );
|
inline std::ostream& operator<< ( const loglevel& l );
|
||||||
|
friend logstream& sglog();
|
||||||
|
protected:
|
||||||
|
static logstream *global_logstream;
|
||||||
|
static void initGlobalLogstream();
|
||||||
};
|
};
|
||||||
|
|
||||||
inline ostream&
|
inline std::ostream&
|
||||||
logstream::operator<< ( const loglevel& l )
|
logstream::operator<< ( const loglevel& l )
|
||||||
{
|
{
|
||||||
lbuf.set_log_state( l.logClass, l.logPriority );
|
lbuf.set_log_state( l.logClass, l.logPriority );
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern logstream *global_logstream;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \relates logstream
|
* \relates logstream
|
||||||
* Return the one and only logstream instance.
|
* Return the one and only logstream instance.
|
||||||
@ -289,22 +288,10 @@ extern logstream *global_logstream;
|
|||||||
inline logstream&
|
inline logstream&
|
||||||
sglog()
|
sglog()
|
||||||
{
|
{
|
||||||
if (global_logstream == NULL) {
|
if (logstream::global_logstream == NULL) {
|
||||||
|
logstream::initGlobalLogstream();
|
||||||
#ifdef __APPLE__
|
|
||||||
/**
|
|
||||||
* There appears to be a bug in the C++ runtime in Mac OS X that
|
|
||||||
* will crash if certain funtions are called (in this case
|
|
||||||
* cerr.rdbuf()) during static initialization of a class. This
|
|
||||||
* print statement is hack to kick the library in the pants so it
|
|
||||||
* won't crash when cerr.rdbuf() is first called -DW
|
|
||||||
**/
|
|
||||||
cout << "Using Mac OS X hack for initializing C++ stdio..." << endl;
|
|
||||||
#endif
|
|
||||||
global_logstream = new logstream (cerr);
|
|
||||||
}
|
}
|
||||||
|
return *logstream::global_logstream;
|
||||||
return *global_logstream;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -319,7 +306,7 @@ sglog()
|
|||||||
#elif defined( __MWERKS__ )
|
#elif defined( __MWERKS__ )
|
||||||
# define SG_LOG(C,P,M) ::sglog() << ::loglevel(C,P) << M << std::endl
|
# define SG_LOG(C,P,M) ::sglog() << ::loglevel(C,P) << M << std::endl
|
||||||
#else
|
#else
|
||||||
# define SG_LOG(C,P,M) sglog() << loglevel(C,P) << M << endl
|
# define SG_LOG(C,P,M) sglog() << loglevel(C,P) << M << std::endl
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SG_STRINGIFY(x) #x
|
#define SG_STRINGIFY(x) #x
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include STL_STRING
|
#include STL_STRING
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include <simgear/bucket/newbucket.hxx>
|
#include <simgear/bucket/newbucket.hxx>
|
||||||
#include <simgear/misc/sg_path.hxx>
|
#include <simgear/misc/sg_path.hxx>
|
||||||
@ -45,6 +46,8 @@
|
|||||||
SG_USING_STD( string );
|
SG_USING_STD( string );
|
||||||
SG_USING_STD( vector );
|
SG_USING_STD( vector );
|
||||||
|
|
||||||
|
using std::cout;
|
||||||
|
using std::endl;
|
||||||
|
|
||||||
enum sgObjectTypes {
|
enum sgObjectTypes {
|
||||||
SG_BOUNDING_SPHERE = 0,
|
SG_BOUNDING_SPHERE = 0,
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
|
|
||||||
#include "sg_socket.hxx"
|
#include "sg_socket.hxx"
|
||||||
@ -49,7 +51,7 @@ TcpClient::process()
|
|||||||
|
|
||||||
sprintf( wbuf, "hello world\n" );
|
sprintf( wbuf, "hello world\n" );
|
||||||
int length = channel->writestring( wbuf );
|
int length = channel->writestring( wbuf );
|
||||||
cout << "writestring returned " << length << "\n";
|
std::cout << "writestring returned " << length << "\n";
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -67,7 +69,7 @@ main()
|
|||||||
TcpClient client( "localhost", "5500" );
|
TcpClient client( "localhost", "5500" );
|
||||||
if (!client.open())
|
if (!client.open())
|
||||||
{
|
{
|
||||||
cout << "client open failed\n";
|
std::cout << "client open failed\n";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,37 +41,21 @@
|
|||||||
# define exception c_exception
|
# define exception c_exception
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SG_HAVE_STD_INCLUDES
|
#include <ostream>
|
||||||
# include <iostream>
|
#include <istream>
|
||||||
# include <cassert>
|
#include <cassert>
|
||||||
# include <cmath>
|
#include <cmath>
|
||||||
#else
|
|
||||||
# include <iostream.h>
|
|
||||||
# include <assert.h>
|
|
||||||
# include <math.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "SGMath.hxx"
|
#include "SGMath.hxx"
|
||||||
|
|
||||||
// I don't understand ... <math.h> or <cmath> should be included
|
|
||||||
// already depending on how you defined SG_HAVE_STD_INCLUDES, but I
|
|
||||||
// can go ahead and add this -- CLO
|
|
||||||
#ifdef __MWERKS__
|
|
||||||
SG_USING_NAMESPACE(std);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SG_USING_STD(ostream);
|
|
||||||
SG_USING_STD(istream);
|
|
||||||
|
|
||||||
|
|
||||||
const double fgPoint3_Epsilon = 0.0000001;
|
const double fgPoint3_Epsilon = 0.0000001;
|
||||||
|
|
||||||
enum {PX, PY, PZ}; // axes
|
enum {PX, PY, PZ}; // axes
|
||||||
|
|
||||||
// Kludge for msvc++ 6.0 - requires forward decls of friend functions.
|
// Kludge for msvc++ 6.0 - requires forward decls of friend functions.
|
||||||
class Point3D;
|
class Point3D;
|
||||||
istream& operator>> ( istream&, Point3D& );
|
std::istream& operator>> ( std::istream&, Point3D& );
|
||||||
ostream& operator<< ( ostream&, const Point3D& );
|
std::ostream& operator<< ( std::ostream&, const Point3D& );
|
||||||
Point3D operator- (const Point3D& p); // -p1
|
Point3D operator- (const Point3D& p); // -p1
|
||||||
bool operator== (const Point3D& a, const Point3D& b); // p1 == p2?
|
bool operator== (const Point3D& a, const Point3D& b); // p1 == p2?
|
||||||
|
|
||||||
@ -141,8 +125,8 @@ public:
|
|||||||
// friends
|
// friends
|
||||||
friend Point3D operator - (const Point3D& p); // -p1
|
friend Point3D operator - (const Point3D& p); // -p1
|
||||||
friend bool operator == (const Point3D& a, const Point3D& b); // p1 == p2?
|
friend bool operator == (const Point3D& a, const Point3D& b); // p1 == p2?
|
||||||
friend istream& operator>> ( istream&, Point3D& );
|
friend std::istream& operator>> ( std::istream&, Point3D& );
|
||||||
friend ostream& operator<< ( ostream&, const Point3D& );
|
friend std::ostream& operator<< ( std::ostream&, const Point3D& );
|
||||||
|
|
||||||
// Special functions
|
// Special functions
|
||||||
double distance3D(const Point3D& a) const; // distance between
|
double distance3D(const Point3D& a) const; // distance between
|
||||||
@ -151,8 +135,8 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
// input from stream
|
// input from stream
|
||||||
inline istream&
|
inline std::istream&
|
||||||
operator >> ( istream& in, Point3D& p)
|
operator >> ( std::istream& in, Point3D& p)
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
@ -183,8 +167,8 @@ operator >> ( istream& in, Point3D& p)
|
|||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ostream&
|
inline std::ostream&
|
||||||
operator<< ( ostream& out, const Point3D& p )
|
operator<< ( std::ostream& out, const Point3D& p )
|
||||||
{
|
{
|
||||||
return out << p.n[PX] << ", " << p.n[PY] << ", " << p.n[PZ];
|
return out << p.n[PX] << ", " << p.n[PY] << ", " << p.n[PZ];
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,9 @@
|
|||||||
|
|
||||||
#include "sgstream.hxx"
|
#include "sgstream.hxx"
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
using std::istream;
|
||||||
|
|
||||||
sg_gzifstream::sg_gzifstream()
|
sg_gzifstream::sg_gzifstream()
|
||||||
: istream(&gzbuf)
|
: istream(&gzbuf)
|
||||||
{
|
{
|
||||||
|
@ -45,14 +45,10 @@
|
|||||||
|
|
||||||
#include <simgear/misc/zfstream.hxx>
|
#include <simgear/misc/zfstream.hxx>
|
||||||
|
|
||||||
SG_USING_STD(string);
|
|
||||||
SG_USING_STD(istream);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An envelope class for gzifstream.
|
* An envelope class for gzifstream.
|
||||||
*/
|
*/
|
||||||
class sg_gzifstream : private gzifstream_base, public istream
|
class sg_gzifstream : private gzifstream_base, public std::istream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** Default constructor */
|
/** Default constructor */
|
||||||
@ -64,7 +60,7 @@ public:
|
|||||||
* @param name name of file
|
* @param name name of file
|
||||||
* @param io_mode file open mode(s) "or'd" together
|
* @param io_mode file open mode(s) "or'd" together
|
||||||
*/
|
*/
|
||||||
sg_gzifstream( const string& name,
|
sg_gzifstream( const std::string& name,
|
||||||
ios_openmode io_mode = ios_in | ios_binary );
|
ios_openmode io_mode = ios_in | ios_binary );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -79,7 +75,7 @@ public:
|
|||||||
* @param name name of file
|
* @param name name of file
|
||||||
* @param io_mode file open mode(s) "or'd" together
|
* @param io_mode file open mode(s) "or'd" together
|
||||||
*/
|
*/
|
||||||
void open( const string& name,
|
void open( const std::string& name,
|
||||||
ios_openmode io_mode = ios_in|ios_binary );
|
ios_openmode io_mode = ios_in|ios_binary );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -108,14 +104,14 @@ private:
|
|||||||
* An istream manipulator that skips to end of line.
|
* An istream manipulator that skips to end of line.
|
||||||
* @param in input stream
|
* @param in input stream
|
||||||
*/
|
*/
|
||||||
istream& skipeol( istream& in );
|
std::istream& skipeol( std::istream& in );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \relates sg_gzifstream
|
* \relates sg_gzifstream
|
||||||
* An istream manipulator that skips over white space.
|
* An istream manipulator that skips over white space.
|
||||||
* @param in input stream
|
* @param in input stream
|
||||||
*/
|
*/
|
||||||
istream& skipws( istream& in );
|
std::istream& skipws( std::istream& in );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \relates sg_gzifstream
|
* \relates sg_gzifstream
|
||||||
@ -123,7 +119,7 @@ istream& skipws( istream& in );
|
|||||||
* Ignores comments that start with '#'.
|
* Ignores comments that start with '#'.
|
||||||
* @param in input stream
|
* @param in input stream
|
||||||
*/
|
*/
|
||||||
istream& skipcomment( istream& in );
|
std::istream& skipcomment( std::istream& in );
|
||||||
|
|
||||||
|
|
||||||
#endif /* _SGSTREAM_HXX */
|
#endif /* _SGSTREAM_HXX */
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
// Allocate memory for 'get' buffer and zero all buffer pointers.
|
// Allocate memory for 'get' buffer and zero all buffer pointers.
|
||||||
//
|
//
|
||||||
gzfilebuf::gzfilebuf()
|
gzfilebuf::gzfilebuf()
|
||||||
: streambuf(),
|
: std::streambuf(),
|
||||||
file(NULL),
|
file(NULL),
|
||||||
#if defined( __MWERKS__ ) || __GNUC__ > 2
|
#if defined( __MWERKS__ ) || __GNUC__ > 2
|
||||||
mode(ios_openmode(0)),
|
mode(ios_openmode(0)),
|
||||||
@ -174,10 +174,10 @@ gzfilebuf::close()
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
streampos
|
std::streampos
|
||||||
gzfilebuf::seekoff( streamoff, ios_seekdir, int )
|
gzfilebuf::seekoff( std::streamoff, ios_seekdir, int )
|
||||||
{
|
{
|
||||||
return streampos(EOF);
|
return std::streampos(EOF);
|
||||||
}
|
}
|
||||||
|
|
||||||
gzfilebuf::int_type
|
gzfilebuf::int_type
|
||||||
|
@ -36,21 +36,16 @@
|
|||||||
# include <streambuf>
|
# include <streambuf>
|
||||||
# include <istream>
|
# include <istream>
|
||||||
|
|
||||||
# define ios_openmode ios_base::openmode
|
# define ios_openmode std::ios_base::openmode
|
||||||
# define ios_in ios_base::in
|
# define ios_in std::ios_base::in
|
||||||
# define ios_out ios_base::out
|
# define ios_out std::ios_base::out
|
||||||
# define ios_app ios_base::app
|
# define ios_app std::ios_base::app
|
||||||
# define ios_binary ios_base::binary
|
# define ios_binary std::ios_base::binary
|
||||||
|
|
||||||
# define ios_seekdir ios_base::seekdir
|
# define ios_seekdir std::ios_base::seekdir
|
||||||
|
|
||||||
# define ios_badbit ios_base::badbit
|
# define ios_badbit std::ios_base::badbit
|
||||||
# define ios_failbit ios_base::failbit
|
# define ios_failbit std::ios_base::failbit
|
||||||
|
|
||||||
SG_USING_STD(streambuf);
|
|
||||||
SG_USING_STD(ios_base);
|
|
||||||
SG_USING_STD(streampos);
|
|
||||||
SG_USING_STD(streamoff);
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@ -88,7 +83,7 @@ SG_USING_STD(streamoff);
|
|||||||
#ifdef SG_NEED_STREAMBUF_HACK
|
#ifdef SG_NEED_STREAMBUF_HACK
|
||||||
class gzfilebuf : public __streambuf
|
class gzfilebuf : public __streambuf
|
||||||
#else
|
#else
|
||||||
class gzfilebuf : public streambuf
|
class gzfilebuf : public std::streambuf
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -132,7 +127,7 @@ public:
|
|||||||
bool is_open() const { return (file != NULL); }
|
bool is_open() const { return (file != NULL); }
|
||||||
|
|
||||||
/** @return stream position */
|
/** @return stream position */
|
||||||
virtual streampos seekoff( streamoff off, ios_seekdir way, int which );
|
virtual std::streampos seekoff( std::streamoff off, ios_seekdir way, int which );
|
||||||
|
|
||||||
/** sync the stream */
|
/** sync the stream */
|
||||||
virtual int sync();
|
virtual int sync();
|
||||||
@ -143,7 +138,7 @@ protected:
|
|||||||
#ifndef SG_HAVE_STD_INCLUDES
|
#ifndef SG_HAVE_STD_INCLUDES
|
||||||
virtual int_type overflow( int_type c = traits_type::eof() );
|
virtual int_type overflow( int_type c = traits_type::eof() );
|
||||||
#else
|
#else
|
||||||
virtual int_type overflow( int_type c = streambuf::traits_type::eof() );
|
virtual int_type overflow( int_type c = std::streambuf::traits_type::eof() );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -9,39 +9,36 @@
|
|||||||
#include "props.hxx"
|
#include "props.hxx"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#if PROPS_STANDALONE
|
#if PROPS_STANDALONE
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using std::cerr;
|
|
||||||
using std::endl;
|
|
||||||
using std::find;
|
|
||||||
using std::sort;
|
|
||||||
using std::vector;
|
|
||||||
using std::stringstream;
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <simgear/compiler.h>
|
#include <simgear/compiler.h>
|
||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
|
|
||||||
SG_USING_STD(sort);
|
|
||||||
SG_USING_STD(find);
|
|
||||||
SG_USING_STD(vector);
|
|
||||||
SG_USING_STD(stringstream);
|
|
||||||
|
|
||||||
#if ( _MSC_VER == 1200 )
|
#if ( _MSC_VER == 1200 )
|
||||||
// MSVC 6 is buggy, and needs something strange here
|
// MSVC 6 is buggy, and needs something strange here
|
||||||
SG_USING_STD(vector<SGPropertyNode_ptr>);
|
SG_USING_STD(vector<SGPropertyNode_ptr>);
|
||||||
SG_USING_STD(vector<SGPropertyChangeListener *>);
|
SG_USING_STD(vector<SGPropertyChangeListener *>);
|
||||||
SG_USING_STD(vector<SGPropertyNode *>);
|
SG_USING_STD(vector<SGPropertyNode *>);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if PROPS_STANDALONE
|
||||||
|
using std::cerr;
|
||||||
|
#endif
|
||||||
|
using std::endl;
|
||||||
|
using std::find;
|
||||||
|
using std::sort;
|
||||||
|
using std::string;
|
||||||
|
using std::vector;
|
||||||
|
using std::stringstream;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -17,30 +17,16 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#if PROPS_STANDALONE
|
#if PROPS_STANDALONE
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
using std::string;
|
|
||||||
using std::vector;
|
|
||||||
using std::istream;
|
|
||||||
using std::ostream;
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <simgear/compiler.h>
|
#include <simgear/compiler.h>
|
||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
#include STL_STRING
|
|
||||||
#include STL_IOSTREAM
|
|
||||||
SG_USING_STD(string);
|
|
||||||
SG_USING_STD(vector);
|
|
||||||
SG_USING_STD(istream);
|
|
||||||
SG_USING_STD(ostream);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <simgear/structure/SGReferenced.hxx>
|
#include <simgear/structure/SGReferenced.hxx>
|
||||||
#include <simgear/structure/SGSharedPtr.hxx>
|
#include <simgear/structure/SGSharedPtr.hxx>
|
||||||
|
|
||||||
@ -479,7 +465,7 @@ protected:
|
|||||||
virtual void unregister_property (SGPropertyNode * node);
|
virtual void unregister_property (SGPropertyNode * node);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
vector<SGPropertyNode *> _properties;
|
std::vector<SGPropertyNode *> _properties;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -666,12 +652,12 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Get a vector of all children with the specified name.
|
* Get a vector of all children with the specified name.
|
||||||
*/
|
*/
|
||||||
vector<SGPropertyNode_ptr> getChildren (const char * name) const;
|
std::vector<SGPropertyNode_ptr> getChildren (const char * name) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a vector of all children with the specified name.
|
* Get a vector of all children with the specified name.
|
||||||
*/
|
*/
|
||||||
vector<SGPropertyNode_ptr> getChildren (const std::string& name) const
|
std::vector<SGPropertyNode_ptr> getChildren (const std::string& name) const
|
||||||
{ return getChildren(name.c_str()); }
|
{ return getChildren(name.c_str()); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -696,14 +682,14 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Remove all children with the specified name.
|
* Remove all children with the specified name.
|
||||||
*/
|
*/
|
||||||
vector<SGPropertyNode_ptr> removeChildren (const char * name,
|
std::vector<SGPropertyNode_ptr> removeChildren (const char * name,
|
||||||
bool keep = true);
|
bool keep = true);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove all children with the specified name.
|
* Remove all children with the specified name.
|
||||||
*/
|
*/
|
||||||
vector<SGPropertyNode_ptr> removeChildren (const std::string& name,
|
std::vector<SGPropertyNode_ptr> removeChildren (const std::string& name,
|
||||||
bool keep = true)
|
bool keep = true)
|
||||||
{ return removeChildren(name.c_str(), keep); }
|
{ return removeChildren(name.c_str(), keep); }
|
||||||
|
|
||||||
@ -1422,16 +1408,16 @@ private:
|
|||||||
class hash_table;
|
class hash_table;
|
||||||
|
|
||||||
int _index;
|
int _index;
|
||||||
string _name;
|
std::string _name;
|
||||||
mutable string _display_name;
|
mutable std::string _display_name;
|
||||||
/// To avoid cyclic reference counting loops this shall not be a reference
|
/// To avoid cyclic reference counting loops this shall not be a reference
|
||||||
/// counted pointer
|
/// counted pointer
|
||||||
SGPropertyNode * _parent;
|
SGPropertyNode * _parent;
|
||||||
vector<SGPropertyNode_ptr> _children;
|
std::vector<SGPropertyNode_ptr> _children;
|
||||||
vector<SGPropertyNode_ptr> _removedChildren;
|
std::vector<SGPropertyNode_ptr> _removedChildren;
|
||||||
vector<hash_table *> _linkedNodes;
|
std::vector<hash_table *> _linkedNodes;
|
||||||
mutable string _path;
|
mutable std::string _path;
|
||||||
mutable string _buffer;
|
mutable std::string _buffer;
|
||||||
hash_table * _path_cache;
|
hash_table * _path_cache;
|
||||||
Type _type;
|
Type _type;
|
||||||
bool _tied;
|
bool _tied;
|
||||||
@ -1457,7 +1443,7 @@ private:
|
|||||||
char * string_val;
|
char * string_val;
|
||||||
} _local_val;
|
} _local_val;
|
||||||
|
|
||||||
vector <SGPropertyChangeListener *> * _listeners;
|
std::vector<SGPropertyChangeListener *> * _listeners;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1486,7 +1472,7 @@ private:
|
|||||||
SGPropertyNode * get_value () { return _value; }
|
SGPropertyNode * get_value () { return _value; }
|
||||||
void set_value (SGPropertyNode * value);
|
void set_value (SGPropertyNode * value);
|
||||||
private:
|
private:
|
||||||
string _key;
|
std::string _key;
|
||||||
SGSharedPtr<SGPropertyNode> _value;
|
SGSharedPtr<SGPropertyNode> _value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -38,6 +38,8 @@ SG_USING_STD(string);
|
|||||||
SG_USING_STD(vector);
|
SG_USING_STD(vector);
|
||||||
SG_USING_STD(map);
|
SG_USING_STD(map);
|
||||||
|
|
||||||
|
using std::endl;
|
||||||
|
|
||||||
#define DEFAULT_MODE (SGPropertyNode::READ|SGPropertyNode::WRITE)
|
#define DEFAULT_MODE (SGPropertyNode::READ|SGPropertyNode::WRITE)
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,25 +20,20 @@
|
|||||||
#include STL_STRING
|
#include STL_STRING
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include STL_IOSTREAM
|
#include <istream>
|
||||||
|
#include <ostream>
|
||||||
SG_USING_STD(string);
|
|
||||||
SG_USING_STD(vector);
|
|
||||||
SG_USING_STD(map);
|
|
||||||
SG_USING_STD(istream);
|
|
||||||
SG_USING_STD(ostream);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read properties from an XML input stream.
|
* Read properties from an XML input stream.
|
||||||
*/
|
*/
|
||||||
void readProperties (istream &input, SGPropertyNode * start_node,
|
void readProperties (std::istream &input, SGPropertyNode * start_node,
|
||||||
const string &base = "", int default_mode = 0);
|
const std::string &base = "", int default_mode = 0);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read properties from an XML file.
|
* Read properties from an XML file.
|
||||||
*/
|
*/
|
||||||
void readProperties (const string &file, SGPropertyNode * start_node,
|
void readProperties (const std::string &file, SGPropertyNode * start_node,
|
||||||
int default_mode = 0);
|
int default_mode = 0);
|
||||||
|
|
||||||
|
|
||||||
@ -52,7 +47,7 @@ void readProperties (const char *buf, const int size,
|
|||||||
/**
|
/**
|
||||||
* Write properties to an XML output stream.
|
* Write properties to an XML output stream.
|
||||||
*/
|
*/
|
||||||
void writeProperties (ostream &output, const SGPropertyNode * start_node,
|
void writeProperties (std::ostream &output, const SGPropertyNode * start_node,
|
||||||
bool write_all = false,
|
bool write_all = false,
|
||||||
SGPropertyNode::Attribute archive_flag = SGPropertyNode::ARCHIVE);
|
SGPropertyNode::Attribute archive_flag = SGPropertyNode::ARCHIVE);
|
||||||
|
|
||||||
@ -60,7 +55,8 @@ void writeProperties (ostream &output, const SGPropertyNode * start_node,
|
|||||||
/**
|
/**
|
||||||
* Write properties to an XML file.
|
* Write properties to an XML file.
|
||||||
*/
|
*/
|
||||||
void writeProperties (const string &file, const SGPropertyNode * start_node,
|
void writeProperties (const std::string &file,
|
||||||
|
const SGPropertyNode * start_node,
|
||||||
bool write_all = false,
|
bool write_all = false,
|
||||||
SGPropertyNode::Attribute archive_flag = SGPropertyNode::ARCHIVE);
|
SGPropertyNode::Attribute archive_flag = SGPropertyNode::ARCHIVE);
|
||||||
|
|
||||||
|
@ -311,7 +311,7 @@ test_property_nodes ()
|
|||||||
cout << endl;
|
cout << endl;
|
||||||
|
|
||||||
cout << "Looking for all /hack[0]/bar children" << endl;
|
cout << "Looking for all /hack[0]/bar children" << endl;
|
||||||
vector<SGPropertyNode_ptr> bar = child->getChildren("bar");
|
std::vector<SGPropertyNode_ptr> bar = child->getChildren("bar");
|
||||||
cout << "There are " << bar.size() << " matches" << endl;
|
cout << "There are " << bar.size() << " matches" << endl;
|
||||||
for (int i = 0; i < (int)bar.size(); i++)
|
for (int i = 0; i < (int)bar.size(); i++)
|
||||||
cout << bar[i]->getName() << '[' << bar[i]->getIndex() << ']' << endl;
|
cout << bar[i]->getName() << '[' << bar[i]->getIndex() << ']' << endl;
|
||||||
@ -337,7 +337,7 @@ int main (int ac, char ** av)
|
|||||||
readProperties(av[i], &root);
|
readProperties(av[i], &root);
|
||||||
writeProperties(cout, &root, true);
|
writeProperties(cout, &root, true);
|
||||||
cout << endl;
|
cout << endl;
|
||||||
} catch (string &message) {
|
} catch (std::string &message) {
|
||||||
cout << "Aborted with " << message << endl;
|
cout << "Aborted with " << message << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include <simgear/compiler.h>
|
#include <simgear/compiler.h>
|
||||||
|
|
||||||
#include STL_STRING // Standard C++ string library
|
#include STL_STRING // Standard C++ string library
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include <osg/ref_ptr>
|
#include <osg/ref_ptr>
|
||||||
#include <osg/Node>
|
#include <osg/Node>
|
||||||
@ -42,8 +43,6 @@
|
|||||||
#include <simgear/props/props.hxx>
|
#include <simgear/props/props.hxx>
|
||||||
#include <simgear/math/sg_random.h>
|
#include <simgear/math/sg_random.h>
|
||||||
|
|
||||||
SG_USING_STD(string);
|
|
||||||
|
|
||||||
|
|
||||||
class SGMatModelGroup;
|
class SGMatModelGroup;
|
||||||
|
|
||||||
@ -142,8 +141,8 @@ private:
|
|||||||
*/
|
*/
|
||||||
void load_models( SGPropertyNode *prop_root );
|
void load_models( SGPropertyNode *prop_root );
|
||||||
|
|
||||||
vector<string> _paths;
|
std::vector<std::string> _paths;
|
||||||
mutable vector<osg::ref_ptr<osg::Node> > _models;
|
mutable std::vector<osg::ref_ptr<osg::Node> > _models;
|
||||||
mutable bool _models_loaded;
|
mutable bool _models_loaded;
|
||||||
double _coverage_m2;
|
double _coverage_m2;
|
||||||
double _range_m;
|
double _range_m;
|
||||||
@ -199,7 +198,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
double _range_m;
|
double _range_m;
|
||||||
vector<SGSharedPtr<SGMatModel> > _objects;
|
std::vector<SGSharedPtr<SGMatModel> > _objects;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _SG_MAT_MODEL_HXX
|
#endif // _SG_MAT_MODEL_HXX
|
||||||
|
@ -208,7 +208,7 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef map<osg::ref_ptr<osg::Texture2D>, osg::ref_ptr<osg::StateSet> >
|
typedef std::map<osg::ref_ptr<osg::Texture2D>, osg::ref_ptr<osg::StateSet> >
|
||||||
StateSetMap;
|
StateSetMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include STL_STRING
|
#include STL_STRING
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <istream>
|
||||||
|
|
||||||
#include <osg/Array>
|
#include <osg/Array>
|
||||||
#include <osg/Geometry>
|
#include <osg/Geometry>
|
||||||
@ -252,7 +253,8 @@ typedef enum {
|
|||||||
|
|
||||||
// storage class for deferred object processing in TileEntry::load()
|
// storage class for deferred object processing in TileEntry::load()
|
||||||
struct Object {
|
struct Object {
|
||||||
Object(object_type t, const string& token, const SGPath& p, istream& in)
|
Object(object_type t, const string& token, const SGPath& p,
|
||||||
|
std::istream& in)
|
||||||
: type(t), path(p)
|
: type(t), path(p)
|
||||||
{
|
{
|
||||||
in >> name;
|
in >> name;
|
||||||
|
@ -128,7 +128,7 @@ SGXmlSound::init(SGPropertyNode *root, SGPropertyNode *node, SGSoundMgr *sndmgr,
|
|||||||
//
|
//
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
float v = 0.0;
|
float v = 0.0;
|
||||||
vector<SGPropertyNode_ptr> kids = node->getChildren("volume");
|
std::vector<SGPropertyNode_ptr> kids = node->getChildren("volume");
|
||||||
for (i = 0; (i < kids.size()) && (i < SGXmlSound::MAXPROP); i++) {
|
for (i = 0; (i < kids.size()) && (i < SGXmlSound::MAXPROP); i++) {
|
||||||
_snd_prop volume = {NULL, NULL, NULL, 1.0, 0.0, 0.0, 0.0, false};
|
_snd_prop volume = {NULL, NULL, NULL, 1.0, 0.0, 0.0, 0.0, false};
|
||||||
|
|
||||||
|
@ -33,6 +33,8 @@
|
|||||||
# error This library requires C++
|
# error This library requires C++
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include <simgear/compiler.h>
|
#include <simgear/compiler.h>
|
||||||
#include <simgear/props/condition.hxx>
|
#include <simgear/props/condition.hxx>
|
||||||
|
|
||||||
@ -149,8 +151,8 @@ private:
|
|||||||
double _stopping; // time after the sound should have stopped.
|
double _stopping; // time after the sound should have stopped.
|
||||||
// This is usefull for lost packets in in-trasit mode.
|
// This is usefull for lost packets in in-trasit mode.
|
||||||
|
|
||||||
vector<_snd_prop> _volume;
|
std::vector<_snd_prop> _volume;
|
||||||
vector<_snd_prop> _pitch;
|
std::vector<_snd_prop> _pitch;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -25,12 +25,10 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||||||
#endif
|
#endif
|
||||||
#define SampleHistogram_h 1
|
#define SampleHistogram_h 1
|
||||||
|
|
||||||
#include <iostream>
|
#include <ostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include "SGSmplstat.hxx"
|
#include "SGSmplstat.hxx"
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
extern const int SampleHistogramMinimum;
|
extern const int SampleHistogramMinimum;
|
||||||
extern const int SampleHistogramMaximum;
|
extern const int SampleHistogramMaximum;
|
||||||
|
|
||||||
@ -56,7 +54,7 @@ public:
|
|||||||
|
|
||||||
double bucketThreshold (int i);
|
double bucketThreshold (int i);
|
||||||
int inBucket (int i);
|
int inBucket (int i);
|
||||||
void printBuckets (ostream &);
|
void printBuckets (std::ostream &);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user