Code: Select all
wxString wxDataInputStream::ReadString( const wxUint32 len )
{
wxString ret;
if ( len > 0 )
{
#if wxUSE_UNICODE
wxCharBuffer tmp(len + 1);
if ( tmp )
{
m_input->Read(tmp.data(), len);
tmp.data()[len] = '\0';
ret = m_conv->cMB2WX(tmp.data());
}
#else
wxStringBuffer buf(ret, len);
if ( buf )
m_input->Read(buf, len);
#endif
}
return ret;
}
One thing to note, I ended up resorting to making a full copy of "wx/datstrm.h" and "wx/datstrm.cpp" in order to add this method, as MSVC wouldn't allow me to derive from the wxDataInputStream class by simply doing this:
Code: Select all
class DataInputStream : public wxDataInputStream
{
public:
#if wxUSE_UNICODE
DataInputStream(wxInputStream& s, const wxMBConv& conv = wxConvUTF8 );
#else
DataInputStream(wxInputStream& s);
#endif
~DataInputStream();
wxString ReadString( wxUint32 len );
}
// Constructors are identical to wxDataInputStream
// wxString ReadString( wxUint32 len) is also identical to snippet above