From: Bertrand <bco...@us...> - 2017-02-25 14:23:23
|
Update of /cvsroot/jsbsim/JSBSim/src/simgear/io/iostreams In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv24758/src/simgear/io/iostreams Added Files: CMakeLists.txt sgstream.cxx sgstream.hxx Log Message: JSBSim now uses SGPath to manage file names. It allows to use absolute paths, to use Unicode file names and to benefit from SimGear maintenance for the corresponding code. --- NEW FILE --- set(SOURCES sgstream.cxx) set(HEADERS sgstream.hxx) add_full_path_name(IOSTREAMS_SRC "${SOURCES}") add_full_path_name(IOSTREAMS_HDR "${HEADERS}") install(FILES ${HEADERS} DESTINATION include/JSBSim/simgear/io/iostreams) --- NEW FILE --- // zlib input file stream wrapper. // // Written by Bernie Bright, 1998 // // Copyright (C) 1998 Bernie Bright - bb...@c0... // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // // $Id: sgstream.cxx,v 1.1 2017/02/25 14:23:19 bcoconni Exp $ #include <simgear/compiler.h> #include <string> #include "sgstream.hxx" #include <simgear/misc/sg_path.hxx> using std::istream; using std::ostream; sg_ifstream::sg_ifstream(const SGPath& path, std::ios::openmode io_mode) { #if defined(SG_WINDOWS) std::wstring ps = path.wstr(); #else std::string ps = path.local8BitStr(); #endif std::ifstream::open(ps.c_str(), io_mode); } void sg_ifstream::open( const SGPath& name, std::ios::openmode io_mode ) { #if defined(SG_WINDOWS) std::wstring ps = name.wstr(); #else std::string ps = name.local8BitStr(); #endif std::ifstream::open(ps.c_str(), io_mode); } sg_ofstream::sg_ofstream(const SGPath& path, std::ios::openmode io_mode) { #if defined(SG_WINDOWS) std::wstring ps = path.wstr(); #else std::string ps = path.local8BitStr(); #endif std::ofstream::open(ps.c_str(), io_mode); } void sg_ofstream::open( const SGPath& name, std::ios::openmode io_mode ) { #if defined(SG_WINDOWS) std::wstring ps = name.wstr(); #else std::string ps = name.local8BitStr(); #endif std::ofstream::open(ps.c_str(), io_mode); } --- NEW FILE --- /** * \file sgstream.hxx * input file stream wrapper. */ // Written by Bernie Bright, 1998 // // Copyright (C) 1998 Bernie Bright - bb...@c0... // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // // $Id: sgstream.hxx,v 1.1 2017/02/25 14:23:19 bcoconni Exp $ #ifndef _SGSTREAM_HXX #define _SGSTREAM_HXX #ifndef __cplusplus # error This library requires C++ #endif #include <simgear/compiler.h> #include <iostream> #include <fstream> #include <string> class SGPath; class sg_ifstream : public std::ifstream { public: sg_ifstream() {} sg_ifstream(const SGPath& path, std::ios::openmode io_mode = std::ios::in | std::ios::binary); void open( const SGPath& name, std::ios::openmode io_mode = std::ios::in|std::ios::binary ); }; class sg_ofstream : public std::ofstream { public: sg_ofstream() { } sg_ofstream(const SGPath& path, std::ios::openmode io_mode = std::ios::out | std::ios::binary); void open( const SGPath& name, std::ios::openmode io_mode = std::ios::out|std::ios::binary ); }; #endif /* _SGSTREAM_HXX */ |