replaced wxStream::GetSize() with GetLength() (still keep the former but it will be deprecated) (second part of patch 1063498)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30428 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2004-11-10 21:10:30 +00:00
parent 30984deafc
commit 588066b7a3
13 changed files with 79 additions and 48 deletions

View File

@ -229,6 +229,7 @@ All:
SQL_C_WXCHAR should be used rather than SQL_C_CHAR to ensure transparent
behavior between Unicode and non-unicode builds
- BLOB example added to samples\db (thanks to Casey ODonnell)
- use wxStream::GetLength() instead of deprecated GetSize()
All (GUI):

View File

@ -27,27 +27,31 @@ None
% ctor & dtor
% -----------
\membersection{wxStreamBase::wxStreamBase}\label{wxstreambasector}
\func{}{wxStreamBase}{\void}
Creates a dummy stream object. It doesn't do anything.
\membersection{wxStreamBase::\destruct{wxStreamBase}}\label{wxstreambasedtor}
\func{}{\destruct{wxStreamBase}}{\void}
Destructor.
\membersection{wxStreamBase::IsOk}\label{wxstreambaseisok}
\constfunc{wxStreamError}{IsOk}{\void}
\membersection{wxStreamBase::GetLength}\label{wxstreambasegetlength}
Returns true if no error occurred on the stream.
\constfunc{wxFileOffset}{GetLength}{\void}
\wxheading{See also}
Returns the length of the stream in bytes. If the length cannot be determined
(this is always the case for socket streams for example), returns
\texttt{wxInvalidOffset}.
\newsince{2.5.4}
\helpref{GetLastError}{wxstreambasegetlasterror}
\membersection{wxStreamBase::GetLastError}\label{wxstreambasegetlasterror}
@ -63,6 +67,33 @@ This function returns the last error.
\twocolitem{{\bf wxSTREAM\_READ\_ERROR}}{A generic error occurred on the last read call.}
\end{twocollist}
\membersection{wxStreamBase::GetSize}\label{wxstreambasegetsize}
\constfunc{size\_t}{GetSize}{\void}
\deprecated{\helpref{GetLength}{wxstreambasegetlength}}
This function returns the size of the stream. For example, for a file it is the
size of the file.
\wxheading{Warning}
There are streams which do not have size by definition, such as socket streams.
In that cases, GetSize returns $0$ so you should always test its return value.
\membersection{wxStreamBase::IsOk}\label{wxstreambaseisok}
\constfunc{wxStreamError}{IsOk}{\void}
Returns true if no error occurred on the stream.
\wxheading{See also}
\helpref{GetLastError}{wxstreambasegetlasterror}
\membersection{wxStreamBase::OnSysRead}\label{wxstreambaseonsysread}
\func{size\_t}{OnSysRead}{\param{void*}{ buffer}, \param{size\_t}{ bufsize}}
@ -70,6 +101,7 @@ This function returns the last error.
Internal function. It is called when the stream wants to read data of the
specified size. It should return the size that was actually read.
\membersection{wxStreamBase::OnSysSeek}\label{wxstreambaseonsysseek}
\func{off\_t}{OnSysSeek}{\param{off\_t}{ pos}, \param{wxSeekMode}{ mode}}
@ -77,6 +109,7 @@ specified size. It should return the size that was actually read.
Internal function. It is called when the stream needs to change the
current position.
\membersection{wxStreamBase::OnSysTell}\label{wxstreambaseonsystell}
\constfunc{off\_t}{OnSysTell}{\void}
@ -84,21 +117,11 @@ current position.
Internal function. Is is called when the stream needs to know the
real position.
\membersection{wxStreamBase::OnSysWrite}\label{wxstreambaseonsyswrite}
\func{size\_t}{OnSysWrite}{\param{void *}{buffer}, \param{size\_t}{ bufsize}}
See \helpref{OnSysRead}{wxstreambaseonsysread}.
\membersection{wxStreamBase::GetSize}\label{wxstreambasegetsize}
\constfunc{size\_t}{GetSize}{\void}
This function returns the size of the stream. For example, for a file it is the size of
the file.
\wxheading{Warning}
There are streams which do not have size by definition, such as socket streams.
In that cases, GetSize returns $0$ so you should always test its return value.

View File

@ -21,7 +21,7 @@ class WXDLLIMPEXP_BASE wxMemoryInputStream : public wxInputStream
public:
wxMemoryInputStream(const void *data, size_t length);
virtual ~wxMemoryInputStream();
virtual size_t GetSize() const { return m_length; }
virtual wxFileOffset GetLength() const { return m_length; }
virtual bool Eof() const;
char Peek();
@ -50,7 +50,7 @@ public:
// if data is !NULL it must be allocated with malloc()
wxMemoryOutputStream(void *data = NULL, size_t length = 0);
virtual ~wxMemoryOutputStream();
virtual size_t GetSize() const { return m_o_streambuf->GetLastAccess(); }
virtual wxFileOffset GetLength() const { return m_o_streambuf->GetLastAccess(); }
size_t CopyTo(void *buffer, size_t len) const;

