From 7f42cff13eaba35dda3527b2ca658dd00b9e7a46 Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Wed, 10 Feb 1999 20:01:06 +0000 Subject: [PATCH] * Doc updates * Fixes about socket, stream core, a superfluous stream. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1670 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/classes.tex | 1 + docs/latex/wx/ftp.tex | 3 +++ docs/latex/wx/protocol.tex | 16 ++++++++++++---- docs/latex/wx/stream.tex | 10 ++++++++++ docs/latex/wx/strmbase.tex | 2 +- include/wx/mstream.h | 6 ------ src/common/ftp.cpp | 1 + src/common/socket.cpp | 1 + src/common/stream.cpp | 12 ++++++++++++ utils/wxMMedia/mmfile.cpp | 31 ++++++++++++++++++------------- utils/wxMMedia/sndpcm.cpp | 12 ++++++++++++ utils/wxMMedia/vidbase.h | 1 + 12 files changed, 72 insertions(+), 24 deletions(-) diff --git a/docs/latex/wx/classes.tex b/docs/latex/wx/classes.tex index 9a88493103..1b99b55c74 100644 --- a/docs/latex/wx/classes.tex +++ b/docs/latex/wx/classes.tex @@ -191,6 +191,7 @@ $$\image{14cm;0cm}{wxclass.ps}$$ \input strlist.tex \input strmbase.tex \input stream.tex +\input strmmem.tex \input sysclevt.tex \input settings.tex \input tab.tex diff --git a/docs/latex/wx/ftp.tex b/docs/latex/wx/ftp.tex index 4a603d9679..27ed3af7f8 100644 --- a/docs/latex/wx/ftp.tex +++ b/docs/latex/wx/ftp.tex @@ -94,3 +94,6 @@ writing data, he has to delete the stream to close it. An initialized write-only stream. +\wxheading{See also} + +\helpref{wxOutputStream}{wxoutputstream} diff --git a/docs/latex/wx/protocol.tex b/docs/latex/wx/protocol.tex index 730514b43f..81c68bc9bb 100644 --- a/docs/latex/wx/protocol.tex +++ b/docs/latex/wx/protocol.tex @@ -30,11 +30,18 @@ TRUE, if the connection is established, else FALSE. Creates a new input stream on the the specified path. You can use all but seek functionnality of wxStream. Seek isn't available on all stream. For example, -http or ftp streams doesn't deal with it. +http or ftp streams doesn't deal with it. Other functions like StreamSize and +Tell aren't available for the moment for this sort of stream. +You will be notified when the EOF is reached by an error. \wxheading{Return value} -Returns the initialized stream. You will have to delete it yourself. +Returns the initialized stream. You will have to delete it yourself once you +don't use it anymore. The destructor closes the network connection. + +\wxheading{See also} + +\helpref{wxInputStream}{wxinputstream} % ---------------------------------------------------------------------------- \membersection{wxProtocol::Abort}\label{wxprotoabort} @@ -43,7 +50,9 @@ Returns the initialized stream. You will have to delete it yourself. Abort the current stream. -\it{WARNING: It is advised to destroy the input stream instead of aborting the stream this way.} +\wxheading{Warning} + +It is advised to destroy the input stream instead of aborting the stream this way. \wxheading{Return value} @@ -89,4 +98,3 @@ Sets the authentication user. It is mainly useful when FTP is used. \func{void}{SetPassword}{\param{const wxString\&}{ user}} Sets the authentication password. It is mainly useful when FTP is used. - diff --git a/docs/latex/wx/stream.tex b/docs/latex/wx/stream.tex index a2fdd74c09..5bf0c73e25 100644 --- a/docs/latex/wx/stream.tex +++ b/docs/latex/wx/stream.tex @@ -48,6 +48,16 @@ functionnalities of a ``normal'' stream. \wxheading{Warning} The "read\_write" mode may not work: it isn't completely finished. +You can create "memory" streams by this way: +\begin{verbatim} + wxStreamBuffer *sb = new wxStreamBuffer(wxStreamBuffer::read) + wxInputStream *input = new wxInputStream(sb); + + sb->Fixed(FALSE); // It can change the size of the buffer. + + // input is now a read-only memory stream. +\end{verbatim} +But you should care about destroying the stream buffer \it{YOURSELF}. \wxheading{See also} diff --git a/docs/latex/wx/strmbase.tex b/docs/latex/wx/strmbase.tex index 140aec0f5d..70eaf82689 100644 --- a/docs/latex/wx/strmbase.tex +++ b/docs/latex/wx/strmbase.tex @@ -84,5 +84,5 @@ current position in the stream. See \helpref{wxStreamBuffer::Seek}{wxstreambuffe \constfunc{off_t}{OnSysTell}{\void} Internal function. Is is called when the stream buffer needs to know the -current position in the stream. +real position in the stream. diff --git a/include/wx/mstream.h b/include/wx/mstream.h index c25fc94a85..0f73867261 100644 --- a/include/wx/mstream.h +++ b/include/wx/mstream.h @@ -27,10 +27,4 @@ class wxMemoryOutputStream: public wxOutputStream { virtual ~wxMemoryOutputStream(); }; -class wxMemoryStream: public wxMemoryInputStream, public wxMemoryOutputStream { - public: - wxMemoryStream(char *data = NULL, size_t length = 0); - virtual ~wxMemoryStream(); -}; - #endif diff --git a/src/common/ftp.cpp b/src/common/ftp.cpp index 28aad19f7f..505a923011 100644 --- a/src/common/ftp.cpp +++ b/src/common/ftp.cpp @@ -328,6 +328,7 @@ bool wxFTP::Abort(void) wxInputStream *wxFTP::GetInputStream(const wxString& path) { wxString tmp_str; + size_t calc_size; if (!SendCommand("TYPE I", '2')) return NULL; diff --git a/src/common/socket.cpp b/src/common/socket.cpp index 56c601c617..9d3dffd789 100644 --- a/src/common/socket.cpp +++ b/src/common/socket.cpp @@ -358,6 +358,7 @@ bool wxSocketBase::Close() wxSocketBase& wxSocketBase::Read(char* buffer, size_t nbytes) { m_lcount = GetPushback(buffer, nbytes, FALSE); + nbytes -= m_lcount; // If we have got the whole needed buffer or if we don't want to // wait then it returns immediately. diff --git a/src/common/stream.cpp b/src/common/stream.cpp index f2bb737c0d..95947e6032 100644 --- a/src/common/stream.cpp +++ b/src/common/stream.cpp @@ -285,6 +285,9 @@ size_t wxStreamBuffer::Read(void *buffer, size_t size) { wxASSERT(m_stream != NULL); + if (m_mode == write) + return 0; + // ------------------ // Buffering disabled // ------------------ @@ -334,6 +337,9 @@ size_t wxStreamBuffer::Read(wxStreamBuffer *s_buf) char buf[BUF_TEMP_SIZE]; size_t s = 0, bytes_read = BUF_TEMP_SIZE; + if (m_mode == write) + return 0; + while (bytes_read == BUF_TEMP_SIZE) { bytes_read = Read(buf, bytes_read); bytes_read = s_buf->Write(buf, bytes_read); @@ -346,6 +352,9 @@ size_t wxStreamBuffer::Write(const void *buffer, size_t size) { wxASSERT(m_stream != NULL); + if (m_mode == read) + return 0; + // ------------------ // Buffering disabled // ------------------ @@ -392,6 +401,9 @@ size_t wxStreamBuffer::Write(wxStreamBuffer *sbuf) char buf[BUF_TEMP_SIZE]; size_t s = 0, bytes_count = BUF_TEMP_SIZE, b_count2; + if (m_mode == read) + return 0; + while (bytes_count == BUF_TEMP_SIZE) { b_count2 = sbuf->Read(buf, bytes_count); bytes_count = Write(buf, b_count2); diff --git a/utils/wxMMedia/mmfile.cpp b/utils/wxMMedia/mmfile.cpp index 011726fc3a..47e31efe09 100644 --- a/utils/wxMMedia/mmfile.cpp +++ b/utils/wxMMedia/mmfile.cpp @@ -17,7 +17,6 @@ #endif #include #include -#include #include "mmfile.h" @@ -44,16 +43,18 @@ wxMMediaFile::wxMMediaFile(wxInputStream& is, bool preload, bool seekable) m_tmpfname((char *)NULL), m_mfname((char *)NULL), m_seekable(seekable) { -/* if (preload) { - wxMemoryStream *tmpstream = new wxMemoryStream(); + wxStreamBuffer *streamb = new wxStreamBuffer(wxStreamBuffer::read_write); - m_o_temp = tmpstream; - m_i_temp = tmpstream; + streamb->Fixed(FALSE); + streamb->Flushable(FALSE); + + m_o_temp = new wxOutputStream(streamb); + m_i_temp = new wxInputStream(streamb); m_o_temp->Write(is); + streamb->ResetBuffer(); } -*/ } wxMMediaFile::wxMMediaFile(const wxString& fname) @@ -75,16 +76,18 @@ void wxMMediaFile::SetFile(wxInputStream& str, bool preload, bool seekable) m_ostream = NULL; m_seekable = seekable; -/* if (preload) { - wxMemoryStream *tmpstream = new wxMemoryStream(); + wxStreamBuffer *streamb = new wxStreamBuffer(wxStreamBuffer::read_write); + + streamb->Fixed(FALSE); + streamb->Flushable(FALSE); - m_i_temp = tmpstream; - m_o_temp = tmpstream; + m_o_temp = new wxOutputStream(streamb); + m_i_temp = new wxInputStream(streamb); - m_o_temp->Write(str); + m_o_temp->Write(is); + streamb->ResetBuffer(); } -*/ } void wxMMediaFile::SetFile(wxOutputStream& str, bool seekable) @@ -113,7 +116,9 @@ void wxMMediaFile::CleanUpPrevious() if (m_ostream) m_ostream->Write(*m_i_temp); - delete m_i_temp; // Only one delete because m_tmpo* and m_tmpi* are linked + delete m_i_temp->StreamBuffer(); + delete m_i_temp; + delete m_o_temp; if (m_tmpfname) wxRemoveFile(m_tmpfname); diff --git a/utils/wxMMedia/sndpcm.cpp b/utils/wxMMedia/sndpcm.cpp index 6838911046..f40fcadedc 100644 --- a/utils/wxMMedia/sndpcm.cpp +++ b/utils/wxMMedia/sndpcm.cpp @@ -1,3 +1,12 @@ +//////////////////////////////////////////////////////////////////////////////// +// Name: sndpcm.cpp +// Purpose: wxMMedia +// Author: Guilhem Lavaux +// Created: 1998 +// Updated: 1999 +// Copyright: (C) 1997, 1998, 1999, Guilhem Lavaux +// License: wxWindows license +//////////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ #pragma implementation "sndpcm.h" #endif @@ -106,9 +115,11 @@ void wxSoundPcmCodec::InputSwapAndSign16() } else { while (StreamOk()) { temp = GET(); + temp2 = GET(); PUT(temp ^ signer1); if (!StreamOk()) { m_in_sound->WriteBack(temp); + m_in_sound->WriteBack(temp2); break; } PUT(GET() ^ signer2); @@ -164,6 +175,7 @@ void wxSoundPcmCodec::OutputSwapAndSign16() PUT(temp ^ signer1); if (!StreamOk()) { m_in_sound->WriteBack(temp); + m_in_sound->WriteBack(temp2); break; } PUT(temp2 ^ signer2); diff --git a/utils/wxMMedia/vidbase.h b/utils/wxMMedia/vidbase.h index 367b37389c..9e766f5500 100644 --- a/utils/wxMMedia/vidbase.h +++ b/utils/wxMMedia/vidbase.h @@ -20,6 +20,7 @@ #include "mmfile.h" #include "wx/string.h" #include "wx/window.h" +#include "wx/frame.h" /// typedef enum { -- 2.45.2