#include <simgear/constants.h>
#include <simgear/math/SGMath.hxx>
-#ifdef SG_HAVE_STD_INCLUDES
-# include <cmath>
-# include <cstdio> // sprintf()
-#else
-# 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);
-
+#include <cmath>
+#include <cstdio> // sprintf()
+#include <ostream>
+#include <string>
/**
* standard size of a bucket in degrees (1/8 of a degree)
* string form.
* @return tile index in string form
*/
- inline string gen_index_str() const {
+ inline std::string gen_index_str() const {
char tmp[20];
- sprintf(tmp, "%ld",
- (((long)lon + 180) << 14) + ((lat + 90) << 6) + (y << 3) + x);
- return (string)tmp;
+ std::sprintf(tmp, "%ld",
+ (((long)lon + 180) << 14) + ((lat + 90) << 6)
+ + (y << 3) + x);
+ return (std::string)tmp;
}
/**
* Build the base path name for this bucket.
* @return base path in string form
*/
- string gen_base_path() const;
+ std::string gen_base_path() const;
/**
* @return the center lon of a tile.
// friends
- friend ostream& operator<< ( ostream&, const SGBucket& );
+ friend std::ostream& operator<< ( std::ostream&, const SGBucket& );
friend bool operator== ( const SGBucket&, const SGBucket& );
};
* @param out output stream
* @param b bucket
*/
-inline ostream&
-operator<< ( ostream& out, const SGBucket& b )
+inline std::ostream&
+operator<< ( std::ostream& out, const SGBucket& b )
{
return out << b.lon << ":" << b.x << ", " << b.lat << ":" << b.y;
}
//
// $Id$
+#include <iostream>
+
#include "logstream.hxx"
-logstream *global_logstream = NULL;
+logstream *logstream::global_logstream = 0;
bool logbuf::logging_enabled = true;
#ifdef _MSC_VER
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);
+}
#ifdef SG_HAVE_STD_INCLUDES
# include <streambuf>
-# include <iostream>
+# include <ostream>
#else
# include <iostream.h>
# include <simgear/sg_traits.hxx>
SG_USING_STD(streambuf);
SG_USING_STD(ostream);
-SG_USING_STD(cout);
-SG_USING_STD(cerr);
-SG_USING_STD(endl);
#ifdef __MWERKS__
SG_USING_STD(iostream);
#ifdef SG_NEED_STREAMBUF_HACK
class logbuf : public __streambuf
#else
-class logbuf : public streambuf
+class logbuf : public std::streambuf
#endif
{
public:
* Set the stream buffer
* @param sb stream buffer
*/
- void set_sb( streambuf* sb );
+ void set_sb( std::streambuf* sb );
#ifdef _MSC_VER
static void has_no_console() { has_console = false; }
private:
// The streambuf used for actual output. Defaults to cerr.rdbuf().
- static streambuf* sbuf;
+ static std::streambuf* sbuf;
static bool logging_enabled;
#ifdef _MSC_VER
/**
* Class to manage the debug logging stream.
*/
-class logstream : private logstream_base, public ostream
+class logstream : private logstream_base, public std::ostream
{
public:
/**
* The default is to send messages to cerr.
* @param out output stream
*/
- logstream( ostream& out )
+ logstream( std::ostream& out )
// : logstream_base(out.rdbuf()),
: logstream_base(),
- ostream(&lbuf) { lbuf.set_sb(out.rdbuf());}
+ std::ostream(&lbuf) { lbuf.set_sb(out.rdbuf());}
/**
* Set the 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.
* Output operator to capture the debug level and priority of a message.
* @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 )
{
lbuf.set_log_state( l.logClass, l.logPriority );
return *this;
}
-extern logstream *global_logstream;
-
/**
* \relates logstream
* Return the one and only logstream instance.
inline logstream&
sglog()
{
- if (global_logstream == NULL) {
-
-#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);
+ if (logstream::global_logstream == NULL) {
+ logstream::initGlobalLogstream();
}
-
- return *global_logstream;
+ return *logstream::global_logstream;
}
#elif defined( __MWERKS__ )
# define SG_LOG(C,P,M) ::sglog() << ::loglevel(C,P) << M << std::endl
#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
#define SG_STRINGIFY(x) #x
#include <vector>
#include STL_STRING
+#include <iostream>
#include <simgear/bucket/newbucket.hxx>
#include <simgear/misc/sg_path.hxx>
SG_USING_STD( string );
SG_USING_STD( vector );
+using std::cout;
+using std::endl;
enum sgObjectTypes {
SG_BOUNDING_SPHERE = 0,
#include <unistd.h>
#endif
+#include <iostream>
+
#include <simgear/debug/logstream.hxx>
#include "sg_socket.hxx"
sprintf( wbuf, "hello world\n" );
int length = channel->writestring( wbuf );
- cout << "writestring returned " << length << "\n";
+ std::cout << "writestring returned " << length << "\n";
return true;
}
TcpClient client( "localhost", "5500" );
if (!client.open())
{
- cout << "client open failed\n";
+ std::cout << "client open failed\n";
return 0;
}
# define exception c_exception
#endif
-#ifdef SG_HAVE_STD_INCLUDES
-# include <iostream>
-# include <cassert>
-# include <cmath>
-#else
-# include <iostream.h>
-# include <assert.h>
-# include <math.h>
-#endif
+#include <ostream>
+#include <istream>
+#include <cassert>
+#include <cmath>
#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;
enum {PX, PY, PZ}; // axes
// Kludge for msvc++ 6.0 - requires forward decls of friend functions.
class Point3D;
-istream& operator>> ( istream&, Point3D& );
-ostream& operator<< ( ostream&, const Point3D& );
+std::istream& operator>> ( std::istream&, Point3D& );
+std::ostream& operator<< ( std::ostream&, const Point3D& );
Point3D operator- (const Point3D& p); // -p1
bool operator== (const Point3D& a, const Point3D& b); // p1 == p2?
// friends
friend Point3D operator - (const Point3D& p); // -p1
friend bool operator == (const Point3D& a, const Point3D& b); // p1 == p2?
- friend istream& operator>> ( istream&, Point3D& );
- friend ostream& operator<< ( ostream&, const Point3D& );
+ friend std::istream& operator>> ( std::istream&, Point3D& );
+ friend std::ostream& operator<< ( std::ostream&, const Point3D& );
// Special functions
double distance3D(const Point3D& a) const; // distance between
// input from stream
-inline istream&
-operator >> ( istream& in, Point3D& p)
+inline std::istream&
+operator >> ( std::istream& in, Point3D& p)
{
char c;
return in;
}
-inline ostream&
-operator<< ( ostream& out, const Point3D& p )
+inline std::ostream&
+operator<< ( std::ostream& out, const Point3D& p )
{
return out << p.n[PX] << ", " << p.n[PY] << ", " << p.n[PZ];
}
#include "sgstream.hxx"
+using std::string;
+using std::istream;
+
sg_gzifstream::sg_gzifstream()
: istream(&gzbuf)
{
#include <simgear/misc/zfstream.hxx>
-SG_USING_STD(string);
-SG_USING_STD(istream);
-
-
/**
* An envelope class for gzifstream.
*/
-class sg_gzifstream : private gzifstream_base, public istream
+class sg_gzifstream : private gzifstream_base, public std::istream
{
public:
/** Default constructor */
* @param name name of file
* @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 );
/**
* @param name name of file
* @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 );
/**
* An istream manipulator that skips to end of line.
* @param in input stream
*/
-istream& skipeol( istream& in );
+std::istream& skipeol( std::istream& in );
/**
* \relates sg_gzifstream
* An istream manipulator that skips over white space.
* @param in input stream
*/
-istream& skipws( istream& in );
+std::istream& skipws( std::istream& in );
/**
* \relates sg_gzifstream
* Ignores comments that start with '#'.
* @param in input stream
*/
-istream& skipcomment( istream& in );
+std::istream& skipcomment( std::istream& in );
#endif /* _SGSTREAM_HXX */
// Allocate memory for 'get' buffer and zero all buffer pointers.
//
gzfilebuf::gzfilebuf()
- : streambuf(),
+ : std::streambuf(),
file(NULL),
#if defined( __MWERKS__ ) || __GNUC__ > 2
mode(ios_openmode(0)),
// }
-streampos
-gzfilebuf::seekoff( streamoff, ios_seekdir, int )
+std::streampos
+gzfilebuf::seekoff( std::streamoff, ios_seekdir, int )
{
- return streampos(EOF);
+ return std::streampos(EOF);
}
gzfilebuf::int_type
# include <streambuf>
# include <istream>
-# define ios_openmode ios_base::openmode
-# define ios_in ios_base::in
-# define ios_out ios_base::out
-# define ios_app ios_base::app
-# define ios_binary ios_base::binary
+# define ios_openmode std::ios_base::openmode
+# define ios_in std::ios_base::in
+# define ios_out std::ios_base::out
+# define ios_app std::ios_base::app
+# 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_failbit ios_base::failbit
-
-SG_USING_STD(streambuf);
-SG_USING_STD(ios_base);
-SG_USING_STD(streampos);
-SG_USING_STD(streamoff);
+# define ios_badbit std::ios_base::badbit
+# define ios_failbit std::ios_base::failbit
#else
#ifdef SG_NEED_STREAMBUF_HACK
class gzfilebuf : public __streambuf
#else
-class gzfilebuf : public streambuf
+class gzfilebuf : public std::streambuf
#endif
{
public:
bool is_open() const { return (file != NULL); }
/** @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 */
virtual int sync();
#ifndef SG_HAVE_STD_INCLUDES
virtual int_type overflow( int_type c = traits_type::eof() );
#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
private:
#include "props.hxx"
#include <algorithm>
+
#include <sstream>
#include <stdio.h>
#include <string.h>
#if PROPS_STANDALONE
-
#include <iostream>
-using std::cerr;
-using std::endl;
-using std::find;
-using std::sort;
-using std::vector;
-using std::stringstream;
-
#else
#include <simgear/compiler.h>
#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 )
// MSVC 6 is buggy, and needs something strange here
SG_USING_STD(vector<SGPropertyNode_ptr>);
SG_USING_STD(vector<SGPropertyChangeListener *>);
SG_USING_STD(vector<SGPropertyNode *>);
#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;
\f
#endif
#include <vector>
-
-#if PROPS_STANDALONE
-
#include <string>
-#include <iostream>
-
-using std::string;
-using std::vector;
-using std::istream;
-using std::ostream;
+#if PROPS_STANDALONE
#else
-
#include <simgear/compiler.h>
#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
+
+
#include <simgear/structure/SGReferenced.hxx>
#include <simgear/structure/SGSharedPtr.hxx>
virtual void unregister_property (SGPropertyNode * node);
private:
- vector<SGPropertyNode *> _properties;
+ std::vector<SGPropertyNode *> _properties;
};
/**
* 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.
*/
- vector<SGPropertyNode_ptr> getChildren (const std::string& name) const
+ std::vector<SGPropertyNode_ptr> getChildren (const std::string& name) const
{ return getChildren(name.c_str()); }
/**
/**
* 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);
/**
* 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)
{ return removeChildren(name.c_str(), keep); }
class hash_table;
int _index;
- string _name;
- mutable string _display_name;
+ std::string _name;
+ mutable std::string _display_name;
/// To avoid cyclic reference counting loops this shall not be a reference
/// counted pointer
SGPropertyNode * _parent;
- vector<SGPropertyNode_ptr> _children;
- vector<SGPropertyNode_ptr> _removedChildren;
- vector<hash_table *> _linkedNodes;
- mutable string _path;
- mutable string _buffer;
+ std::vector<SGPropertyNode_ptr> _children;
+ std::vector<SGPropertyNode_ptr> _removedChildren;
+ std::vector<hash_table *> _linkedNodes;
+ mutable std::string _path;
+ mutable std::string _buffer;
hash_table * _path_cache;
Type _type;
bool _tied;
char * string_val;
} _local_val;
- vector <SGPropertyChangeListener *> * _listeners;
+ std::vector<SGPropertyChangeListener *> * _listeners;
/**
SGPropertyNode * get_value () { return _value; }
void set_value (SGPropertyNode * value);
private:
- string _key;
+ std::string _key;
SGSharedPtr<SGPropertyNode> _value;
};
SG_USING_STD(vector);
SG_USING_STD(map);
+using std::endl;
+
#define DEFAULT_MODE (SGPropertyNode::READ|SGPropertyNode::WRITE)
#include STL_STRING
#include <vector>
#include <map>
-#include STL_IOSTREAM
-
-SG_USING_STD(string);
-SG_USING_STD(vector);
-SG_USING_STD(map);
-SG_USING_STD(istream);
-SG_USING_STD(ostream);
+#include <istream>
+#include <ostream>
/**
* Read properties from an XML input stream.
*/
-void readProperties (istream &input, SGPropertyNode * start_node,
- const string &base = "", int default_mode = 0);
+void readProperties (std::istream &input, SGPropertyNode * start_node,
+ const std::string &base = "", int default_mode = 0);
/**
* 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);
/**
* 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,
SGPropertyNode::Attribute archive_flag = SGPropertyNode::ARCHIVE);
/**
* 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,
SGPropertyNode::Attribute archive_flag = SGPropertyNode::ARCHIVE);
cout << 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;
for (int i = 0; i < (int)bar.size(); i++)
cout << bar[i]->getName() << '[' << bar[i]->getIndex() << ']' << endl;
readProperties(av[i], &root);
writeProperties(cout, &root, true);
cout << endl;
- } catch (string &message) {
+ } catch (std::string &message) {
cout << "Aborted with " << message << endl;
}
}
#include <simgear/compiler.h>
#include STL_STRING // Standard C++ string library
+#include <vector>
#include <osg/ref_ptr>
#include <osg/Node>
#include <simgear/props/props.hxx>
#include <simgear/math/sg_random.h>
-SG_USING_STD(string);
-
class SGMatModelGroup;
*/
void load_models( SGPropertyNode *prop_root );
- vector<string> _paths;
- mutable vector<osg::ref_ptr<osg::Node> > _models;
+ std::vector<std::string> _paths;
+ mutable std::vector<osg::ref_ptr<osg::Node> > _models;
mutable bool _models_loaded;
double _coverage_m2;
double _range_m;
private:
double _range_m;
- vector<SGSharedPtr<SGMatModel> > _objects;
+ std::vector<SGSharedPtr<SGMatModel> > _objects;
};
#endif // _SG_MAT_MODEL_HXX
}
};
-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;
}
#include STL_STRING
#include <sstream>
+#include <istream>
#include <osg/Array>
#include <osg/Geometry>
// storage class for deferred object processing in TileEntry::load()
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)
{
in >> name;
//
unsigned int i;
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++) {
_snd_prop volume = {NULL, NULL, NULL, 1.0, 0.0, 0.0, 0.0, false};
# error This library requires C++
#endif
+#include <vector>
+
#include <simgear/compiler.h>
#include <simgear/props/condition.hxx>
double _stopping; // time after the sound should have stopped.
// This is usefull for lost packets in in-trasit mode.
- vector<_snd_prop> _volume;
- vector<_snd_prop> _pitch;
+ std::vector<_snd_prop> _volume;
+ std::vector<_snd_prop> _pitch;
};
#endif
#define SampleHistogram_h 1
-#include <iostream>
+#include <ostream>
#include <fstream>
#include "SGSmplstat.hxx"
-using namespace std;
-
extern const int SampleHistogramMinimum;
extern const int SampleHistogramMaximum;
double bucketThreshold (int i);
int inBucket (int i);
- void printBuckets (ostream &);
+ void printBuckets (std::ostream &);
};