2012-03-22 01:36:20 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield
|
2008-11-07 23:08:08 +08:00
|
|
|
*
|
2012-03-22 01:36:20 +08:00
|
|
|
* This library is open source and may be redistributed and/or modified under
|
|
|
|
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
2008-11-07 23:08:08 +08:00
|
|
|
* (at your option) any later version. The full license is in LICENSE file
|
|
|
|
* included with this distribution, and on the openscenegraph.org website.
|
2012-03-22 01:36:20 +08:00
|
|
|
*
|
2008-11-07 23:08:08 +08:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2012-03-22 01:36:20 +08:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2008-11-07 23:08:08 +08:00
|
|
|
* OpenSceneGraph Public License for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef OSGDB_FSTREAM
|
|
|
|
#define OSGDB_FSTREAM 1
|
|
|
|
|
|
|
|
#include <osgDB/Export>
|
2009-02-19 22:24:10 +08:00
|
|
|
#include <osg/Export>
|
2008-11-07 23:08:08 +08:00
|
|
|
|
|
|
|
#include <fstream>
|
|
|
|
|
2013-06-12 20:49:18 +08:00
|
|
|
|
2008-11-07 23:08:08 +08:00
|
|
|
namespace osgDB
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
2013-06-12 20:49:18 +08:00
|
|
|
* Convenience function for fstream open , std::ifstream, and std::ofstream to
|
2008-11-07 23:08:08 +08:00
|
|
|
* automatically handle UTF-8 to UTF-16 filename conversion. Always use one
|
|
|
|
* of these classes in any OpenSceneGraph code instead of the STL equivalent.
|
|
|
|
*/
|
|
|
|
|
2013-06-12 20:49:18 +08:00
|
|
|
void OSGDB_EXPORT open(std::fstream& fs, const char* filename,std::ios_base::openmode mode);
|
2008-11-07 23:08:08 +08:00
|
|
|
|
2016-08-05 20:16:07 +08:00
|
|
|
class ifstream : public std::ifstream
|
2008-11-07 23:08:08 +08:00
|
|
|
{
|
|
|
|
public:
|
2016-08-05 20:16:07 +08:00
|
|
|
OSGDB_EXPORT ifstream();
|
|
|
|
OSGDB_EXPORT explicit ifstream(const char* filename,
|
2008-11-07 23:08:08 +08:00
|
|
|
std::ios_base::openmode mode = std::ios_base::in);
|
2016-08-05 20:16:07 +08:00
|
|
|
OSGDB_EXPORT ~ifstream();
|
2008-11-07 23:08:08 +08:00
|
|
|
|
2016-08-05 20:16:07 +08:00
|
|
|
void OSGDB_EXPORT open(const char* filename,
|
2008-11-07 23:08:08 +08:00
|
|
|
std::ios_base::openmode mode = std::ios_base::in);
|
|
|
|
};
|
|
|
|
|
2016-08-05 20:16:07 +08:00
|
|
|
class ofstream : public std::ofstream
|
2008-11-07 23:08:08 +08:00
|
|
|
{
|
|
|
|
public:
|
2016-08-05 20:16:07 +08:00
|
|
|
OSGDB_EXPORT ofstream();
|
|
|
|
OSGDB_EXPORT explicit ofstream(const char* filename,
|
2008-11-07 23:08:08 +08:00
|
|
|
std::ios_base::openmode mode = std::ios_base::out);
|
2016-08-05 20:16:07 +08:00
|
|
|
OSGDB_EXPORT ~ofstream();
|
2008-11-07 23:08:08 +08:00
|
|
|
|
2016-08-05 20:16:07 +08:00
|
|
|
void OSGDB_EXPORT open(const char* filename,
|
2008-11-07 23:08:08 +08:00
|
|
|
std::ios_base::openmode mode = std::ios_base::out);
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|