Added wxStream but I haven't tested them.
Modified wxDataStream. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@234 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -16,15 +16,12 @@
|
|||||||
#pragma interface "datstrm.h"
|
#pragma interface "datstrm.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/wx.h"
|
#include <wx/stream.h>
|
||||||
|
|
||||||
class wxDataStream {
|
class wxDataStream: public wxFilterInputStream {
|
||||||
public:
|
public:
|
||||||
wxDataStream(iostream& s);
|
wxDataInputStream(wxInputStream& s);
|
||||||
wxDataStream(istream& s);
|
virtual ~wxDataInputStream();
|
||||||
wxDataStream(ostream& s);
|
|
||||||
|
|
||||||
virtual ~wxDataStream();
|
|
||||||
|
|
||||||
unsigned long Read32();
|
unsigned long Read32();
|
||||||
unsigned short Read16();
|
unsigned short Read16();
|
||||||
@@ -32,6 +29,12 @@ public:
|
|||||||
double ReadDouble();
|
double ReadDouble();
|
||||||
wxString ReadLine();
|
wxString ReadLine();
|
||||||
wxString ReadString();
|
wxString ReadString();
|
||||||
|
};
|
||||||
|
|
||||||
|
class wxDataOutputStream: public wxFilterOutputStream {
|
||||||
|
public:
|
||||||
|
wxDataOutputStream(wxOutputStream& s);
|
||||||
|
virtual ~wxDataOutputStream();
|
||||||
|
|
||||||
void Write32(unsigned long i);
|
void Write32(unsigned long i);
|
||||||
void Write16(unsigned short i);
|
void Write16(unsigned short i);
|
||||||
@@ -39,10 +42,7 @@ public:
|
|||||||
void WriteDouble(double d);
|
void WriteDouble(double d);
|
||||||
void WriteLine(const wxString& line);
|
void WriteLine(const wxString& line);
|
||||||
void WriteString(const wxString& string);
|
void WriteString(const wxString& string);
|
||||||
protected:
|
|
||||||
istream *m_istream;
|
|
||||||
ostream *m_ostream;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// __HELPBASEH__
|
// __DATSTREAMH__
|
||||||
|
@@ -55,6 +55,9 @@ LIB_CPP_SRC=\
|
|||||||
common/time.cpp \
|
common/time.cpp \
|
||||||
common/timercmn.cpp \
|
common/timercmn.cpp \
|
||||||
common/utilscmn.cpp \
|
common/utilscmn.cpp \
|
||||||
|
common/stream.cpp \
|
||||||
|
common/fstream.cpp \
|
||||||
|
common/mstream.cpp \
|
||||||
common/datstrm.cpp \
|
common/datstrm.cpp \
|
||||||
\
|
\
|
||||||
gtk/app.cpp \
|
gtk/app.cpp \
|
||||||
|
@@ -26,36 +26,23 @@
|
|||||||
|
|
||||||
#include "wx/datstrm.h"
|
#include "wx/datstrm.h"
|
||||||
|
|
||||||
wxDataStream::wxDataStream(istream& s)
|
wxDataInputStream::wxDataInputStream(wxInputStream& s)
|
||||||
{
|
: wxFilterInputStream(s)
|
||||||
m_istream = &s;
|
|
||||||
m_ostream = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxDataStream::wxDataStream(ostream& s)
|
|
||||||
{
|
|
||||||
m_istream = NULL;
|
|
||||||
m_ostream = &s;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxDataStream::wxDataStream(iostream& s)
|
|
||||||
{
|
|
||||||
m_istream = &s;
|
|
||||||
m_ostream = &s;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxDataStream::~wxDataStream()
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long wxDataStream::Read32()
|
wxDataInputStream::~wxDataInputStream()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long wxDataInputStream::Read32()
|
||||||
{
|
{
|
||||||
char buf[4];
|
char buf[4];
|
||||||
|
|
||||||
if (!m_istream)
|
if (!m_istream)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
m_istream->read(buf, 4);
|
Read(buf, 4);
|
||||||
|
|
||||||
return (unsigned long)buf[0] |
|
return (unsigned long)buf[0] |
|
||||||
((unsigned long)buf[1] << 8) |
|
((unsigned long)buf[1] << 8) |
|
||||||
@@ -63,34 +50,34 @@ unsigned long wxDataStream::Read32()
|
|||||||
((unsigned long)buf[3] << 24);
|
((unsigned long)buf[3] << 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short wxDataStream::Read16()
|
unsigned short wxDataInputStream::Read16()
|
||||||
{
|
{
|
||||||
char buf[2];
|
char buf[2];
|
||||||
|
|
||||||
if (!m_istream)
|
if (!m_istream)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
m_istream->read(buf, 2);
|
Read(buf, 2);
|
||||||
|
|
||||||
return (unsigned short)buf[0] |
|
return (unsigned short)buf[0] |
|
||||||
((unsigned short)buf[1] << 8);
|
((unsigned short)buf[1] << 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char wxDataStream::Read8()
|
unsigned char wxDataInputStream::Read8()
|
||||||
{
|
{
|
||||||
char buf;
|
char buf;
|
||||||
|
|
||||||
if (!m_istream)
|
if (!m_istream)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
m_istream->read(&buf, 1);
|
Read(&buf, 1);
|
||||||
return (unsigned char)buf;
|
return (unsigned char)buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Must be at global scope for VC++ 5
|
// Must be at global scope for VC++ 5
|
||||||
extern "C" double ConvertFromIeeeExtended(const unsigned char *bytes);
|
extern "C" double ConvertFromIeeeExtended(const unsigned char *bytes);
|
||||||
|
|
||||||
double wxDataStream::ReadDouble()
|
double wxDataInputStream::ReadDouble()
|
||||||
{
|
{
|
||||||
#if USE_APPLE_IEEE
|
#if USE_APPLE_IEEE
|
||||||
char buf[10];
|
char buf[10];
|
||||||
@@ -98,25 +85,25 @@ double wxDataStream::ReadDouble()
|
|||||||
if (!m_istream)
|
if (!m_istream)
|
||||||
return 0.0;
|
return 0.0;
|
||||||
|
|
||||||
m_istream->read(buf, 10);
|
Read(buf, 10);
|
||||||
return ConvertFromIeeeExtended((unsigned char *)buf);
|
return ConvertFromIeeeExtended((unsigned char *)buf);
|
||||||
#else
|
#else
|
||||||
return 0.0;
|
return 0.0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxDataStream::ReadLine()
|
wxString wxDataInputStream::ReadLine()
|
||||||
{
|
{
|
||||||
char i_strg[255];
|
char i_strg[255];
|
||||||
|
|
||||||
if (!m_istream)
|
if (!m_istream)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
m_istream->getline(i_strg, 255);
|
// TODO: Implement ReadLine
|
||||||
return i_strg;
|
return i_strg;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxDataStream::ReadString()
|
wxString wxDataInputStream::ReadString()
|
||||||
{
|
{
|
||||||
wxString wx_string;
|
wxString wx_string;
|
||||||
char *string;
|
char *string;
|
||||||
@@ -128,7 +115,7 @@ wxString wxDataStream::ReadString()
|
|||||||
len = Read32();
|
len = Read32();
|
||||||
string = new char[len+1];
|
string = new char[len+1];
|
||||||
|
|
||||||
m_istream->read(string, len);
|
Read(string, len);
|
||||||
|
|
||||||
string[len] = 0;
|
string[len] = 0;
|
||||||
wx_string = string;
|
wx_string = string;
|
||||||
@@ -137,7 +124,12 @@ wxString wxDataStream::ReadString()
|
|||||||
return wx_string;
|
return wx_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDataStream::Write32(unsigned long i)
|
wxDataOutputStream::wxDataOutputStream(wxOutputStream& s)
|
||||||
|
: wxFilterOutputStream(s)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxDataOutputStream::Write32(unsigned long i)
|
||||||
{
|
{
|
||||||
char buf[4];
|
char buf[4];
|
||||||
|
|
||||||
@@ -148,10 +140,10 @@ void wxDataStream::Write32(unsigned long i)
|
|||||||
buf[1] = (i >> 8) & 0xff;
|
buf[1] = (i >> 8) & 0xff;
|
||||||
buf[2] = (i >> 16) & 0xff;
|
buf[2] = (i >> 16) & 0xff;
|
||||||
buf[3] = (i >> 24) & 0xff;
|
buf[3] = (i >> 24) & 0xff;
|
||||||
m_ostream->write(buf, 4);
|
Write(buf, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDataStream::Write16(unsigned short i)
|
void wxDataOutputStream::Write16(unsigned short i)
|
||||||
{
|
{
|
||||||
char buf[2];
|
char buf[2];
|
||||||
|
|
||||||
@@ -160,18 +152,18 @@ void wxDataStream::Write16(unsigned short i)
|
|||||||
|
|
||||||
buf[0] = i & 0xff;
|
buf[0] = i & 0xff;
|
||||||
buf[1] = (i >> 8) & 0xff;
|
buf[1] = (i >> 8) & 0xff;
|
||||||
m_ostream->write(buf, 2);
|
Write(buf, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDataStream::Write8(unsigned char i)
|
void wxDataOutputStream::Write8(unsigned char i)
|
||||||
{
|
{
|
||||||
if (!m_ostream)
|
if (!m_ostream)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_ostream->write(&i, 1);
|
Write(&i, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDataStream::WriteLine(const wxString& line)
|
void wxDataOutputStream::WriteLine(const wxString& line)
|
||||||
{
|
{
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
wxString tmp_string = line + "\r\n";
|
wxString tmp_string = line + "\r\n";
|
||||||
@@ -182,22 +174,22 @@ void wxDataStream::WriteLine(const wxString& line)
|
|||||||
if (!m_ostream)
|
if (!m_ostream)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_ostream->write((const char *) tmp_string, tmp_string.Length());
|
Write((const char *) tmp_string, tmp_string.Length());
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDataStream::WriteString(const wxString& string)
|
void wxDataOutputStream::WriteString(const wxString& string)
|
||||||
{
|
{
|
||||||
if (!m_ostream)
|
if (!m_ostream)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Write32(string.Length());
|
Write32(string.Length());
|
||||||
m_ostream->write((const char *) string, string.Length());
|
Write((const char *) string, string.Length());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Must be at global scope for VC++ 5
|
// Must be at global scope for VC++ 5
|
||||||
extern "C" void ConvertToIeeeExtended(double num, unsigned char *bytes);
|
extern "C" void ConvertToIeeeExtended(double num, unsigned char *bytes);
|
||||||
|
|
||||||
void wxDataStream::WriteDouble(double d)
|
void wxDataOutputStream::WriteDouble(double d)
|
||||||
{
|
{
|
||||||
char buf[10];
|
char buf[10];
|
||||||
|
|
||||||
@@ -210,5 +202,5 @@ void wxDataStream::WriteDouble(double d)
|
|||||||
# pragma warning "wxDataStream::WriteDouble() not using IeeeExtended - will not work!"
|
# pragma warning "wxDataStream::WriteDouble() not using IeeeExtended - will not work!"
|
||||||
buf[0] = '\0';
|
buf[0] = '\0';
|
||||||
#endif
|
#endif
|
||||||
m_ostream->write(buf, 10);
|
Write(buf, 10);
|
||||||
}
|
}
|
||||||
|
105
src/common/fstream.cpp
Normal file
105
src/common/fstream.cpp
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: fstream.cpp
|
||||||
|
// Purpose: "File stream" classes
|
||||||
|
// Author: Julian Smart
|
||||||
|
// Modified by:
|
||||||
|
// Created: 11/07/98
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) Guilhem Lavaux
|
||||||
|
// Licence: wxWindows license
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation "fstream.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wx/object.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <wx/stream.h>
|
||||||
|
#include <wx/fstream.h>
|
||||||
|
|
||||||
|
#define BUF_TEMP_SIZE 10000
|
||||||
|
|
||||||
|
#if !USE_SHARED_LIBRARY
|
||||||
|
IMPLEMENT_CLASS(wxFileStreamBase, wxStream)
|
||||||
|
IMPLEMENT_CLASS(wxFileInputStream, wxFileStreamBase)
|
||||||
|
IMPLEMENT_CLASS(wxFileOutputStream, wxFileStreamBase)
|
||||||
|
IMPLEMENT_CLASS(wxFileStream, wxFileStreamBase)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
wxFileStreamBase::wxFileStreamBase(const wxString& fileName, int iolimit)
|
||||||
|
: wxStream()
|
||||||
|
{
|
||||||
|
char *open_mode;
|
||||||
|
|
||||||
|
switch (iolimit) {
|
||||||
|
case 0:
|
||||||
|
open_mode = "a+";
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
open_mode = "rb";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
open_mode = "wb";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
m_file = fopen(fileName, open_mode);
|
||||||
|
fseek(m_file, 0, SEEK_SET);
|
||||||
|
|
||||||
|
m_eof = FALSE;
|
||||||
|
m_bad = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxFileStreamBase::~wxFileStreamBase()
|
||||||
|
{
|
||||||
|
fclose(m_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxInputStream& wxFileStreamBase::Read(void *buffer, size_t size)
|
||||||
|
{
|
||||||
|
m_lastread = fread(buffer, 1, size, m_file);
|
||||||
|
m_eof = feof(m_file);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxOutputStream& wxFileStreamBase::Write(const void *buffer, size_t size)
|
||||||
|
{
|
||||||
|
m_lastwrite = fwrite(buffer, 1, size, m_file);
|
||||||
|
m_bad = ferror(m_file) != 0;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t wxFileStreamBase::SeekI(int pos, wxWhenceType whence)
|
||||||
|
{
|
||||||
|
int real_whence;
|
||||||
|
|
||||||
|
if (whence == wxBeginPosition)
|
||||||
|
real_whence = SEEK_SET;
|
||||||
|
else if (whence == wxCurrentPosition)
|
||||||
|
real_whence = SEEK_CUR;
|
||||||
|
else if (whence == wxEndPosition)
|
||||||
|
real_whence = SEEK_END;
|
||||||
|
|
||||||
|
fseek(m_file, pos, real_whence);
|
||||||
|
return ftell(m_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t wxFileStreamBase::TellI() const
|
||||||
|
{
|
||||||
|
return ftell(m_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t wxFileStreamBase::TellO() const
|
||||||
|
{
|
||||||
|
return ftell(m_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t wxFileStreamBase::SeekO(int pos, wxWhenceType whence)
|
||||||
|
{
|
||||||
|
return SeekI(pos, whence);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxFileStreamBase::Sync()
|
||||||
|
{
|
||||||
|
fflush(m_file);
|
||||||
|
}
|
133
src/common/mstream.cpp
Normal file
133
src/common/mstream.cpp
Normal file
@@ -0,0 +1,133 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: mmstream.cpp
|
||||||
|
// Purpose: "Memory stream" classes
|
||||||
|
// Author: Guilhem Lavaux
|
||||||
|
// Modified by:
|
||||||
|
// Created: 04/01/98
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) Guilhem Lavaux
|
||||||
|
// Licence: wxWindows license
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation "mmstream.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <wx/stream.h>
|
||||||
|
#include <wx/mmstream.h>
|
||||||
|
|
||||||
|
wxMemoryStreamBase::wxMemoryStreamBase(char *data, size_t length, int iolimit)
|
||||||
|
{
|
||||||
|
m_buffer = data;
|
||||||
|
m_iolimit = iolimit;
|
||||||
|
m_persistent = FALSE;
|
||||||
|
m_length = length;
|
||||||
|
m_position_i = m_position_o = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxMemoryStreamBase::~wxMemoryStreamBase()
|
||||||
|
{
|
||||||
|
free(m_buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxInputStream& wxMemoryStreamBase::Read(void *buffer, size_t size)
|
||||||
|
{
|
||||||
|
if (m_iolimit == 2) {
|
||||||
|
m_eof = TRUE;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
if (m_position_i+size > m_length)
|
||||||
|
size = m_length-m_position_i;
|
||||||
|
|
||||||
|
memcpy((void *)((unsigned long)buffer+m_position_i), m_buffer, size);
|
||||||
|
m_position_i += size;
|
||||||
|
m_lastread = size;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t wxMemoryStreamBase::SeekI(int pos, wxWhenceType whence)
|
||||||
|
{
|
||||||
|
if (m_iolimit == 2)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
switch (whence) {
|
||||||
|
case wxBeginPosition:
|
||||||
|
if ((size_t)pos > m_length)
|
||||||
|
return m_position_i;
|
||||||
|
return (m_position_i = pos);
|
||||||
|
|
||||||
|
case wxCurrentPosition:
|
||||||
|
if ((size_t)(m_position_i+pos) > m_length)
|
||||||
|
return m_position_i;
|
||||||
|
|
||||||
|
return (m_position_i += pos);
|
||||||
|
|
||||||
|
case wxEndPosition:
|
||||||
|
if ((size_t)(m_length-pos) > m_length)
|
||||||
|
return m_position_i;
|
||||||
|
|
||||||
|
return (m_position_i = m_length-pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_position_i;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxOutputStream& wxMemoryStreamBase::Write(const void *buffer, size_t size)
|
||||||
|
{
|
||||||
|
if (m_iolimit == 1) {
|
||||||
|
m_bad = TRUE;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_position_o+size > m_length)
|
||||||
|
if (!ChangeBufferSize(m_position_o+size)) {
|
||||||
|
m_bad = TRUE;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(m_buffer+m_position_o, buffer, size);
|
||||||
|
m_position_o += size;
|
||||||
|
m_lastwrite = size;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t wxMemoryStreamBase::SeekO(int pos, wxWhenceType whence)
|
||||||
|
{
|
||||||
|
if (m_iolimit == 2)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
switch (whence) {
|
||||||
|
case wxBeginPosition:
|
||||||
|
if ((size_t)pos > m_length)
|
||||||
|
return m_position_o;
|
||||||
|
return (m_position_o = pos);
|
||||||
|
|
||||||
|
case wxCurrentPosition:
|
||||||
|
if ((size_t)(m_position_o+pos) > m_length)
|
||||||
|
return m_position_o;
|
||||||
|
|
||||||
|
return (m_position_o += pos);
|
||||||
|
|
||||||
|
case wxEndPosition:
|
||||||
|
if ((size_t)(m_length-pos) > m_length)
|
||||||
|
return m_position_o;
|
||||||
|
|
||||||
|
return (m_position_o = m_length-pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_position_o;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxMemoryStreamBase::ChangeBufferSize(size_t new_size)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
73
src/common/stream.cpp
Normal file
73
src/common/stream.cpp
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: stream.cpp
|
||||||
|
// Purpose: wxStream base classes
|
||||||
|
// Author: Guilhem Lavaux
|
||||||
|
// Modified by:
|
||||||
|
// Created: 11/07/98
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) Guilhem Lavaux
|
||||||
|
// Licence: wxWindows license
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation "stream.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wx/object.h>
|
||||||
|
#include "stream.h"
|
||||||
|
|
||||||
|
#if !USE_SHARED_LIBRARY
|
||||||
|
IMPLEMENT_ABSTRACT_CLASS(wxInputStream, wxObject)
|
||||||
|
IMPLEMENT_ABSTRACT_CLASS(wxOutputStream, wxObject)
|
||||||
|
IMPLEMENT_ABSTRACT_CLASS2(wxStream, wxInputStream, wxOutputStream)
|
||||||
|
IMPLEMENT_CLASS(wxFilterInputStream, wxInputStream)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
wxInputStream::wxInputStream()
|
||||||
|
: wxObject()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
wxInputStream::~wxInputStream()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#define BUF_TEMP_SIZE 10000
|
||||||
|
|
||||||
|
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()) {
|
||||||
|
bytes_read = Read(buf, bytes_read).LastRead();
|
||||||
|
|
||||||
|
stream_out.Write(buf, bytes_read);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxOutputStream::wxOutputStream()
|
||||||
|
: wxObject()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
wxOutputStream::~wxOutputStream()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
wxOutputStream& wxOutputStream::Write(wxInputStream& stream_in)
|
||||||
|
{
|
||||||
|
stream_in.Read(*this);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxFilterInputStream::wxFilterInputStream(wxInputStream& stream)
|
||||||
|
: wxInputStream()
|
||||||
|
{
|
||||||
|
m_parent_stream = &stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxFilterInputStream::~wxFilterInputStream()
|
||||||
|
{
|
||||||
|
}
|
@@ -105,6 +105,9 @@ COMMONOBJS = \
|
|||||||
$(MSWDIR)\time.obj \
|
$(MSWDIR)\time.obj \
|
||||||
$(MSWDIR)\wxexpr.obj \
|
$(MSWDIR)\wxexpr.obj \
|
||||||
$(MSWDIR)\y_tab.obj \
|
$(MSWDIR)\y_tab.obj \
|
||||||
|
$(MSWDIR)\stream.obj \
|
||||||
|
$(MSWDIR)\fstream.obj \
|
||||||
|
$(MSWDIR)\mstream.obj \
|
||||||
$(MSWDIR)\datstrm.obj \
|
$(MSWDIR)\datstrm.obj \
|
||||||
$(MSWDIR)\extended.obj
|
$(MSWDIR)\extended.obj
|
||||||
|
|
||||||
@@ -465,6 +468,12 @@ $(MSWDIR)\time.obj: $(COMMDIR)\time.$(SRCSUFF)
|
|||||||
|
|
||||||
$(MSWDIR)\datstrm.obj: $(COMMDIR)\datstrm.$(SRCSUFF)
|
$(MSWDIR)\datstrm.obj: $(COMMDIR)\datstrm.$(SRCSUFF)
|
||||||
|
|
||||||
|
$(MSWDIR)\mstream.obj: $(COMMDIR)\mstream.$(SRCSUFF)
|
||||||
|
|
||||||
|
$(MSWDIR)\fstream.obj: $(COMMDIR)\fstream.$(SRCSUFF)
|
||||||
|
|
||||||
|
$(MSWDIR)\stream.obj: $(COMMDIR)\stream.$(SRCSUFF)
|
||||||
|
|
||||||
$(MSWDIR)\extended.obj: $(COMMDIR)\extended.c
|
$(MSWDIR)\extended.obj: $(COMMDIR)\extended.c
|
||||||
|
|
||||||
########################################################
|
########################################################
|
||||||
|
@@ -106,6 +106,9 @@ COMMONOBJS = \
|
|||||||
$(COMMDIR)\string.obj \
|
$(COMMDIR)\string.obj \
|
||||||
$(COMMDIR)\time.obj \
|
$(COMMDIR)\time.obj \
|
||||||
$(COMMDIR)\y_tab.obj \
|
$(COMMDIR)\y_tab.obj \
|
||||||
|
$(COMMDIR)\stream.obj \
|
||||||
|
$(COMMDIR)\fstream.obj \
|
||||||
|
$(COMMDIR)\mstream.obj \
|
||||||
$(COMMDIR)\datstrm.obj \
|
$(COMMDIR)\datstrm.obj \
|
||||||
$(COMMDIR)\extended.obj
|
$(COMMDIR)\extended.obj
|
||||||
|
|
||||||
|
@@ -111,6 +111,9 @@ COMMONOBJS = \
|
|||||||
$(COMMDIR)/string.$(OBJSUFF) \
|
$(COMMDIR)/string.$(OBJSUFF) \
|
||||||
$(COMMDIR)/time.$(OBJSUFF) \
|
$(COMMDIR)/time.$(OBJSUFF) \
|
||||||
$(COMMDIR)/y_tab.$(OBJSUFF) \
|
$(COMMDIR)/y_tab.$(OBJSUFF) \
|
||||||
|
$(COMMDIR)/stream.$(OBJSUFF) \
|
||||||
|
$(COMMDIR)/fstream.$(OBJSUFF) \
|
||||||
|
$(COMMDIR)/mstream.$(OBJSUFF) \
|
||||||
$(COMMDIR)/datstrm.$(OBJSUFF) \
|
$(COMMDIR)/datstrm.$(OBJSUFF) \
|
||||||
$(COMMDIR)/extended.$(OBJSUFF)
|
$(COMMDIR)/extended.$(OBJSUFF)
|
||||||
|
|
||||||
|
@@ -107,6 +107,9 @@ COMMONOBJS = \
|
|||||||
$(COMMDIR)\time.obj \
|
$(COMMDIR)\time.obj \
|
||||||
$(COMMDIR)\wxexpr.obj \
|
$(COMMDIR)\wxexpr.obj \
|
||||||
$(COMMDIR)\y_tab.obj \
|
$(COMMDIR)\y_tab.obj \
|
||||||
|
$(COMMDIR)\stream.obj \
|
||||||
|
$(COMMDIR)\fstream.obj \
|
||||||
|
$(COMMDIR)\mstream.obj \
|
||||||
$(COMMDIR)\datstrm.obj \
|
$(COMMDIR)\datstrm.obj \
|
||||||
$(COMMDIR)\extended.obj \
|
$(COMMDIR)\extended.obj \
|
||||||
$(COMMDIR)\process.obj
|
$(COMMDIR)\process.obj
|
||||||
|
Reference in New Issue
Block a user