]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/datstrm.cpp
Don't use "Cancel" button in the about dialog of the listctrl sample.
[wxWidgets.git] / src / common / datstrm.cpp
index b4a4816f45f90f0e0f9b68539b2236d90b50ca41..cb76a5528ea30e6831e6fe0c8379e33d6d52329b 100644 (file)
 #if wxUSE_STREAMS
 
 #include "wx/datstrm.h"
-#include "wx/math.h"
+
+#ifndef WX_PRECOMP
+    #include "wx/math.h"
+#endif //WX_PRECOMP
 
 // ---------------------------------------------------------------------------
 // wxDataInputStream
@@ -42,6 +45,14 @@ wxDataInputStream::~wxDataInputStream()
 #endif // wxUSE_UNICODE
 }
 
+#if wxUSE_UNICODE
+void wxDataInputStream::SetConv( const wxMBConv &conv )
+{
+    delete m_conv;
+    m_conv = conv.Clone();
+}
+#endif
+
 #if wxHAS_INT64
 wxUint64 wxDataInputStream::Read64()
 {
@@ -89,7 +100,7 @@ double wxDataInputStream::ReadDouble()
   char buf[10];
 
   m_input->Read(buf, 10);
-  return ConvertFromIeeeExtended((const wxInt8 *)buf);
+  return wxConvertFromIeeeExtended((const wxInt8 *)buf);
 #else
   return 0.0;
 #endif
@@ -97,25 +108,26 @@ double wxDataInputStream::ReadDouble()
 
 wxString wxDataInputStream::ReadString()
 {
-  size_t len;
-
-  len = Read32();
+    wxString ret;
 
-  if (len > 0)
-  {
+    const size_t len = Read32();
+    if ( len > 0 )
+    {
 #if wxUSE_UNICODE
-    wxCharBuffer tmp(len + 1);
-    m_input->Read(tmp.data(), len);
-    tmp.data()[len] = '\0';
-    wxString ret(m_conv->cMB2WX(tmp.data()));
+        wxCharBuffer tmp(len);
+        if ( tmp )
+        {
+            m_input->Read(tmp.data(), len);
+            ret = m_conv->cMB2WX(tmp.data());
+        }
 #else
-    wxString ret;
-    m_input->Read( wxStringBuffer(ret, len), len);
+        wxStringBuffer buf(ret, len);
+        if ( buf )
+            m_input->Read(buf, len);
 #endif
+    }
+
     return ret;
-  }
-  else
-    return wxEmptyString;
 }
 
 #if wxUSE_LONGLONG
@@ -468,6 +480,14 @@ wxDataOutputStream::~wxDataOutputStream()
 #endif // wxUSE_UNICODE
 }
 
+#if wxUSE_UNICODE
+void wxDataOutputStream::SetConv( const wxMBConv &conv )
+{
+    delete m_conv;
+    m_conv = conv.Clone();
+}
+#endif
+
 #if wxHAS_INT64
 void wxDataOutputStream::Write64(wxUint64 i)
 {
@@ -526,10 +546,15 @@ void wxDataOutputStream::WriteDouble(double d)
   char buf[10];
 
 #if wxUSE_APPLE_IEEE
-  ConvertToIeeeExtended(d, (wxInt8 *)buf);
+  wxConvertToIeeeExtended(d, (wxInt8 *)buf);
 #else
+  wxUnusedVar(d);
 #if !defined(__VMS__) && !defined(__GNUG__)
+#ifdef _MSC_VER
+# pragma message("wxDataOutputStream::WriteDouble() not using IeeeExtended - will not work!")
+#else
 # pragma warning "wxDataOutputStream::WriteDouble() not using IeeeExtended - will not work!"
+#endif
 #endif
    buf[0] = '\0';
 #endif
@@ -647,13 +672,6 @@ void wxDataOutputStream::WriteDouble(const double *buffer, size_t size)
   }
 }
 
-wxDataOutputStream& wxDataOutputStream::operator<<(const wxChar *string)
-{
-  Write32(wxStrlen(string));
-  m_output->Write((const char *)string, wxStrlen(string)*sizeof(wxChar));
-  return *this;
-}
-
 wxDataOutputStream& wxDataOutputStream::operator<<(const wxString& string)
 {
   WriteString(string);