Work on streams of all sorts. More to come.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2908 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
1999-06-27 10:39:38 +00:00
parent abe2606b70
commit 3883022093
20 changed files with 263 additions and 99 deletions

View File

@@ -29,17 +29,13 @@
#if wxUSE_TIMEDATE
#include "wx/date.h"
#include <wx/intl.h>
#include "wx/intl.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#if wxUSE_IOSTREAMH
#include <iostream.h>
#else
#include <iostream>
#endif
#include "wx/ioswrap.h"
#include <time.h>
#include <string.h>
@@ -274,6 +270,9 @@ bool WXDLLEXPORT operator != (const wxDate &dt1, const wxDate &dt2)
return ( dt1.julian != dt2.julian );
}
#if wxUSE_STD_IOSTREAM
////////////////////////////////////////////////////////////////
// Ostream operations
////////////////////////////////////////////////////////////////
@@ -283,6 +282,8 @@ ostream WXDLLEXPORT & operator << (ostream &os, const wxDate &dt)
return os << dt.FormatDate().mb_str();
}
#endif
//////////////////////////////////////////////////////////////
// Conversion routines
//////////////////////////////////////////////////////////////

View File

@@ -99,7 +99,7 @@ void wxObject::CopyObject(wxObject& object_dest) const
wxASSERT(object_dest.GetClassInfo()->IsKindOf(GetClassInfo()));
}
#if defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT
#if wxUSE_STD_IOSTREAM && (defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT)
void wxObject::Dump(ostream& str)
{
if (GetClassInfo() && GetClassInfo()->GetClassName())

View File

@@ -603,28 +603,29 @@ wxInputStream& wxInputStream::operator>>(char& c)
return *this;
}
wxInputStream& wxInputStream::operator>>(short& i)
wxInputStream& wxInputStream::operator>>(signed short& i)
{
long l;
signed long l;
*this >> l;
i = (short)l;
i = (signed short)l;
return *this;
}
wxInputStream& wxInputStream::operator>>(int& i)
wxInputStream& wxInputStream::operator>>(signed int& i)
{
long l;
signed long l;
*this >> l;
i = (short)l;
i = (signed int)l;
return *this;
}
wxInputStream& wxInputStream::operator>>(long& i)
wxInputStream& wxInputStream::operator>>(signed long& i)
{
/* I only implemented a simple integer parser */
int c, sign;
char c;
int sign;
while (isspace( c = GetC() ) )
/* Do nothing */ ;
@@ -651,6 +652,46 @@ wxInputStream& wxInputStream::operator>>(long& i)
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 */
char c;
while (isspace( c = GetC() ) )
/* Do nothing */ ;
i = 0;
if (!isdigit(c)) {
InputStreamBuffer()->WriteBack(c);
return *this;
}
while (isdigit(c)) {
i = i*10 + c;
c = GetC();
}
return *this;
}
wxInputStream& wxInputStream::operator>>(double& f)
{
/* I only implemented a simple float parser */
@@ -772,27 +813,41 @@ wxOutputStream& wxOutputStream::operator<<(char c)
return Write(&c, 1);
}
wxOutputStream& wxOutputStream::operator<<(short i)
wxOutputStream& wxOutputStream::operator<<(signed short i)
{
wxString strint;
strint.Printf(_T("%i"), i);
return *this << strint;
signed long l = (signed long)i;
return *this << l;
}
wxOutputStream& wxOutputStream::operator<<(int i)
wxOutputStream& wxOutputStream::operator<<(signed int i)
{
wxString strint;
strint.Printf(_T("%i"), i);
return *this << strint;
signed long l = (signed long)i;
return *this << l;
}
wxOutputStream& wxOutputStream::operator<<(long i)
wxOutputStream& wxOutputStream::operator<<(signed long i)
{
wxString strlong;
strlong.Printf(_T("%ld"), i);
return *this << strlong;
}
strlong.Printf(_T("%i"), i);
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;
}

View File

@@ -36,7 +36,7 @@ seconds since January 1, 1901, GMT.
#include "wx/ioswrap.h"
#if wxUSE_IOSTREAMH
#if wxUSE_IOSTREAMH && wxUSE_STD_IOSTREAM
#include <iomanip.h>
#else
#include <iomanip>

View File

@@ -30,14 +30,6 @@
#include "wx/textdlg.h"
#endif
#include "wx/ioswrap.h"
#if wxUSE_IOSTREAMH
#include <fstream.h>
#else
#include <fstream>
#endif
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>

