* New wxStreams (to be documented), new classes: wxBufferedStreams,
wxTextStreams git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2962 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -153,6 +153,7 @@ wx_include_HEADERS = \
|
||||
textctrl.h \
|
||||
textdlg.h \
|
||||
textfile.h \
|
||||
txtstrm.h \
|
||||
thread.h \
|
||||
time.h \
|
||||
timer.h \
|
||||
|
@@ -20,28 +20,54 @@
|
||||
|
||||
#if wxUSE_STREAMS
|
||||
|
||||
class WXDLLEXPORT wxDataInputStream: public wxFilterInputStream {
|
||||
class WXDLLEXPORT wxDataInputStream {
|
||||
public:
|
||||
wxDataInputStream(wxInputStream& s);
|
||||
virtual ~wxDataInputStream();
|
||||
~wxDataInputStream();
|
||||
|
||||
wxUint32 Read32();
|
||||
wxUint16 Read16();
|
||||
wxUint8 Read8();
|
||||
double ReadDouble();
|
||||
wxString ReadString();
|
||||
|
||||
wxDataInputStream& operator>>(wxString& s);
|
||||
wxDataInputStream& operator>>(wxInt8& c);
|
||||
wxDataInputStream& operator>>(wxInt16& i);
|
||||
wxDataInputStream& operator>>(wxInt32& i);
|
||||
wxDataInputStream& operator>>(wxUint8& c);
|
||||
wxDataInputStream& operator>>(wxUint16& i);
|
||||
wxDataInputStream& operator>>(wxUint32& i);
|
||||
wxDataInputStream& operator>>(double& i);
|
||||
wxDataInputStream& operator>>(float& f);
|
||||
protected:
|
||||
wxInputStream *m_input;
|
||||
};
|
||||
|
||||
class WXDLLEXPORT wxDataOutputStream: public wxFilterOutputStream {
|
||||
class WXDLLEXPORT wxDataOutputStream {
|
||||
public:
|
||||
wxDataOutputStream(wxOutputStream& s);
|
||||
virtual ~wxDataOutputStream();
|
||||
~wxDataOutputStream();
|
||||
|
||||
void Write32(wxUint32 i);
|
||||
void Write16(wxUint16 i);
|
||||
void Write8(wxUint8 i);
|
||||
void WriteDouble(double d);
|
||||
void WriteString(const wxString& string);
|
||||
|
||||
wxDataOutputStream& operator<<(const wxChar *string);
|
||||
wxDataOutputStream& operator<<(wxString& string);
|
||||
wxDataOutputStream& operator<<(wxInt8 c);
|
||||
wxDataOutputStream& operator<<(wxInt16 i);
|
||||
wxDataOutputStream& operator<<(wxInt32 i);
|
||||
wxDataOutputStream& operator<<(wxUint8 c);
|
||||
wxDataOutputStream& operator<<(wxUint16 i);
|
||||
wxDataOutputStream& operator<<(wxUint32 i);
|
||||
wxDataOutputStream& operator<<(double f);
|
||||
wxDataOutputStream& operator<<(float f);
|
||||
|
||||
protected:
|
||||
wxOutputStream *m_output;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -83,6 +83,7 @@ class SocketWaiter: public wxThread {
|
||||
wxSocketInternal *m_internal;
|
||||
int m_fd;
|
||||
};
|
||||
#endif
|
||||
|
||||
class SocketRequester
|
||||
#if wxUSE_THREADS
|
||||
@@ -99,17 +100,17 @@ class SocketRequester
|
||||
|
||||
bool WaitFor(wxSocketBase::wxRequestNotify req, int millisec);
|
||||
|
||||
#if wxUSE_THREADS
|
||||
// Thread Entry point
|
||||
// ---
|
||||
virtual void *Entry();
|
||||
#endif
|
||||
|
||||
public:
|
||||
wxSocketBase *m_socket;
|
||||
wxSocketInternal *m_internal;
|
||||
int m_fd;
|
||||
};
|
||||
#endif
|
||||
// wxUSE_THREADS
|
||||
|
||||
class wxSocketInternal {
|
||||
public:
|
||||
@@ -134,6 +135,7 @@ class wxSocketInternal {
|
||||
void QueueRequest(SockRequest *request, bool async);
|
||||
void WaitForEnd(SockRequest *request);
|
||||
|
||||
// Used by SocketRequester
|
||||
SockRequest *WaitForReq();
|
||||
void EndRequest(SockRequest *req);
|
||||
public:
|
||||
|
@@ -34,85 +34,6 @@ typedef wxOutputStream& (*__wxOutputManip)(wxOutputStream&);
|
||||
|
||||
WXDLLEXPORT wxOutputStream& wxEndL(wxOutputStream& o_stream);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Stream buffer
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxStreamBuffer {
|
||||
public:
|
||||
typedef enum {
|
||||
read = 0, write, read_write
|
||||
} BufMode;
|
||||
|
||||
// -----------
|
||||
// ctor & dtor
|
||||
// -----------
|
||||
wxStreamBuffer(wxStreamBase& stream, BufMode mode);
|
||||
wxStreamBuffer(BufMode mode);
|
||||
wxStreamBuffer(const wxStreamBuffer& buf);
|
||||
~wxStreamBuffer();
|
||||
|
||||
// -----------
|
||||
// Filtered IO
|
||||
// -----------
|
||||
size_t Read(void *buffer, size_t size);
|
||||
size_t Read(wxStreamBuffer *buf);
|
||||
size_t Write(const void *buffer, size_t size);
|
||||
size_t Write(wxStreamBuffer *buf);
|
||||
|
||||
size_t WriteBack(const char *buffer, size_t size);
|
||||
bool WriteBack(char c);
|
||||
char GetChar();
|
||||
void PutChar(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);
|
||||
char *GetBufferStart() const { return m_buffer_start; }
|
||||
char *GetBufferEnd() const { return m_buffer_end; }
|
||||
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; }
|
||||
void Flushable(bool f) { m_flushable = f; }
|
||||
|
||||
bool FlushBuffer();
|
||||
bool FillBuffer();
|
||||
size_t GetDataLeft();
|
||||
|
||||
// --------------
|
||||
// Administration
|
||||
// --------------
|
||||
wxStreamBase *Stream() { return m_stream; }
|
||||
|
||||
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;
|
||||
|
||||
char *m_wback;
|
||||
size_t m_wbacksize, m_wbackcur;
|
||||
|
||||
bool m_fixed, m_flushable;
|
||||
|
||||
wxStreamBase *m_stream;
|
||||
BufMode m_mode;
|
||||
bool m_destroybuf, m_destroystream;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// wxStream: base classes
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -138,7 +59,6 @@ class WXDLLEXPORT wxStreamBase {
|
||||
virtual size_t StreamSize() const { return ~((size_t)0); }
|
||||
|
||||
protected:
|
||||
friend class wxStreamBuffer;
|
||||
|
||||
virtual size_t OnSysRead(void *buffer, size_t bufsize);
|
||||
virtual size_t OnSysWrite(const void *buffer, size_t bufsize);
|
||||
@@ -146,6 +66,8 @@ class WXDLLEXPORT wxStreamBase {
|
||||
virtual off_t OnSysTell() const;
|
||||
|
||||
protected:
|
||||
friend class wxStreamBuffer;
|
||||
|
||||
size_t m_lastcount;
|
||||
wxStreamError m_lasterror;
|
||||
};
|
||||
@@ -153,7 +75,6 @@ class WXDLLEXPORT wxStreamBase {
|
||||
class WXDLLEXPORT wxInputStream: public wxStreamBase {
|
||||
public:
|
||||
wxInputStream();
|
||||
wxInputStream(wxStreamBuffer *sbuf);
|
||||
virtual ~wxInputStream();
|
||||
|
||||
// IO functions
|
||||
@@ -161,78 +82,56 @@ class WXDLLEXPORT wxInputStream: public wxStreamBase {
|
||||
char GetC();
|
||||
virtual wxInputStream& Read(void *buffer, size_t size);
|
||||
wxInputStream& Read(wxOutputStream& stream_out);
|
||||
wxString ReadLine();
|
||||
|
||||
// Position functions
|
||||
off_t SeekI(off_t pos, wxSeekMode mode = wxFromStart);
|
||||
off_t TellI() const;
|
||||
virtual off_t SeekI(off_t pos, wxSeekMode mode = wxFromStart);
|
||||
virtual off_t TellI() const;
|
||||
|
||||
// State functions
|
||||
wxStreamBuffer *InputStreamBuffer() { return m_i_streambuf; }
|
||||
size_t LastRead() { return wxStreamBase::m_lastcount; }
|
||||
virtual size_t LastRead() { return wxStreamBase::m_lastcount; }
|
||||
|
||||
// Ungetch
|
||||
size_t Ungetch(void *buffer, size_t size);
|
||||
bool Ungetch(char c);
|
||||
|
||||
// Operators
|
||||
wxInputStream& operator>>(wxOutputStream& out) { return Read(out); }
|
||||
wxInputStream& operator>>(wxString& line);
|
||||
wxInputStream& operator>>(char& c);
|
||||
wxInputStream& operator>>(signed short& i);
|
||||
wxInputStream& operator>>(signed int& i);
|
||||
wxInputStream& operator>>(signed long& i);
|
||||
wxInputStream& operator>>(unsigned char& c);
|
||||
wxInputStream& operator>>(unsigned short& i);
|
||||
wxInputStream& operator>>(unsigned int& i);
|
||||
wxInputStream& operator>>(unsigned long& i);
|
||||
wxInputStream& operator>>(double& i);
|
||||
wxInputStream& operator>>(float& f) { double d; operator>>((double&)d); f = (float)d; return *this; }
|
||||
#if wxUSE_SERIAL
|
||||
wxInputStream& operator>>(wxObject *& obj);
|
||||
#endif
|
||||
wxInputStream& operator>>( __wxInputManip func) { return func(*this); }
|
||||
|
||||
protected:
|
||||
bool m_i_destroybuf;
|
||||
wxStreamBuffer *m_i_streambuf;
|
||||
// Ungetch managers
|
||||
char *m_wback;
|
||||
size_t m_wbacksize;
|
||||
size_t m_wbackcur;
|
||||
|
||||
char *AllocSpaceWBack(size_t needed_size);
|
||||
size_t GetWBack(char *buf, size_t bsize);
|
||||
|
||||
};
|
||||
|
||||
class WXDLLEXPORT wxOutputStream: public wxStreamBase {
|
||||
public:
|
||||
wxOutputStream();
|
||||
wxOutputStream(wxStreamBuffer *sbuf);
|
||||
virtual ~wxOutputStream();
|
||||
|
||||
virtual wxOutputStream& Write(const void *buffer, size_t size);
|
||||
wxOutputStream& Write(wxInputStream& stream_in);
|
||||
void WriteLine(const wxString& line);
|
||||
|
||||
off_t SeekO(off_t pos, wxSeekMode mode = wxFromStart);
|
||||
off_t TellO() const;
|
||||
virtual off_t SeekO(off_t pos, wxSeekMode mode = wxFromStart);
|
||||
virtual off_t TellO() const;
|
||||
|
||||
size_t LastWrite() const { return wxStreamBase::m_lastcount; }
|
||||
wxStreamBuffer *OutputStreamBuffer() { return m_o_streambuf; }
|
||||
virtual size_t LastWrite() const { return wxStreamBase::m_lastcount; }
|
||||
|
||||
void Sync();
|
||||
virtual void Sync();
|
||||
|
||||
wxOutputStream& operator<<(wxInputStream& out) { return Write(out); }
|
||||
wxOutputStream& operator<<(const char *string);
|
||||
wxOutputStream& operator<<(wxString& string);
|
||||
wxOutputStream& operator<<(char c);
|
||||
wxOutputStream& operator<<(signed short i);
|
||||
wxOutputStream& operator<<(signed int i);
|
||||
wxOutputStream& operator<<(signed long i);
|
||||
wxOutputStream& operator<<(unsigned char c);
|
||||
wxOutputStream& operator<<(unsigned short i);
|
||||
wxOutputStream& operator<<(unsigned int i);
|
||||
wxOutputStream& operator<<(unsigned long i);
|
||||
wxOutputStream& operator<<(double f);
|
||||
wxOutputStream& operator<<(float f) { return operator<<((double)f); }
|
||||
#if wxUSE_SERIAL
|
||||
wxOutputStream& operator<<(wxObject& obj);
|
||||
#endif
|
||||
wxOutputStream& operator<<( __wxOutputManip func) { return func(*this); }
|
||||
|
||||
protected:
|
||||
bool m_o_destroybuf;
|
||||
wxStreamBuffer *m_o_streambuf;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -267,6 +166,130 @@ class WXDLLEXPORT wxFilterOutputStream: public wxOutputStream {
|
||||
wxOutputStream *m_parent_o_stream;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Stream buffer
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxStreamBuffer {
|
||||
public:
|
||||
typedef enum {
|
||||
read = 0, write, read_write
|
||||
} BufMode;
|
||||
|
||||
// -----------
|
||||
// ctor & dtor
|
||||
// -----------
|
||||
wxStreamBuffer(wxStreamBase& stream, BufMode mode);
|
||||
wxStreamBuffer(BufMode mode);
|
||||
wxStreamBuffer(const wxStreamBuffer& buf);
|
||||
~wxStreamBuffer();
|
||||
|
||||
// -----------
|
||||
// Filtered IO
|
||||
// -----------
|
||||
size_t Read(void *buffer, size_t size);
|
||||
size_t Read(wxStreamBuffer *buf);
|
||||
size_t Write(const void *buffer, size_t size);
|
||||
size_t Write(wxStreamBuffer *buf);
|
||||
|
||||
char GetChar();
|
||||
void PutChar(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);
|
||||
char *GetBufferStart() const { return m_buffer_start; }
|
||||
char *GetBufferEnd() const { return m_buffer_end; }
|
||||
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; }
|
||||
void Flushable(bool f) { m_flushable = f; }
|
||||
|
||||
bool FlushBuffer();
|
||||
bool FillBuffer();
|
||||
size_t GetDataLeft();
|
||||
|
||||
// --------------
|
||||
// Administration
|
||||
// --------------
|
||||
wxStreamBase *Stream() { return m_stream; }
|
||||
|
||||
protected:
|
||||
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;
|
||||
|
||||
char *m_wback;
|
||||
size_t m_wbacksize, m_wbackcur;
|
||||
|
||||
bool m_fixed, m_flushable;
|
||||
|
||||
wxStreamBase *m_stream;
|
||||
BufMode m_mode;
|
||||
bool m_destroybuf, m_destroystream;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// wxBufferedStreams
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
class wxBufferedInputStream: public wxFilterInputStream {
|
||||
public:
|
||||
wxBufferedInputStream(wxInputStream& stream);
|
||||
~wxBufferedInputStream();
|
||||
|
||||
wxInputStream& Read(void *buffer, size_t size);
|
||||
|
||||
// Position functions
|
||||
off_t SeekI(off_t pos, wxSeekMode mode = wxFromStart);
|
||||
off_t TellI() const;
|
||||
|
||||
wxStreamBuffer *InputStreamBuffer() const { return m_i_streambuf; }
|
||||
|
||||
protected:
|
||||
size_t OnSysRead(void *buffer, size_t bufsize);
|
||||
off_t OnSysSeek(off_t seek, wxSeekMode mode);
|
||||
off_t OnSysTell() const;
|
||||
|
||||
protected:
|
||||
wxStreamBuffer *m_i_streambuf;
|
||||
};
|
||||
|
||||
class wxBufferedOutputStream: public wxFilterOutputStream {
|
||||
public:
|
||||
wxBufferedOutputStream(wxOutputStream& stream);
|
||||
~wxBufferedOutputStream();
|
||||
|
||||
wxOutputStream& Write(const void *buffer, size_t size);
|
||||
|
||||
// Position functions
|
||||
off_t SeekO(off_t pos, wxSeekMode mode = wxFromStart);
|
||||
off_t TellO() const;
|
||||
|
||||
void Sync();
|
||||
|
||||
wxStreamBuffer *OutputStreamBuffer() const { return m_o_streambuf; }
|
||||
|
||||
protected:
|
||||
size_t OnSysWrite(const void *buffer, size_t bufsize);
|
||||
off_t OnSysSeek(off_t seek, wxSeekMode mode);
|
||||
off_t OnSysTell() const;
|
||||
|
||||
protected:
|
||||
wxStreamBuffer *m_o_streambuf;
|
||||
};
|
||||
|
||||
#endif
|
||||
// wxUSE_STREAMS
|
||||
|
||||
|
79
include/wx/txtstrm.h
Normal file
79
include/wx/txtstrm.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: txtstrm.h
|
||||
// Purpose: Text stream classes
|
||||
// Author: Guilhem Lavaux
|
||||
// Modified by:
|
||||
// Created: 28/06/1998
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Guilhem Lavaux
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_TXTSTREAM_H_
|
||||
#define _WX_TXTSTREAM_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "txtstrm.h"
|
||||
#endif
|
||||
|
||||
#include <wx/stream.h>
|
||||
|
||||
#if wxUSE_STREAMS
|
||||
|
||||
class WXDLLEXPORT wxTextInputStream {
|
||||
public:
|
||||
wxTextInputStream(wxInputStream& s);
|
||||
~wxTextInputStream();
|
||||
|
||||
wxUint32 Read32();
|
||||
wxUint16 Read16();
|
||||
wxUint8 Read8();
|
||||
double ReadDouble();
|
||||
wxString ReadString();
|
||||
|
||||
// Operators
|
||||
wxTextInputStream& operator>>(wxString& line);
|
||||
wxTextInputStream& operator>>(wxInt8& c);
|
||||
wxTextInputStream& operator>>(wxInt16& i);
|
||||
wxTextInputStream& operator>>(wxInt32& i);
|
||||
wxTextInputStream& operator>>(wxUint8& c);
|
||||
wxTextInputStream& operator>>(wxUint16& i);
|
||||
wxTextInputStream& operator>>(wxUint32& i);
|
||||
wxTextInputStream& operator>>(double& i);
|
||||
wxTextInputStream& operator>>(float& f);
|
||||
|
||||
protected:
|
||||
wxInputStream *m_input;
|
||||
};
|
||||
|
||||
class WXDLLEXPORT wxTextOutputStream {
|
||||
public:
|
||||
wxTextOutputStream(wxOutputStream& s);
|
||||
~wxTextOutputStream();
|
||||
|
||||
void Write32(wxUint32 i);
|
||||
void Write16(wxUint16 i);
|
||||
void Write8(wxUint8 i);
|
||||
void WriteDouble(double d);
|
||||
void WriteString(const wxString& string);
|
||||
|
||||
wxTextOutputStream& operator<<(const wxChar *string);
|
||||
wxTextOutputStream& operator<<(const wxString& string);
|
||||
wxTextOutputStream& operator<<(wxInt8 c);
|
||||
wxTextOutputStream& operator<<(wxInt16 c);
|
||||
wxTextOutputStream& operator<<(wxInt32 c);
|
||||
wxTextOutputStream& operator<<(wxUint8 c);
|
||||
wxTextOutputStream& operator<<(wxUint16 c);
|
||||
wxTextOutputStream& operator<<(wxUint32 c);
|
||||
wxTextOutputStream& operator<<(double f);
|
||||
wxTextOutputStream& operator<<(float f);
|
||||
|
||||
protected:
|
||||
wxOutputStream *m_output;
|
||||
};
|
||||
|
||||
#endif
|
||||
// wxUSE_STREAMS
|
||||
|
||||
#endif
|
||||
// _WX_DATSTREAM_H_
|
@@ -44,7 +44,7 @@
|
||||
|
||||
#include "wx/wfstream.h"
|
||||
#include "wx/datstrm.h"
|
||||
|
||||
#include "wx/txtstrm.h"
|
||||
|
||||
// Create a new application object
|
||||
IMPLEMENT_APP (MyApp)
|
||||
@@ -111,36 +111,38 @@ void MyApp::DoStreamDemo(wxCommandEvent& WXUNUSED(event))
|
||||
|
||||
ofstream std_file_output( "test_std.dat" );
|
||||
wxFileOutputStream file_output( "test_wx.dat" );
|
||||
wxBufferedOutputStream buf_output( file_output );
|
||||
wxTextOutputStream text_output( buf_output );
|
||||
|
||||
wxString tmp;
|
||||
signed int si = 0xFFFFFFFF;
|
||||
tmp.Printf( "Signed int: %d\n", si );
|
||||
textCtrl.WriteText( tmp );
|
||||
file_output << si << "\n";
|
||||
text_output << si << "\n";
|
||||
std_file_output << si << "\n";
|
||||
|
||||
unsigned int ui = 0xFFFFFFFF;
|
||||
tmp.Printf( "Unsigned int: %u\n", ui );
|
||||
textCtrl.WriteText( tmp );
|
||||
file_output << ui << "\n";
|
||||
text_output << ui << "\n";
|
||||
std_file_output << ui << "\n";
|
||||
|
||||
double d = 2.01234567890123456789;
|
||||
tmp.Printf( "Double: %f\n", d );
|
||||
textCtrl.WriteText( tmp );
|
||||
file_output << d << "\n";
|
||||
text_output << d << "\n";
|
||||
std_file_output << d << "\n";
|
||||
|
||||
float f = 0.00001;
|
||||
tmp.Printf( "Float: %f\n", f );
|
||||
textCtrl.WriteText( tmp );
|
||||
file_output << f << "\n";
|
||||
text_output << f << "\n";
|
||||
std_file_output << f << "\n";
|
||||
|
||||
wxString str( "Hello!" );
|
||||
tmp.Printf( "String: %s\n", str.c_str() );
|
||||
textCtrl.WriteText( tmp );
|
||||
file_output << str << "\n";
|
||||
text_output << str << "\n";
|
||||
std_file_output << str.c_str() << "\n";
|
||||
|
||||
textCtrl.WriteText( "\nReading from ifstream:\n" );
|
||||
@@ -169,27 +171,29 @@ void MyApp::DoStreamDemo(wxCommandEvent& WXUNUSED(event))
|
||||
|
||||
textCtrl.WriteText( "\nReading from wxFileInputStream:\n" );
|
||||
|
||||
file_output.OutputStreamBuffer()->FlushBuffer();
|
||||
buf_output.Sync();
|
||||
|
||||
wxFileInputStream file_input( "test_wx.dat" );
|
||||
wxBufferedInputStream buf_input( file_input );
|
||||
wxTextInputStream text_input( buf_input );
|
||||
|
||||
file_input >> si;
|
||||
text_input >> si;
|
||||
tmp.Printf( "Signed int: %d\n", si );
|
||||
textCtrl.WriteText( tmp );
|
||||
|
||||
file_input >> ui;
|
||||
text_input >> ui;
|
||||
tmp.Printf( "Unsigned int: %u\n", ui );
|
||||
textCtrl.WriteText( tmp );
|
||||
|
||||
file_input >> d;
|
||||
text_input >> d;
|
||||
tmp.Printf( "Double: %f\n", d );
|
||||
textCtrl.WriteText( tmp );
|
||||
|
||||
file_input >> f;
|
||||
text_input >> f;
|
||||
tmp.Printf( "Float: %f\n", f );
|
||||
textCtrl.WriteText( tmp );
|
||||
|
||||
file_input >> str;
|
||||
text_input >> str;
|
||||
tmp.Printf( "String: %s\n", str.c_str() );
|
||||
textCtrl.WriteText( tmp );
|
||||
|
||||
@@ -199,7 +203,7 @@ void MyApp::DoStreamDemo(wxCommandEvent& WXUNUSED(event))
|
||||
textCtrl.WriteText( "Writing to wxDataOutputStream:\n" );
|
||||
|
||||
file_output.SeekO( 0 );
|
||||
wxDataOutputStream data_output( file_output );
|
||||
wxDataOutputStream data_output( buf_output );
|
||||
|
||||
wxInt16 i16 = 0xFFFF;
|
||||
tmp.Printf( "Signed int16: %d\n", (int)i16 );
|
||||
@@ -221,12 +225,12 @@ void MyApp::DoStreamDemo(wxCommandEvent& WXUNUSED(event))
|
||||
textCtrl.WriteText( tmp );
|
||||
data_output.WriteString( str );
|
||||
|
||||
file_output.OutputStreamBuffer()->FlushBuffer();
|
||||
buf_output.Sync();
|
||||
|
||||
textCtrl.WriteText( "\nReading from wxDataInputStream:\n" );
|
||||
|
||||
file_input.SeekI( 0 );
|
||||
wxDataInputStream data_input( file_input );
|
||||
wxDataInputStream data_input( buf_input );
|
||||
|
||||
i16 = data_input.Read16();
|
||||
tmp.Printf( "Signed int16: %d\n", (int)i16 );
|
||||
|
@@ -29,7 +29,7 @@
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
wxDataInputStream::wxDataInputStream(wxInputStream& s)
|
||||
: wxFilterInputStream(s)
|
||||
: m_input(&s)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ wxUint32 wxDataInputStream::Read32()
|
||||
{
|
||||
char buf[4];
|
||||
|
||||
Read(buf, 4);
|
||||
m_input->Read(buf, 4);
|
||||
|
||||
return (wxUint32)buf[0] |
|
||||
((wxUint32)buf[1] << 8) |
|
||||
@@ -53,7 +53,7 @@ wxUint16 wxDataInputStream::Read16()
|
||||
{
|
||||
char buf[2];
|
||||
|
||||
Read(buf, 2);
|
||||
m_input->Read(buf, 2);
|
||||
|
||||
return (wxUint16)buf[0] |
|
||||
((wxUint16)buf[1] << 8);
|
||||
@@ -63,7 +63,7 @@ wxUint8 wxDataInputStream::Read8()
|
||||
{
|
||||
wxUint8 buf;
|
||||
|
||||
Read((char *)&buf, 1);
|
||||
m_input->Read((char *)&buf, 1);
|
||||
return (wxUint8)buf;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ double wxDataInputStream::ReadDouble()
|
||||
#if wxUSE_APPLE_IEEE
|
||||
char buf[10];
|
||||
|
||||
Read(buf, 10);
|
||||
m_input->Read(buf, 10);
|
||||
return ConvertFromIeeeExtended((unsigned char *)buf);
|
||||
#else
|
||||
return 0.0;
|
||||
@@ -91,7 +91,7 @@ wxString wxDataInputStream::ReadString()
|
||||
len = Read32();
|
||||
string = new char[len+1];
|
||||
|
||||
Read(string, len);
|
||||
m_input->Read(string, len);
|
||||
|
||||
string[len] = 0;
|
||||
wx_string = string;
|
||||
@@ -100,12 +100,66 @@ wxString wxDataInputStream::ReadString()
|
||||
return wx_string;
|
||||
}
|
||||
|
||||
wxDataInputStream& wxDataInputStream::operator>>(wxString& s)
|
||||
{
|
||||
s = ReadString();
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxDataInputStream& wxDataInputStream::operator>>(wxInt8& c)
|
||||
{
|
||||
c = (wxInt8)Read8();
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxDataInputStream& wxDataInputStream::operator>>(wxInt16& i)
|
||||
{
|
||||
i = (wxInt16)Read16();
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxDataInputStream& wxDataInputStream::operator>>(wxInt32& i)
|
||||
{
|
||||
i = (wxInt32)Read32();
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxDataInputStream& wxDataInputStream::operator>>(wxUint8& c)
|
||||
{
|
||||
c = Read8();
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxDataInputStream& wxDataInputStream::operator>>(wxUint16& i)
|
||||
{
|
||||
i = Read16();
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxDataInputStream& wxDataInputStream::operator>>(wxUint32& i)
|
||||
{
|
||||
i = Read32();
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxDataInputStream& wxDataInputStream::operator>>(double& i)
|
||||
{
|
||||
i = ReadDouble();
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxDataInputStream& wxDataInputStream::operator>>(float& f)
|
||||
{
|
||||
f = (float)ReadDouble();
|
||||
return *this;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// wxDataOutputStream
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
wxDataOutputStream::wxDataOutputStream(wxOutputStream& s)
|
||||
: wxFilterOutputStream(s)
|
||||
: m_output(&s)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -121,7 +175,7 @@ void wxDataOutputStream::Write32(wxUint32 i)
|
||||
buf[1] = (i >> 8) & 0xff;
|
||||
buf[2] = (i >> 16) & 0xff;
|
||||
buf[3] = (i >> 24) & 0xff;
|
||||
Write(buf, 4);
|
||||
m_output->Write(buf, 4);
|
||||
}
|
||||
|
||||
void wxDataOutputStream::Write16(wxUint16 i)
|
||||
@@ -130,18 +184,18 @@ void wxDataOutputStream::Write16(wxUint16 i)
|
||||
|
||||
buf[0] = i & 0xff;
|
||||
buf[1] = (i >> 8) & 0xff;
|
||||
Write(buf, 2);
|
||||
m_output->Write(buf, 2);
|
||||
}
|
||||
|
||||
void wxDataOutputStream::Write8(wxUint8 i)
|
||||
{
|
||||
Write(&i, 1);
|
||||
m_output->Write(&i, 1);
|
||||
}
|
||||
|
||||
void wxDataOutputStream::WriteString(const wxString& string)
|
||||
{
|
||||
Write32(string.Length());
|
||||
Write((const wxChar *) string, string.Length()*sizeof(wxChar));
|
||||
m_output->Write((const wxChar *) string, string.Length()*sizeof(wxChar));
|
||||
}
|
||||
|
||||
// Must be at global scope for VC++ 5
|
||||
@@ -157,7 +211,68 @@ void wxDataOutputStream::WriteDouble(double d)
|
||||
# pragma warning "wxDataOutputStream::WriteDouble() not using IeeeExtended - will not work!"
|
||||
buf[0] = '\0';
|
||||
#endif
|
||||
Write(buf, 10);
|
||||
m_output->Write(buf, 10);
|
||||
}
|
||||
|
||||
wxDataOutputStream& wxDataOutputStream::operator<<(const wxChar *string)
|
||||
{
|
||||
Write32(wxStrlen(string));
|
||||
m_output->Write((const char *)string, wxStrlen(string)*sizeof(wxChar));
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxDataOutputStream& wxDataOutputStream::operator<<(wxString& string)
|
||||
{
|
||||
WriteString(string);
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxDataOutputStream& wxDataOutputStream::operator<<(wxInt8 c)
|
||||
{
|
||||
Write8((wxUint8)c);
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxDataOutputStream& wxDataOutputStream::operator<<(wxInt16 i)
|
||||
{
|
||||
Write16((wxUint16)i);
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxDataOutputStream& wxDataOutputStream::operator<<(wxInt32 i)
|
||||
{
|
||||
Write32((wxUint32)i);
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxDataOutputStream& wxDataOutputStream::operator<<(wxUint8 c)
|
||||
{
|
||||
Write8(c);
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxDataOutputStream& wxDataOutputStream::operator<<(wxUint16 i)
|
||||
{
|
||||
Write16(i);
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxDataOutputStream& wxDataOutputStream::operator<<(wxUint32 i)
|
||||
{
|
||||
Write32(i);
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxDataOutputStream& wxDataOutputStream::operator<<(double f)
|
||||
{
|
||||
WriteDouble(f);
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxDataOutputStream& wxDataOutputStream::operator<<(float f)
|
||||
{
|
||||
WriteDouble((double)f);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -28,6 +28,7 @@
|
||||
#include "wx/tokenzr.h"
|
||||
#include "wx/socket.h"
|
||||
#include "wx/protocol/protocol.h"
|
||||
#include "wx/url.h"
|
||||
#include "wx/protocol/http.h"
|
||||
#include "wx/sckstrm.h"
|
||||
|
||||
@@ -178,13 +179,14 @@ bool wxHTTP::Connect(wxSockAddress& addr, bool WXUNUSED(wait))
|
||||
|
||||
bool wxHTTP::BuildRequest(const wxString& path, wxHTTP_Req req)
|
||||
{
|
||||
char *tmp_buf;
|
||||
char buf[HTTP_BSIZE];
|
||||
const wxWX2MBbuf pathbuf = path.mb_str();
|
||||
wxChar *tmp_buf;
|
||||
wxCharBuffer buf("");
|
||||
const wxWX2MBbuf pathbuf;
|
||||
wxString tmp_str;
|
||||
|
||||
switch (req) {
|
||||
case wxHTTP_GET:
|
||||
tmp_buf = "GET";
|
||||
tmp_buf = _T("GET");
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
@@ -194,13 +196,12 @@ bool wxHTTP::BuildRequest(const wxString& path, wxHTTP_Req req)
|
||||
SetFlags(NONE);
|
||||
Notify(FALSE);
|
||||
|
||||
sprintf(buf, "%s %s\n\r", tmp_buf, (const char*) pathbuf);
|
||||
Write(buf, strlen(buf));
|
||||
tmp_str = wxURL::ConvertToValidURI(path);
|
||||
wxSprintf(buf, _T("%s %s\n\r"), tmp_buf, tmp_str.GetData());
|
||||
pathbuf = wxConvLibc.cWX2MB(buf);
|
||||
Write(pathbuf, strlen(pathbuf));
|
||||
SendHeaders();
|
||||
sprintf(buf, "\n\r");
|
||||
Write(buf, strlen(buf));
|
||||
|
||||
wxString tmp_str;
|
||||
Write("\n\r", 2);
|
||||
|
||||
m_error = GetLine(this, tmp_str);
|
||||
if (m_error != wxPROTO_NOERR) {
|
||||
|
@@ -33,9 +33,11 @@
|
||||
wxMemoryInputStream::wxMemoryInputStream(const char *data, size_t len)
|
||||
: wxInputStream()
|
||||
{
|
||||
/*
|
||||
m_i_streambuf->SetBufferIO((char*) data, (char*) (data+len));
|
||||
m_i_streambuf->SetIntPosition(0); // seek to start pos
|
||||
m_i_streambuf->Fixed(TRUE);
|
||||
*/
|
||||
m_length = len;
|
||||
}
|
||||
|
||||
@@ -45,7 +47,10 @@ wxMemoryInputStream::~wxMemoryInputStream()
|
||||
|
||||
char wxMemoryInputStream::Peek()
|
||||
{
|
||||
/*
|
||||
return m_i_streambuf->GetBufferStart()[m_i_streambuf->GetIntPosition()];
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -55,9 +60,11 @@ char wxMemoryInputStream::Peek()
|
||||
wxMemoryOutputStream::wxMemoryOutputStream(char *data, size_t len)
|
||||
: wxOutputStream()
|
||||
{
|
||||
/*
|
||||
if (data)
|
||||
m_o_streambuf->SetBufferIO(data, data+len);
|
||||
m_o_streambuf->Fixed(TRUE);
|
||||
*/
|
||||
}
|
||||
|
||||
wxMemoryOutputStream::~wxMemoryOutputStream()
|
||||
|
@@ -186,6 +186,8 @@ void *SocketWaiter::Entry()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// --------- SocketRequester ------------------------------------
|
||||
// --------------------------------------------------------------
|
||||
@@ -307,6 +309,8 @@ void SocketRequester::ProcessWaitEvent(SockRequest *req)
|
||||
m_internal->EndRequest(req);
|
||||
}
|
||||
|
||||
|
||||
#if wxUSE_THREADS
|
||||
void *SocketRequester::Entry()
|
||||
{
|
||||
SockRequest *req;
|
||||
|
@@ -229,7 +229,7 @@ bool wxTCPConnection::Execute (wxChar *data, int size, wxIPCFormat format)
|
||||
m_codeco->WriteString(data);
|
||||
else {
|
||||
m_codeco->Write32(size);
|
||||
m_codeco->Write(data, size);
|
||||
m_sockstrm->Write(data, size);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -256,7 +256,7 @@ char *wxTCPConnection::Request (const wxString& item, int *size, wxIPCFormat for
|
||||
|
||||
s = m_codeci->Read32();
|
||||
data = new char[s];
|
||||
m_codeci->Read(data, s);
|
||||
m_sockstrm->Read(data, s);
|
||||
|
||||
if (size)
|
||||
*size = s;
|
||||
@@ -276,7 +276,7 @@ bool wxTCPConnection::Poke (const wxString& item, wxChar *data, int size, wxIPCF
|
||||
m_codeco->WriteString(data);
|
||||
else {
|
||||
m_codeco->Write32(size);
|
||||
m_codeco->Write(data, size);
|
||||
m_sockstrm->Write(data, size);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -332,7 +332,7 @@ bool wxTCPConnection::Advise (const wxString& item,
|
||||
m_codeco->WriteString(data);
|
||||
else {
|
||||
m_codeco->Write32(size);
|
||||
m_codeco->Write(data, size);
|
||||
m_sockstrm->Write(data, size);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -345,6 +345,7 @@ void Client_OnRequest(wxSocketBase& sock, wxSocketBase::wxRequestEvent evt,
|
||||
wxTCPConnection *connection = (wxTCPConnection *)cdata;
|
||||
wxDataInputStream *codeci;
|
||||
wxDataOutputStream *codeco;
|
||||
wxSocketStream *sockstrm;
|
||||
wxString topic_name = connection->m_topic;
|
||||
wxString item;
|
||||
|
||||
@@ -358,6 +359,7 @@ void Client_OnRequest(wxSocketBase& sock, wxSocketBase::wxRequestEvent evt,
|
||||
// Receive message number.
|
||||
codeci = connection->m_codeci;
|
||||
codeco = connection->m_codeco;
|
||||
sockstrm = connection->m_sockstrm;
|
||||
msg = codeci->Read8();
|
||||
|
||||
switch (msg) {
|
||||
@@ -369,7 +371,7 @@ void Client_OnRequest(wxSocketBase& sock, wxSocketBase::wxRequestEvent evt,
|
||||
format = (wxIPCFormat)codeci->Read8();
|
||||
size = codeci->Read32();
|
||||
data = new char[size];
|
||||
codeci->Read(data, size);
|
||||
sockstrm->Read(data, size);
|
||||
|
||||
connection->OnExecute (topic_name, data, size, format);
|
||||
|
||||
@@ -385,7 +387,7 @@ void Client_OnRequest(wxSocketBase& sock, wxSocketBase::wxRequestEvent evt,
|
||||
format = (wxIPCFormat)codeci->Read8();
|
||||
size = codeci->Read32();
|
||||
data = new char[size];
|
||||
codeci->Read(data, size);
|
||||
sockstrm->Read(data, size);
|
||||
|
||||
connection->OnAdvise (topic_name, item, data, size, format);
|
||||
|
||||
@@ -423,7 +425,7 @@ void Client_OnRequest(wxSocketBase& sock, wxSocketBase::wxRequestEvent evt,
|
||||
format = (wxIPCFormat)codeci->Read8();
|
||||
size = codeci->Read32();
|
||||
data = new wxChar[size];
|
||||
codeci->Read(data, size);
|
||||
sockstrm->Read(data, size);
|
||||
|
||||
connection->OnPoke (topic_name, item, data, size, format);
|
||||
|
||||
@@ -444,7 +446,7 @@ void Client_OnRequest(wxSocketBase& sock, wxSocketBase::wxRequestEvent evt,
|
||||
codeco->Write8(IPC_REQUEST_REPLY);
|
||||
if (user_size != -1) {
|
||||
codeco->Write32(user_size);
|
||||
codeco->Write(user_data, user_size);
|
||||
sockstrm->Write(user_data, user_size);
|
||||
} else
|
||||
codeco->WriteString(user_data);
|
||||
} else
|
||||
|
@@ -43,16 +43,14 @@
|
||||
|
||||
wxStreamBuffer::wxStreamBuffer(wxStreamBase& stream, BufMode mode)
|
||||
: m_buffer_start(NULL), m_buffer_end(NULL), m_buffer_pos(NULL),
|
||||
m_buffer_size(0), m_wback(NULL), m_wbacksize(0), m_wbackcur(0),
|
||||
m_fixed(TRUE), m_flushable(TRUE), m_stream(&stream),
|
||||
m_buffer_size(0), m_fixed(TRUE), m_flushable(TRUE), m_stream(&stream),
|
||||
m_mode(mode), m_destroybuf(FALSE), m_destroystream(FALSE)
|
||||
{
|
||||
}
|
||||
|
||||
wxStreamBuffer::wxStreamBuffer(BufMode mode)
|
||||
: m_buffer_start(NULL), m_buffer_end(NULL), m_buffer_pos(NULL),
|
||||
m_buffer_size(0), m_wback(NULL), m_wbacksize(0), m_wbackcur(0),
|
||||
m_fixed(TRUE), m_flushable(FALSE), m_stream(NULL),
|
||||
m_buffer_size(0), m_fixed(TRUE), m_flushable(FALSE), m_stream(NULL),
|
||||
m_mode(mode), m_destroybuf(FALSE), m_destroystream(TRUE)
|
||||
{
|
||||
m_stream = new wxStreamBase();
|
||||
@@ -70,48 +68,16 @@ wxStreamBuffer::wxStreamBuffer(const wxStreamBuffer& buffer)
|
||||
m_mode = buffer.m_mode;
|
||||
m_destroybuf = FALSE;
|
||||
m_destroystream = FALSE;
|
||||
m_wback = NULL;
|
||||
m_wbacksize = 0;
|
||||
m_wbackcur = 0;
|
||||
}
|
||||
|
||||
wxStreamBuffer::~wxStreamBuffer()
|
||||
{
|
||||
if (m_wback)
|
||||
free(m_wback);
|
||||
if (m_destroybuf)
|
||||
wxDELETEA(m_buffer_start);
|
||||
if (m_destroystream)
|
||||
delete m_stream;
|
||||
}
|
||||
|
||||
size_t wxStreamBuffer::WriteBack(const char *buf, size_t bufsize)
|
||||
{
|
||||
char *ptrback;
|
||||
|
||||
if (m_mode != read)
|
||||
return 0;
|
||||
|
||||
ptrback = AllocSpaceWBack(bufsize);
|
||||
if (!ptrback)
|
||||
return 0;
|
||||
|
||||
memcpy(ptrback, buf, bufsize);
|
||||
return bufsize;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if (m_destroybuf)
|
||||
@@ -154,44 +120,6 @@ void wxStreamBuffer::ResetBuffer()
|
||||
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;
|
||||
m_wback = temp_b;
|
||||
|
||||
return (char *)(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;
|
||||
@@ -301,13 +229,6 @@ size_t wxStreamBuffer::Read(void *buffer, size_t size)
|
||||
// ------------------
|
||||
|
||||
m_stream->m_lasterror = wxStream_NOERROR;
|
||||
m_stream->m_lastcount = GetWBack((char *)buffer, size);
|
||||
size -= m_stream->m_lastcount;
|
||||
if (size == 0)
|
||||
return m_stream->m_lastcount;
|
||||
|
||||
buffer = (void *)((char *)buffer+m_stream->m_lastcount);
|
||||
|
||||
if (!m_buffer_size)
|
||||
return (m_stream->m_lastcount += m_stream->OnSysRead(buffer, size));
|
||||
|
||||
@@ -408,15 +329,18 @@ size_t wxStreamBuffer::Write(wxStreamBuffer *sbuf)
|
||||
{
|
||||
char buf[BUF_TEMP_SIZE];
|
||||
size_t s = 0, bytes_count = BUF_TEMP_SIZE, b_count2;
|
||||
wxInputStream *in_stream;
|
||||
|
||||
if (m_mode == read)
|
||||
return 0;
|
||||
|
||||
in_stream = (wxInputStream *)sbuf->Stream();
|
||||
|
||||
while (bytes_count == BUF_TEMP_SIZE) {
|
||||
b_count2 = sbuf->Read(buf, bytes_count);
|
||||
bytes_count = Write(buf, b_count2);
|
||||
if (b_count2 > bytes_count)
|
||||
sbuf->WriteBack(buf+bytes_count, b_count2-bytes_count);
|
||||
in_stream->Ungetch(buf+bytes_count, b_count2-bytes_count);
|
||||
s += bytes_count;
|
||||
}
|
||||
return s;
|
||||
@@ -523,78 +447,115 @@ off_t wxStreamBase::OnSysTell() const
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxInputStream::wxInputStream()
|
||||
: wxStreamBase()
|
||||
: wxStreamBase(),
|
||||
m_wback(NULL), m_wbacksize(0), m_wbackcur(0)
|
||||
{
|
||||
m_i_destroybuf = TRUE;
|
||||
m_i_streambuf = new wxStreamBuffer(*this, wxStreamBuffer::read);
|
||||
}
|
||||
|
||||
wxInputStream::wxInputStream(wxStreamBuffer *buffer)
|
||||
: wxStreamBase()
|
||||
{
|
||||
m_i_destroybuf = FALSE;
|
||||
m_i_streambuf = buffer;
|
||||
}
|
||||
|
||||
wxInputStream::~wxInputStream()
|
||||
{
|
||||
if (m_i_destroybuf)
|
||||
delete m_i_streambuf;
|
||||
if (m_wback)
|
||||
free(m_wback);
|
||||
}
|
||||
|
||||
char *wxInputStream::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;
|
||||
m_wback = temp_b;
|
||||
|
||||
return (char *)(m_wback+(m_wbacksize-needed_size));
|
||||
}
|
||||
|
||||
size_t wxInputStream::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;
|
||||
}
|
||||
|
||||
size_t wxInputStream::Ungetch(void *buf, size_t bufsize)
|
||||
{
|
||||
char *ptrback;
|
||||
|
||||
ptrback = AllocSpaceWBack(bufsize);
|
||||
if (!ptrback)
|
||||
return 0;
|
||||
|
||||
memcpy(ptrback, buf, bufsize);
|
||||
return bufsize;
|
||||
}
|
||||
|
||||
bool wxInputStream::Ungetch(char c)
|
||||
{
|
||||
char *ptrback;
|
||||
|
||||
ptrback = AllocSpaceWBack(1);
|
||||
if (!ptrback)
|
||||
return FALSE;
|
||||
|
||||
*ptrback = c;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
char wxInputStream::GetC()
|
||||
{
|
||||
char c;
|
||||
m_i_streambuf->Read(&c, 1);
|
||||
Read(&c, 1);
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
wxString wxInputStream::ReadLine()
|
||||
{
|
||||
char c, last_endl = 0;
|
||||
bool end_line = FALSE;
|
||||
wxString line;
|
||||
|
||||
while (!end_line) {
|
||||
c = GetC();
|
||||
if (LastError() != wxStream_NOERROR)
|
||||
break;
|
||||
|
||||
switch (c) {
|
||||
case '\n':
|
||||
end_line = TRUE;
|
||||
break;
|
||||
case '\r':
|
||||
last_endl = '\r';
|
||||
break;
|
||||
default:
|
||||
if (last_endl == '\r') {
|
||||
end_line = TRUE;
|
||||
InputStreamBuffer()->WriteBack(c);
|
||||
break;
|
||||
}
|
||||
line += c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return line;
|
||||
}
|
||||
|
||||
wxInputStream& wxInputStream::Read(void *buffer, size_t size)
|
||||
{
|
||||
m_i_streambuf->Read(buffer, size);
|
||||
// wxStreamBuffer sets all variables for us
|
||||
size_t retsize;
|
||||
char *buf = (char *)buffer;
|
||||
|
||||
retsize = GetWBack(buf, size);
|
||||
if (retsize == size) {
|
||||
m_lastcount = size;
|
||||
m_lasterror = wxStream_NOERROR;
|
||||
return *this;
|
||||
}
|
||||
size -= retsize;
|
||||
buf += retsize;
|
||||
|
||||
m_lastcount = OnSysRead(buf, size);
|
||||
return *this;
|
||||
}
|
||||
|
||||
char wxInputStream::Peek()
|
||||
{
|
||||
m_i_streambuf->GetDataLeft();
|
||||
char c;
|
||||
|
||||
return *(m_i_streambuf->GetBufferPos());
|
||||
Read(&c, 1);
|
||||
if (m_lasterror == wxStream_NOERROR) {
|
||||
Ungetch(c);
|
||||
return c;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
wxInputStream& wxInputStream::Read(wxOutputStream& stream_out)
|
||||
{
|
||||
@@ -610,168 +571,18 @@ wxInputStream& wxInputStream::Read(wxOutputStream& stream_out)
|
||||
|
||||
off_t wxInputStream::SeekI(off_t pos, wxSeekMode mode)
|
||||
{
|
||||
return m_i_streambuf->Seek(pos, mode);
|
||||
return wxInvalidOffset;
|
||||
}
|
||||
|
||||
off_t wxInputStream::TellI() const
|
||||
{
|
||||
return m_i_streambuf->Tell();
|
||||
return wxInvalidOffset;
|
||||
}
|
||||
|
||||
// --------------------
|
||||
// Overloaded operators
|
||||
// --------------------
|
||||
|
||||
wxInputStream& wxInputStream::operator>>(wxString& line)
|
||||
{
|
||||
line = ReadLine();
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxInputStream& wxInputStream::operator>>(char& c)
|
||||
{
|
||||
c = GetC();
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxInputStream& wxInputStream::operator>>(signed short& i)
|
||||
{
|
||||
signed long l;
|
||||
|
||||
*this >> l;
|
||||
i = (signed short)l;
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxInputStream& wxInputStream::operator>>(signed int& i)
|
||||
{
|
||||
signed long l;
|
||||
|
||||
*this >> l;
|
||||
i = (signed int)l;
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxInputStream& wxInputStream::operator>>(signed long& i)
|
||||
{
|
||||
/* I only implemented a simple integer parser */
|
||||
int c;
|
||||
int sign;
|
||||
|
||||
while (isspace( c = GetC() ) )
|
||||
/* Do nothing */ ;
|
||||
|
||||
i = 0;
|
||||
if (! (c == '-' || isdigit(c)) ) {
|
||||
InputStreamBuffer()->WriteBack(c);
|
||||
return *this;
|
||||
}
|
||||
|
||||
if (c == '-') {
|
||||
sign = -1;
|
||||
c = GetC();
|
||||
} else if (c == '+') {
|
||||
sign = 1;
|
||||
c = GetC();
|
||||
} else {
|
||||
sign = 1;
|
||||
}
|
||||
|
||||
while (isdigit(c)) {
|
||||
i = i*10 + (c - (int)'0');
|
||||
c = GetC();
|
||||
}
|
||||
|
||||
i *= sign;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxInputStream& wxInputStream::operator>>(unsigned short& i)
|
||||
{
|
||||
unsigned long l;
|
||||
|
||||
*this >> l;
|
||||
i = (unsigned short)l;
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxInputStream& wxInputStream::operator>>(unsigned int& i)
|
||||
{
|
||||
unsigned long l;
|
||||
|
||||
*this >> l;
|
||||
i = (unsigned int)l;
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxInputStream& wxInputStream::operator>>(unsigned long& i)
|
||||
{
|
||||
/* I only implemented a simple integer parser */
|
||||
int c;
|
||||
|
||||
while (isspace( c = GetC() ) )
|
||||
/* Do nothing */ ;
|
||||
|
||||
i = 0;
|
||||
if (!isdigit(c)) {
|
||||
InputStreamBuffer()->WriteBack(c);
|
||||
return *this;
|
||||
}
|
||||
|
||||
while (isdigit(c)) {
|
||||
i = i*10 + c - '0';
|
||||
c = GetC();
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxInputStream& wxInputStream::operator>>(double& f)
|
||||
{
|
||||
/* I only implemented a simple float parser */
|
||||
int c, sign;
|
||||
|
||||
while (isspace( c = GetC() ) )
|
||||
/* Do nothing */ ;
|
||||
|
||||
f = 0.0;
|
||||
if (! (c == '-' || isdigit(c)) ) {
|
||||
InputStreamBuffer()->WriteBack(c);
|
||||
return *this;
|
||||
}
|
||||
|
||||
if (c == '-') {
|
||||
sign = -1;
|
||||
c = GetC();
|
||||
} else if (c == '+') {
|
||||
sign = 1;
|
||||
c = GetC();
|
||||
} else {
|
||||
sign = 1;
|
||||
}
|
||||
|
||||
while (isdigit(c)) {
|
||||
f = f*10 + (c - '0');
|
||||
c = GetC();
|
||||
}
|
||||
|
||||
if (c == '.') {
|
||||
double f_multiplicator = (double) 0.1;
|
||||
c = GetC();
|
||||
|
||||
while (isdigit(c)) {
|
||||
f += (c-'0')*f_multiplicator;
|
||||
f_multiplicator /= 10;
|
||||
c = GetC();
|
||||
}
|
||||
}
|
||||
|
||||
f *= sign;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if wxUSE_SERIAL
|
||||
wxInputStream& wxInputStream::operator>>(wxObject *& obj)
|
||||
{
|
||||
@@ -788,26 +599,15 @@ wxInputStream& wxInputStream::operator>>(wxObject *& obj)
|
||||
wxOutputStream::wxOutputStream()
|
||||
: wxStreamBase()
|
||||
{
|
||||
m_o_destroybuf = TRUE;
|
||||
m_o_streambuf = new wxStreamBuffer(*this, wxStreamBuffer::write);
|
||||
}
|
||||
|
||||
wxOutputStream::wxOutputStream(wxStreamBuffer *buffer)
|
||||
: wxStreamBase()
|
||||
{
|
||||
m_o_destroybuf = FALSE;
|
||||
m_o_streambuf = buffer;
|
||||
}
|
||||
|
||||
wxOutputStream::~wxOutputStream()
|
||||
{
|
||||
if (m_o_destroybuf)
|
||||
delete m_o_streambuf;
|
||||
}
|
||||
|
||||
wxOutputStream& wxOutputStream::Write(const void *buffer, size_t size)
|
||||
{
|
||||
m_o_streambuf->Write(buffer, size);
|
||||
m_lastcount = OnSysWrite(buffer, size);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -819,98 +619,16 @@ wxOutputStream& wxOutputStream::Write(wxInputStream& stream_in)
|
||||
|
||||
off_t wxOutputStream::TellO() const
|
||||
{
|
||||
return m_o_streambuf->Tell();
|
||||
return wxInvalidOffset;
|
||||
}
|
||||
|
||||
off_t wxOutputStream::SeekO(off_t pos, wxSeekMode mode)
|
||||
{
|
||||
return m_o_streambuf->Seek(pos, mode);
|
||||
return wxInvalidOffset;
|
||||
}
|
||||
|
||||
void wxOutputStream::Sync()
|
||||
{
|
||||
m_o_streambuf->FlushBuffer();
|
||||
}
|
||||
|
||||
void wxOutputStream::WriteLine(const wxString& line)
|
||||
{
|
||||
#ifdef __WXMSW__
|
||||
wxString tmp_string = line + _T("\r\n");
|
||||
#else
|
||||
#ifdef __WXMAC__
|
||||
wxString tmp_string = line + _T('\r');
|
||||
#else
|
||||
wxString tmp_string = line + _T('\n');
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Write((const wxChar *) tmp_string, tmp_string.Length()*sizeof(wxChar));
|
||||
}
|
||||
|
||||
wxOutputStream& wxOutputStream::operator<<(const char *string)
|
||||
{
|
||||
return Write(string, strlen(string));
|
||||
}
|
||||
|
||||
wxOutputStream& wxOutputStream::operator<<(wxString& string)
|
||||
{
|
||||
#if wxUSE_UNICODE
|
||||
const wxWX2MBbuf buf = string.mb_str();
|
||||
return *this << buf;
|
||||
#else
|
||||
return Write(string, string.Len());
|
||||
#endif
|
||||
}
|
||||
|
||||
wxOutputStream& wxOutputStream::operator<<(char c)
|
||||
{
|
||||
return Write(&c, 1);
|
||||
}
|
||||
|
||||
wxOutputStream& wxOutputStream::operator<<(signed short i)
|
||||
{
|
||||
signed long l = (signed long)i;
|
||||
return *this << l;
|
||||
}
|
||||
|
||||
wxOutputStream& wxOutputStream::operator<<(signed int i)
|
||||
{
|
||||
signed long l = (signed long)i;
|
||||
return *this << l;
|
||||
}
|
||||
|
||||
wxOutputStream& wxOutputStream::operator<<(signed long i)
|
||||
{
|
||||
wxString strlong;
|
||||
strlong.Printf(_T("%ld"), i);
|
||||
return *this << strlong;
|
||||
}
|
||||
|
||||
wxOutputStream& wxOutputStream::operator<<(unsigned short i)
|
||||
{
|
||||
unsigned long l = (unsigned long)i;
|
||||
return *this << l;
|
||||
}
|
||||
|
||||
wxOutputStream& wxOutputStream::operator<<(unsigned int i)
|
||||
{
|
||||
unsigned long l = (unsigned long)i;
|
||||
return *this << l;
|
||||
}
|
||||
|
||||
wxOutputStream& wxOutputStream::operator<<(unsigned long i)
|
||||
{
|
||||
wxString strlong;
|
||||
strlong.Printf(_T("%lu"), i);
|
||||
return *this << strlong;
|
||||
}
|
||||
|
||||
wxOutputStream& wxOutputStream::operator<<(double f)
|
||||
{
|
||||
wxString strfloat;
|
||||
|
||||
strfloat.Printf(_T("%f"), f);
|
||||
return *this << strfloat;
|
||||
}
|
||||
|
||||
#if wxUSE_SERIAL
|
||||
@@ -926,13 +644,12 @@ wxOutputStream& wxOutputStream::operator<<(wxObject& obj)
|
||||
// wxFilterInputStream
|
||||
// ----------------------------------------------------------------------------
|
||||
wxFilterInputStream::wxFilterInputStream()
|
||||
: wxInputStream(NULL)
|
||||
: wxInputStream()
|
||||
{
|
||||
// WARNING streambuf set to NULL !
|
||||
}
|
||||
|
||||
wxFilterInputStream::wxFilterInputStream(wxInputStream& stream)
|
||||
: wxInputStream(stream.InputStreamBuffer())
|
||||
: wxInputStream()
|
||||
{
|
||||
m_parent_i_stream = &stream;
|
||||
}
|
||||
@@ -945,12 +662,12 @@ wxFilterInputStream::~wxFilterInputStream()
|
||||
// wxFilterOutputStream
|
||||
// ----------------------------------------------------------------------------
|
||||
wxFilterOutputStream::wxFilterOutputStream()
|
||||
: wxOutputStream(NULL)
|
||||
: wxOutputStream()
|
||||
{
|
||||
}
|
||||
|
||||
wxFilterOutputStream::wxFilterOutputStream(wxOutputStream& stream)
|
||||
: wxOutputStream(stream.OutputStreamBuffer())
|
||||
: wxOutputStream()
|
||||
{
|
||||
m_parent_o_stream = &stream;
|
||||
}
|
||||
@@ -959,6 +676,118 @@ wxFilterOutputStream::~wxFilterOutputStream()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxBufferedInputStream
|
||||
// ----------------------------------------------------------------------------
|
||||
wxBufferedInputStream::wxBufferedInputStream(wxInputStream& s)
|
||||
: wxFilterInputStream(s)
|
||||
{
|
||||
m_i_streambuf = new wxStreamBuffer(*this, wxStreamBuffer::read);
|
||||
m_i_streambuf->SetBufferIO(1024);
|
||||
}
|
||||
|
||||
wxBufferedInputStream::~wxBufferedInputStream()
|
||||
{
|
||||
delete m_i_streambuf;
|
||||
}
|
||||
|
||||
wxInputStream& wxBufferedInputStream::Read(void *buffer, size_t size)
|
||||
{
|
||||
size_t retsize;
|
||||
char *buf = (char *)buffer;
|
||||
|
||||
retsize = GetWBack(buf, size);
|
||||
if (retsize == size) {
|
||||
m_lastcount = size;
|
||||
m_lasterror = wxStream_NOERROR;
|
||||
return *this;
|
||||
}
|
||||
size -= retsize;
|
||||
buf += retsize;
|
||||
|
||||
m_i_streambuf->Read(buf, size);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
off_t wxBufferedInputStream::SeekI(off_t pos, wxSeekMode mode)
|
||||
{
|
||||
return m_i_streambuf->Seek(pos, mode);
|
||||
}
|
||||
|
||||
off_t wxBufferedInputStream::TellI() const
|
||||
{
|
||||
return m_i_streambuf->Tell();
|
||||
}
|
||||
|
||||
size_t wxBufferedInputStream::OnSysRead(void *buffer, size_t bufsize)
|
||||
{
|
||||
return m_parent_i_stream->Read(buffer, bufsize).LastRead();
|
||||
}
|
||||
|
||||
off_t wxBufferedInputStream::OnSysSeek(off_t seek, wxSeekMode mode)
|
||||
{
|
||||
return m_parent_i_stream->SeekI(seek, mode);
|
||||
}
|
||||
|
||||
off_t wxBufferedInputStream::OnSysTell() const
|
||||
{
|
||||
return m_parent_i_stream->TellI();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxBufferedOutputStream
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxBufferedOutputStream::wxBufferedOutputStream(wxOutputStream& s)
|
||||
: wxFilterOutputStream(s)
|
||||
{
|
||||
m_o_streambuf = new wxStreamBuffer(*this, wxStreamBuffer::write);
|
||||
m_o_streambuf->SetBufferIO(1024);
|
||||
}
|
||||
|
||||
wxBufferedOutputStream::~wxBufferedOutputStream()
|
||||
{
|
||||
delete m_o_streambuf;
|
||||
}
|
||||
|
||||
wxOutputStream& wxBufferedOutputStream::Write(const void *buffer, size_t size)
|
||||
{
|
||||
m_o_streambuf->Write(buffer, size);
|
||||
return *this;
|
||||
}
|
||||
|
||||
off_t wxBufferedOutputStream::SeekO(off_t pos, wxSeekMode mode)
|
||||
{
|
||||
return m_o_streambuf->Seek(pos, mode);
|
||||
}
|
||||
|
||||
off_t wxBufferedOutputStream::TellO() const
|
||||
{
|
||||
return m_o_streambuf->Tell();
|
||||
}
|
||||
|
||||
void wxBufferedOutputStream::Sync()
|
||||
{
|
||||
m_o_streambuf->FlushBuffer();
|
||||
m_parent_o_stream->Sync();
|
||||
}
|
||||
|
||||
size_t wxBufferedOutputStream::OnSysWrite(const void *buffer, size_t bufsize)
|
||||
{
|
||||
return m_parent_o_stream->Write(buffer, bufsize).LastWrite();
|
||||
}
|
||||
|
||||
off_t wxBufferedOutputStream::OnSysSeek(off_t seek, wxSeekMode mode)
|
||||
{
|
||||
return m_parent_o_stream->SeekO(seek, mode);
|
||||
}
|
||||
|
||||
off_t wxBufferedOutputStream::OnSysTell() const
|
||||
{
|
||||
return m_parent_o_stream->TellO();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Some IOManip function
|
||||
// ----------------------------------------------------------------------------
|
||||
|
352
src/common/txtstrm.cpp
Normal file
352
src/common/txtstrm.cpp
Normal file
@@ -0,0 +1,352 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// Name: txtstrm.cpp
|
||||
// Purpose: Text stream classes
|
||||
// Author: Guilhem Lavaux
|
||||
// Modified by:
|
||||
// Created: 28/06/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Guilhem Lavaux
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "txtstrm.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#if wxUSE_STREAMS
|
||||
|
||||
#include "wx/txtstrm.h"
|
||||
|
||||
wxTextInputStream::wxTextInputStream(wxInputStream& s)
|
||||
: m_input(&s)
|
||||
{
|
||||
}
|
||||
|
||||
wxTextInputStream::~wxTextInputStream()
|
||||
{
|
||||
}
|
||||
|
||||
wxUint32 wxTextInputStream::Read32()
|
||||
{
|
||||
/* I only implemented a simple integer parser */
|
||||
int c;
|
||||
int sign;
|
||||
wxInt32 i;
|
||||
|
||||
while (isspace( c = m_input->GetC() ) )
|
||||
/* Do nothing */ ;
|
||||
|
||||
i = 0;
|
||||
if (! (c == '-' || isdigit(c)) ) {
|
||||
m_input->Ungetch(c);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (c == '-') {
|
||||
sign = -1;
|
||||
c = m_input->GetC();
|
||||
} else if (c == '+') {
|
||||
sign = 1;
|
||||
c = m_input->GetC();
|
||||
} else {
|
||||
sign = 1;
|
||||
}
|
||||
|
||||
while (isdigit(c)) {
|
||||
i = i*10 + (c - (int)'0');
|
||||
c = m_input->GetC();
|
||||
}
|
||||
|
||||
if (c != '\n' && c != '\r')
|
||||
m_input->Ungetch(c);
|
||||
|
||||
i *= sign;
|
||||
|
||||
return (wxUint32)i;
|
||||
}
|
||||
|
||||
wxUint16 wxTextInputStream::Read16()
|
||||
{
|
||||
return (wxUint16)Read32();
|
||||
}
|
||||
|
||||
wxUint8 wxTextInputStream::Read8()
|
||||
{
|
||||
return (wxUint8)Read32();
|
||||
}
|
||||
|
||||
double wxTextInputStream::ReadDouble()
|
||||
{
|
||||
/* I only implemented a simple float parser */
|
||||
double f;
|
||||
int c, sign;
|
||||
|
||||
while (isspace( c = m_input->GetC() ) || c == '\n' || c == '\r')
|
||||
/* Do nothing */ ;
|
||||
|
||||
f = 0.0;
|
||||
if (! (c == '-' || isdigit(c)) ) {
|
||||
m_input->Ungetch(c);
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
if (c == '-') {
|
||||
sign = -1;
|
||||
c = m_input->GetC();
|
||||
} else if (c == '+') {
|
||||
sign = 1;
|
||||
c = m_input->GetC();
|
||||
} else {
|
||||
sign = 1;
|
||||
}
|
||||
|
||||
while (isdigit(c)) {
|
||||
f = f*10 + (c - '0');
|
||||
c = m_input->GetC();
|
||||
}
|
||||
|
||||
if (c == '.') {
|
||||
double f_multiplicator = (double) 0.1;
|
||||
|
||||
c = m_input->GetC();
|
||||
|
||||
while (isdigit(c)) {
|
||||
f += (c-'0')*f_multiplicator;
|
||||
f_multiplicator /= 10;
|
||||
c = m_input->GetC();
|
||||
}
|
||||
|
||||
if (c == 'e') {
|
||||
double f_multiplicator = 0.0;
|
||||
int i, e;
|
||||
|
||||
c = m_input->GetC();
|
||||
|
||||
switch(c) {
|
||||
case '-':
|
||||
f_multiplicator = 0.1;
|
||||
break;
|
||||
case '+':
|
||||
f_multiplicator = 10.0;
|
||||
break;
|
||||
}
|
||||
|
||||
e = Read8();
|
||||
|
||||
for (i=0;i<e;i++)
|
||||
f *= f_multiplicator;
|
||||
} else if (c != '\n' && c != '\r')
|
||||
m_input->Ungetch(c);
|
||||
|
||||
}
|
||||
|
||||
f *= sign;
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
wxString wxTextInputStream::ReadString()
|
||||
{
|
||||
char c, last_endl = 0;
|
||||
bool end_line = FALSE;
|
||||
wxString line;
|
||||
|
||||
while (!end_line) {
|
||||
c = m_input->GetC();
|
||||
if (m_input->LastError() != wxStream_NOERROR)
|
||||
break;
|
||||
|
||||
switch (c) {
|
||||
case '\n':
|
||||
end_line = TRUE;
|
||||
break;
|
||||
case '\r':
|
||||
last_endl = '\r';
|
||||
break;
|
||||
default:
|
||||
if (last_endl == '\r') {
|
||||
end_line = TRUE;
|
||||
m_input->Ungetch(c);
|
||||
break;
|
||||
}
|
||||
line += c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return line;
|
||||
}
|
||||
|
||||
wxTextInputStream& wxTextInputStream::operator>>(wxString& line)
|
||||
{
|
||||
line = ReadString();
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxTextInputStream& wxTextInputStream::operator>>(wxInt8& c)
|
||||
{
|
||||
c = (wxInt8)Read8();
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxTextInputStream& wxTextInputStream::operator>>(wxInt16& i)
|
||||
{
|
||||
i = (wxInt16)Read16();
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxTextInputStream& wxTextInputStream::operator>>(wxInt32& i)
|
||||
{
|
||||
i = (wxInt32)Read32();
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxTextInputStream& wxTextInputStream::operator>>(wxUint8& c)
|
||||
{
|
||||
c = Read8();
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxTextInputStream& wxTextInputStream::operator>>(wxUint16& i)
|
||||
{
|
||||
i = Read16();
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxTextInputStream& wxTextInputStream::operator>>(wxUint32& i)
|
||||
{
|
||||
i = Read32();
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxTextInputStream& wxTextInputStream::operator>>(double& i)
|
||||
{
|
||||
i = ReadDouble();
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxTextInputStream& wxTextInputStream::operator>>(float& f)
|
||||
{
|
||||
f = (float)ReadDouble();
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxTextOutputStream::wxTextOutputStream(wxOutputStream& s)
|
||||
: m_output(&s)
|
||||
{
|
||||
}
|
||||
|
||||
wxTextOutputStream::~wxTextOutputStream()
|
||||
{
|
||||
}
|
||||
|
||||
void wxTextOutputStream::Write32(wxUint32 i)
|
||||
{
|
||||
wxString str;
|
||||
|
||||
str.Printf(_T("%u"), i);
|
||||
WriteString(str);
|
||||
}
|
||||
|
||||
void wxTextOutputStream::Write16(wxUint16 i)
|
||||
{
|
||||
wxString str;
|
||||
|
||||
str.Printf(_T("%u"), i);
|
||||
WriteString(str);
|
||||
}
|
||||
|
||||
void wxTextOutputStream::Write8(wxUint8 i)
|
||||
{
|
||||
wxString str;
|
||||
|
||||
str.Printf(_T("%u"), i);
|
||||
WriteString(str);
|
||||
}
|
||||
|
||||
void wxTextOutputStream::WriteDouble(double d)
|
||||
{
|
||||
wxString str;
|
||||
|
||||
str.Printf(_T("%f"), d);
|
||||
WriteString(str);
|
||||
}
|
||||
|
||||
void wxTextOutputStream::WriteString(const wxString& string)
|
||||
{
|
||||
#if wxUSE_UNICODE
|
||||
const wxWX2MBbuf buf = string.mb_str();
|
||||
m_output->Write(buf, string.Len());
|
||||
#else
|
||||
m_output->Write(string, string.Len());
|
||||
#endif
|
||||
}
|
||||
|
||||
wxTextOutputStream& wxTextOutputStream::operator<<(const wxChar *string)
|
||||
{
|
||||
WriteString(wxString(string));
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxTextOutputStream& wxTextOutputStream::operator<<(const wxString& string)
|
||||
{
|
||||
WriteString(string);
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxTextOutputStream& wxTextOutputStream::operator<<(wxInt8 c)
|
||||
{
|
||||
Write8((wxUint8)c);
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxTextOutputStream& wxTextOutputStream::operator<<(wxInt16 c)
|
||||
{
|
||||
Write16((wxUint16)c);
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxTextOutputStream& wxTextOutputStream::operator<<(wxInt32 c)
|
||||
{
|
||||
Write32((wxUint32)c);
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxTextOutputStream& wxTextOutputStream::operator<<(wxUint8 c)
|
||||
{
|
||||
Write8(c);
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxTextOutputStream& wxTextOutputStream::operator<<(wxUint16 c)
|
||||
{
|
||||
Write16(c);
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxTextOutputStream& wxTextOutputStream::operator<<(wxUint32 c)
|
||||
{
|
||||
Write32(c);
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxTextOutputStream &wxTextOutputStream::operator<<(double f)
|
||||
{
|
||||
WriteDouble(f);
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxTextOutputStream& wxTextOutputStream::operator<<(float f)
|
||||
{
|
||||
WriteDouble((double)f);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif
|
||||
// wxUSE_STREAMS
|
@@ -45,15 +45,13 @@ IMPLEMENT_CLASS(wxURL, wxObject)
|
||||
wxProtoInfo *wxURL::g_protocols = NULL;
|
||||
wxHTTP *wxURL::g_proxy;
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// wxURL ////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// --------------------------------------------------------------
|
||||
// wxURL
|
||||
// --------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* --------------------------------------------------------------
|
||||
* --------- wxURL CONSTRUCTOR DESTRUCTOR -----------------------
|
||||
* --------------------------------------------------------------
|
||||
*/
|
||||
// --------------------------------------------------------------
|
||||
// --------- wxURL CONSTRUCTOR DESTRUCTOR -----------------------
|
||||
// --------------------------------------------------------------
|
||||
|
||||
wxURL::wxURL(const wxString& url)
|
||||
{
|
||||
@@ -118,11 +116,10 @@ wxURL::~wxURL()
|
||||
CleanData();
|
||||
}
|
||||
|
||||
/*
|
||||
* --------------------------------------------------------------
|
||||
* --------- wxURL urls decoders --------------------------------
|
||||
* --------------------------------------------------------------
|
||||
*/
|
||||
// --------------------------------------------------------------
|
||||
// --------- wxURL urls decoders --------------------------------
|
||||
// --------------------------------------------------------------
|
||||
|
||||
bool wxURL::PrepProto(wxString& url)
|
||||
{
|
||||
int pos;
|
||||
@@ -219,11 +216,10 @@ bool wxURL::FetchProtocol()
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* --------------------------------------------------------------
|
||||
* --------- wxURL get ------------------------------------------
|
||||
* --------------------------------------------------------------
|
||||
*/
|
||||
// --------------------------------------------------------------
|
||||
// --------- wxURL get ------------------------------------------
|
||||
// --------------------------------------------------------------
|
||||
|
||||
wxInputStream *wxURL::GetInputStream(void)
|
||||
{
|
||||
wxIPV4address addr;
|
||||
@@ -318,7 +314,22 @@ void wxURL::SetProxy(const wxString& url_proxy)
|
||||
|
||||
wxString wxURL::ConvertToValidURI(const wxString& uri)
|
||||
{
|
||||
return wxString(uri);
|
||||
wxString out_str;
|
||||
wxString hexa_code;
|
||||
size_t i;
|
||||
|
||||
for (i=0;i<uri.Len();i++) {
|
||||
wxChar c = uri.GetChar(i);
|
||||
|
||||
if (!isalpha(c) && c != _T('.') && c != _T('+') && c != _T('.') &&
|
||||
c != _T('/')) {
|
||||
hexa_code.Printf(_T("%02X"), c);
|
||||
out_str += hexa_code;
|
||||
} else
|
||||
out_str += c;
|
||||
}
|
||||
|
||||
return out_str;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -203,9 +203,9 @@ bool wxGenericValidator::TransferToWindow(void)
|
||||
pControl->SetSelection(*m_pInt) ;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
else if (m_validatorWindow->IsKindOf(CLASSINFO(wxStaticText)) )
|
||||
if (m_validatorWindow->IsKindOf(CLASSINFO(wxStaticText)) )
|
||||
{
|
||||
wxStaticText* pControl = (wxStaticText*) m_validatorWindow;
|
||||
if (m_pString)
|
||||
|
@@ -26,7 +26,11 @@
|
||||
# include <fstream>
|
||||
#endif
|
||||
|
||||
#if wxUSE_STREAMS
|
||||
#include "wx/stream.h"
|
||||
#include "wx/txtstrm.h"
|
||||
#endif
|
||||
|
||||
#include "wx/string.h"
|
||||
#include "wx/variant.h"
|
||||
|
||||
@@ -371,13 +375,16 @@ bool wxVariantDataLong::Read(istream& str)
|
||||
#if wxUSE_STREAMS
|
||||
bool wxVariantDataLong::Write(wxOutputStream& str) const
|
||||
{
|
||||
str << m_value;
|
||||
wxTextOutputStream s(str);
|
||||
|
||||
s.Write32(m_value);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxVariantDataLong::Read(wxInputStream& str)
|
||||
{
|
||||
str >> m_value;
|
||||
wxTextInputStream s(str);
|
||||
m_value = s.Read32();
|
||||
return TRUE;
|
||||
}
|
||||
#endif // wxUSE_STREAMS
|
||||
@@ -469,13 +476,15 @@ bool wxVariantDataReal::Read(istream& str)
|
||||
#if wxUSE_STREAMS
|
||||
bool wxVariantDataReal::Write(wxOutputStream& str) const
|
||||
{
|
||||
str << m_value;
|
||||
wxTextOutputStream s(str);
|
||||
s.WriteDouble((double)m_value);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxVariantDataReal::Read(wxInputStream& str)
|
||||
{
|
||||
str >> (float&)m_value;
|
||||
wxTextInputStream s(str);
|
||||
m_value = (float)s.ReadDouble();
|
||||
return TRUE;
|
||||
}
|
||||
#endif // wxUSE_STREAMS
|
||||
@@ -569,13 +578,17 @@ bool wxVariantDataBool::Read(istream& WXUNUSED(str))
|
||||
#if wxUSE_STREAMS
|
||||
bool wxVariantDataBool::Write(wxOutputStream& str) const
|
||||
{
|
||||
str << (char)m_value;
|
||||
wxTextOutputStream s(str);
|
||||
|
||||
s.Write8(m_value);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxVariantDataBool::Read(wxInputStream& str)
|
||||
{
|
||||
str >> (char&)m_value;
|
||||
wxTextInputStream s(str);
|
||||
|
||||
m_value = s.Read8();
|
||||
return TRUE;
|
||||
}
|
||||
#endif // wxUSE_STREAMS
|
||||
@@ -667,13 +680,17 @@ bool wxVariantDataChar::Read(istream& WXUNUSED(str))
|
||||
#if wxUSE_STREAMS
|
||||
bool wxVariantDataChar::Write(wxOutputStream& str) const
|
||||
{
|
||||
str << m_value;
|
||||
wxTextOutputStream s(str);
|
||||
|
||||
s.Write8(m_value);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxVariantDataChar::Read(wxInputStream& str)
|
||||
{
|
||||
str >> m_value;
|
||||
wxTextInputStream s(str);
|
||||
|
||||
m_value = s.Read8();
|
||||
return TRUE;
|
||||
}
|
||||
#endif // wxUSE_STREAMS
|
||||
@@ -771,13 +788,16 @@ bool wxVariantDataString::Read(istream& str)
|
||||
bool wxVariantDataString::Write(wxOutputStream& str) const
|
||||
{
|
||||
// why doesn't wxOutputStream::operator<< take "const wxString&"
|
||||
str << (const char*) m_value.mb_str();
|
||||
wxTextOutputStream s(str);
|
||||
s.WriteString(m_value);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxVariantDataString::Read(wxInputStream& str)
|
||||
{
|
||||
str >> m_value;
|
||||
wxTextInputStream s(str);
|
||||
|
||||
m_value = s.ReadString();
|
||||
return TRUE;
|
||||
}
|
||||
#endif // wxUSE_STREAMS
|
||||
|
@@ -39,7 +39,6 @@ wxFileInputStream::wxFileInputStream(const wxString& fileName)
|
||||
{
|
||||
m_file = new wxFile(fileName, wxFile::read);
|
||||
m_file_destroy = TRUE;
|
||||
m_i_streambuf->SetBufferIO(1024);
|
||||
}
|
||||
|
||||
wxFileInputStream::wxFileInputStream()
|
||||
@@ -53,14 +52,12 @@ wxFileInputStream::wxFileInputStream(wxFile& file)
|
||||
{
|
||||
m_file = &file;
|
||||
m_file_destroy = FALSE;
|
||||
m_i_streambuf->SetBufferIO(1024);
|
||||
}
|
||||
|
||||
wxFileInputStream::wxFileInputStream(int fd)
|
||||
{
|
||||
m_file = new wxFile(fd);
|
||||
m_file_destroy = TRUE;
|
||||
m_i_streambuf->SetBufferIO(1024);
|
||||
}
|
||||
|
||||
wxFileInputStream::~wxFileInputStream()
|
||||
@@ -81,7 +78,18 @@ size_t wxFileInputStream::StreamSize() const
|
||||
|
||||
size_t wxFileInputStream::OnSysRead(void *buffer, size_t size)
|
||||
{
|
||||
return m_file->Read(buffer, size);
|
||||
off_t ret;
|
||||
|
||||
ret = m_file->Read(buffer, size);
|
||||
|
||||
if (m_file->Eof())
|
||||
m_lasterror = wxStream_EOF;
|
||||
if (ret == wxInvalidOffset) {
|
||||
m_lasterror = wxStream_READ_ERR;
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
off_t wxFileInputStream::OnSysSeek(off_t pos, wxSeekMode mode)
|
||||
@@ -102,20 +110,17 @@ wxFileOutputStream::wxFileOutputStream(const wxString& fileName)
|
||||
{
|
||||
m_file = new wxFile(fileName, wxFile::write);
|
||||
m_file_destroy = TRUE;
|
||||
m_o_streambuf->SetBufferIO(1024);
|
||||
}
|
||||
|
||||
wxFileOutputStream::wxFileOutputStream(wxFile& file)
|
||||
{
|
||||
m_file = &file;
|
||||
m_file_destroy = FALSE;
|
||||
m_o_streambuf->SetBufferIO(1024);
|
||||
}
|
||||
|
||||
wxFileOutputStream::wxFileOutputStream()
|
||||
: wxOutputStream()
|
||||
{
|
||||
m_o_streambuf->SetBufferIO(1024);
|
||||
m_file_destroy = FALSE;
|
||||
m_file = NULL;
|
||||
}
|
||||
@@ -124,7 +129,6 @@ wxFileOutputStream::wxFileOutputStream(int fd)
|
||||
{
|
||||
m_file = new wxFile(fd);
|
||||
m_file_destroy = TRUE;
|
||||
m_o_streambuf->SetBufferIO(1024);
|
||||
}
|
||||
|
||||
wxFileOutputStream::~wxFileOutputStream()
|
||||
|
@@ -44,8 +44,6 @@ wxZlibInputStream::wxZlibInputStream(wxInputStream& stream)
|
||||
int err;
|
||||
|
||||
// I need a private stream buffer.
|
||||
m_i_streambuf = new wxStreamBuffer(*this, wxStreamBuffer::read);
|
||||
m_i_destroybuf = TRUE;
|
||||
m_inflate = new z_stream_s;
|
||||
|
||||
m_inflate->zalloc = (alloc_func)0;
|
||||
@@ -106,8 +104,6 @@ wxZlibOutputStream::wxZlibOutputStream(wxOutputStream& stream)
|
||||
{
|
||||
int err;
|
||||
|
||||
m_o_streambuf = new wxStreamBuffer(*this, wxStreamBuffer::write);
|
||||
m_o_destroybuf = TRUE;
|
||||
m_deflate = new z_stream_s;
|
||||
|
||||
m_deflate->zalloc = (alloc_func)0;
|
||||
|
@@ -86,6 +86,7 @@ libwx_gtk_la_SOURCES = \
|
||||
tbarbase.cpp \
|
||||
tbarsmpl.cpp \
|
||||
textfile.cpp \
|
||||
txtstrm.cpp \
|
||||
time.cpp \
|
||||
timercmn.cpp \
|
||||
tokenzr.cpp \
|
||||
|
@@ -86,6 +86,7 @@ libwx_gtk_la_SOURCES = \
|
||||
tbarbase.cpp \
|
||||
tbarsmpl.cpp \
|
||||
textfile.cpp \
|
||||
txtstrm.cpp \
|
||||
time.cpp \
|
||||
timercmn.cpp \
|
||||
tokenzr.cpp \
|
||||
|
@@ -96,6 +96,7 @@ libwx_motif_la_SOURCES = \
|
||||
tbarbase.cpp \
|
||||
tbarsmpl.cpp \
|
||||
textfile.cpp \
|
||||
txtstrm.cpp \
|
||||
time.cpp \
|
||||
url.cpp \
|
||||
valgen.cpp \
|
||||
|
@@ -247,6 +247,7 @@ MSWOBJS = \
|
||||
$(MSWDIR)\tabctrl.obj \
|
||||
$(MSWDIR)\tbarmsw.obj \
|
||||
$(MSWDIR)\textctrl.obj \
|
||||
$(MSWDIR)\txtstrm.obj \
|
||||
$(MSWDIR)\thread.obj \
|
||||
$(MSWDIR)\timer.obj \
|
||||
$(MSWDIR)\tooltip.obj \
|
||||
@@ -464,6 +465,8 @@ $(MSWDIR)\tbarmsw.obj: $(MSWDIR)\tbarmsw.$(SRCSUFF)
|
||||
|
||||
$(MSWDIR)\textctrl.obj: $(MSWDIR)\textctrl.$(SRCSUFF)
|
||||
|
||||
$(MSWDIR)\txtstrm.obj: $(MSWDIR)\txtstrm.$(SRCSUFF)
|
||||
|
||||
$(MSWDIR)\thread.obj: $(MSWDIR)\thread.$(SRCSUFF)
|
||||
|
||||
$(MSWDIR)\timer.obj: $(MSWDIR)\timer.$(SRCSUFF)
|
||||
|
@@ -250,6 +250,7 @@ MSWOBJS = \
|
||||
..\msw\$D\tbar95.obj \
|
||||
..\msw\$D\tbarmsw.obj \
|
||||
..\msw\$D\textctrl.obj \
|
||||
..\msw\$D\txtstrm.obj \
|
||||
..\msw\$D\thread.obj \
|
||||
..\msw\$D\timer.obj \
|
||||
..\msw\$D\tooltip.obj \
|
||||
|
@@ -668,6 +668,9 @@ wxThreadError wxThread::Resume()
|
||||
|
||||
wxThread::ExitCode wxThread::Delete()
|
||||
{
|
||||
if (IsPaused())
|
||||
Resume();
|
||||
|
||||
m_critsect.Enter();
|
||||
wxThreadState state = p_internal->GetState();
|
||||
|
||||
|
Reference in New Issue
Block a user