1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield 2 * 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 5 * (at your option) any later version. The full license is in LICENSE file 6 * included with this distribution, and on the openscenegraph.org website. 7 * 8 * This library is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * OpenSceneGraph Public License for more details. 12*/ 13 14#ifndef OSGDB_FSTREAM 15#define OSGDB_FSTREAM 1 16 17#include <osgDB/Export> 18#include <osg/Export> 19 20#include <fstream> 21 22 23namespace osgDB 24{ 25 26/** 27* Convenience function for fstream open , std::ifstream, and std::ofstream to 28* automatically handle UTF-8 to UTF-16 filename conversion. Always use one 29* of these classes in any OpenSceneGraph code instead of the STL equivalent. 30*/ 31 32void OSGDB_EXPORT open(std::fstream& fs, const char* filename,std::ios_base::openmode mode); 33 34class ifstream : public std::ifstream 35{ 36public: 37 OSGDB_EXPORT ifstream(); 38 OSGDB_EXPORT explicit ifstream(const char* filename, 39 std::ios_base::openmode mode = std::ios_base::in); 40 OSGDB_EXPORT ~ifstream(); 41 42 void OSGDB_EXPORT open(const char* filename, 43 std::ios_base::openmode mode = std::ios_base::in); 44}; 45 46class ofstream : public std::ofstream 47{ 48public: 49 OSGDB_EXPORT ofstream(); 50 OSGDB_EXPORT explicit ofstream(const char* filename, 51 std::ios_base::openmode mode = std::ios_base::out); 52 OSGDB_EXPORT ~ofstream(); 53 54 void OSGDB_EXPORT open(const char* filename, 55 std::ios_base::openmode mode = std::ios_base::out); 56}; 57 58} 59 60#endif 61