#if wxUSE_STREAMS
-class WXDLLIMPEXP_BASE wxDataInputStream
+// Common wxDataInputStream and wxDataOutputStream parameters.
+class WXDLLIMPEXP_BASE wxDataStreamBase
{
public:
+ 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:
+ // 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
- wxDataInputStream(wxInputStream& s, const wxMBConv& conv = wxConvUTF8 );
-#else
- wxDataInputStream(wxInputStream& s);
+ wxMBConv *m_conv;
#endif
- ~wxDataInputStream();
+
+ 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(); }
wxDataInputStream& operator>>(double& i);
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:
wxInputStream *m_input;
- bool m_be_order;
-#if wxUSE_UNICODE
- wxMBConv *m_conv;
-#endif
wxDECLARE_NO_COPY_CLASS(wxDataInputStream);
};
-class WXDLLIMPEXP_BASE wxDataOutputStream
+class WXDLLIMPEXP_BASE wxDataOutputStream : public wxDataStreamBase
{
public:
-#if wxUSE_UNICODE
- wxDataOutputStream(wxOutputStream& s, const wxMBConv& conv = wxConvUTF8 );
-#else
- wxDataOutputStream(wxOutputStream& s);
-#endif
- ~wxDataOutputStream();
+ wxDataOutputStream(wxOutputStream& s, const wxMBConv& conv = wxConvUTF8);
bool IsOk() { return m_output->IsOk(); }
wxDataOutputStream& operator<<(double 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:
wxOutputStream *m_output;
- bool m_be_order;
-#if wxUSE_UNICODE
- wxMBConv *m_conv;
-#endif
wxDECLARE_NO_COPY_CLASS(wxDataOutputStream);
};
#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;
+}
+
+#if wxUSE_UNICODE
+void wxDataStreamBase::SetConv( const wxMBConv &conv )
{
+ delete m_conv;
+ m_conv = conv.Clone();
}
+#endif
-wxDataInputStream::~wxDataInputStream()
+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()
// 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
-{
-}
-
-wxDataOutputStream::~wxDataOutputStream()
+ : wxDataStreamBase(conv),
+ m_output(&s)
{
-#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)