// Modified by:
// Created: 28/06/98
// RCS-ID: $Id$
-// Copyright: (c) Guilhem Lavaux
+// Copyright: (c) Guilhem Lavaux
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
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();
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
#endif
// wxUSE_STREAMS
-
+