// Created: 10/09/98
// RCS-ID: $Id$
// Copyright: (c)
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#include "wx/wxprec.h"
#ifdef __BORLANDC__
-#pragma hdrstop
+ #pragma hdrstop
#endif
#if wxUSE_IOSTREAMH
# include <fstream.h>
#else
# include <fstream>
-# ifdef _MSC_VER
- using namespace std;
-# endif
#endif
#include "wx/stream.h"
IMPLEMENT_ABSTRACT_CLASS(wxVariantData, wxObject)
-wxVariant wxNullVariant;
+wxVariant WXDLLEXPORT wxNullVariant;
/*
* wxVariantDataList
virtual void Copy(wxVariantData& data);
virtual bool Eq(wxVariantData& data) const;
- virtual bool Write(ostream& str) const;
+
+ virtual bool Read(wxString& str);
virtual bool Write(wxString& str) const;
- virtual bool Write(wxOutputStream &str) const;
virtual bool Read(istream& str);
+ virtual bool Write(ostream& str) const;
+
+#if wxUSE_STREAMS
virtual bool Read(wxInputStream& str);
- virtual bool Read(wxString& str);
+ virtual bool Write(wxOutputStream &str) const;
+#endif // wxUSE_STREAMS
+
virtual wxString GetType() const { return "long"; };
protected:
return TRUE;
}
-bool wxVariantDataLong::Write(wxOutputStream& str) const
-{
- str << m_value;
- return TRUE;
-}
-
bool wxVariantDataLong::Write(wxString& str) const
{
str.Printf("%ld", m_value);
return TRUE;
}
+#if wxUSE_STREAMS
+bool wxVariantDataLong::Write(wxOutputStream& str) const
+{
+ str << m_value;
+ return TRUE;
+}
+
bool wxVariantDataLong::Read(wxInputStream& str)
{
str >> m_value;
return TRUE;
}
+#endif // wxUSE_STREAMS
bool wxVariantDataLong::Read(wxString& str)
{
virtual void Copy(wxVariantData& data);
virtual bool Eq(wxVariantData& data) const;
+ virtual bool Read(wxString& str);
virtual bool Write(ostream& str) const;
virtual bool Write(wxString& str) const;
- virtual bool Write(wxOutputStream &str) const;
virtual bool Read(istream& str);
+#if wxUSE_STREAMS
virtual bool Read(wxInputStream& str);
- virtual bool Read(wxString& str);
+ virtual bool Write(wxOutputStream &str) const;
+#endif // wxUSE_STREAMS
virtual wxString GetType() const { return "double"; };
protected:
return TRUE;
}
-bool wxVariantDataReal::Write(wxOutputStream& str) const
-{
- str << m_value;
- return TRUE;
-}
-
bool wxVariantDataReal::Write(wxString& str) const
{
str.Printf("%.4f", m_value);
return TRUE;
}
+#if wxUSE_STREAMS
+bool wxVariantDataReal::Write(wxOutputStream& str) const
+{
+ str << m_value;
+ return TRUE;
+}
+
bool wxVariantDataReal::Read(wxInputStream& str)
{
str >> (float&)m_value;
return TRUE;
}
+#endif // wxUSE_STREAMS
bool wxVariantDataReal::Read(wxString& str)
{
return TRUE;
}
+#ifdef HAVE_BOOL
/*
* wxVariantDataBool
*/
virtual void Copy(wxVariantData& data);
virtual bool Eq(wxVariantData& data) const;
virtual bool Write(ostream& str) const;
- virtual bool Write(wxOutputStream& str) const;
virtual bool Write(wxString& str) const;
+ virtual bool Read(wxString& str);
virtual bool Read(istream& str);
+#if wxUSE_STREAMS
virtual bool Read(wxInputStream& str);
- virtual bool Read(wxString& str);
+ virtual bool Write(wxOutputStream& str) const;
+#endif // wxUSE_STREAMS
virtual wxString GetType() const { return "bool"; };
protected:
return TRUE;
}
-bool wxVariantDataBool::Write(wxOutputStream& str) const
-{
- str << (char)m_value;
- return TRUE;
-}
-
bool wxVariantDataBool::Write(wxString& str) const
{
str.Printf("%d", (int) m_value);
return FALSE;
}
+#if wxUSE_STREAMS
+bool wxVariantDataBool::Write(wxOutputStream& str) const
+{
+ str << (char)m_value;
+ return TRUE;
+}
+
bool wxVariantDataBool::Read(wxInputStream& str)
{
str >> (char&)m_value;
return TRUE;
}
+#endif // wxUSE_STREAMS
bool wxVariantDataBool::Read(wxString& str)
{
m_value = (atol((const char*) str) != 0);
return TRUE;
}
+#endif // HAVE_BOOL
/*
* wxVariantDataChar
virtual void Copy(wxVariantData& data);
virtual bool Eq(wxVariantData& data) const;
+ virtual bool Read(istream& str);
virtual bool Write(ostream& str) const;
- virtual bool Write(wxOutputStream& str) const;
+ virtual bool Read(wxString& str);
virtual bool Write(wxString& str) const;
- virtual bool Read(istream& str);
+#if wxUSE_STREAMS
virtual bool Read(wxInputStream& str);
- virtual bool Read(wxString& str);
+ virtual bool Write(wxOutputStream& str) const;
+#endif // wxUSE_STREAMS
virtual wxString GetType() const { return "char"; };
protected:
return TRUE;
}
-bool wxVariantDataChar::Write(wxOutputStream& str) const
-{
- str << m_value;
- return TRUE;
-}
-
bool wxVariantDataChar::Write(wxString& str) const
{
str.Printf("%c", m_value);
return FALSE;
}
+#if wxUSE_STREAMS
+bool wxVariantDataChar::Write(wxOutputStream& str) const
+{
+ str << m_value;
+ return TRUE;
+}
+
bool wxVariantDataChar::Read(wxInputStream& str)
{
str >> m_value;
return TRUE;
}
+#endif // wxUSE_STREAMS
bool wxVariantDataChar::Read(wxString& str)
{
* wxVariantDataString
*/
+#if defined(__BORLANDC__) && defined(__WIN16__)
+// Change name because of truncation
+#define wxVariantDataString wxVariantStringData
+#endif
+
class WXDLLEXPORT wxVariantDataString: public wxVariantData
{
+#if defined(__BORLANDC__) && defined(__WIN16__)
+DECLARE_DYNAMIC_CLASS(wxVariantStringData)
+#else
DECLARE_DYNAMIC_CLASS(wxVariantDataString)
+#endif
public:
wxVariantDataString() { }
wxVariantDataString(const wxString& value) { m_value = value; }
virtual void Copy(wxVariantData& data);
virtual bool Eq(wxVariantData& data) const;
virtual bool Write(ostream& str) const;
- virtual bool Write(wxOutputStream& str) const;
+ virtual bool Read(wxString& str);
virtual bool Write(wxString& str) const;
virtual bool Read(istream& str);
+#if wxUSE_STREAMS
virtual bool Read(wxInputStream& str);
- virtual bool Read(wxString& str);
+ virtual bool Write(wxOutputStream& str) const;
+#endif // wxUSE_STREAMS
virtual wxString GetType() const { return "string"; };
protected:
return TRUE;
}
-bool wxVariantDataString::Write(wxOutputStream& str) const
-{
- str << (const char*) m_value;
- return TRUE;
-}
-
bool wxVariantDataString::Write(wxString& str) const
{
str = m_value;
return TRUE;
}
+#if wxUSE_STREAMS
+bool wxVariantDataString::Write(wxOutputStream& str) const
+{
+ str << (const char*) m_value;
+ return TRUE;
+}
+
bool wxVariantDataString::Read(wxInputStream& str)
{
str >> m_value;
return TRUE;
}
+#endif // wxUSE_STREAMS
bool wxVariantDataString::Read(wxString& str)
{
return TRUE;
}
+#if defined(__BORLANDC__) && defined(__WIN16__)
+IMPLEMENT_DYNAMIC_CLASS(wxVariantStringData, wxVariantData)
+#else
IMPLEMENT_DYNAMIC_CLASS(wxVariantDataString, wxVariantData)
+#endif
/*
* wxVariantDataTime
m_name = name;
}
+#ifdef HAVE_BOOL
wxVariant::wxVariant(bool val, const wxString& name)
{
m_data = new wxVariantDataBool(val);
m_name = name;
}
+#endif
wxVariant::wxVariant(char val, const wxString& name)
{
}
}
+#ifdef HAVE_BOOL
bool wxVariant::operator== (bool value) const
{
bool thisValue;
m_data = new wxVariantDataBool(value);
}
}
+#endif // HAVE_BOOL
bool wxVariant::operator== (const wxString& value) const
{
*value = (long) (((wxVariantDataReal*)GetData())->GetValue());
else if (type == "long")
*value = ((wxVariantDataLong*)GetData())->GetValue();
+#ifdef HAVE_BOOL
else if (type == "bool")
*value = (long) (((wxVariantDataBool*)GetData())->GetValue());
+#endif
else if (type == "string")
*value = atol((const char*) ((wxVariantDataString*)GetData())->GetValue());
else
*value = ((int) (((wxVariantDataReal*)GetData())->GetValue()) != 0);
else if (type == "long")
*value = (((wxVariantDataLong*)GetData())->GetValue() != 0);
+#ifdef HAVE_BOOL
else if (type == "bool")
*value = ((wxVariantDataBool*)GetData())->GetValue();
+#endif
else if (type == "string")
{
wxString val(((wxVariantDataString*)GetData())->GetValue());
*value = ((wxVariantDataReal*)GetData())->GetValue();
else if (type == "long")
*value = (double) (((wxVariantDataLong*)GetData())->GetValue());
+#ifdef HAVE_BOOL
else if (type == "bool")
*value = (double) (((wxVariantDataBool*)GetData())->GetValue());
+#endif
else if (type == "string")
*value = (double) atof((const char*) ((wxVariantDataString*)GetData())->GetValue());
else
*value = ((wxVariantDataChar*)GetData())->GetValue();
else if (type == "long")
*value = (char) (((wxVariantDataLong*)GetData())->GetValue());
+#ifdef HAVE_BOOL
else if (type == "bool")
*value = (char) (((wxVariantDataBool*)GetData())->GetValue());
+#endif
else
return FALSE;