* wxSocket fixes
* wxStream: - new inheritance, new stream buffer, nearly the same API for the end user - updated other streams consequently * wxGTK: some change to make it compile on GTK 1.0 and GTK 1.1 * small changes on wxThread to prepare a more reentrant lib * wxVariant works with wxStream too now git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@829 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
1b19f0560f
commit
75ed1d15d0
@ -18,7 +18,7 @@
|
||||
|
||||
#include <wx/stream.h>
|
||||
|
||||
class wxDataInputStream: public virtual wxFilterInputStream {
|
||||
class wxDataInputStream: public wxFilterInputStream {
|
||||
public:
|
||||
wxDataInputStream(wxInputStream& s);
|
||||
virtual ~wxDataInputStream();
|
||||
@ -31,7 +31,7 @@ public:
|
||||
wxString ReadString();
|
||||
};
|
||||
|
||||
class wxDataOutputStream: public virtual wxFilterOutputStream {
|
||||
class wxDataOutputStream: public wxFilterOutputStream {
|
||||
public:
|
||||
wxDataOutputStream(wxOutputStream& s);
|
||||
virtual ~wxDataOutputStream();
|
||||
@ -44,11 +44,5 @@ class wxDataOutputStream: public virtual wxFilterOutputStream {
|
||||
void WriteString(const wxString& string);
|
||||
};
|
||||
|
||||
class wxDataStream: public wxDataInputStream, public wxDataOutputStream,
|
||||
public wxFilterStream {
|
||||
public:
|
||||
wxDataStream(wxStream& stream);
|
||||
};
|
||||
|
||||
#endif
|
||||
// _WX_DATSTREAM_H_
|
||||
|
@ -21,23 +21,11 @@
|
||||
#include <wx/stream.h>
|
||||
#include <wx/file.h>
|
||||
|
||||
// Disable warnings such as
|
||||
// 'wxFileStream' : inherits 'wxFileInputStream::Peek' via dominance
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4250)
|
||||
#endif
|
||||
|
||||
class wxFileStreamBase {
|
||||
protected:
|
||||
wxFile *m_file;
|
||||
bool m_file_destroy;
|
||||
};
|
||||
|
||||
class wxFileInputStream: public virtual wxInputStream,
|
||||
public virtual wxFileStreamBase {
|
||||
class wxFileInputStream: public wxInputStream {
|
||||
public:
|
||||
wxFileInputStream(const wxString& fileName);
|
||||
wxFileInputStream(const wxString& ifileName);
|
||||
wxFileInputStream(wxFile& file);
|
||||
wxFileInputStream(int fd);
|
||||
virtual ~wxFileInputStream();
|
||||
|
||||
virtual char Peek();
|
||||
@ -47,15 +35,20 @@ class wxFileInputStream: public virtual wxInputStream,
|
||||
protected:
|
||||
wxFileInputStream();
|
||||
|
||||
size_t DoRead(void *buffer, size_t size);
|
||||
off_t DoSeekInput(off_t pos, wxSeekMode mode);
|
||||
off_t DoTellInput() const;
|
||||
size_t OnSysRead(void *buffer, size_t size);
|
||||
off_t OnSysSeek(off_t pos, wxSeekMode mode);
|
||||
off_t OnSysTell() const;
|
||||
|
||||
protected:
|
||||
wxFile *m_file;
|
||||
bool m_file_destroy;
|
||||
};
|
||||
|
||||
class wxFileOutputStream: public virtual wxOutputStream,
|
||||
public virtual wxFileStreamBase {
|
||||
class wxFileOutputStream: public wxOutputStream {
|
||||
public:
|
||||
wxFileOutputStream(const wxString& fileName);
|
||||
wxFileOutputStream(wxFile& file);
|
||||
wxFileOutputStream(int fd);
|
||||
virtual ~wxFileOutputStream();
|
||||
|
||||
// To solve an ambiguity on GCC
|
||||
@ -69,20 +62,13 @@ class wxFileOutputStream: public virtual wxOutputStream,
|
||||
protected:
|
||||
wxFileOutputStream();
|
||||
|
||||
size_t DoWrite(const void *buffer, size_t size);
|
||||
off_t DoSeekOutput(off_t pos, wxSeekMode mode);
|
||||
off_t DoTellOutput() const;
|
||||
size_t OnSysWrite(const void *buffer, size_t size);
|
||||
off_t OnSysSeek(off_t pos, wxSeekMode mode);
|
||||
off_t OnSysTell() const;
|
||||
|
||||
protected:
|
||||
wxFile *m_file;
|
||||
bool m_file_destroy;
|
||||
};
|
||||
|
||||
class wxFileStream: public wxStream,
|
||||
public wxFileInputStream, public wxFileOutputStream {
|
||||
public:
|
||||
wxFileStream(const wxString& fileName);
|
||||
virtual ~wxFileStream();
|
||||
};
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(default:4250)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -13,53 +13,18 @@
|
||||
|
||||
#include <wx/stream.h>
|
||||
|
||||
class wxMemoryStreamBase {
|
||||
protected:
|
||||
wxMemoryStreamBase();
|
||||
virtual ~wxMemoryStreamBase();
|
||||
|
||||
bool ChangeBufferSize(size_t new_length);
|
||||
|
||||
protected:
|
||||
bool m_persistent;
|
||||
size_t m_length;
|
||||
char *m_buffer;
|
||||
int m_iolimit;
|
||||
};
|
||||
|
||||
class wxMemoryInputStream: public virtual wxMemoryStreamBase, public wxInputStream {
|
||||
class wxMemoryInputStream: public wxInputStream {
|
||||
public:
|
||||
wxMemoryInputStream(const char *data, size_t length);
|
||||
virtual ~wxMemoryInputStream();
|
||||
|
||||
char Peek();
|
||||
|
||||
protected:
|
||||
|
||||
size_t DoRead(void *buffer, size_t size);
|
||||
off_t DoSeekInput(off_t pos, wxSeekMode mode);
|
||||
off_t DoTellInput() const { return m_position_i; }
|
||||
|
||||
protected:
|
||||
off_t m_position_i;
|
||||
};
|
||||
|
||||
class wxMemoryOutputStream: public virtual wxMemoryStreamBase, public wxOutputStream {
|
||||
class wxMemoryOutputStream: public wxOutputStream {
|
||||
public:
|
||||
wxMemoryOutputStream(char *data = NULL, size_t length = 0);
|
||||
virtual ~wxMemoryOutputStream();
|
||||
|
||||
char *GetData() { Sync(); return m_buffer; }
|
||||
size_t GetLength() { Sync(); return m_length; }
|
||||
|
||||
protected:
|
||||
|
||||
size_t DoWrite(const void *buffer, size_t size);
|
||||
off_t DoSeekOutput(off_t pos, wxSeekMode mode);
|
||||
off_t DoTellOutput() const { return m_position_o; }
|
||||
|
||||
protected:
|
||||
off_t m_position_o;
|
||||
};
|
||||
|
||||
class wxMemoryStream: public wxMemoryInputStream, public wxMemoryOutputStream {
|
||||
|
@ -56,7 +56,8 @@ class wxTCPConnection: public wxConnectionBase
|
||||
protected:
|
||||
wxSocketBase *m_sock;
|
||||
wxSocketStream *m_sockstrm;
|
||||
wxDataStream *m_codec;
|
||||
wxDataInputStream *m_codeci;
|
||||
wxDataOutputStream *m_codeco;
|
||||
wxString m_topic;
|
||||
|
||||
friend class wxTCPServer;
|
||||
|
@ -18,11 +18,11 @@
|
||||
#include "wx/stream.h"
|
||||
#include "wx/socket.h"
|
||||
|
||||
class WXDLLEXPORT wxSocketOutputStream : public virtual wxOutputStream
|
||||
class WXDLLEXPORT wxSocketOutputStream : public wxOutputStream
|
||||
{
|
||||
public:
|
||||
wxSocketOutputStream(wxSocketBase& s);
|
||||
virtual ~wxSocketOutputStream();
|
||||
~wxSocketOutputStream();
|
||||
|
||||
wxOutputStream& Write(const void *buffer, size_t size);
|
||||
off_t SeekO( off_t WXUNUSED(pos), wxSeekMode WXUNUSED(mode) )
|
||||
@ -30,13 +30,11 @@ class WXDLLEXPORT wxSocketOutputStream : public virtual wxOutputStream
|
||||
off_t TellO()
|
||||
{ return -1; }
|
||||
|
||||
bool Bad() { return m_o_socket->IsDisconnected(); }
|
||||
size_t LastWrite() { return m_o_socket->LastCount(); }
|
||||
protected:
|
||||
wxSocketBase *m_o_socket;
|
||||
};
|
||||
|
||||
class WXDLLEXPORT wxSocketInputStream : public virtual wxInputStream
|
||||
class WXDLLEXPORT wxSocketInputStream : public wxInputStream
|
||||
{
|
||||
public:
|
||||
wxSocketInputStream(wxSocketBase& s);
|
||||
@ -48,19 +46,16 @@ class WXDLLEXPORT wxSocketInputStream : public virtual wxInputStream
|
||||
off_t TellI()
|
||||
{ return -1; }
|
||||
|
||||
bool Eof() { return m_i_socket->IsDisconnected(); }
|
||||
size_t LastRead() { return m_i_socket->LastCount(); }
|
||||
protected:
|
||||
wxSocketBase *m_i_socket;
|
||||
};
|
||||
|
||||
class WXDLLEXPORT wxSocketStream : public wxSocketInputStream,
|
||||
public wxSocketOutputStream,
|
||||
public wxStream {
|
||||
|
||||
public wxSocketOutputStream
|
||||
{
|
||||
public:
|
||||
wxSocketStream(wxSocketBase& i_s, wxSocketBase& o_s);
|
||||
wxSocketStream(wxSocketBase& s);
|
||||
~wxSocketStream();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -259,7 +259,7 @@ public:
|
||||
|
||||
virtual bool Connect(wxSockAddress& addr_man, bool wait = TRUE);
|
||||
|
||||
bool WaitOnConnect(long seconds = -1);
|
||||
bool WaitOnConnect(long seconds = -1, long microseconds = 0);
|
||||
|
||||
virtual void OnRequest(wxRequestEvent flags);
|
||||
};
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "wx/string.h"
|
||||
#include "wx/filefn.h" // for off_t, wxInvalidOffset and wxSeekMode
|
||||
|
||||
class WXDLLEXPORT wxStreamBase;
|
||||
class WXDLLEXPORT wxInputStream;
|
||||
class WXDLLEXPORT wxOutputStream;
|
||||
|
||||
@ -29,74 +30,118 @@ typedef wxOutputStream& (*__wxOutputManip)(wxOutputStream&);
|
||||
|
||||
wxOutputStream& WXDLLEXPORT wxEndL(wxOutputStream& o_stream);
|
||||
|
||||
// Disable warnings such as
|
||||
// 'wxFilterStream' : inherits 'wxFilterInputStream::Peek' via dominance
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4250)
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Stream buffer
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxStreamBuffer {
|
||||
public:
|
||||
wxStreamBuffer(wxInputStream& stream);
|
||||
wxStreamBuffer(wxOutputStream& stream);
|
||||
typedef enum {
|
||||
read, write
|
||||
} BufMode;
|
||||
|
||||
// -----------
|
||||
// ctor & dtor
|
||||
// -----------
|
||||
wxStreamBuffer(wxStreamBase& stream, BufMode mode);
|
||||
~wxStreamBuffer();
|
||||
|
||||
// -----------
|
||||
// Filtered IO
|
||||
// -----------
|
||||
void Read(void *buffer, size_t size);
|
||||
void Write(const void *buffer, size_t size);
|
||||
void WriteBack(char c);
|
||||
bool WriteBack(const char *buffer, size_t size);
|
||||
bool WriteBack(char c);
|
||||
off_t Tell() const;
|
||||
off_t Seek(off_t pos, wxSeekMode mode);
|
||||
|
||||
// --------------
|
||||
// Buffer control
|
||||
// --------------
|
||||
void ResetBuffer();
|
||||
void SetBufferIO(char *buffer_start, char *buffer_end);
|
||||
void SetBufferIO(size_t bufsize);
|
||||
void ResetBuffer();
|
||||
|
||||
void SetBufferPosition(char *buffer_position)
|
||||
{ m_buffer_pos = buffer_position; }
|
||||
void SetIntPosition(size_t pos)
|
||||
{ m_buffer_pos = m_buffer_start + pos; }
|
||||
char *GetBufferPosition() const { return m_buffer_pos; }
|
||||
size_t GetIntPosition() const { return m_buffer_pos - m_buffer_start; }
|
||||
|
||||
char *GetBufferStart() const { return m_buffer_start; }
|
||||
char *GetBufferEnd() const { return m_buffer_end; }
|
||||
size_t GetBufferSize() const { return m_buffer_size; }
|
||||
char *GetBufferPos() const { return m_buffer_pos; }
|
||||
off_t GetIntPosition() const { return m_buffer_pos-m_buffer_start; }
|
||||
void SetIntPosition(off_t pos) { m_buffer_pos = m_buffer_start+pos; }
|
||||
size_t GetLastAccess() const { return m_buffer_end-m_buffer_start; }
|
||||
void Fixed(bool fixed) { m_fixed = fixed; }
|
||||
|
||||
bool FlushBuffer();
|
||||
bool FillBuffer();
|
||||
size_t GetDataLeft() const;
|
||||
|
||||
protected:
|
||||
char *AllocSpaceWBack(size_t needed_size);
|
||||
size_t GetWBack(char *buf, size_t bsize);
|
||||
|
||||
void GetFromBuffer(void *buffer, size_t size);
|
||||
void PutToBuffer(const void *buffer, size_t size);
|
||||
|
||||
protected:
|
||||
char *m_buffer_start, *m_buffer_end, *m_buffer_pos;
|
||||
size_t m_buffer_size;
|
||||
|
||||
wxInputStream *m_istream;
|
||||
wxOutputStream *m_ostream;
|
||||
char *m_wback;
|
||||
size_t m_wbacksize, m_wbackcur;
|
||||
|
||||
bool m_fixed;
|
||||
|
||||
wxStreamBase *m_stream;
|
||||
BufMode m_mode;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// wxStream: base classes
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxInputStream {
|
||||
typedef enum {
|
||||
wxStream_NOERROR,
|
||||
wxStream_EOF
|
||||
} wxStreamError;
|
||||
|
||||
class WXDLLEXPORT wxStreamBase {
|
||||
public:
|
||||
wxStreamBase();
|
||||
virtual ~wxStreamBase();
|
||||
|
||||
wxStreamError LastError() { return m_lasterror; }
|
||||
|
||||
protected:
|
||||
friend class wxStreamBuffer;
|
||||
|
||||
virtual size_t OnSysRead(void *buffer, size_t bufsize);
|
||||
virtual size_t OnSysWrite(const void *buffer, size_t bufsize);
|
||||
virtual off_t OnSysSeek(off_t seek, wxSeekMode mode);
|
||||
virtual off_t OnSysTell();
|
||||
|
||||
protected:
|
||||
size_t m_lastcount;
|
||||
wxStreamError m_lasterror;
|
||||
};
|
||||
|
||||
class WXDLLEXPORT wxInputStream: public wxStreamBase {
|
||||
public:
|
||||
wxInputStream();
|
||||
wxInputStream(wxStreamBuffer *sbuf);
|
||||
virtual ~wxInputStream();
|
||||
|
||||
// IO functions
|
||||
virtual char Peek() { return 0; }
|
||||
virtual char GetC();
|
||||
virtual wxInputStream& Read(void *buffer, size_t size);
|
||||
virtual char Peek();
|
||||
char GetC();
|
||||
wxInputStream& Read(void *buffer, size_t size);
|
||||
wxInputStream& Read(wxOutputStream& stream_out);
|
||||
|
||||
// Position functions
|
||||
virtual off_t SeekI(off_t pos, wxSeekMode mode = wxFromStart);
|
||||
virtual off_t TellI() const;
|
||||
off_t SeekI(off_t pos, wxSeekMode mode = wxFromStart);
|
||||
off_t TellI() const;
|
||||
|
||||
// State functions
|
||||
bool Eof() const { return m_eof; }
|
||||
size_t LastRead() { return m_lastread; }
|
||||
wxStreamBuffer *InputStreamBuffer() { return m_i_streambuf; }
|
||||
size_t LastRead() { return wxStreamBase::m_lastcount; }
|
||||
|
||||
// Operators
|
||||
wxInputStream& operator>>(wxOutputStream& out) { return Read(out); }
|
||||
@ -105,11 +150,12 @@ class WXDLLEXPORT wxInputStream {
|
||||
wxInputStream& operator>>(short& i);
|
||||
wxInputStream& operator>>(int& i);
|
||||
wxInputStream& operator>>(long& i);
|
||||
wxInputStream& operator>>(float& i);
|
||||
wxInputStream& operator>>(double& i);
|
||||
#if wxUSE_SERIAL
|
||||
wxInputStream& operator>>(wxObject *& obj);
|
||||
#endif
|
||||
|
||||
wxInputStream& operator>>(float& f) { double d; operator>>((double&)d); f = (float)d; return *this; }
|
||||
wxInputStream& operator>>(unsigned char& c) { return operator>>((char&)c); }
|
||||
wxInputStream& operator>>(unsigned short& i) { return operator>>((short&)i); }
|
||||
wxInputStream& operator>>(unsigned int& i) { return operator>>((int&)i); }
|
||||
@ -117,40 +163,26 @@ class WXDLLEXPORT wxInputStream {
|
||||
wxInputStream& operator>>( __wxInputManip func) { return func(*this); }
|
||||
|
||||
protected:
|
||||
friend class wxStreamBuffer;
|
||||
friend class wxFilterInputStream;
|
||||
|
||||
wxInputStream(wxStreamBuffer *buffer);
|
||||
|
||||
virtual size_t DoRead(void *WXUNUSED(buffer), size_t WXUNUSED(size) )
|
||||
{ return 0; }
|
||||
virtual off_t DoSeekInput( off_t WXUNUSED(pos), wxSeekMode WXUNUSED(mode) )
|
||||
{ return wxInvalidOffset; }
|
||||
virtual off_t DoTellInput() const
|
||||
{ return wxInvalidOffset; }
|
||||
|
||||
protected:
|
||||
bool m_eof, m_i_destroybuf;
|
||||
size_t m_lastread;
|
||||
bool m_i_destroybuf;
|
||||
wxStreamBuffer *m_i_streambuf;
|
||||
};
|
||||
|
||||
class WXDLLEXPORT wxOutputStream {
|
||||
class WXDLLEXPORT wxOutputStream: public wxStreamBase {
|
||||
public:
|
||||
wxOutputStream();
|
||||
wxOutputStream(wxStreamBuffer *sbuf);
|
||||
virtual ~wxOutputStream();
|
||||
|
||||
virtual wxOutputStream& Write(const void *buffer, size_t size);
|
||||
wxOutputStream& Write(const void *buffer, size_t size);
|
||||
wxOutputStream& Write(wxInputStream& stream_in);
|
||||
|
||||
virtual off_t SeekO(off_t pos, wxSeekMode mode = wxFromStart);
|
||||
virtual off_t TellO() const;
|
||||
off_t SeekO(off_t pos, wxSeekMode mode = wxFromStart);
|
||||
off_t TellO() const;
|
||||
|
||||
virtual bool Bad() const { return m_bad; }
|
||||
virtual size_t LastWrite() const { return m_lastwrite; }
|
||||
size_t LastWrite() const { return wxStreamBase::m_lastcount; }
|
||||
wxStreamBuffer *OutputStreamBuffer() { return m_o_streambuf; }
|
||||
|
||||
virtual void Sync();
|
||||
void Sync();
|
||||
|
||||
wxOutputStream& operator<<(wxInputStream& out) { return Write(out); }
|
||||
wxOutputStream& operator<<(const char *string);
|
||||
@ -172,36 +204,15 @@ class WXDLLEXPORT wxOutputStream {
|
||||
wxOutputStream& operator<<( __wxOutputManip func) { return func(*this); }
|
||||
|
||||
protected:
|
||||
friend class wxStreamBuffer;
|
||||
friend class wxFilterOutputStream;
|
||||
|
||||
wxOutputStream(wxStreamBuffer *buffer);
|
||||
|
||||
virtual size_t DoWrite( const void *WXUNUSED(buffer), size_t WXUNUSED(size) )
|
||||
{ return 0; }
|
||||
virtual off_t DoSeekOutput( off_t WXUNUSED(pos), wxSeekMode WXUNUSED(mode) )
|
||||
{ return wxInvalidOffset; }
|
||||
virtual off_t DoTellOutput() const
|
||||
{ return wxInvalidOffset; }
|
||||
|
||||
protected:
|
||||
bool m_bad, m_o_destroybuf;
|
||||
size_t m_lastwrite;
|
||||
bool m_o_destroybuf;
|
||||
wxStreamBuffer *m_o_streambuf;
|
||||
};
|
||||
|
||||
class WXDLLEXPORT wxStream: public virtual wxInputStream,
|
||||
public virtual wxOutputStream
|
||||
{
|
||||
public:
|
||||
wxStream();
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// "Filter" streams
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxFilterInputStream: public virtual wxInputStream {
|
||||
class WXDLLEXPORT wxFilterInputStream: public wxInputStream {
|
||||
public:
|
||||
wxFilterInputStream();
|
||||
wxFilterInputStream(wxInputStream& stream);
|
||||
@ -209,50 +220,18 @@ class WXDLLEXPORT wxFilterInputStream: public virtual wxInputStream {
|
||||
|
||||
char Peek() { return m_parent_i_stream->Peek(); }
|
||||
|
||||
bool Eof() const { return m_parent_i_stream->Eof(); }
|
||||
size_t LastRead() const { return m_parent_i_stream->LastRead(); }
|
||||
off_t TellI() const { return m_parent_i_stream->TellI(); }
|
||||
|
||||
protected:
|
||||
size_t DoRead(void *buffer, size_t size);
|
||||
off_t DoSeekInput(off_t pos, wxSeekMode mode);
|
||||
off_t DoTellInput() const;
|
||||
|
||||
protected:
|
||||
wxInputStream *m_parent_i_stream;
|
||||
};
|
||||
|
||||
class WXDLLEXPORT wxFilterOutputStream: public virtual wxOutputStream {
|
||||
class WXDLLEXPORT wxFilterOutputStream: public wxOutputStream {
|
||||
public:
|
||||
wxFilterOutputStream();
|
||||
wxFilterOutputStream(wxOutputStream& stream);
|
||||
virtual ~wxFilterOutputStream();
|
||||
|
||||
bool Bad() const { return m_parent_o_stream->Bad(); }
|
||||
size_t LastWrite() const { return m_parent_o_stream->LastWrite(); }
|
||||
off_t TellO() const { return m_parent_o_stream->TellO(); }
|
||||
|
||||
protected:
|
||||
// The forward is implicitely done by wxStreamBuffer.
|
||||
|
||||
size_t DoWrite(const void *buffer, size_t size);
|
||||
off_t DoSeekOutput(off_t pos, wxSeekMode mode);
|
||||
off_t DoTellOutput() const;
|
||||
~wxFilterOutputStream();
|
||||
|
||||
protected:
|
||||
wxOutputStream *m_parent_o_stream;
|
||||
};
|
||||
|
||||
class WXDLLEXPORT wxFilterStream: public wxStream,
|
||||
public virtual wxFilterInputStream,
|
||||
public virtual wxFilterOutputStream {
|
||||
public:
|
||||
wxFilterStream(wxStream& stream);
|
||||
wxFilterStream();
|
||||
};
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(default:4250)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -152,7 +152,8 @@ private:
|
||||
// ---------------------------------------------------------------------------
|
||||
// Global variables
|
||||
|
||||
// GUI mutex.
|
||||
WXDLLEXPORT_DATA(extern wxMutex) wxMainMutex;
|
||||
// GUI mutex handling.
|
||||
void WXDLLEXPORT wxMutexGuiEnter();
|
||||
void WXDLLEXPORT wxMutexGuiLeave();
|
||||
|
||||
#endif
|
||||
|
@ -22,12 +22,8 @@ class wxZlibInputStream: public wxFilterInputStream {
|
||||
wxZlibInputStream(wxInputStream& stream);
|
||||
virtual ~wxZlibInputStream();
|
||||
|
||||
bool Eof() const;
|
||||
|
||||
protected:
|
||||
size_t DoRead(void *buffer, size_t size);
|
||||
off_t DoSeekInput(off_t WXUNUSED(pos), wxSeekMode WXUNUSED(mode)) { return wxInvalidOffset; }
|
||||
off_t DoTellInput() const { return wxInvalidOffset; }
|
||||
size_t OnSysRead(void *buffer, size_t size);
|
||||
|
||||
protected:
|
||||
size_t m_z_size;
|
||||
@ -42,12 +38,8 @@ class wxZlibOutputStream: public wxFilterOutputStream {
|
||||
|
||||
void Sync();
|
||||
|
||||
bool Bad() const;
|
||||
|
||||
protected:
|
||||
size_t DoWrite(const void *buffer, size_t size);
|
||||
off_t DoSeekOutput(off_t WXUNUSED(pos), wxSeekMode WXUNUSED(mode)) { return wxInvalidOffset; }
|
||||
off_t DoTellOutput() const { return wxInvalidOffset; }
|
||||
size_t OnSysWrite(const void *buffer, size_t size);
|
||||
|
||||
protected:
|
||||
size_t m_z_size;
|
||||
|
@ -200,12 +200,3 @@ void wxDataOutputStream::WriteDouble(double d)
|
||||
#endif
|
||||
Write(buf, 10);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// wxDataStream
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
wxDataStream::wxDataStream(wxStream& stream)
|
||||
: wxDataInputStream(stream), wxDataOutputStream(stream)
|
||||
{
|
||||
}
|
||||
|
@ -53,17 +53,17 @@ char wxFileInputStream::Peek()
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t wxFileInputStream::DoRead(void *buffer, size_t size)
|
||||
size_t wxFileInputStream::OnSysRead(void *buffer, size_t size)
|
||||
{
|
||||
return m_file->Read(buffer, size);
|
||||
}
|
||||
|
||||
off_t wxFileInputStream::DoSeekInput(off_t pos, wxSeekMode mode)
|
||||
off_t wxFileInputStream::OnSysSeek(off_t pos, wxSeekMode mode)
|
||||
{
|
||||
return m_file->Seek(pos, mode);
|
||||
}
|
||||
|
||||
off_t wxFileInputStream::DoTellInput() const
|
||||
off_t wxFileInputStream::OnSysTell() const
|
||||
{
|
||||
return m_file->Tell();
|
||||
}
|
||||
@ -95,19 +95,19 @@ wxFileOutputStream::~wxFileOutputStream()
|
||||
}
|
||||
}
|
||||
|
||||
size_t wxFileOutputStream::DoWrite(const void *buffer, size_t size)
|
||||
size_t wxFileOutputStream::OnSysWrite(const void *buffer, size_t size)
|
||||
{
|
||||
size_t ret = m_file->Write(buffer, size);
|
||||
m_bad = m_file->Error();
|
||||
m_lasterror = wxStream_EOF; // TODO
|
||||
return ret;
|
||||
}
|
||||
|
||||
off_t wxFileOutputStream::DoTellOutput() const
|
||||
off_t wxFileOutputStream::OnSysTell() const
|
||||
{
|
||||
return m_file->Tell();
|
||||
}
|
||||
|
||||
off_t wxFileOutputStream::DoSeekOutput(off_t pos, wxSeekMode mode)
|
||||
off_t wxFileOutputStream::OnSysSeek(off_t pos, wxSeekMode mode)
|
||||
{
|
||||
return m_file->Seek(pos, mode);
|
||||
}
|
||||
@ -117,21 +117,3 @@ void wxFileOutputStream::Sync()
|
||||
wxOutputStream::Sync();
|
||||
m_file->Flush();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFileStream
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxFileStream::wxFileStream(const wxString& fileName)
|
||||
: wxFileInputStream(), wxFileOutputStream()
|
||||
{
|
||||
m_file = new wxFile(fileName, wxFile::read_write);
|
||||
// Reread the initial buffer.
|
||||
m_i_streambuf->SetBufferIO(1024);
|
||||
}
|
||||
|
||||
wxFileStream::~wxFileStream()
|
||||
{
|
||||
Sync();
|
||||
delete m_file;
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ public:
|
||||
: wxSocketInputStream(*sock), m_ftp(ftp_clt) {}
|
||||
virtual ~wxInputFTPStream(void)
|
||||
{
|
||||
if (Eof())
|
||||
if (LastError() != wxStream_NOERROR)
|
||||
m_ftp->GetResult('2');
|
||||
else
|
||||
m_ftp->Abort();
|
||||
@ -256,7 +256,7 @@ public:
|
||||
: wxSocketOutputStream(*sock), m_ftp(ftp_clt) {}
|
||||
virtual ~wxOutputFTPStream(void)
|
||||
{
|
||||
if (Bad())
|
||||
if (LastError() != wxStream_NOERROR)
|
||||
m_ftp->GetResult('2');
|
||||
else
|
||||
m_ftp->Abort();
|
||||
|
@ -23,52 +23,15 @@
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxMemoryStreamBase
|
||||
// ----------------------------------------------------------------------------
|
||||
wxMemoryStreamBase::wxMemoryStreamBase()
|
||||
{
|
||||
m_buffer = NULL;
|
||||
m_iolimit = 0;
|
||||
m_persistent = FALSE;
|
||||
m_length = 0;
|
||||
}
|
||||
|
||||
wxMemoryStreamBase::~wxMemoryStreamBase()
|
||||
{
|
||||
if (!m_persistent && m_buffer)
|
||||
free(m_buffer);
|
||||
}
|
||||
|
||||
bool wxMemoryStreamBase::ChangeBufferSize(size_t new_size)
|
||||
{
|
||||
if (m_iolimit == 1)
|
||||
return FALSE;
|
||||
|
||||
m_length = new_size;
|
||||
if (!m_buffer)
|
||||
m_buffer = (char *)malloc(m_length);
|
||||
else
|
||||
m_buffer = (char *)realloc(m_buffer, m_length);
|
||||
|
||||
return (m_buffer != NULL);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxMemoryInputStream
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxMemoryInputStream::wxMemoryInputStream(const char *data, size_t len)
|
||||
: wxInputStream()
|
||||
{
|
||||
m_persistent = TRUE;
|
||||
m_length = len;
|
||||
m_buffer = (char *)data; // It's bad.
|
||||
m_position_i = 0;
|
||||
m_lastread = 0;
|
||||
m_eof = FALSE;
|
||||
m_iolimit = 1;
|
||||
|
||||
m_i_streambuf->SetBufferIO(0);
|
||||
m_i_streambuf->SetBufferIO((char *)data, data+len);
|
||||
m_i_streambuf->Fixed(TRUE);
|
||||
}
|
||||
|
||||
wxMemoryInputStream::~wxMemoryInputStream()
|
||||
@ -77,51 +40,7 @@ wxMemoryInputStream::~wxMemoryInputStream()
|
||||
|
||||
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 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;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
off_t wxMemoryInputStream::DoSeekInput(off_t pos, wxSeekMode mode)
|
||||
{
|
||||
if (m_iolimit == 2)
|
||||
return 0;
|
||||
|
||||
switch (mode) {
|
||||
case wxFromStart:
|
||||
if ((size_t)pos > m_length)
|
||||
return m_position_i;
|
||||
return (m_position_i = pos);
|
||||
|
||||
case wxFromCurrent:
|
||||
if ((size_t)(m_position_i+pos) > m_length)
|
||||
return m_position_i;
|
||||
|
||||
return (m_position_i += pos);
|
||||
|
||||
case wxFromEnd:
|
||||
if ((size_t)(m_length-pos) > m_length)
|
||||
return m_position_i;
|
||||
|
||||
return (m_position_i = m_length-pos);
|
||||
}
|
||||
|
||||
return m_position_i;
|
||||
return m_i_streambuf->GetBufferStart()[m_i_streambuf->GetIntPosition()];
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -129,82 +48,13 @@ off_t wxMemoryInputStream::DoSeekInput(off_t pos, wxSeekMode mode)
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxMemoryOutputStream::wxMemoryOutputStream(char *data, size_t len)
|
||||
: wxOutputStream()
|
||||
{
|
||||
m_persistent = FALSE;
|
||||
m_buffer = data;
|
||||
m_length = len;
|
||||
m_position_o = 0;
|
||||
m_lastwrite = 0;
|
||||
m_bad = FALSE;
|
||||
m_iolimit = 2;
|
||||
|
||||
m_o_streambuf->SetBufferIO(0);
|
||||
if (data)
|
||||
m_o_streambuf->SetBufferIO(data, data+len);
|
||||
m_o_streambuf->Fixed(TRUE);
|
||||
}
|
||||
|
||||
wxMemoryOutputStream::~wxMemoryOutputStream()
|
||||
{
|
||||
Sync();
|
||||
}
|
||||
|
||||
size_t wxMemoryOutputStream::DoWrite(const void *buffer, size_t size)
|
||||
{
|
||||
if (m_iolimit == 1) {
|
||||
m_bad = TRUE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (m_position_o+size > m_length)
|
||||
if (!ChangeBufferSize(m_position_o+size)) {
|
||||
m_bad = TRUE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
memcpy(m_buffer+m_position_o, buffer, size);
|
||||
m_position_o += size;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
off_t wxMemoryOutputStream::DoSeekOutput(off_t pos, wxSeekMode mode)
|
||||
{
|
||||
if (m_iolimit == 1)
|
||||
return 0;
|
||||
|
||||
switch (mode) {
|
||||
case wxFromStart:
|
||||
if ((size_t)pos > m_length)
|
||||
return m_position_o;
|
||||
return (m_position_o = pos);
|
||||
|
||||
case wxFromCurrent:
|
||||
if ((size_t)(m_position_o+pos) > m_length)
|
||||
return m_position_o;
|
||||
|
||||
return (m_position_o += pos);
|
||||
|
||||
case wxFromEnd:
|
||||
if ((size_t)(m_length-pos) > m_length)
|
||||
return m_position_o;
|
||||
|
||||
return (m_position_o = m_length-pos);
|
||||
}
|
||||
|
||||
return m_position_o;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxMemoryStream
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxMemoryStream::wxMemoryStream(char *data, size_t len)
|
||||
: wxMemoryInputStream(NULL, 0), wxMemoryOutputStream(NULL, 0)
|
||||
{
|
||||
m_persistent = FALSE;
|
||||
m_buffer = data;
|
||||
m_length = len;
|
||||
m_iolimit = 0;
|
||||
}
|
||||
|
||||
wxMemoryStream::~wxMemoryStream()
|
||||
{
|
||||
}
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "wx/listbox.h"
|
||||
#include "wx/choice.h"
|
||||
#include "wx/checkbox.h"
|
||||
#include "wx/settings.h"
|
||||
#include "wx/slider.h"
|
||||
#include "wx/statbox.h"
|
||||
#if wxUSE_GAUGE
|
||||
|
@ -92,7 +92,8 @@ wxConnectionBase *wxTCPClient::MakeConnection (const wxString& host,
|
||||
wxSocketHandler *hsock = &wxSocketHandler::Master();
|
||||
wxSocketClient *client = hsock->CreateClient();
|
||||
wxSocketStream *stream = new wxSocketStream(*client);
|
||||
wxDataStream data_s(*stream);
|
||||
wxDataInputStream data_is(*stream);
|
||||
wxDataOutputStream data_os(*stream);
|
||||
|
||||
client->SetNotify(wxSocketBase::REQ_READ | wxSocketBase::REQ_LOST);
|
||||
addr.Service(server_name);
|
||||
@ -107,10 +108,10 @@ wxConnectionBase *wxTCPClient::MakeConnection (const wxString& host,
|
||||
// Send topic name, and enquire whether this has succeeded
|
||||
unsigned char msg;
|
||||
|
||||
data_s.Write8(IPC_CONNECT);
|
||||
data_s.WriteString(topic);
|
||||
data_os.Write8(IPC_CONNECT);
|
||||
data_os.WriteString(topic);
|
||||
|
||||
msg = data_s.Read8();
|
||||
msg = data_is.Read8();
|
||||
|
||||
// OK! Confirmation.
|
||||
if (msg == IPC_CONNECT) {
|
||||
@ -183,14 +184,15 @@ wxConnectionBase *wxTCPServer::OnAcceptConnection( const wxString& WXUNUSED(topi
|
||||
|
||||
wxTCPConnection::wxTCPConnection (void)
|
||||
: wxConnectionBase(),
|
||||
m_sock(NULL), m_sockstrm(NULL), m_codec(NULL)
|
||||
m_sock(NULL), m_sockstrm(NULL), m_codeci(NULL), m_codeco(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
wxTCPConnection::~wxTCPConnection (void)
|
||||
{
|
||||
wxDELETE(m_sock);
|
||||
wxDELETE(m_codec);
|
||||
wxDELETE(m_codeci);
|
||||
wxDELETE(m_codeco);
|
||||
wxDELETE(m_sockstrm);
|
||||
}
|
||||
|
||||
@ -203,7 +205,7 @@ void wxTCPConnection::Compress(bool WXUNUSED(on))
|
||||
bool wxTCPConnection::Disconnect (void)
|
||||
{
|
||||
// Send the the disconnect message to the peer.
|
||||
m_codec->Write8(IPC_DISCONNECT);
|
||||
m_codeco->Write8(IPC_DISCONNECT);
|
||||
m_sock->Close();
|
||||
|
||||
return TRUE;
|
||||
@ -215,13 +217,13 @@ bool wxTCPConnection::Execute (char *data, int size, wxDataFormat format)
|
||||
return FALSE;
|
||||
|
||||
// Prepare EXECUTE message
|
||||
m_codec->Write8(IPC_EXECUTE);
|
||||
m_codec->Write8(format);
|
||||
m_codeco->Write8(IPC_EXECUTE);
|
||||
m_codeco->Write8(format);
|
||||
if (size < 0)
|
||||
m_codec->WriteString(data);
|
||||
m_codeco->WriteString(data);
|
||||
else {
|
||||
m_codec->Write32(size);
|
||||
m_codec->Write(data, size);
|
||||
m_codeco->Write32(size);
|
||||
m_codeco->Write(data, size);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@ -232,23 +234,23 @@ char *wxTCPConnection::Request (const wxString& item, int *size, wxDataFormat fo
|
||||
if (!m_sock->IsConnected())
|
||||
return NULL;
|
||||
|
||||
m_codec->Write8(IPC_REQUEST);
|
||||
m_codec->WriteString(item);
|
||||
m_codec->Write8(format);
|
||||
m_codeco->Write8(IPC_REQUEST);
|
||||
m_codeco->WriteString(item);
|
||||
m_codeco->Write8(format);
|
||||
|
||||
// If Unpack doesn't initialize it.
|
||||
int ret;
|
||||
|
||||
ret = m_codec->Read8();
|
||||
ret = m_codeci->Read8();
|
||||
if (ret == IPC_FAIL)
|
||||
return NULL;
|
||||
else {
|
||||
size_t s;
|
||||
char *data = NULL;
|
||||
|
||||
s = m_codec->Read32();
|
||||
s = m_codeci->Read32();
|
||||
data = new char[s];
|
||||
m_codec->Read(data, s);
|
||||
m_codeci->Read(data, s);
|
||||
|
||||
if (size)
|
||||
*size = s;
|
||||
@ -261,14 +263,14 @@ bool wxTCPConnection::Poke (const wxString& item, char *data, int size, wxDataFo
|
||||
if (!m_sock->IsConnected())
|
||||
return FALSE;
|
||||
|
||||
m_codec->Write8(IPC_POKE);
|
||||
m_codec->WriteString(item);
|
||||
m_codec->Write8(format);
|
||||
m_codeco->Write8(IPC_POKE);
|
||||
m_codeco->WriteString(item);
|
||||
m_codeco->Write8(format);
|
||||
if (size < 0)
|
||||
m_codec->WriteString(data);
|
||||
m_codeco->WriteString(data);
|
||||
else {
|
||||
m_codec->Write32(size);
|
||||
m_codec->Write(data, size);
|
||||
m_codeco->Write32(size);
|
||||
m_codeco->Write(data, size);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@ -281,10 +283,10 @@ bool wxTCPConnection::StartAdvise (const wxString& item)
|
||||
if (!m_sock->IsConnected())
|
||||
return FALSE;
|
||||
|
||||
m_codec->Write8(IPC_ADVISE_START);
|
||||
m_codec->WriteString(item);
|
||||
m_codeco->Write8(IPC_ADVISE_START);
|
||||
m_codeco->WriteString(item);
|
||||
|
||||
ret = m_codec->Read8();
|
||||
ret = m_codeci->Read8();
|
||||
|
||||
if (ret != IPC_FAIL)
|
||||
return TRUE;
|
||||
@ -299,10 +301,10 @@ bool wxTCPConnection::StopAdvise (const wxString& item)
|
||||
if (!m_sock->IsConnected())
|
||||
return FALSE;
|
||||
|
||||
m_codec->Write8(IPC_ADVISE_STOP);
|
||||
m_codec->WriteString(item);
|
||||
m_codeco->Write8(IPC_ADVISE_STOP);
|
||||
m_codeco->WriteString(item);
|
||||
|
||||
msg = m_codec->Read8();
|
||||
msg = m_codeci->Read8();
|
||||
|
||||
if (msg != IPC_FAIL)
|
||||
return TRUE;
|
||||
@ -317,14 +319,14 @@ bool wxTCPConnection::Advise (const wxString& item,
|
||||
if (!m_sock->IsConnected())
|
||||
return FALSE;
|
||||
|
||||
m_codec->Write8(IPC_ADVISE);
|
||||
m_codec->WriteString(item);
|
||||
m_codec->Write8(format);
|
||||
m_codeco->Write8(IPC_ADVISE);
|
||||
m_codeco->WriteString(item);
|
||||
m_codeco->Write8(format);
|
||||
if (size < 0)
|
||||
m_codec->WriteString(data);
|
||||
m_codeco->WriteString(data);
|
||||
else {
|
||||
m_codec->Write32(size);
|
||||
m_codec->Write(data, size);
|
||||
m_codeco->Write32(size);
|
||||
m_codeco->Write(data, size);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@ -335,7 +337,8 @@ void Client_OnRequest(wxSocketBase& sock, wxSocketBase::wxRequestEvent evt,
|
||||
{
|
||||
int msg = 0;
|
||||
wxTCPConnection *connection = (wxTCPConnection *)cdata;
|
||||
wxDataStream *codec;
|
||||
wxDataInputStream *codeci;
|
||||
wxDataOutputStream *codeco;
|
||||
wxString topic_name = connection->m_topic;
|
||||
wxString item;
|
||||
|
||||
@ -347,8 +350,9 @@ void Client_OnRequest(wxSocketBase& sock, wxSocketBase::wxRequestEvent evt,
|
||||
}
|
||||
|
||||
// Receive message number.
|
||||
codec = connection->m_codec;
|
||||
msg = codec->Read8();
|
||||
codeci = connection->m_codeci;
|
||||
codeco = connection->m_codeco;
|
||||
msg = codeci->Read8();
|
||||
|
||||
switch (msg) {
|
||||
case IPC_EXECUTE: {
|
||||
@ -356,10 +360,10 @@ void Client_OnRequest(wxSocketBase& sock, wxSocketBase::wxRequestEvent evt,
|
||||
size_t size;
|
||||
wxDataFormat format;
|
||||
|
||||
format = (wxDataFormat)codec->Read8();
|
||||
size = codec->Read32();
|
||||
format = (wxDataFormat)codeci->Read8();
|
||||
size = codeci->Read32();
|
||||
data = new char[size];
|
||||
codec->Read(data, size);
|
||||
codeci->Read(data, size);
|
||||
|
||||
connection->OnExecute (topic_name, data, size, format);
|
||||
|
||||
@ -371,11 +375,11 @@ void Client_OnRequest(wxSocketBase& sock, wxSocketBase::wxRequestEvent evt,
|
||||
size_t size;
|
||||
wxDataFormat format;
|
||||
|
||||
item = codec->ReadString();
|
||||
format = (wxDataFormat)codec->Read8();
|
||||
size = codec->Read32();
|
||||
item = codeci->ReadString();
|
||||
format = (wxDataFormat)codeci->Read8();
|
||||
size = codeci->Read32();
|
||||
data = new char[size];
|
||||
codec->Read(data, size);
|
||||
codeci->Read(data, size);
|
||||
|
||||
connection->OnAdvise (topic_name, item, data, size, format);
|
||||
|
||||
@ -383,24 +387,24 @@ void Client_OnRequest(wxSocketBase& sock, wxSocketBase::wxRequestEvent evt,
|
||||
break;
|
||||
}
|
||||
case IPC_ADVISE_START: {
|
||||
item = codec->ReadString();
|
||||
item = codeci->ReadString();
|
||||
|
||||
bool ok = connection->OnStartAdvise (topic_name, item);
|
||||
if (ok)
|
||||
codec->Write8(IPC_ADVISE_START);
|
||||
codeco->Write8(IPC_ADVISE_START);
|
||||
else
|
||||
codec->Write8(IPC_FAIL);
|
||||
codeco->Write8(IPC_FAIL);
|
||||
|
||||
break;
|
||||
}
|
||||
case IPC_ADVISE_STOP: {
|
||||
item = codec->ReadString();
|
||||
item = codeci->ReadString();
|
||||
|
||||
bool ok = connection->OnStopAdvise (topic_name, item);
|
||||
if (ok)
|
||||
codec->Write8(IPC_ADVISE_STOP);
|
||||
codeco->Write8(IPC_ADVISE_STOP);
|
||||
else
|
||||
codec->Write8(IPC_FAIL);
|
||||
codeco->Write8(IPC_FAIL);
|
||||
|
||||
break;
|
||||
}
|
||||
@ -409,11 +413,11 @@ void Client_OnRequest(wxSocketBase& sock, wxSocketBase::wxRequestEvent evt,
|
||||
size_t size;
|
||||
char *data;
|
||||
|
||||
item = codec->ReadString();
|
||||
format = (wxDataFormat)codec->Read8();
|
||||
size = codec->Read32();
|
||||
item = codeci->ReadString();
|
||||
format = (wxDataFormat)codeci->Read8();
|
||||
size = codeci->Read32();
|
||||
data = new char[size];
|
||||
codec->Read(data, size);
|
||||
codeci->Read(data, size);
|
||||
|
||||
connection->OnPoke (topic_name, item, data, size, format);
|
||||
|
||||
@ -424,21 +428,21 @@ void Client_OnRequest(wxSocketBase& sock, wxSocketBase::wxRequestEvent evt,
|
||||
case IPC_REQUEST: {
|
||||
wxDataFormat format;
|
||||
|
||||
item = codec->ReadString();
|
||||
format = (wxDataFormat)codec->Read8();
|
||||
item = codeci->ReadString();
|
||||
format = (wxDataFormat)codeci->Read8();
|
||||
|
||||
int user_size = -1;
|
||||
char *user_data = connection->OnRequest (topic_name, item, &user_size, format);
|
||||
|
||||
if (user_data) {
|
||||
codec->Write8(IPC_REQUEST_REPLY);
|
||||
codeco->Write8(IPC_REQUEST_REPLY);
|
||||
if (user_size != -1) {
|
||||
codec->Write32(user_size);
|
||||
codec->Write(user_data, user_size);
|
||||
codeco->Write32(user_size);
|
||||
codeco->Write(user_data, user_size);
|
||||
} else
|
||||
codec->WriteString(user_data);
|
||||
codeco->WriteString(user_data);
|
||||
} else
|
||||
codec->Write8(IPC_FAIL);
|
||||
codeco->Write8(IPC_FAIL);
|
||||
|
||||
break;
|
||||
}
|
||||
@ -448,7 +452,7 @@ void Client_OnRequest(wxSocketBase& sock, wxSocketBase::wxRequestEvent evt,
|
||||
break;
|
||||
}
|
||||
default:
|
||||
codec->Write8(IPC_FAIL);
|
||||
codeco->Write8(IPC_FAIL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -458,7 +462,8 @@ void Server_OnRequest(wxSocketServer& server,
|
||||
{
|
||||
wxTCPServer *ipcserv = (wxTCPServer *)cdata;
|
||||
wxSocketStream *stream;
|
||||
wxDataStream *codec;
|
||||
wxDataInputStream *codeci;
|
||||
wxDataOutputStream *codeco;
|
||||
|
||||
if (evt != wxSocketBase::EVT_ACCEPT)
|
||||
return;
|
||||
@ -469,17 +474,18 @@ void Server_OnRequest(wxSocketServer& server,
|
||||
sock->SetNotify(wxSocketBase::REQ_READ | wxSocketBase::REQ_LOST);
|
||||
|
||||
stream = new wxSocketStream(*sock);
|
||||
codec = new wxDataStream(*stream);
|
||||
codeci = new wxDataInputStream(*stream);
|
||||
codeco = new wxDataOutputStream(*stream);
|
||||
|
||||
if (!sock->Ok())
|
||||
return;
|
||||
|
||||
int msg;
|
||||
msg = codec->Read8();
|
||||
msg = codeci->Read8();
|
||||
|
||||
if (msg == IPC_CONNECT) {
|
||||
wxString topic_name;
|
||||
topic_name = codec->ReadString();
|
||||
topic_name = codeci->ReadString();
|
||||
|
||||
/* Register new socket with the notifier */
|
||||
wxTCPConnection *new_connection =
|
||||
@ -487,21 +493,22 @@ void Server_OnRequest(wxSocketServer& server,
|
||||
if (new_connection) {
|
||||
if (!new_connection->IsKindOf(CLASSINFO(wxTCPConnection))) {
|
||||
delete new_connection;
|
||||
codec->Write8(IPC_FAIL);
|
||||
codeco->Write8(IPC_FAIL);
|
||||
return;
|
||||
}
|
||||
// Acknowledge success
|
||||
codec->Write8(IPC_CONNECT);
|
||||
codeco->Write8(IPC_CONNECT);
|
||||
|
||||
new_connection->m_topic = topic_name;
|
||||
new_connection->m_sockstrm = stream;
|
||||
new_connection->m_codec = codec;
|
||||
new_connection->m_codeci = codeci;
|
||||
new_connection->m_codeco = codeco;
|
||||
sock->Callback(Client_OnRequest);
|
||||
sock->CallbackData((char *)new_connection);
|
||||
sock->Notify(TRUE);
|
||||
} else {
|
||||
// Send failure message
|
||||
codec->Write8(IPC_FAIL);
|
||||
codeco->Write8(IPC_FAIL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ wxSocketOutputStream::~wxSocketOutputStream()
|
||||
|
||||
wxOutputStream& wxSocketOutputStream::Write(const void *buffer, size_t size)
|
||||
{
|
||||
m_o_socket->Write((const char *)buffer, size);
|
||||
m_lastcount = m_o_socket->Write((const char *)buffer, size).LastCount();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -60,19 +60,19 @@ wxSocketInputStream::~wxSocketInputStream()
|
||||
|
||||
wxInputStream& wxSocketInputStream::Read(void *buffer, size_t size)
|
||||
{
|
||||
m_i_socket->Read((char *)buffer, size);
|
||||
m_lastcount = m_i_socket->Read((char *)buffer, size).LastCount();
|
||||
return *this;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// wxSocketStream (IO)
|
||||
// wxSocketStream
|
||||
// ---------------------------------------------------------------------------
|
||||
wxSocketStream::wxSocketStream(wxSocketBase& i_s, wxSocketBase& o_s)
|
||||
: wxSocketInputStream(i_s), wxSocketOutputStream(o_s)
|
||||
{
|
||||
}
|
||||
|
||||
wxSocketStream::wxSocketStream(wxSocketBase& s)
|
||||
: wxSocketInputStream(s), wxSocketOutputStream(s)
|
||||
{
|
||||
}
|
||||
|
||||
wxSocketStream::~wxSocketStream()
|
||||
{
|
||||
}
|
||||
|
@ -1246,9 +1246,9 @@ bool wxSocketClient::Connect(wxSockAddress& addr_man, bool WXUNUSED(wait) )
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxSocketClient::WaitOnConnect(long seconds)
|
||||
bool wxSocketClient::WaitOnConnect(long seconds, long microseconds)
|
||||
{
|
||||
int ret = _Wait(seconds, 0, REQ_CONNECT | REQ_LOST);
|
||||
int ret = _Wait(seconds, microseconds, REQ_CONNECT | REQ_LOST);
|
||||
|
||||
if (ret)
|
||||
m_connected = TRUE;
|
||||
|
@ -28,15 +28,9 @@
|
||||
// wxStreamBuffer
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxStreamBuffer::wxStreamBuffer(wxInputStream& i_stream)
|
||||
wxStreamBuffer::wxStreamBuffer(wxStreamBase& stream, BufMode mode)
|
||||
: m_buffer_start(NULL), m_buffer_end(NULL), m_buffer_pos(NULL),
|
||||
m_buffer_size(0), m_istream(&i_stream), m_ostream(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
wxStreamBuffer::wxStreamBuffer(wxOutputStream& o_stream)
|
||||
: m_buffer_start(NULL), m_buffer_end(NULL), m_buffer_pos(NULL),
|
||||
m_buffer_size(0), m_istream(NULL), m_ostream(&o_stream)
|
||||
m_buffer_size(0), m_stream(&stream), m_mode(mode)
|
||||
{
|
||||
}
|
||||
|
||||
@ -45,34 +39,37 @@ wxStreamBuffer::~wxStreamBuffer()
|
||||
wxDELETEA(m_buffer_start);
|
||||
}
|
||||
|
||||
void wxStreamBuffer::WriteBack(char c)
|
||||
bool wxStreamBuffer::WriteBack(const char *buf, size_t bufsize)
|
||||
{
|
||||
if (m_ostream)
|
||||
return;
|
||||
char *ptrback;
|
||||
|
||||
// Assume that if we write "back" we have read a few bytes: so we have some
|
||||
// space.
|
||||
if (m_buffer_pos == m_buffer_start)
|
||||
return;
|
||||
ptrback = AllocSpaceWBack(bufsize);
|
||||
if (!ptrback)
|
||||
return FALSE;
|
||||
|
||||
m_buffer_pos--;
|
||||
*m_buffer_pos = c;
|
||||
memcpy(ptrback, buf, bufsize);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxStreamBuffer::WriteBack(char c)
|
||||
{
|
||||
char *ptrback;
|
||||
|
||||
ptrback = AllocSpaceWBack(1);
|
||||
if (!ptrback)
|
||||
return FALSE;
|
||||
|
||||
*ptrback = c;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxStreamBuffer::SetBufferIO(char *buffer_start, char *buffer_end)
|
||||
{
|
||||
size_t ret;
|
||||
|
||||
m_buffer_start = buffer_start;
|
||||
m_buffer_end = buffer_end;
|
||||
|
||||
m_buffer_size = m_buffer_end-m_buffer_start;
|
||||
|
||||
if (m_istream) {
|
||||
ret = m_istream->DoRead(m_buffer_start, m_buffer_size);
|
||||
m_buffer_end = m_buffer_start + ret;
|
||||
}
|
||||
m_buffer_pos = m_buffer_start;
|
||||
ResetBuffer();
|
||||
}
|
||||
|
||||
void wxStreamBuffer::SetBufferIO(size_t bufsize)
|
||||
@ -96,22 +93,121 @@ void wxStreamBuffer::SetBufferIO(size_t bufsize)
|
||||
|
||||
void wxStreamBuffer::ResetBuffer()
|
||||
{
|
||||
if (m_istream)
|
||||
if (m_mode == read)
|
||||
m_buffer_pos = m_buffer_end;
|
||||
else
|
||||
m_buffer_pos = m_buffer_start;
|
||||
}
|
||||
|
||||
char *wxStreamBuffer::AllocSpaceWBack(size_t needed_size)
|
||||
{
|
||||
char *temp_b;
|
||||
|
||||
m_wbacksize += needed_size;
|
||||
|
||||
if (!m_wback)
|
||||
temp_b = (char *)malloc(m_wbacksize);
|
||||
else
|
||||
temp_b = (char *)realloc(m_wback, m_wbacksize);
|
||||
|
||||
if (!temp_b)
|
||||
return NULL;
|
||||
return (char *)((size_t)m_wback+(m_wbacksize-needed_size));
|
||||
}
|
||||
|
||||
size_t wxStreamBuffer::GetWBack(char *buf, size_t bsize)
|
||||
{
|
||||
size_t s_toget = m_wbacksize-m_wbackcur;
|
||||
|
||||
if (bsize < s_toget)
|
||||
s_toget = bsize;
|
||||
|
||||
memcpy(buf, (m_wback+m_wbackcur), s_toget);
|
||||
|
||||
m_wbackcur += s_toget;
|
||||
if (m_wbackcur == m_wbacksize) {
|
||||
free(m_wback);
|
||||
m_wback = (char *)NULL;
|
||||
m_wbacksize = 0;
|
||||
m_wbackcur = 0;
|
||||
}
|
||||
|
||||
return s_toget;
|
||||
}
|
||||
|
||||
bool wxStreamBuffer::FillBuffer()
|
||||
{
|
||||
size_t count;
|
||||
|
||||
count = m_stream->OnSysRead(m_buffer_start, m_buffer_size);
|
||||
m_buffer_end = m_buffer_start+count;
|
||||
m_buffer_pos = m_buffer_start;
|
||||
|
||||
if (count == 0)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxStreamBuffer::FlushBuffer()
|
||||
{
|
||||
size_t count, current;
|
||||
|
||||
if (m_buffer_pos == m_buffer_start)
|
||||
return FALSE;
|
||||
|
||||
current = m_buffer_pos-m_buffer_start;
|
||||
count = m_stream->OnSysWrite(m_buffer_start, current);
|
||||
if (count != current)
|
||||
return FALSE;
|
||||
m_buffer_pos = m_buffer_start;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxStreamBuffer::GetFromBuffer(void *buffer, size_t size)
|
||||
{
|
||||
size_t s_toget = m_buffer_end-m_buffer_pos;
|
||||
|
||||
if (size < s_toget)
|
||||
s_toget = size;
|
||||
|
||||
memcpy(buffer, m_buffer_pos, s_toget);
|
||||
m_buffer_pos += s_toget;
|
||||
}
|
||||
|
||||
void wxStreamBuffer::PutToBuffer(const void *buffer, size_t size)
|
||||
{
|
||||
size_t s_toput = m_buffer_end-m_buffer_pos;
|
||||
|
||||
if (s_toput < size && !m_fixed) {
|
||||
m_buffer_start = (char *)realloc(m_buffer_start, m_buffer_size+size);
|
||||
// I round a bit
|
||||
m_buffer_end = m_buffer_start+m_buffer_size;
|
||||
s_toput = size;
|
||||
}
|
||||
if (s_toput > size)
|
||||
s_toput = size;
|
||||
memcpy(m_buffer_pos, buffer, s_toput);
|
||||
m_buffer_pos += s_toput;
|
||||
}
|
||||
|
||||
void wxStreamBuffer::Read(void *buffer, size_t size)
|
||||
{
|
||||
wxASSERT(m_istream != NULL);
|
||||
wxASSERT(m_stream != NULL);
|
||||
|
||||
// ------------------
|
||||
// Buffering disabled
|
||||
// ------------------
|
||||
|
||||
m_stream->m_lastcount = GetWBack((char *)buffer, size);
|
||||
size -= m_stream->m_lastcount;
|
||||
if (size == 0)
|
||||
return;
|
||||
|
||||
buffer = (void *)((char *)buffer+m_stream->m_lastcount);
|
||||
|
||||
if (!m_buffer_size) {
|
||||
m_istream->m_lastread = m_istream->DoRead(buffer, size);
|
||||
m_stream->m_lastcount += m_stream->OnSysRead(buffer, size);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -119,51 +215,41 @@ void wxStreamBuffer::Read(void *buffer, size_t size)
|
||||
// Buffering enabled
|
||||
// -----------------
|
||||
size_t buf_left, orig_size = size;
|
||||
size_t read_ret;
|
||||
|
||||
while (size > 0) {
|
||||
buf_left = m_buffer_end - m_buffer_pos;
|
||||
buf_left = GetDataLeft();
|
||||
|
||||
// First case: the requested buffer is larger than the stream buffer,
|
||||
// we split
|
||||
if (size > buf_left) {
|
||||
memcpy(buffer, m_buffer_pos, buf_left);
|
||||
GetFromBuffer(buffer, buf_left);
|
||||
size -= buf_left;
|
||||
buffer = (char *)buffer + buf_left; // ANSI C++ violation.
|
||||
|
||||
read_ret = m_istream->DoRead(m_buffer_start, m_buffer_size);
|
||||
|
||||
// Read failed: EOF
|
||||
if (read_ret == 0) {
|
||||
m_istream->m_lastread = orig_size-size;
|
||||
m_istream->m_eof = TRUE;
|
||||
m_buffer_pos = m_buffer_end = m_buffer_start;
|
||||
if (!FillBuffer()) {
|
||||
m_stream->m_lastcount = orig_size-size;
|
||||
return;
|
||||
} else {
|
||||
m_buffer_end = m_buffer_start+read_ret;
|
||||
m_buffer_pos = m_buffer_start;
|
||||
}
|
||||
} else {
|
||||
|
||||
// Second case: we just copy from the stream buffer.
|
||||
memcpy(buffer, m_buffer_pos, size);
|
||||
m_buffer_pos += size;
|
||||
GetFromBuffer(buffer, size);
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_istream->m_lastread = orig_size;
|
||||
m_stream->m_lastcount += orig_size;
|
||||
}
|
||||
|
||||
void wxStreamBuffer::Write(const void *buffer, size_t size)
|
||||
{
|
||||
wxASSERT(m_ostream != NULL);
|
||||
wxASSERT(m_stream != NULL);
|
||||
|
||||
// ------------------
|
||||
// Buffering disabled
|
||||
// ------------------
|
||||
|
||||
if (!m_buffer_size) {
|
||||
m_ostream->m_lastwrite = m_ostream->DoWrite(buffer, size);
|
||||
m_stream->m_lastcount = m_stream->OnSysWrite(buffer, size);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -172,7 +258,6 @@ void wxStreamBuffer::Write(const void *buffer, size_t size)
|
||||
// ------------------
|
||||
|
||||
size_t buf_left, orig_size = size;
|
||||
size_t write_ret;
|
||||
|
||||
while (size > 0) {
|
||||
buf_left = m_buffer_end - m_buffer_pos;
|
||||
@ -180,15 +265,12 @@ void wxStreamBuffer::Write(const void *buffer, size_t size)
|
||||
// First case: the buffer to write is larger than the stream buffer,
|
||||
// we split it
|
||||
if (size > buf_left) {
|
||||
memcpy(m_buffer_pos, buffer, buf_left);
|
||||
PutToBuffer(buffer, buf_left);
|
||||
size -= buf_left;
|
||||
buffer = (char *)buffer + buf_left; // ANSI C++ violation.
|
||||
|
||||
write_ret = m_ostream->DoWrite(m_buffer_start, m_buffer_size);
|
||||
if (write_ret != m_buffer_size) {
|
||||
m_ostream->m_bad = TRUE;
|
||||
m_ostream->m_lastwrite = orig_size-size;
|
||||
m_buffer_pos = m_buffer_end = m_buffer_start;
|
||||
if (!FlushBuffer()) {
|
||||
m_stream->m_lastcount = orig_size-size;
|
||||
return;
|
||||
}
|
||||
m_buffer_pos = m_buffer_start;
|
||||
@ -196,13 +278,95 @@ void wxStreamBuffer::Write(const void *buffer, size_t size)
|
||||
} else {
|
||||
|
||||
// Second case: just copy it in the stream buffer.
|
||||
|
||||
memcpy(m_buffer_pos, buffer, size);
|
||||
m_buffer_pos += size;
|
||||
PutToBuffer(buffer, size);
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_ostream->m_lastwrite = orig_size;
|
||||
m_stream->m_lastcount = orig_size;
|
||||
}
|
||||
|
||||
off_t wxStreamBuffer::Seek(off_t pos, wxSeekMode mode)
|
||||
{
|
||||
off_t ret_off, diff, last_access;
|
||||
|
||||
last_access = GetLastAccess();
|
||||
|
||||
switch (mode) {
|
||||
case wxFromStart: {
|
||||
// We'll try to compute an internal position later ...
|
||||
ret_off = m_stream->OnSysSeek(pos, wxFromStart);
|
||||
ResetBuffer();
|
||||
return ret_off;
|
||||
}
|
||||
case wxFromCurrent: {
|
||||
diff = pos + GetIntPosition();
|
||||
|
||||
if ( (diff > last_access) || (diff < 0) ) {
|
||||
ret_off = m_stream->OnSysSeek(pos, wxFromCurrent);
|
||||
ResetBuffer();
|
||||
return ret_off;
|
||||
} else {
|
||||
SetIntPosition(diff);
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
case wxFromEnd:
|
||||
// Hard to compute: always seek to the requested position.
|
||||
ret_off = m_stream->OnSysSeek(pos, wxFromEnd);
|
||||
ResetBuffer();
|
||||
return ret_off;
|
||||
}
|
||||
return wxInvalidOffset;
|
||||
}
|
||||
|
||||
off_t wxStreamBuffer::Tell() const
|
||||
{
|
||||
off_t pos;
|
||||
|
||||
pos = m_stream->OnSysTell();
|
||||
if (pos == wxInvalidOffset)
|
||||
return wxInvalidOffset;
|
||||
|
||||
return pos - GetLastAccess() + GetIntPosition();
|
||||
}
|
||||
|
||||
size_t wxStreamBuffer::GetDataLeft() const
|
||||
{
|
||||
return m_buffer_end-m_buffer_pos;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStreamBase
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxStreamBase::wxStreamBase()
|
||||
{
|
||||
m_lasterror = wxStream_NOERROR;
|
||||
m_lastcount = 0;
|
||||
}
|
||||
|
||||
wxStreamBase::~wxStreamBase()
|
||||
{
|
||||
}
|
||||
|
||||
size_t wxStreamBase::OnSysRead(void *buffer, size_t size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t wxStreamBase::OnSysWrite(const void *buffer, size_t bufsize)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
off_t wxStreamBase::OnSysSeek(off_t seek, wxSeekMode mode)
|
||||
{
|
||||
return wxInvalidOffset;
|
||||
}
|
||||
|
||||
off_t wxStreamBase::OnSysTell()
|
||||
{
|
||||
return wxInvalidOffset;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -210,19 +374,17 @@ void wxStreamBuffer::Write(const void *buffer, size_t size)
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxInputStream::wxInputStream()
|
||||
: wxStreamBase()
|
||||
{
|
||||
m_i_destroybuf = TRUE;
|
||||
m_i_streambuf = new wxStreamBuffer(*this);
|
||||
m_eof = FALSE;
|
||||
m_lastread = 0;
|
||||
m_i_streambuf = new wxStreamBuffer(*this, wxStreamBuffer::read);
|
||||
}
|
||||
|
||||
wxInputStream::wxInputStream(wxStreamBuffer *buffer)
|
||||
: wxStreamBase()
|
||||
{
|
||||
m_i_destroybuf = FALSE;
|
||||
m_i_streambuf = buffer;
|
||||
m_eof = FALSE;
|
||||
m_lastread = 0;
|
||||
}
|
||||
|
||||
wxInputStream::~wxInputStream()
|
||||
@ -245,6 +407,14 @@ wxInputStream& wxInputStream::Read(void *buffer, size_t size)
|
||||
return *this;
|
||||
}
|
||||
|
||||
char wxInputStream::Peek()
|
||||
{
|
||||
if (!m_i_streambuf->GetDataLeft())
|
||||
m_i_streambuf->FillBuffer();
|
||||
|
||||
return *(m_i_streambuf->GetBufferPos());
|
||||
}
|
||||
|
||||
#define BUF_TEMP_SIZE 10000
|
||||
|
||||
wxInputStream& wxInputStream::Read(wxOutputStream& stream_out)
|
||||
@ -252,7 +422,7 @@ wxInputStream& wxInputStream::Read(wxOutputStream& stream_out)
|
||||
char buf[BUF_TEMP_SIZE];
|
||||
size_t bytes_read = BUF_TEMP_SIZE;
|
||||
|
||||
while (bytes_read == BUF_TEMP_SIZE && !stream_out.Bad()) {
|
||||
while (bytes_read == BUF_TEMP_SIZE && stream_out.LastError() != wxStream_NOERROR) {
|
||||
bytes_read = Read(buf, bytes_read).LastRead();
|
||||
|
||||
stream_out.Write(buf, bytes_read);
|
||||
@ -260,6 +430,20 @@ wxInputStream& wxInputStream::Read(wxOutputStream& stream_out)
|
||||
return *this;
|
||||
}
|
||||
|
||||
off_t wxInputStream::SeekI(off_t pos, wxSeekMode mode)
|
||||
{
|
||||
return m_i_streambuf->Seek(pos, mode);
|
||||
}
|
||||
|
||||
off_t wxInputStream::TellI() const
|
||||
{
|
||||
return m_i_streambuf->Tell();
|
||||
}
|
||||
|
||||
// --------------------
|
||||
// Overloaded operators
|
||||
// --------------------
|
||||
|
||||
wxInputStream& wxInputStream::operator>>(wxString& line)
|
||||
{
|
||||
wxDataInputStream s(*this);
|
||||
@ -322,7 +506,7 @@ wxInputStream& wxInputStream::operator>>(long& i)
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxInputStream& wxInputStream::operator>>(float& f)
|
||||
wxInputStream& wxInputStream::operator>>(double& f)
|
||||
{
|
||||
/* I only implemented a simple float parser */
|
||||
int c, sign;
|
||||
@ -343,16 +527,16 @@ wxInputStream& wxInputStream::operator>>(float& f)
|
||||
sign = 1;
|
||||
|
||||
while (isdigit(c)) {
|
||||
f = f*10 + c;
|
||||
f = f*10 + (c - '0');
|
||||
c = GetC();
|
||||
}
|
||||
|
||||
if (c == '.') {
|
||||
float f_multiplicator = (float) 0.1;
|
||||
double f_multiplicator = (double) 0.1;
|
||||
c = GetC();
|
||||
|
||||
while (isdigit(c)) {
|
||||
f += c*f_multiplicator;
|
||||
f += (c-'0')*f_multiplicator;
|
||||
f_multiplicator /= 10;
|
||||
c = GetC();
|
||||
}
|
||||
@ -372,66 +556,22 @@ wxInputStream& wxInputStream::operator>>(wxObject *& obj)
|
||||
}
|
||||
#endif
|
||||
|
||||
off_t wxInputStream::SeekI(off_t pos, wxSeekMode mode)
|
||||
{
|
||||
off_t ret_off, diff, last_access;
|
||||
|
||||
last_access = m_i_streambuf->GetLastAccess();
|
||||
|
||||
switch (mode) {
|
||||
case wxFromStart:
|
||||
diff = DoTellInput() - pos;
|
||||
if ( diff < 0 || diff > last_access ) {
|
||||
ret_off = DoSeekInput(pos, wxFromStart);
|
||||
m_i_streambuf->ResetBuffer();
|
||||
return ret_off;
|
||||
} else {
|
||||
m_i_streambuf->SetIntPosition(last_access - diff);
|
||||
return pos;
|
||||
}
|
||||
case wxFromCurrent:
|
||||
diff = pos + m_i_streambuf->GetIntPosition();
|
||||
|
||||
if ( (diff > last_access) || (diff < 0) ) {
|
||||
ret_off = DoSeekInput(pos, wxFromCurrent);
|
||||
m_i_streambuf->ResetBuffer();
|
||||
return ret_off;
|
||||
} else {
|
||||
m_i_streambuf->SetIntPosition(diff);
|
||||
return pos;
|
||||
}
|
||||
case wxFromEnd:
|
||||
// Hard to compute: always seek to the requested position.
|
||||
ret_off = DoSeekInput(pos, wxFromEnd);
|
||||
m_i_streambuf->ResetBuffer();
|
||||
return ret_off;
|
||||
}
|
||||
return wxInvalidOffset;
|
||||
}
|
||||
|
||||
off_t wxInputStream::TellI() const
|
||||
{
|
||||
return DoTellInput() - m_i_streambuf->GetLastAccess() +
|
||||
m_i_streambuf->GetIntPosition();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxOutputStream
|
||||
// ----------------------------------------------------------------------------
|
||||
wxOutputStream::wxOutputStream()
|
||||
: wxStreamBase()
|
||||
{
|
||||
m_o_destroybuf = TRUE;
|
||||
m_o_streambuf = new wxStreamBuffer(*this);
|
||||
m_bad = FALSE;
|
||||
m_lastwrite = 0;
|
||||
m_o_streambuf = new wxStreamBuffer(*this, wxStreamBuffer::write);
|
||||
}
|
||||
|
||||
wxOutputStream::wxOutputStream(wxStreamBuffer *buffer)
|
||||
: wxStreamBase()
|
||||
{
|
||||
m_o_destroybuf = FALSE;
|
||||
m_o_streambuf = buffer;
|
||||
m_bad = FALSE;
|
||||
m_lastwrite = 0;
|
||||
}
|
||||
|
||||
wxOutputStream::~wxOutputStream()
|
||||
@ -452,49 +592,19 @@ wxOutputStream& wxOutputStream::Write(wxInputStream& stream_in)
|
||||
return *this;
|
||||
}
|
||||
|
||||
off_t wxOutputStream::SeekO(off_t pos, wxSeekMode mode)
|
||||
{
|
||||
off_t ret_off;
|
||||
|
||||
switch (mode) {
|
||||
case wxFromStart:
|
||||
if ( (unsigned)abs (DoTellOutput()-pos) > m_o_streambuf->GetLastAccess() ) {
|
||||
ret_off = DoSeekOutput(pos, wxFromStart);
|
||||
m_o_streambuf->ResetBuffer();
|
||||
return ret_off;
|
||||
} else {
|
||||
m_o_streambuf->SetIntPosition( DoTellOutput() - pos);
|
||||
return pos;
|
||||
}
|
||||
case wxFromCurrent:
|
||||
if ( ((unsigned)pos > m_o_streambuf->GetLastAccess()) || (pos < 0) ) {
|
||||
ret_off = DoSeekOutput(pos, wxFromCurrent);
|
||||
m_o_streambuf->ResetBuffer();
|
||||
return ret_off;
|
||||
} else {
|
||||
m_o_streambuf->SetIntPosition(pos);
|
||||
return pos;
|
||||
}
|
||||
case wxFromEnd:
|
||||
// Hard to compute: always seek to the requested position.
|
||||
ret_off = DoSeekOutput(pos, wxFromEnd);
|
||||
m_o_streambuf->ResetBuffer();
|
||||
return ret_off;
|
||||
}
|
||||
return wxInvalidOffset;
|
||||
}
|
||||
|
||||
off_t wxOutputStream::TellO() const
|
||||
{
|
||||
return DoTellOutput() - m_o_streambuf->GetLastAccess()
|
||||
+ m_o_streambuf->GetIntPosition();
|
||||
return m_o_streambuf->Tell();
|
||||
}
|
||||
|
||||
off_t wxOutputStream::SeekO(off_t pos, wxSeekMode mode)
|
||||
{
|
||||
return m_o_streambuf->Seek(pos, mode);
|
||||
}
|
||||
|
||||
void wxOutputStream::Sync()
|
||||
{
|
||||
DoWrite(m_o_streambuf->GetBufferStart(), m_o_streambuf->GetIntPosition());
|
||||
|
||||
m_o_streambuf->ResetBuffer();
|
||||
m_o_streambuf->FlushBuffer();
|
||||
}
|
||||
|
||||
wxOutputStream& wxOutputStream::operator<<(const char *string)
|
||||
@ -553,51 +663,25 @@ wxOutputStream& wxOutputStream::operator<<(wxObject& obj)
|
||||
}
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStream
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxStream::wxStream()
|
||||
: wxInputStream(), wxOutputStream()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFilterInputStream
|
||||
// ----------------------------------------------------------------------------
|
||||
wxFilterInputStream::wxFilterInputStream()
|
||||
: wxInputStream(NULL)
|
||||
{
|
||||
// WARNING streambuf set to NULL !
|
||||
}
|
||||
|
||||
wxFilterInputStream::wxFilterInputStream(wxInputStream& stream)
|
||||
: wxInputStream(NULL)
|
||||
: wxInputStream(stream.InputStreamBuffer())
|
||||
{
|
||||
m_parent_i_stream = &stream;
|
||||
wxDELETE(m_i_streambuf); // In case m_i_streambuf has been initialized.
|
||||
m_i_destroybuf = FALSE;
|
||||
m_i_streambuf = stream.InputStreamBuffer();
|
||||
}
|
||||
|
||||
wxFilterInputStream::~wxFilterInputStream()
|
||||
{
|
||||
}
|
||||
|
||||
size_t wxFilterInputStream::DoRead(void *buffer, size_t size)
|
||||
{
|
||||
return m_parent_i_stream->Read(buffer, size).LastRead();
|
||||
}
|
||||
|
||||
off_t wxFilterInputStream::DoSeekInput(off_t pos, wxSeekMode mode)
|
||||
{
|
||||
return m_parent_i_stream->SeekI(pos, mode);
|
||||
}
|
||||
|
||||
off_t wxFilterInputStream::DoTellInput() const
|
||||
{
|
||||
return m_parent_i_stream->TellI();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFilterOutputStream
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -607,46 +691,15 @@ wxFilterOutputStream::wxFilterOutputStream()
|
||||
}
|
||||
|
||||
wxFilterOutputStream::wxFilterOutputStream(wxOutputStream& stream)
|
||||
: wxOutputStream(NULL)
|
||||
: wxOutputStream(stream.OutputStreamBuffer())
|
||||
{
|
||||
m_parent_o_stream = &stream;
|
||||
wxDELETE(m_o_streambuf); // In case m_o_streambuf has been initialized.
|
||||
m_o_destroybuf = FALSE;
|
||||
m_o_streambuf = stream.OutputStreamBuffer();
|
||||
}
|
||||
|
||||
wxFilterOutputStream::~wxFilterOutputStream()
|
||||
{
|
||||
}
|
||||
|
||||
size_t wxFilterOutputStream::DoWrite(const void *buffer, size_t size)
|
||||
{
|
||||
return m_parent_o_stream->Write(buffer, size).LastWrite();
|
||||
}
|
||||
|
||||
off_t wxFilterOutputStream::DoSeekOutput(off_t pos, wxSeekMode mode)
|
||||
{
|
||||
return m_parent_o_stream->SeekO(pos, mode);
|
||||
}
|
||||
|
||||
off_t wxFilterOutputStream::DoTellOutput() const
|
||||
{
|
||||
return m_parent_o_stream->TellO();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFilterStream
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxFilterStream::wxFilterStream()
|
||||
{
|
||||
}
|
||||
|
||||
wxFilterStream::wxFilterStream(wxStream& stream)
|
||||
: wxFilterInputStream(stream), wxFilterOutputStream(stream)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Some IOManip function
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -29,6 +29,7 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include "wx/stream.h"
|
||||
#include "wx/string.h"
|
||||
#include "wx/variant.h"
|
||||
|
||||
@ -294,7 +295,9 @@ public:
|
||||
virtual bool Eq(wxVariantData& data) const;
|
||||
virtual bool Write(ostream& str) const;
|
||||
virtual bool Write(wxString& str) const;
|
||||
virtual bool Write(wxOutputStream &str) const;
|
||||
virtual bool Read(istream& str);
|
||||
virtual bool Read(wxInputStream& str);
|
||||
virtual bool Read(wxString& str);
|
||||
virtual wxString GetType() const { return "long"; };
|
||||
|
||||
@ -330,6 +333,12 @@ bool wxVariantDataLong::Write(ostream& str) const
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxVariantDataLong::Write(wxOutputStream& str) const
|
||||
{
|
||||
str << m_value;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxVariantDataLong::Write(wxString& str) const
|
||||
{
|
||||
str.Printf("%ld", m_value);
|
||||
@ -342,6 +351,12 @@ bool wxVariantDataLong::Read(istream& str)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxVariantDataLong::Read(wxInputStream& str)
|
||||
{
|
||||
str >> m_value;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxVariantDataLong::Read(wxString& str)
|
||||
{
|
||||
m_value = atol((const char*) str);
|
||||
@ -366,7 +381,9 @@ public:
|
||||
virtual bool Eq(wxVariantData& data) const;
|
||||
virtual bool Write(ostream& str) const;
|
||||
virtual bool Write(wxString& str) const;
|
||||
virtual bool Write(wxOutputStream &str) const;
|
||||
virtual bool Read(istream& str);
|
||||
virtual bool Read(wxInputStream& str);
|
||||
virtual bool Read(wxString& str);
|
||||
virtual wxString GetType() const { return "double"; };
|
||||
|
||||
@ -402,6 +419,12 @@ bool wxVariantDataReal::Write(ostream& str) const
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxVariantDataReal::Write(wxOutputStream& str) const
|
||||
{
|
||||
str << m_value;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxVariantDataReal::Write(wxString& str) const
|
||||
{
|
||||
str.Printf("%.4f", m_value);
|
||||
@ -414,6 +437,12 @@ bool wxVariantDataReal::Read(istream& str)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxVariantDataReal::Read(wxInputStream& str)
|
||||
{
|
||||
str >> (float&)m_value;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxVariantDataReal::Read(wxString& str)
|
||||
{
|
||||
m_value = atof((const char*) str);
|
||||
@ -437,8 +466,10 @@ public:
|
||||
virtual void Copy(wxVariantData& data);
|
||||
virtual bool Eq(wxVariantData& data) const;
|
||||
virtual bool Write(ostream& str) const;
|
||||
virtual bool Write(wxOutputStream& str) const;
|
||||
virtual bool Write(wxString& str) const;
|
||||
virtual bool Read(istream& str);
|
||||
virtual bool Read(wxInputStream& str);
|
||||
virtual bool Read(wxString& str);
|
||||
virtual wxString GetType() const { return "bool"; };
|
||||
|
||||
@ -474,6 +505,12 @@ bool wxVariantDataBool::Write(ostream& str) const
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxVariantDataBool::Write(wxOutputStream& str) const
|
||||
{
|
||||
str << (char)m_value;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxVariantDataBool::Write(wxString& str) const
|
||||
{
|
||||
str.Printf("%d", (int) m_value);
|
||||
@ -487,6 +524,12 @@ bool wxVariantDataBool::Read(istream& WXUNUSED(str))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxVariantDataBool::Read(wxInputStream& str)
|
||||
{
|
||||
str >> (char&)m_value;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxVariantDataBool::Read(wxString& str)
|
||||
{
|
||||
m_value = (atol((const char*) str) != 0);
|
||||
@ -510,8 +553,10 @@ public:
|
||||
virtual void Copy(wxVariantData& data);
|
||||
virtual bool Eq(wxVariantData& data) const;
|
||||
virtual bool Write(ostream& str) const;
|
||||
virtual bool Write(wxOutputStream& str) const;
|
||||
virtual bool Write(wxString& str) const;
|
||||
virtual bool Read(istream& str);
|
||||
virtual bool Read(wxInputStream& str);
|
||||
virtual bool Read(wxString& str);
|
||||
virtual wxString GetType() const { return "char"; };
|
||||
|
||||
@ -547,6 +592,12 @@ bool wxVariantDataChar::Write(ostream& str) const
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxVariantDataChar::Write(wxOutputStream& str) const
|
||||
{
|
||||
str << m_value;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxVariantDataChar::Write(wxString& str) const
|
||||
{
|
||||
str.Printf("%c", m_value);
|
||||
@ -560,6 +611,12 @@ bool wxVariantDataChar::Read(istream& WXUNUSED(str))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxVariantDataChar::Read(wxInputStream& str)
|
||||
{
|
||||
str >> m_value;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxVariantDataChar::Read(wxString& str)
|
||||
{
|
||||
m_value = str[(size_t)0];
|
||||
@ -583,8 +640,10 @@ public:
|
||||
virtual void Copy(wxVariantData& data);
|
||||
virtual bool Eq(wxVariantData& data) const;
|
||||
virtual bool Write(ostream& str) const;
|
||||
virtual bool Write(wxOutputStream& str) const;
|
||||
virtual bool Write(wxString& str) const;
|
||||
virtual bool Read(istream& str);
|
||||
virtual bool Read(wxInputStream& str);
|
||||
virtual bool Read(wxString& str);
|
||||
virtual wxString GetType() const { return "string"; };
|
||||
|
||||
@ -616,6 +675,12 @@ bool wxVariantDataString::Write(ostream& str) const
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxVariantDataString::Write(wxOutputStream& str) const
|
||||
{
|
||||
str << m_value;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxVariantDataString::Write(wxString& str) const
|
||||
{
|
||||
str = m_value;
|
||||
@ -628,6 +693,12 @@ bool wxVariantDataString::Read(istream& str)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxVariantDataString::Read(wxInputStream& str)
|
||||
{
|
||||
str >> m_value;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxVariantDataString::Read(wxString& str)
|
||||
{
|
||||
m_value = str;
|
||||
|
@ -36,7 +36,7 @@ wxZlibInputStream::wxZlibInputStream(wxInputStream& stream)
|
||||
int err;
|
||||
|
||||
// I need a private stream buffer.
|
||||
m_i_streambuf = new wxStreamBuffer(*this);
|
||||
m_i_streambuf = new wxStreamBuffer(*this, wxStreamBuffer::read);
|
||||
m_i_destroybuf = TRUE;
|
||||
m_inflate = new z_stream_s;
|
||||
|
||||
@ -64,7 +64,7 @@ wxZlibInputStream::~wxZlibInputStream()
|
||||
delete m_inflate;
|
||||
}
|
||||
|
||||
size_t wxZlibInputStream::DoRead(void *buffer, size_t size)
|
||||
size_t wxZlibInputStream::OnSysRead(void *buffer, size_t size)
|
||||
{
|
||||
int err;
|
||||
|
||||
@ -78,7 +78,7 @@ size_t wxZlibInputStream::DoRead(void *buffer, size_t size)
|
||||
m_inflate->next_in = m_z_buffer;
|
||||
m_inflate->avail_in = m_parent_i_stream->LastRead();
|
||||
|
||||
if (m_parent_i_stream->Eof())
|
||||
if (m_parent_i_stream->LastError() != wxStream_NOERROR)
|
||||
return (size - m_inflate->avail_in);
|
||||
}
|
||||
err = inflate(m_inflate, Z_FINISH);
|
||||
@ -89,13 +89,6 @@ size_t wxZlibInputStream::DoRead(void *buffer, size_t size)
|
||||
return size-m_inflate->avail_in;
|
||||
}
|
||||
|
||||
bool wxZlibInputStream::Eof() const
|
||||
{
|
||||
if (!m_eof)
|
||||
return m_parent_i_stream->Eof();
|
||||
return m_eof;
|
||||
}
|
||||
|
||||
//////////////////////
|
||||
// wxZlibOutputStream
|
||||
//////////////////////
|
||||
@ -105,7 +98,7 @@ wxZlibOutputStream::wxZlibOutputStream(wxOutputStream& stream)
|
||||
{
|
||||
int err;
|
||||
|
||||
m_o_streambuf = new wxStreamBuffer(*this);
|
||||
m_o_streambuf = new wxStreamBuffer(*this, wxStreamBuffer::write);
|
||||
m_o_destroybuf = TRUE;
|
||||
m_deflate = new z_stream_s;
|
||||
|
||||
@ -155,7 +148,6 @@ void wxZlibOutputStream::Sync()
|
||||
|
||||
err = deflate(m_deflate, Z_FULL_FLUSH);
|
||||
if (err != Z_OK) {
|
||||
m_bad = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -164,7 +156,7 @@ void wxZlibOutputStream::Sync()
|
||||
m_deflate->avail_out = m_z_size;
|
||||
}
|
||||
|
||||
size_t wxZlibOutputStream::DoWrite(const void *buffer, size_t size)
|
||||
size_t wxZlibOutputStream::OnSysWrite(const void *buffer, size_t size)
|
||||
{
|
||||
int err;
|
||||
|
||||
@ -175,7 +167,7 @@ size_t wxZlibOutputStream::DoWrite(const void *buffer, size_t size)
|
||||
|
||||
if (m_deflate->avail_out == 0) {
|
||||
m_parent_o_stream->Write(m_z_buffer, m_z_size);
|
||||
if (m_parent_o_stream->Bad())
|
||||
if (m_parent_o_stream->LastError() != wxStream_NOERROR)
|
||||
return (size - m_deflate->avail_in);
|
||||
|
||||
m_deflate->next_out = m_z_buffer;
|
||||
@ -188,10 +180,3 @@ size_t wxZlibOutputStream::DoWrite(const void *buffer, size_t size)
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
bool wxZlibOutputStream::Bad() const
|
||||
{
|
||||
if (!m_bad)
|
||||
return m_parent_o_stream->Bad();
|
||||
return m_bad;
|
||||
}
|
||||
|
@ -300,19 +300,31 @@ void wxComboBox::SetValue( const wxString& value )
|
||||
void wxComboBox::Copy(void)
|
||||
{
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
#if (GTK_MINOR_VERSION == 1)
|
||||
gtk_editable_copy_clipboard( GTK_EDITABLE(entry) );
|
||||
#else
|
||||
gtk_editable_copy_clipboard( GTK_EDITABLE(entry), 0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxComboBox::Cut(void)
|
||||
{
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
#if (GTK_MINOR_VERSION == 1)
|
||||
gtk_editable_cut_clipboard( GTK_EDITABLE(entry) );
|
||||
#else
|
||||
gtk_editable_cut_clipboard( GTK_EDITABLE(entry), 0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxComboBox::Paste(void)
|
||||
{
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
#if (GTK_MINOR_VERSION == 1)
|
||||
gtk_editable_paste_clipboard( GTK_EDITABLE(entry) );
|
||||
#else
|
||||
gtk_editable_paste_clipboard( GTK_EDITABLE(entry), 0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxComboBox::SetInsertionPoint( long pos )
|
||||
|
@ -300,17 +300,29 @@ void wxTextCtrl::Replace( long from, long to, const wxString &value )
|
||||
|
||||
void wxTextCtrl::Cut()
|
||||
{
|
||||
#if (GTK_MINOR_VERSION == 1)
|
||||
gtk_editable_cut_clipboard( GTK_EDITABLE(m_text) );
|
||||
#else
|
||||
gtk_editable_cut_clipboard( GTK_EDITABLE(m_text), 0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxTextCtrl::Copy()
|
||||
{
|
||||
#if (GTK_MINOR_VERSION == 1)
|
||||
gtk_editable_copy_clipboard( GTK_EDITABLE(m_text) );
|
||||
#else
|
||||
gtk_editable_copy_clipboard( GTK_EDITABLE(m_text), 0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxTextCtrl::Paste()
|
||||
{
|
||||
#if (GTK_MINOR_VERSION == 1)
|
||||
gtk_editable_paste_clipboard( GTK_EDITABLE(m_text) );
|
||||
#else
|
||||
gtk_editable_paste_clipboard( GTK_EDITABLE(m_text), 0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxTextCtrl::Clear()
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Static variables
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@ -63,3 +62,29 @@ static void wxThreadGuiExit()
|
||||
close(p_thrd_pipe[0]);
|
||||
close(p_thrd_pipe[1]);
|
||||
}
|
||||
|
||||
#ifdef NO_DEFINE_GDK_1_1
|
||||
|
||||
void wxMutexGuiEnter()
|
||||
{
|
||||
gdk_mutex_enter();
|
||||
}
|
||||
|
||||
void wxMutexGuiLeave()
|
||||
{
|
||||
gdk_mutex_leave();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void wxMutexGuiEnter()
|
||||
{
|
||||
wxMainMutex.Lock();
|
||||
}
|
||||
|
||||
void wxMutexGuiLeave()
|
||||
{
|
||||
wxMainMutex.Unlock();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -9,6 +9,7 @@
|
||||
/////////////////////////////////////////////////////////////////////////// */
|
||||
|
||||
#include "wx/gtk/win_gtk.h"
|
||||
#include <gtk/gtkfeatures.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -34,6 +35,9 @@ static void gtk_myfixed_add (GtkContainer *container,
|
||||
static void gtk_myfixed_remove (GtkContainer *container,
|
||||
GtkWidget *widget);
|
||||
static void gtk_myfixed_foreach (GtkContainer *container,
|
||||
#if (GTK_MINOR_VERSION == 1)
|
||||
gboolean include_internals,
|
||||
#endif
|
||||
GtkCallback callback,
|
||||
gpointer callback_data);
|
||||
|
||||
@ -88,7 +92,11 @@ gtk_myfixed_class_init (GtkMyFixedClass *klass)
|
||||
|
||||
container_class->add = gtk_myfixed_add;
|
||||
container_class->remove = gtk_myfixed_remove;
|
||||
#if (GTK_MINOR_VERSION == 1)
|
||||
container_class->forall = gtk_myfixed_foreach;
|
||||
#else
|
||||
container_class->foreach = gtk_myfixed_foreach;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
@ -454,6 +462,9 @@ gtk_myfixed_remove (GtkContainer *container,
|
||||
|
||||
static void
|
||||
gtk_myfixed_foreach (GtkContainer *container,
|
||||
#if (GTK_MINOR_VERSION == 1)
|
||||
gboolean include_internals,
|
||||
#endif
|
||||
GtkCallback callback,
|
||||
gpointer callback_data)
|
||||
{
|
||||
|
@ -300,19 +300,31 @@ void wxComboBox::SetValue( const wxString& value )
|
||||
void wxComboBox::Copy(void)
|
||||
{
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
#if (GTK_MINOR_VERSION == 1)
|
||||
gtk_editable_copy_clipboard( GTK_EDITABLE(entry) );
|
||||
#else
|
||||
gtk_editable_copy_clipboard( GTK_EDITABLE(entry), 0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxComboBox::Cut(void)
|
||||
{
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
#if (GTK_MINOR_VERSION == 1)
|
||||
gtk_editable_cut_clipboard( GTK_EDITABLE(entry) );
|
||||
#else
|
||||
gtk_editable_cut_clipboard( GTK_EDITABLE(entry), 0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxComboBox::Paste(void)
|
||||
{
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
#if (GTK_MINOR_VERSION == 1)
|
||||
gtk_editable_paste_clipboard( GTK_EDITABLE(entry) );
|
||||
#else
|
||||
gtk_editable_paste_clipboard( GTK_EDITABLE(entry), 0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxComboBox::SetInsertionPoint( long pos )
|
||||
|
@ -300,17 +300,29 @@ void wxTextCtrl::Replace( long from, long to, const wxString &value )
|
||||
|
||||
void wxTextCtrl::Cut()
|
||||
{
|
||||
#if (GTK_MINOR_VERSION == 1)
|
||||
gtk_editable_cut_clipboard( GTK_EDITABLE(m_text) );
|
||||
#else
|
||||
gtk_editable_cut_clipboard( GTK_EDITABLE(m_text), 0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxTextCtrl::Copy()
|
||||
{
|
||||
#if (GTK_MINOR_VERSION == 1)
|
||||
gtk_editable_copy_clipboard( GTK_EDITABLE(m_text) );
|
||||
#else
|
||||
gtk_editable_copy_clipboard( GTK_EDITABLE(m_text), 0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxTextCtrl::Paste()
|
||||
{
|
||||
#if (GTK_MINOR_VERSION == 1)
|
||||
gtk_editable_paste_clipboard( GTK_EDITABLE(m_text) );
|
||||
#else
|
||||
gtk_editable_paste_clipboard( GTK_EDITABLE(m_text), 0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxTextCtrl::Clear()
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Static variables
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@ -63,3 +62,29 @@ static void wxThreadGuiExit()
|
||||
close(p_thrd_pipe[0]);
|
||||
close(p_thrd_pipe[1]);
|
||||
}
|
||||
|
||||
#ifdef NO_DEFINE_GDK_1_1
|
||||
|
||||
void wxMutexGuiEnter()
|
||||
{
|
||||
gdk_mutex_enter();
|
||||
}
|
||||
|
||||
void wxMutexGuiLeave()
|
||||
{
|
||||
gdk_mutex_leave();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void wxMutexGuiEnter()
|
||||
{
|
||||
wxMainMutex.Lock();
|
||||
}
|
||||
|
||||
void wxMutexGuiLeave()
|
||||
{
|
||||
wxMainMutex.Unlock();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -9,6 +9,7 @@
|
||||
/////////////////////////////////////////////////////////////////////////// */
|
||||
|
||||
#include "wx/gtk/win_gtk.h"
|
||||
#include <gtk/gtkfeatures.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -34,6 +35,9 @@ static void gtk_myfixed_add (GtkContainer *container,
|
||||
static void gtk_myfixed_remove (GtkContainer *container,
|
||||
GtkWidget *widget);
|
||||
static void gtk_myfixed_foreach (GtkContainer *container,
|
||||
#if (GTK_MINOR_VERSION == 1)
|
||||
gboolean include_internals,
|
||||
#endif
|
||||
GtkCallback callback,
|
||||
gpointer callback_data);
|
||||
|
||||
@ -88,7 +92,11 @@ gtk_myfixed_class_init (GtkMyFixedClass *klass)
|
||||
|
||||
container_class->add = gtk_myfixed_add;
|
||||
container_class->remove = gtk_myfixed_remove;
|
||||
#if (GTK_MINOR_VERSION == 1)
|
||||
container_class->forall = gtk_myfixed_foreach;
|
||||
#else
|
||||
container_class->foreach = gtk_myfixed_foreach;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
@ -454,6 +462,9 @@ gtk_myfixed_remove (GtkContainer *container,
|
||||
|
||||
static void
|
||||
gtk_myfixed_foreach (GtkContainer *container,
|
||||
#if (GTK_MINOR_VERSION == 1)
|
||||
gboolean include_internals,
|
||||
#endif
|
||||
GtkCallback callback,
|
||||
gpointer callback_data)
|
||||
{
|
||||
|
@ -21,9 +21,10 @@
|
||||
WXDIR = $(WXWIN)
|
||||
|
||||
# Set all these to 1 if you want to build a dynamic library
|
||||
#DLL=1
|
||||
#WXMAKINGDLL=1
|
||||
#WXBUILDDLL=1
|
||||
!if "$(DLL)" == "1"
|
||||
WXMAKINGDLL=1
|
||||
WXBUILDDLL=1
|
||||
!endif
|
||||
|
||||
!include $(WXDIR)\src\makeb32.env
|
||||
|
||||
|
@ -12,9 +12,10 @@
|
||||
|
||||
WXDIR = $(WXWIN)
|
||||
|
||||
DLL=1
|
||||
!if "$(DLL)" == "1"
|
||||
WXBUILDDLL=1
|
||||
WXUSINGDLL=1
|
||||
!endif
|
||||
|
||||
!include $(WXDIR)\src\makeb32.env
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user