X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5a96d2f45fec76a2d0da1c0c7672b62c19280f43..55c020cf641a1e9db2e21a89aa62f85f4f23bc87:/src/common/datstrm.cpp diff --git a/src/common/datstrm.cpp b/src/common/datstrm.cpp index 5112d93f6b..e0bd854d4c 100644 --- a/src/common/datstrm.cpp +++ b/src/common/datstrm.cpp @@ -5,7 +5,7 @@ // Modified by: // Created: 28/06/98 // RCS-ID: $Id$ -// Copyright: (c) Guilhem Lavaux +// Copyright: (c) Guilhem Lavaux // Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// @@ -86,22 +86,29 @@ double wxDataInputStream::ReadDouble() wxString wxDataInputStream::ReadString() { - wxString wx_string; - char *string; - unsigned long len; + size_t len; len = Read32(); - string = new char[len+1]; - m_input->Read(string, len); - - string[len] = 0; - wx_string = string; - delete string; - - return wx_string; + if (len > 0) + { +#if wxUSE_UNICODE + char *tmp = new char[len + 1]; + m_input->Read(tmp, len); + tmp[len] = 0; + wxString s(tmp); + delete[] tmp; +#else + wxString s; + m_input->Read(s.GetWriteBuf(len), len); + s.UngetWriteBuf(); +#endif + return s; + } + else + return wxEmptyString; } - + wxDataInputStream& wxDataInputStream::operator>>(wxString& s) { s = ReadString(); @@ -161,7 +168,7 @@ wxDataInputStream& wxDataInputStream::operator>>(float& f) // --------------------------------------------------------------------------- wxDataOutputStream::wxDataOutputStream(wxOutputStream& s) - : m_output(&s) + : m_output(&s), m_be_order(FALSE) { } @@ -200,8 +207,9 @@ void wxDataOutputStream::Write8(wxUint8 i) void wxDataOutputStream::WriteString(const wxString& string) { const wxWX2MBbuf buf = string.mb_str(); - Write32(string.Length()); - m_output->Write(buf, string.Len()); + Write32(string.Len()); + if (string.Len() > 0) + m_output->Write(buf, string.Len()); } // Must be at global scope for VC++ 5 @@ -214,8 +222,10 @@ void wxDataOutputStream::WriteDouble(double d) #if wxUSE_APPLE_IEEE ConvertToIeeeExtended(d, (unsigned char *)buf); #else -# pragma warning "wxDataOutputStream::WriteDouble() not using IeeeExtended - will not work!" - buf[0] = '\0'; +#ifndef __VMS__ +# pragma warning "wxDataOutputStream::WriteDouble() not using IeeeExtended - will not work!" +#endif + buf[0] = '\0'; #endif m_output->Write(buf, 10); } @@ -227,7 +237,7 @@ wxDataOutputStream& wxDataOutputStream::operator<<(const wxChar *string) return *this; } -wxDataOutputStream& wxDataOutputStream::operator<<(wxString& string) +wxDataOutputStream& wxDataOutputStream::operator<<(const wxString& string) { WriteString(string); return *this; @@ -283,4 +293,4 @@ wxDataOutputStream& wxDataOutputStream::operator<<(float f) #endif // wxUSE_STREAMS - +