Extract common parts of wxData{In,Out}putStream in a common base class.

No real changes, just put BigEndianOrdered() and SetConv() methods and the
corresponding fields in a common wxDataStreamBase class instead of duplicating
them in wxDataInputStream and wxDataOutputStream.

This will make it simpler to add more features common to both classes in the
future, see #10625.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73933 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2013-05-06 00:30:42 +00:00
parent 9618496b6a
commit 61eb6bb673
2 changed files with 58 additions and 70 deletions

View File

@@ -24,34 +24,45 @@
#include "wx/math.h"
#endif //WX_PRECOMP
// ---------------------------------------------------------------------------
// wxDataInputStream
// ---------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// wxDataStreamBase
// ----------------------------------------------------------------------------
wxDataStreamBase::wxDataStreamBase(const wxMBConv& conv)
#if wxUSE_UNICODE
wxDataInputStream::wxDataInputStream(wxInputStream& s, const wxMBConv& conv)
: m_input(&s), m_be_order(false), m_conv(conv.Clone())
#else
wxDataInputStream::wxDataInputStream(wxInputStream& s)
: m_input(&s), m_be_order(false)
#endif
: m_conv(conv.Clone())
#endif // wxUSE_UNICODE
{
// It is unused in non-Unicode build, so suppress a warning there.
wxUnusedVar(conv);
m_be_order = false;
}
wxDataInputStream::~wxDataInputStream()
#if wxUSE_UNICODE
void wxDataStreamBase::SetConv( const wxMBConv &conv )
{
delete m_conv;
m_conv = conv.Clone();
}
#endif
wxDataStreamBase::~wxDataStreamBase()
{
#if wxUSE_UNICODE
delete m_conv;
#endif // wxUSE_UNICODE
}
#if wxUSE_UNICODE
void wxDataInputStream::SetConv( const wxMBConv &conv )
// ---------------------------------------------------------------------------
// wxDataInputStream
// ---------------------------------------------------------------------------
wxDataInputStream::wxDataInputStream(wxInputStream& s, const wxMBConv& conv)
: wxDataStreamBase(conv),
m_input(&s)
{
delete m_conv;
m_conv = conv.Clone();
}
#endif
#if wxHAS_INT64
wxUint64 wxDataInputStream::Read64()
@@ -463,31 +474,12 @@ wxDataInputStream& wxDataInputStream::operator>>(float& f)
// wxDataOutputStream
// ---------------------------------------------------------------------------
#if wxUSE_UNICODE
wxDataOutputStream::wxDataOutputStream(wxOutputStream& s, const wxMBConv& conv)
: m_output(&s), m_be_order(false), m_conv(conv.Clone())
#else
wxDataOutputStream::wxDataOutputStream(wxOutputStream& s)
: m_output(&s), m_be_order(false)
#endif
: wxDataStreamBase(conv),
m_output(&s)
{
}
wxDataOutputStream::~wxDataOutputStream()
{
#if wxUSE_UNICODE
delete m_conv;
#endif // wxUSE_UNICODE
}
#if wxUSE_UNICODE
void wxDataOutputStream::SetConv( const wxMBConv &conv )
{
delete m_conv;
m_conv = conv.Clone();
}
#endif
#if wxHAS_INT64
void wxDataOutputStream::Write64(wxUint64 i)
{