| 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 | namespace osgDB |
|---|
| 23 | { |
|---|
| 24 | |
|---|
| 25 | /** |
|---|
| 26 | * Replacements for std::fstream, std::ifstream, and std::ofstream to |
|---|
| 27 | * automatically handle UTF-8 to UTF-16 filename conversion. Always use one |
|---|
| 28 | * of these classes in any OpenSceneGraph code instead of the STL equivalent. |
|---|
| 29 | */ |
|---|
| 30 | |
|---|
| 31 | class OSGDB_EXPORT fstream : public std::fstream |
|---|
| 32 | { |
|---|
| 33 | public: |
|---|
| 34 | fstream(); |
|---|
| 35 | explicit fstream(const char* filename, |
|---|
| 36 | std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out); |
|---|
| 37 | ~fstream(); |
|---|
| 38 | |
|---|
| 39 | void open(const char* filename, |
|---|
| 40 | std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out); |
|---|
| 41 | }; |
|---|
| 42 | |
|---|
| 43 | class OSGDB_EXPORT ifstream : public std::ifstream |
|---|
| 44 | { |
|---|
| 45 | public: |
|---|
| 46 | ifstream(); |
|---|
| 47 | explicit ifstream(const char* filename, |
|---|
| 48 | std::ios_base::openmode mode = std::ios_base::in); |
|---|
| 49 | ~ifstream(); |
|---|
| 50 | |
|---|
| 51 | void open(const char* filename, |
|---|
| 52 | std::ios_base::openmode mode = std::ios_base::in); |
|---|
| 53 | }; |
|---|
| 54 | |
|---|
| 55 | class OSGDB_EXPORT ofstream : public std::ofstream |
|---|
| 56 | { |
|---|
| 57 | public: |
|---|
| 58 | ofstream(); |
|---|
| 59 | explicit ofstream(const char* filename, |
|---|
| 60 | std::ios_base::openmode mode = std::ios_base::out); |
|---|
| 61 | ~ofstream(); |
|---|
| 62 | |
|---|
| 63 | void open(const char* filename, |
|---|
| 64 | std::ios_base::openmode mode = std::ios_base::out); |
|---|
| 65 | }; |
|---|
| 66 | |
|---|
| 67 | } |
|---|
| 68 | |
|---|
| 69 | #endif |
|---|