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:
@@ -18,15 +18,38 @@
|
|||||||
|
|
||||||
#if wxUSE_STREAMS
|
#if wxUSE_STREAMS
|
||||||
|
|
||||||
class WXDLLIMPEXP_BASE wxDataInputStream
|
// Common wxDataInputStream and wxDataOutputStream parameters.
|
||||||
|
class WXDLLIMPEXP_BASE wxDataStreamBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
void BigEndianOrdered(bool be_order) { m_be_order = be_order; }
|
||||||
|
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
wxDataInputStream(wxInputStream& s, const wxMBConv& conv = wxConvUTF8 );
|
void SetConv( const wxMBConv &conv );
|
||||||
#else
|
wxMBConv *GetConv() const { return m_conv; }
|
||||||
wxDataInputStream(wxInputStream& s);
|
|
||||||
#endif
|
#endif
|
||||||
~wxDataInputStream();
|
|
||||||
|
protected:
|
||||||
|
// Ctor and dtor are both protected, this class is never used directly but
|
||||||
|
// only by its derived classes.
|
||||||
|
wxDataStreamBase(const wxMBConv& conv);
|
||||||
|
~wxDataStreamBase();
|
||||||
|
|
||||||
|
|
||||||
|
bool m_be_order;
|
||||||
|
|
||||||
|
#if wxUSE_UNICODE
|
||||||
|
wxMBConv *m_conv;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
wxDECLARE_NO_COPY_CLASS(wxDataStreamBase);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class WXDLLIMPEXP_BASE wxDataInputStream : public wxDataStreamBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxDataInputStream(wxInputStream& s, const wxMBConv& conv = wxConvUTF8);
|
||||||
|
|
||||||
bool IsOk() { return m_input->IsOk(); }
|
bool IsOk() { return m_input->IsOk(); }
|
||||||
|
|
||||||
@@ -77,32 +100,16 @@ public:
|
|||||||
wxDataInputStream& operator>>(double& i);
|
wxDataInputStream& operator>>(double& i);
|
||||||
wxDataInputStream& operator>>(float& f);
|
wxDataInputStream& operator>>(float& f);
|
||||||
|
|
||||||
void BigEndianOrdered(bool be_order) { m_be_order = be_order; }
|
|
||||||
|
|
||||||
#if wxUSE_UNICODE
|
|
||||||
void SetConv( const wxMBConv &conv );
|
|
||||||
wxMBConv *GetConv() const { return m_conv; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
wxInputStream *m_input;
|
wxInputStream *m_input;
|
||||||
bool m_be_order;
|
|
||||||
#if wxUSE_UNICODE
|
|
||||||
wxMBConv *m_conv;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
wxDECLARE_NO_COPY_CLASS(wxDataInputStream);
|
wxDECLARE_NO_COPY_CLASS(wxDataInputStream);
|
||||||
};
|
};
|
||||||
|
|
||||||
class WXDLLIMPEXP_BASE wxDataOutputStream
|
class WXDLLIMPEXP_BASE wxDataOutputStream : public wxDataStreamBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
#if wxUSE_UNICODE
|
wxDataOutputStream(wxOutputStream& s, const wxMBConv& conv = wxConvUTF8);
|
||||||
wxDataOutputStream(wxOutputStream& s, const wxMBConv& conv = wxConvUTF8 );
|
|
||||||
#else
|
|
||||||
wxDataOutputStream(wxOutputStream& s);
|
|
||||||
#endif
|
|
||||||
~wxDataOutputStream();
|
|
||||||
|
|
||||||
bool IsOk() { return m_output->IsOk(); }
|
bool IsOk() { return m_output->IsOk(); }
|
||||||
|
|
||||||
@@ -155,19 +162,8 @@ public:
|
|||||||
wxDataOutputStream& operator<<(double f);
|
wxDataOutputStream& operator<<(double f);
|
||||||
wxDataOutputStream& operator<<(float f);
|
wxDataOutputStream& operator<<(float f);
|
||||||
|
|
||||||
void BigEndianOrdered(bool be_order) { m_be_order = be_order; }
|
|
||||||
|
|
||||||
#if wxUSE_UNICODE
|
|
||||||
void SetConv( const wxMBConv &conv );
|
|
||||||
wxMBConv *GetConv() const { return m_conv; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
wxOutputStream *m_output;
|
wxOutputStream *m_output;
|
||||||
bool m_be_order;
|
|
||||||
#if wxUSE_UNICODE
|
|
||||||
wxMBConv *m_conv;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
wxDECLARE_NO_COPY_CLASS(wxDataOutputStream);
|
wxDECLARE_NO_COPY_CLASS(wxDataOutputStream);
|
||||||
};
|
};
|
||||||
|
@@ -24,34 +24,45 @@
|
|||||||
#include "wx/math.h"
|
#include "wx/math.h"
|
||||||
#endif //WX_PRECOMP
|
#endif //WX_PRECOMP
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxDataInputStream
|
// wxDataStreamBase
|
||||||
// ---------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxDataStreamBase::wxDataStreamBase(const wxMBConv& conv)
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
wxDataInputStream::wxDataInputStream(wxInputStream& s, const wxMBConv& conv)
|
: m_conv(conv.Clone())
|
||||||
: m_input(&s), m_be_order(false), m_conv(conv.Clone())
|
#endif // wxUSE_UNICODE
|
||||||
#else
|
|
||||||
wxDataInputStream::wxDataInputStream(wxInputStream& s)
|
|
||||||
: m_input(&s), m_be_order(false)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
|
// 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
|
#if wxUSE_UNICODE
|
||||||
delete m_conv;
|
delete m_conv;
|
||||||
#endif // wxUSE_UNICODE
|
#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
|
#if wxHAS_INT64
|
||||||
wxUint64 wxDataInputStream::Read64()
|
wxUint64 wxDataInputStream::Read64()
|
||||||
@@ -463,31 +474,12 @@ wxDataInputStream& wxDataInputStream::operator>>(float& f)
|
|||||||
// wxDataOutputStream
|
// wxDataOutputStream
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
#if wxUSE_UNICODE
|
|
||||||
wxDataOutputStream::wxDataOutputStream(wxOutputStream& s, const wxMBConv& conv)
|
wxDataOutputStream::wxDataOutputStream(wxOutputStream& s, const wxMBConv& conv)
|
||||||
: m_output(&s), m_be_order(false), m_conv(conv.Clone())
|
: wxDataStreamBase(conv),
|
||||||
#else
|
m_output(&s)
|
||||||
wxDataOutputStream::wxDataOutputStream(wxOutputStream& s)
|
|
||||||
: m_output(&s), m_be_order(false)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
#if wxHAS_INT64
|
||||||
void wxDataOutputStream::Write64(wxUint64 i)
|
void wxDataOutputStream::Write64(wxUint64 i)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user