X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/cf44735628cecb0326b953c4872260f223fc8769..447daba1ce4295f84185d6ecdaec46ae982a2299:/src/common/datstrm.cpp diff --git a/src/common/datstrm.cpp b/src/common/datstrm.cpp index 048b3c50dc..17f2100ebe 100644 --- a/src/common/datstrm.cpp +++ b/src/common/datstrm.cpp @@ -87,10 +87,11 @@ unsigned char wxDataStream::Read8() return (unsigned char)buf; } +// Must be at global scope for VC++ 5 +extern "C" double ConvertFromIeeeExtended(const unsigned char *bytes); + double wxDataStream::ReadDouble() { - extern "C" double ConvertFromIeeeExtended(const unsigned char *bytes); - #if USE_APPLE_IEEE char buf[10]; @@ -115,6 +116,27 @@ wxString wxDataStream::ReadLine() return i_strg; } +wxString wxDataStream::ReadString() +{ + wxString wx_string; + char *string; + unsigned long len; + + if (!m_istream) + return ""; + + len = Read32(); + string = new char[len+1]; + + m_istream->read(string, len); + + string[len] = 0; + wx_string = string; + delete string; + + return wx_string; +} + void wxDataStream::Write32(unsigned long i) { char buf[4]; @@ -151,7 +173,11 @@ void wxDataStream::Write8(unsigned char i) void wxDataStream::WriteLine(const wxString& line) { +#ifdef __WINDOWS__ + wxString tmp_string = line + "\r\n"; +#else wxString tmp_string = line + '\n'; +#endif if (!m_ostream) return; @@ -159,14 +185,30 @@ void wxDataStream::WriteLine(const wxString& line) m_ostream->write((const char *) tmp_string, tmp_string.Length()); } +void wxDataStream::WriteString(const wxString& string) +{ + if (!m_ostream) + return; + + Write32(string.Length()); + m_ostream->write((const char *) string, string.Length()); +} + +// Must be at global scope for VC++ 5 +extern "C" void ConvertToIeeeExtended(double num, unsigned char *bytes); + void wxDataStream::WriteDouble(double d) { - extern "C" void ConvertToIeeeExtended(double num, unsigned char *bytes) char buf[10]; if (!m_ostream) return; +#if USE_APPLE_IEEE ConvertToIeeeExtended(d, (unsigned char *)buf); +#else +# pragma warning "wxDataStream::WriteDouble() not using IeeeExtended - will not work!" + buf[0] = '\0'; +#endif m_ostream->write(buf, 10); }