View File

@ -31,7 +31,7 @@ public:
m_pos = 0;
}
virtual size_t GetSize() const { return m_str.length(); }
virtual wxFileOffset GetLength() const { return m_str.length(); }
protected:
virtual wxFileOffset OnSysSeek(wxFileOffset ofs, wxSeekMode mode);

View File

@ -82,7 +82,8 @@ public:
void Reset() { m_lasterror = wxSTREAM_NO_ERROR; }
// this doesn't make sense for all streams, always test its return value
virtual size_t GetSize() const { return 0; }
virtual size_t GetSize() const;
virtual wxFileOffset GetLength() const { return wxInvalidOffset; }
#if WXWIN_COMPATIBILITY_2_2
// deprecated, for compatibility only
@ -283,7 +284,7 @@ class WXDLLIMPEXP_BASE wxCountingOutputStream : public wxOutputStream
public:
wxCountingOutputStream();
size_t GetSize() const;
wxFileOffset GetLength() const;
bool Ok() const { return true; }
protected:
@ -309,7 +310,7 @@ public:
char Peek() { return m_parent_i_stream->Peek(); }
size_t GetSize() const { return m_parent_i_stream->GetSize(); }
wxFileOffset GetLength() const { return m_parent_i_stream->GetLength(); }
wxInputStream *GetFilterInputStream() const { return m_parent_i_stream; }
@ -326,7 +327,7 @@ public:
wxFilterOutputStream(wxOutputStream& stream);
virtual ~wxFilterOutputStream();
size_t GetSize() const { return m_parent_o_stream->GetSize(); }
wxFileOffset GetLength() const { return m_parent_o_stream->GetLength(); }
wxOutputStream *GetFilterOutputStream() const { return m_parent_o_stream; }
@ -515,7 +516,7 @@ public:
void Sync();
size_t GetSize() const;
wxFileOffset GetLength() const;
// the buffer given to the stream will be deleted by it
void SetOutputStreamBuffer(wxStreamBuffer *buffer);

View File

