Files
pcsx2/common/include/Utilities/pxStreams.h
T
Jake.Stine 2b4d7cc384 wxIsoFile branch: (needs linux testing)
* Convert IsoFileFormats.cpp into a class.
 * Use wxFile and wxFileInputStream instead of windows/posix specific file functions.
 * Added new ScopedAlloc classes, which are very simple dependency-free templates for exception-safe allocations.
 * FastFormatString: Improved performance ad fixed an obscure bug.
 * Drag&Drop (UI) - Improved the friendliness and responsiveness, so that PCSX2 doesn't end up tying up an explorer window while it prompts the user or issues error messages.

git-svn-id: http://pcsx2.googlecode.com/svn/branches/wxIsoFile@3934 96395faa-99c1-11dd-bbfe-3dabce05a288
2010-10-18 01:40:49 +00:00

81 lines
2.7 KiB
C++

/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2010 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* PCSX2 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with PCSX2.
* If not, see <http://www.gnu.org/licenses/>.
*/
// --------------------------------------------------------------------------------------
// pxStreamWriter
// --------------------------------------------------------------------------------------
class pxStreamWriter
{
DeclareNoncopyableObject(pxStreamWriter);
protected:
wxString m_filename;
ScopedPtr<wxOutputStream> m_outstream;
public:
pxStreamWriter(const wxString& filename, ScopedPtr<wxOutputStream>& output);
pxStreamWriter(const wxString& filename, wxOutputStream* output);
virtual ~pxStreamWriter() throw() {}
virtual void Write( const void* data, size_t size );
void Close() { m_outstream.Delete(); }
wxOutputStream* GetBaseStream() const { return m_outstream; }
void SetStream( const wxString& filename, ScopedPtr<wxOutputStream>& stream );
void SetStream( const wxString& filename, wxOutputStream* stream );
wxString GetStreamName() const { return m_filename; }
template< typename T >
void Write( const T& data )
{
Write( &data, sizeof(data) );
}
};
// --------------------------------------------------------------------------------------
// pxStreamReader
// --------------------------------------------------------------------------------------
class pxStreamReader
{
DeclareNoncopyableObject(pxStreamReader);
protected:
wxString m_filename;
ScopedPtr<wxInputStream> m_stream;
public:
pxStreamReader(const wxString& filename, ScopedPtr<wxInputStream>& input);
pxStreamReader(const wxString& filename, wxInputStream* input);
virtual ~pxStreamReader() throw() {}
virtual void Read( void* dest, size_t size );
void SetStream( const wxString& filename, ScopedPtr<wxInputStream>& stream );
void SetStream( const wxString& filename, wxInputStream* stream );
wxInputStream* GetBaseStream() const { return m_stream; }
void Close() { m_stream.Delete(); }
wxString GetStreamName() const { return m_filename; }
template< typename T >
void Read( T& dest )
{
Read( &dest, sizeof(dest) );
}
};