X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/216a72f3b9ab2bf72f489aceac0093138a6e7707..137c8bde085d6d5b7c459902d2ea1a198ab48765:/src/common/datstrm.cpp diff --git a/src/common/datstrm.cpp b/src/common/datstrm.cpp index 656b628b35..50e4eb4b2e 100644 --- a/src/common/datstrm.cpp +++ b/src/common/datstrm.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: datstrm.cpp +// Name: src/common/datstrm.cpp // Purpose: Data stream classes // Author: Guilhem Lavaux // Modified by: Mickael Gilabert @@ -19,15 +19,18 @@ #if wxUSE_STREAMS #include "wx/datstrm.h" -#include "wx/math.h" + +#ifndef WX_PRECOMP + #include "wx/math.h" +#endif //WX_PRECOMP // --------------------------------------------------------------------------- // wxDataInputStream // --------------------------------------------------------------------------- #if wxUSE_UNICODE -wxDataInputStream::wxDataInputStream(wxInputStream& s, wxMBConv& conv) - : m_input(&s), m_be_order(false), m_conv(conv) +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) @@ -35,6 +38,13 @@ wxDataInputStream::wxDataInputStream(wxInputStream& s) { } +wxDataInputStream::~wxDataInputStream() +{ +#if wxUSE_UNICODE + delete m_conv; +#endif // wxUSE_UNICODE +} + #if wxHAS_INT64 wxUint64 wxDataInputStream::Read64() { @@ -100,7 +110,7 @@ wxString wxDataInputStream::ReadString() wxCharBuffer tmp(len + 1); m_input->Read(tmp.data(), len); tmp.data()[len] = '\0'; - wxString ret(m_conv.cMB2WX(tmp.data())); + wxString ret(m_conv->cMB2WX(tmp.data())); #else wxString ret; m_input->Read( wxStringBuffer(ret, len), len); @@ -296,7 +306,7 @@ void wxDataInputStream::ReadLL(wxLongLong *buffer, size_t size) wxLongLong wxDataInputStream::ReadLL(void) { wxLongLong ll; - DoReadLL(&ll, 1, m_input, m_be_order); + DoReadLL(&ll, (size_t)1, m_input, m_be_order); return ll; } #endif // wxUSE_LONGLONG @@ -445,8 +455,8 @@ wxDataInputStream& wxDataInputStream::operator>>(float& f) // --------------------------------------------------------------------------- #if wxUSE_UNICODE -wxDataOutputStream::wxDataOutputStream(wxOutputStream& s, wxMBConv& conv) - : m_output(&s), m_be_order(false), m_conv(conv) +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) @@ -454,6 +464,13 @@ wxDataOutputStream::wxDataOutputStream(wxOutputStream& s) { } +wxDataOutputStream::~wxDataOutputStream() +{ +#if wxUSE_UNICODE + delete m_conv; +#endif // wxUSE_UNICODE +} + #if wxHAS_INT64 void wxDataOutputStream::Write64(wxUint64 i) { @@ -497,7 +514,7 @@ void wxDataOutputStream::Write8(wxUint8 i) void wxDataOutputStream::WriteString(const wxString& string) { #if wxUSE_UNICODE - const wxWX2MBbuf buf = string.mb_str(m_conv); + const wxWX2MBbuf buf = string.mb_str(*m_conv); #else const wxWX2MBbuf buf = string.mb_str(); #endif @@ -724,4 +741,3 @@ wxDataOutputStream& wxDataOutputStream::operator<<(float f) #endif // wxUSE_STREAMS -