X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/79c3e0e1aeebb64da2ac893e6ed7b27edca01a64..314055fa8d202ca0628a197877bfa299d3e7540d:/src/common/mstream.cpp?ds=sidebyside diff --git a/src/common/mstream.cpp b/src/common/mstream.cpp index d37a9ddaa3..7f72e82db4 100644 --- a/src/common/mstream.cpp +++ b/src/common/mstream.cpp @@ -23,12 +23,6 @@ #pragma hdrstop #endif -#if !USE_SHARED_LIBRARY -IMPLEMENT_CLASS(wxMemoryInputStream, wxInputStream) -IMPLEMENT_CLASS(wxMemoryOutputStream, wxOutputStream) -IMPLEMENT_CLASS2(wxMemoryStream, wxInputStream, wxOutputStream) -#endif - // ---------------------------------------------------------------------------- // wxMemoryStreamBase // ---------------------------------------------------------------------------- @@ -73,25 +67,37 @@ wxMemoryInputStream::wxMemoryInputStream(const char *data, size_t len) m_lastread = 0; m_eof = FALSE; m_iolimit = 1; + + m_i_streambuf->SetBufferIO(0); +} + +wxMemoryInputStream::~wxMemoryInputStream() +{ } -wxInputStream& wxMemoryInputStream::Read(void *buffer, size_t size) +char wxMemoryInputStream::Peek() +{ + // wxStreamBuffer is disabled so just peek the current character. + + return m_buffer[m_position_i]; +} + +size_t wxMemoryInputStream::DoRead(void *buffer, size_t size) { if (m_iolimit == 2) { m_eof = TRUE; - return *this; + return 0; } if (m_position_i+size > m_length) size = m_length-m_position_i; memcpy((void *)((unsigned long)buffer+m_position_i), m_buffer, size); m_position_i += size; - m_lastread = size; - return *this; + return size; } -off_t wxMemoryInputStream::SeekI(off_t pos, wxSeekMode mode) +off_t wxMemoryInputStream::DoSeekInput(off_t pos, wxSeekMode mode) { if (m_iolimit == 2) return 0; @@ -131,29 +137,35 @@ wxMemoryOutputStream::wxMemoryOutputStream(char *data, size_t len) m_lastwrite = 0; m_bad = FALSE; m_iolimit = 2; + + m_o_streambuf->SetBufferIO(0); } -wxOutputStream& wxMemoryOutputStream::Write(const void *buffer, size_t size) +wxMemoryOutputStream::~wxMemoryOutputStream() +{ + Sync(); +} + +size_t wxMemoryOutputStream::DoWrite(const void *buffer, size_t size) { if (m_iolimit == 1) { m_bad = TRUE; - return *this; + return 0; } if (m_position_o+size > m_length) if (!ChangeBufferSize(m_position_o+size)) { m_bad = TRUE; - return *this; + return 0; } memcpy(m_buffer+m_position_o, buffer, size); m_position_o += size; - m_lastwrite = size; - return *this; + return size; } -off_t wxMemoryOutputStream::SeekO(off_t pos, wxSeekMode mode) +off_t wxMemoryOutputStream::DoSeekOutput(off_t pos, wxSeekMode mode) { if (m_iolimit == 1) return 0;