View File

@@ -20,7 +20,7 @@
#pragma hdrstop
#endif
#if wxUSE_IOSTREAMH
#if wxUSE_IOSTREAMH && wxUSE_STD_IOSTREAM
# include <fstream.h>
#else
# include <fstream>
@@ -51,9 +51,13 @@ public:
virtual void Copy(wxVariantData& data);
virtual bool Eq(wxVariantData& data) const;
#if wxUSE_STD_IOSTREAM
virtual bool Write(ostream& str) const;
#endif
virtual bool Write(wxString& str) const;
#if wxUSE_STD_IOSTREAM
virtual bool Read(istream& str);
#endif
virtual bool Read(wxString& str);
virtual wxString GetType() const { return _T("list"); };
@@ -135,6 +139,7 @@ bool wxVariantDataList::Eq(wxVariantData& data) const
return TRUE;
}
#if wxUSE_STD_IOSTREAM
bool wxVariantDataList::Write(ostream& str) const
{
wxString s;
@@ -142,6 +147,7 @@ bool wxVariantDataList::Write(ostream& str) const
str << (const char*) s.mb_str();
return TRUE;
}
#endif
bool wxVariantDataList::Write(wxString& str) const
{
@@ -160,12 +166,14 @@ bool wxVariantDataList::Write(wxString& str) const
return TRUE;
}
#if wxUSE_STD_IOSTREAM
bool wxVariantDataList::Read(istream& WXUNUSED(str))
{
wxFAIL_MSG(_T("Unimplemented"));
// TODO
return FALSE;
}
#endif
bool wxVariantDataList::Read(wxString& WXUNUSED(str))
{
@@ -190,9 +198,13 @@ public:
virtual void Copy(wxVariantData& data);
virtual bool Eq(wxVariantData& data) const;
#if wxUSE_STD_IOSTREAM
virtual bool Write(ostream& str) const;
#endif
virtual bool Write(wxString& str) const;
#if wxUSE_STD_IOSTREAM
virtual bool Read(istream& str);
#endif
virtual bool Read(wxString& str);
virtual wxString GetType() const { return _T("stringlist"); };
@@ -236,6 +248,7 @@ bool wxVariantDataStringList::Eq(wxVariantData& data) const
return TRUE;
}
#if wxUSE_STD_IOSTREAM
bool wxVariantDataStringList::Write(ostream& str) const
{
wxString s;
@@ -243,6 +256,7 @@ bool wxVariantDataStringList::Write(ostream& str) const
str << (const char*) s.mb_str();
return TRUE;
}
#endif
bool wxVariantDataStringList::Write(wxString& str) const
{
@@ -260,12 +274,14 @@ bool wxVariantDataStringList::Write(wxString& str) const
return TRUE;
}
#if wxUSE_STD_IOSTREAM
bool wxVariantDataStringList::Read(istream& WXUNUSED(str))
{
wxFAIL_MSG(_T("Unimplemented"));
// TODO
return FALSE;
}
#endif
bool wxVariantDataStringList::Read(wxString& WXUNUSED(str))
{
@@ -293,9 +309,10 @@ public:
virtual bool Read(wxString& str);
virtual bool Write(wxString& str) const;
#if wxUSE_STD_IOSTREAM
virtual bool Read(istream& str);
virtual bool Write(ostream& str) const;
#endif
#if wxUSE_STREAMS
virtual bool Read(wxInputStream& str);
virtual bool Write(wxOutputStream &str) const;
@@ -327,6 +344,7 @@ bool wxVariantDataLong::Eq(wxVariantData& data) const
return (otherData.m_value == m_value);
}
#if wxUSE_STD_IOSTREAM
bool wxVariantDataLong::Write(ostream& str) const
{
wxString s;
@@ -334,6 +352,7 @@ bool wxVariantDataLong::Write(ostream& str) const
str << (const char*) s.mb_str();
return TRUE;
}
#endif
bool wxVariantDataLong::Write(wxString& str) const
{
@@ -341,11 +360,13 @@ bool wxVariantDataLong::Write(wxString& str) const
return TRUE;
}
#if wxUSE_STD_IOSTREAM
bool wxVariantDataLong::Read(istream& str)
{
str >> m_value;
return TRUE;
}
#endif
#if wxUSE_STREAMS
bool wxVariantDataLong::Write(wxOutputStream& str) const
@@ -384,9 +405,13 @@ public:
virtual void Copy(wxVariantData& data);
virtual bool Eq(wxVariantData& data) const;
virtual bool Read(wxString& str);
#if wxUSE_STD_IOSTREAM
virtual bool Write(ostream& str) const;
#endif
virtual bool Write(wxString& str) const;
#if wxUSE_STD_IOSTREAM
virtual bool Read(istream& str);
#endif
#if wxUSE_STREAMS
virtual bool Read(wxInputStream& str);
virtual bool Write(wxOutputStream &str) const;
@@ -417,6 +442,7 @@ bool wxVariantDataReal::Eq(wxVariantData& data) const
return (otherData.m_value == m_value);
}
#if wxUSE_STD_IOSTREAM
bool wxVariantDataReal::Write(ostream& str) const
{
wxString s;
@@ -424,6 +450,7 @@ bool wxVariantDataReal::Write(ostream& str) const
str << (const char*) s.mb_str();
return TRUE;
}
#endif
bool wxVariantDataReal::Write(wxString& str) const
{
@@ -431,11 +458,13 @@ bool wxVariantDataReal::Write(wxString& str) const
return TRUE;
}
#if wxUSE_STD_IOSTREAM
bool wxVariantDataReal::Read(istream& str)
{
str >> m_value;
return TRUE;
}
#endif
#if wxUSE_STREAMS
bool wxVariantDataReal::Write(wxOutputStream& str) const
@@ -474,10 +503,14 @@ public:
virtual void Copy(wxVariantData& data);
virtual bool Eq(wxVariantData& data) const;
#if wxUSE_STD_IOSTREAM
virtual bool Write(ostream& str) const;
#endif
virtual bool Write(wxString& str) const;
virtual bool Read(wxString& str);
#if wxUSE_STD_IOSTREAM
virtual bool Read(istream& str);
#endif
#if wxUSE_STREAMS
virtual bool Read(wxInputStream& str);
virtual bool Write(wxOutputStream& str) const;
@@ -508,6 +541,7 @@ bool wxVariantDataBool::Eq(wxVariantData& data) const
return (otherData.m_value == m_value);
}
#if wxUSE_STD_IOSTREAM
bool wxVariantDataBool::Write(ostream& str) const
{
wxString s;
@@ -515,6 +549,7 @@ bool wxVariantDataBool::Write(ostream& str) const
str << (const char*) s.mb_str();
return TRUE;
}
#endif
bool wxVariantDataBool::Write(wxString& str) const
{
@@ -522,12 +557,14 @@ bool wxVariantDataBool::Write(wxString& str) const
return TRUE;
}
#if wxUSE_STD_IOSTREAM
bool wxVariantDataBool::Read(istream& WXUNUSED(str))
{
wxFAIL_MSG(_T("Unimplemented"));
// str >> (long) m_value;
return FALSE;
}
#endif
#if wxUSE_STREAMS
bool wxVariantDataBool::Write(wxOutputStream& str) const
@@ -566,8 +603,10 @@ public:
virtual void Copy(wxVariantData& data);
virtual bool Eq(wxVariantData& data) const;
#if wxUSE_STD_IOSTREAM
virtual bool Read(istream& str);
virtual bool Write(ostream& str) const;
#endif
virtual bool Read(wxString& str);
virtual bool Write(wxString& str) const;
#if wxUSE_STREAMS
@@ -600,6 +639,7 @@ bool wxVariantDataChar::Eq(wxVariantData& data) const
return (otherData.m_value == m_value);
}
#if wxUSE_STD_IOSTREAM
bool wxVariantDataChar::Write(ostream& str) const
{
wxString s;
@@ -607,6 +647,7 @@ bool wxVariantDataChar::Write(ostream& str) const
str << (const char*) s.mb_str();
return TRUE;
}
#endif
bool wxVariantDataChar::Write(wxString& str) const
{
@@ -614,12 +655,14 @@ bool wxVariantDataChar::Write(wxString& str) const
return TRUE;
}
#if wxUSE_STD_IOSTREAM
bool wxVariantDataChar::Read(istream& WXUNUSED(str))
{
wxFAIL_MSG(_T("Unimplemented"));
// str >> m_value;
return FALSE;
}
#endif
#if wxUSE_STREAMS
bool wxVariantDataChar::Write(wxOutputStream& str) const
@@ -666,10 +709,14 @@ public:
virtual void Copy(wxVariantData& data);
virtual bool Eq(wxVariantData& data) const;
#if wxUSE_STD_IOSTREAM
virtual bool Write(ostream& str) const;
#endif
virtual bool Read(wxString& str);
virtual bool Write(wxString& str) const;
#if wxUSE_STD_IOSTREAM
virtual bool Read(istream& str);
#endif
#if wxUSE_STREAMS
virtual bool Read(wxInputStream& str);
virtual bool Write(wxOutputStream& str) const;
@@ -698,11 +745,13 @@ bool wxVariantDataString::Eq(wxVariantData& data) const
return (otherData.m_value == m_value);
}
#if wxUSE_STD_IOSTREAM
bool wxVariantDataString::Write(ostream& str) const
{
str << (const char*) m_value.mb_str();
return TRUE;
}
#endif
bool wxVariantDataString::Write(wxString& str) const
{
@@ -710,11 +759,13 @@ bool wxVariantDataString::Write(wxString& str) const
return TRUE;
}
#if wxUSE_STD_IOSTREAM
bool wxVariantDataString::Read(istream& str)
{
str >> m_value;
return TRUE;
}
#endif
#if wxUSE_STREAMS
bool wxVariantDataString::Write(wxOutputStream& str) const
@@ -761,9 +812,13 @@ public:
virtual void Copy(wxVariantData& data);
virtual bool Eq(wxVariantData& data) const;
#if wxUSE_STD_IOSTREAM
virtual bool Write(ostream& str) const;
#endif
virtual bool Write(wxString& str) const;
#if wxUSE_STD_IOSTREAM
virtual bool Read(istream& str);
#endif
virtual bool Read(wxString& str);
virtual wxString GetType() const { return _T("time"); };
virtual wxVariantData* Clone() { return new wxVariantDataTime; }
@@ -792,6 +847,7 @@ bool wxVariantDataTime::Eq(wxVariantData& data) const
return (otherData.m_value == m_value);
}
#if wxUSE_STD_IOSTREAM
bool wxVariantDataTime::Write(ostream& str) const
{
wxString s;
@@ -799,6 +855,7 @@ bool wxVariantDataTime::Write(ostream& str) const
str << (const char*) s.mb_str();
return TRUE;
}
#endif
bool wxVariantDataTime::Write(wxString& str) const
{
@@ -807,11 +864,13 @@ bool wxVariantDataTime::Write(wxString& str) const
return TRUE;
}
#if wxUSE_STD_IOSTREAM
bool wxVariantDataTime::Read(istream& WXUNUSED(str))
{
// Not implemented
return FALSE;
}
#endif
bool wxVariantDataTime::Read(wxString& WXUNUSED(str))
{
@@ -835,9 +894,13 @@ public:
virtual void Copy(wxVariantData& data);
virtual bool Eq(wxVariantData& data) const;
#if wxUSE_STD_IOSTREAM
virtual bool Write(ostream& str) const;
#endif
virtual bool Write(wxString& str) const;
#if wxUSE_STD_IOSTREAM
virtual bool Read(istream& str);
#endif
virtual bool Read(wxString& str);
virtual wxString GetType() const { return _T("date"); };
virtual wxVariantData* Clone() { return new wxVariantDataDate; }
@@ -866,6 +929,7 @@ bool wxVariantDataDate::Eq(wxVariantData& data) const
return (otherData.m_value == m_value);
}
#if wxUSE_STD_IOSTREAM
bool wxVariantDataDate::Write(ostream& str) const
{
wxString s;
@@ -873,6 +937,7 @@ bool wxVariantDataDate::Write(ostream& str) const
str << (const char*) s.mb_str();
return TRUE;
}
#endif
bool wxVariantDataDate::Write(wxString& str) const
{
@@ -880,11 +945,13 @@ bool wxVariantDataDate::Write(wxString& str) const
return TRUE;
}
#if wxUSE_STD_IOSTREAM
bool wxVariantDataDate::Read(istream& WXUNUSED(str))
{
// Not implemented
return FALSE;
}
#endif
bool wxVariantDataDate::Read(wxString& WXUNUSED(str))
{
@@ -910,9 +977,13 @@ public:
virtual void Copy(wxVariantData& data);
virtual bool Eq(wxVariantData& data) const;
#if wxUSE_STD_IOSTREAM
virtual bool Write(ostream& str) const;
#endif
virtual bool Write(wxString& str) const;
#if wxUSE_STD_IOSTREAM
virtual bool Read(istream& str);
#endif
virtual bool Read(wxString& str);
virtual wxString GetType() const { return _T("void*"); };
virtual wxVariantData* Clone() { return new wxVariantDataVoidPtr; }
@@ -941,6 +1012,7 @@ bool wxVariantDataVoidPtr::Eq(wxVariantData& data) const
return (otherData.m_value == m_value);
}
#if wxUSE_STD_IOSTREAM
bool wxVariantDataVoidPtr::Write(ostream& str) const
{
wxString s;
@@ -948,6 +1020,7 @@ bool wxVariantDataVoidPtr::Write(ostream& str) const
str << (const char*) s.mb_str();
return TRUE;
}
#endif
bool wxVariantDataVoidPtr::Write(wxString& str) const
{
@@ -955,11 +1028,13 @@ bool wxVariantDataVoidPtr::Write(wxString& str) const
return TRUE;
}
#if wxUSE_STD_IOSTREAM
bool wxVariantDataVoidPtr::Read(istream& WXUNUSED(str))
{
// Not implemented
return FALSE;
}
#endif
bool wxVariantDataVoidPtr::Read(wxString& WXUNUSED(str))
{

View File

@@ -94,7 +94,7 @@ BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
EVT_UPDATE_UI(wxID_REDO, wxTextCtrl::OnUpdateRedo)
END_EVENT_TABLE()
#ifndef NO_TEXT_WINDOW_STREAM
#if wxUSE_STD_IOSTREAM
wxTextCtrl::wxTextCtrl() : streambuf()
{
if (allocate()) setp(base(),ebuf());
@@ -108,7 +108,7 @@ wxTextCtrl::wxTextCtrl()
}
#endif
#ifndef NO_TEXT_WINDOW_STREAM
#if wxUSE_STD_IOSTREAM
wxTextCtrl::wxTextCtrl( wxWindow *parent, wxWindowID id, const wxString &value,
const wxPoint &pos, const wxSize &size,
int style, const wxValidator& validator, const wxString &name ) : streambuf()
@@ -913,7 +913,7 @@ void wxTextCtrl::OnChar( wxKeyEvent &key_event )
key_event.Skip();
}
#ifndef NO_TEXT_WINDOW_STREAM
#if wxUSE_STD_IOSTREAM
int wxTextCtrl::overflow( int WXUNUSED(c) )
{
int len = pptr() - pbase();
@@ -942,6 +942,7 @@ int wxTextCtrl::underflow()
{
return EOF;
}
#endif
wxTextCtrl& wxTextCtrl::operator<<(const wxString& s)
{
@@ -990,7 +991,6 @@ wxTextCtrl& wxTextCtrl::operator<<(const char c)
AppendText(buf);
return *this;
}
#endif
GtkWidget* wxTextCtrl::GetConnectWidget()
{

View File

@@ -94,7 +94,7 @@ BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
EVT_UPDATE_UI(wxID_REDO, wxTextCtrl::OnUpdateRedo)
END_EVENT_TABLE()
#ifndef NO_TEXT_WINDOW_STREAM
#if wxUSE_STD_IOSTREAM
wxTextCtrl::wxTextCtrl() : streambuf()
{
if (allocate()) setp(base(),ebuf());
@@ -108,7 +108,7 @@ wxTextCtrl::wxTextCtrl()
}
#endif
#ifndef NO_TEXT_WINDOW_STREAM
#if wxUSE_STD_IOSTREAM
wxTextCtrl::wxTextCtrl( wxWindow *parent, wxWindowID id, const wxString &value,
const wxPoint &pos, const wxSize &size,
int style, const wxValidator& validator, const wxString &name ) : streambuf()
@@ -913,7 +913,7 @@ void wxTextCtrl::OnChar( wxKeyEvent &key_event )
key_event.Skip();
}
#ifndef NO_TEXT_WINDOW_STREAM
#if wxUSE_STD_IOSTREAM
int wxTextCtrl::overflow( int WXUNUSED(c) )
{
int len = pptr() - pbase();
@@ -942,6 +942,7 @@ int wxTextCtrl::underflow()
{
return EOF;
}
#endif
wxTextCtrl& wxTextCtrl::operator<<(const wxString& s)
{
@@ -990,7 +991,6 @@ wxTextCtrl& wxTextCtrl::operator<<(const char c)
AppendText(buf);
return *this;
}
#endif
GtkWidget* wxTextCtrl::GetConnectWidget()
{