@ -37,7 +37,7 @@ class WXDLLIMPEXP_BASE wxFileInputStream: public wxInputStream {
wxFileInputStream(int fd);
~wxFileInputStream();
size_t GetSize() const;
wxFileOffset GetLength() const;
bool Ok() const { return m_file->IsOpened(); }
@ -67,7 +67,7 @@ class WXDLLIMPEXP_BASE wxFileOutputStream: public wxOutputStream {
// { return wxOutputStream::Write(buffer, size); }
void Sync();
size_t GetSize() const;
wxFileOffset GetLength() const;
bool Ok() const { return m_file->IsOpened(); }
@ -106,7 +106,7 @@ class WXDLLIMPEXP_BASE wxFFileInputStream: public wxInputStream {
wxFFileInputStream(FILE *file);
~wxFFileInputStream();
size_t GetSize() const;
wxFileOffset GetLength() const;
bool Ok() const { return m_file->IsOpened(); }
@ -136,7 +136,7 @@ class WXDLLIMPEXP_BASE wxFFileOutputStream: public wxOutputStream {
// { return wxOutputStream::Write(buffer, size); }
void Sync();
size_t GetSize() const;
wxFileOffset GetLength() const;
bool Ok() const { return m_file->IsOpened(); }

View File

@ -34,7 +34,7 @@ public:
// Remember that archive must be local file accesible via fopen, fread functions!
~wxZipInputStream();
virtual size_t GetSize() const {return m_Size;}
virtual wxFileOffset GetLength() const {return m_Size;}
virtual bool Eof() const;
protected:
@ -43,7 +43,7 @@ protected:
virtual wxFileOffset OnSysTell() const {return m_Pos;}
private:
size_t m_Size;
wxFileOffset m_Size;
wxFileOffset m_Pos;
// this void* is handle of archive . I'm sorry it is void and not proper

View File

@ -46,7 +46,7 @@ class WXDLLIMPEXP_BASE wxZlibInputStream: public wxFilterInputStream {
virtual ~wxZlibInputStream();
char Peek() { return wxInputStream::Peek(); }
size_t GetSize() const { return wxInputStream::GetSize(); }
wxFileOffset GetLength() const { return wxInputStream::GetLength(); }
static bool CanHandleGZip();
@ -72,7 +72,7 @@ class WXDLLIMPEXP_BASE wxZlibOutputStream: public wxFilterOutputStream {
virtual ~wxZlibOutputStream();
void Sync() { DoFlush(false); }
size_t GetSize() const { return (size_t)m_pos; }
wxFileOffset GetLength() const { return m_pos; }
static bool CanHandleGZip();

View File

@ -657,6 +657,12 @@ wxStreamBase::~wxStreamBase()
{
}
size_t wxStreamBase::GetSize() const
{
wxFileOffset length = GetLength();
return length == wxInvalidOffset ? 0 : (size_t)length;
}
wxFileOffset wxStreamBase::OnSysSeek(wxFileOffset WXUNUSED(seek), wxSeekMode WXUNUSED(mode))
{
return wxInvalidOffset;
@ -957,7 +963,7 @@ wxCountingOutputStream::wxCountingOutputStream ()
m_currentPos = 0;
}
size_t wxCountingOutputStream::GetSize() const
wxFileOffset wxCountingOutputStream::GetLength() const
{
return m_lastcount;
}
@ -1218,9 +1224,9 @@ wxFileOffset wxBufferedOutputStream::OnSysTell() const
return m_parent_o_stream->TellO();
}
size_t wxBufferedOutputStream::GetSize() const
wxFileOffset wxBufferedOutputStream::GetLength() const
{
return m_parent_o_stream->GetSize() + m_o_streambuf->GetIntPosition();
return m_parent_o_stream->GetLength() + m_o_streambuf->GetIntPosition();
}
void wxBufferedOutputStream::SetOutputStreamBuffer(wxStreamBuffer *buffer)

View File

@ -62,7 +62,7 @@ wxFileInputStream::~wxFileInputStream()
delete m_file;
}
size_t wxFileInputStream::GetSize() const
wxFileOffset wxFileInputStream::GetLength() const
{
return m_file->Length();
}
@ -176,7 +176,7 @@ void wxFileOutputStream::Sync()
m_file->Flush();
}
size_t wxFileOutputStream::GetSize() const
wxFileOffset wxFileOutputStream::GetLength() const
{
return m_file->Length();
}
@ -227,7 +227,7 @@ wxFFileInputStream::~wxFFileInputStream()
delete m_file;
}
size_t wxFFileInputStream::GetSize() const
wxFileOffset wxFFileInputStream::GetLength() const
{
return m_file->Length();
}
@ -343,7 +343,7 @@ void wxFFileOutputStream::Sync()
m_file->Flush();
}
size_t wxFFileOutputStream::GetSize() const
wxFileOffset wxFFileOutputStream::GetLength() const
{
return m_file->Length();
}

View File

@ -60,7 +60,7 @@ wxZipInputStream::wxZipInputStream(const wxString& archive, const wxString& file
m_lasterror = wxSTREAM_READ_ERROR;
return;
}
m_Size = (size_t)zinfo.uncompressed_size;
m_Size = zinfo.uncompressed_size;
}
@ -77,25 +77,25 @@ wxZipInputStream::~wxZipInputStream()
bool wxZipInputStream::Eof() const
{
wxASSERT_MSG( m_Pos <= (wxFileOffset)m_Size,
wxASSERT_MSG( m_Pos <= m_Size,
_T("wxZipInputStream: invalid current position") );
return m_Pos >= (wxFileOffset)m_Size;
return m_Pos >= m_Size;
}
size_t wxZipInputStream::OnSysRead(void *buffer, size_t bufsize)
{
wxASSERT_MSG( m_Pos <= (wxFileOffset)m_Size,
wxASSERT_MSG( m_Pos <= m_Size,
_T("wxZipInputStream: invalid current position") );
if ( m_Pos >= (wxFileOffset)m_Size )
if ( m_Pos >= m_Size )
{
m_lasterror = wxSTREAM_EOF;
return 0;
}
if (m_Pos + bufsize > m_Size)
if (m_Pos + bufsize > m_Size + (size_t)0)
bufsize = m_Size - m_Pos;
unzReadCurrentFile((unzFile)m_Archive, buffer, bufsize);

View File

@ -69,7 +69,7 @@ public:
class wxPyCBInputStream : public wxInputStream {
public:
~wxPyCBInputStream();
virtual size_t GetSize() const;
virtual wxFileOffset GetLength() const;
// factory function
static wxPyCBInputStream* create(PyObject *py, bool block=true);

View File

@ -1385,7 +1385,7 @@ PyObject* wxPyCBInputStream::getMethod(PyObject* py, char* name) {
}
size_t wxPyCBInputStream::GetSize() const {
wxFileOffset wxPyCBInputStream::GetLength() const {
wxPyCBInputStream* self = (wxPyCBInputStream*)this; // cast off const
if (m_seek && m_tell) {
wxFileOffset temp = self->OnSysTell();
@ -1394,7 +1394,7 @@ size_t wxPyCBInputStream::GetSize() const {
return ret;
}
else
return 0;
return wxInvalidOffset;
}