Hi Robert,
Hiding the standard functions and classes with our own fopen and
fstream/ifstream/ofstream does seem the ideal option.
Hiding fopen in the osg and osgDB namespaces is trivial.
However, hiding fstream/ifstream/ofstream is not so easy as they are in
the std namespace.
This works:
//header file osg/fstream
#include <fstream>
namespace osg{
namespace std{
using namespace ::std;
class fstream : public ::std::fstream{...};
}}
//cpp file
#include <osg/fstream>
namespace osg{
void someFunc(){
std::fstream f;//constructs an osg::std::fstream
}}
However, most OpenSceneGraph CPP files contain the following line:
using namespace osg;
Consequently all subsequent references to the std namespace are
ambiguous and won't compile.
Personally I think "using namespace osg" is incorrect, and should be
replaced with "namespace osg{" but that's a separate issue.
In conclusion, yes we should have osg::fopen(). We could have
osg::fstream, which would look a bit neater, but won't prevent
accidental use of std::fstream.
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> ] On Behalf Of
Robert Osfield
Sent: 07 October 2008 21:14
To: OpenSceneGraph Users
Subject: Re: [osg-users] Unicode support for Windows
Off the top of my head my first suggestions, perhaps naive, would be to
have a osgDB::ifstream and osgDB::ofstream implementations that take
std::string (or alternatively) as parameters for the constructors and
open() and hide the traditional methods, and have these subclasses do
the internal conversions required. An osgDB::fopen() could also be
written.
Thoughts?
Robert.
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
g
<http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.o
rg>
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
<http://www.messagelabs.com/email>
______________________________________________________________________
______________________________________________________________________
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
_____________________________________________________________________________________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org