]>
git.saurik.com Git - wxWidgets.git/blob - src/common/datstrm.cpp
cab308f18ed0ec7abe1586bc2dcae268572a13fb
   1 ///////////////////////////////////////////////////////////////////////////// 
   3 // Purpose:     Data stream classes 
   4 // Author:      Guilhem Lavaux 
   8 // Copyright:   (c) Guilhem Lavaux  
   9 // Licence:     wxWindows license 
  10 ///////////////////////////////////////////////////////////////////////////// 
  13 #pragma implementation "datstrm.h" 
  16 // For compilers that support precompilation, includes "wx.h". 
  17 #include "wx/wxprec.h" 
  25 #include "wx/datstrm.h" 
  27 // --------------------------------------------------------------------------- 
  29 // --------------------------------------------------------------------------- 
  31 wxDataInputStream::wxDataInputStream(wxInputStream
& s
) 
  32   : wxFilterInputStream(s
) 
  36 wxDataInputStream::~wxDataInputStream() 
  40 wxUint32 
wxDataInputStream::Read32() 
  46   return (wxUint32
)buf
[0] | 
  47          ((wxUint32
)buf
[1] << 8) | 
  48          ((wxUint32
)buf
[2] << 16) | 
  49          ((wxUint32
)buf
[3] << 24); 
  52 wxUint16 
wxDataInputStream::Read16() 
  58   return (wxUint16
)buf
[0] | 
  59          ((wxUint16
)buf
[1] << 8); 
  62 wxUint8 
wxDataInputStream::Read8() 
  66   Read((char *)&buf
, 1); 
  70 // Must be at global scope for VC++ 5 
  71 extern "C" double ConvertFromIeeeExtended(const unsigned char *bytes
); 
  73 double wxDataInputStream::ReadDouble() 
  79   return ConvertFromIeeeExtended((unsigned char *)buf
); 
  85 wxString 
wxDataInputStream::ReadLine() 
  87   char c
, last_endl 
= 0; 
  88   bool end_line 
= FALSE
; 
  93     if (LastError() != wxStream_NOERROR
) 
 104       if (last_endl 
== '\r') { 
 106         InputStreamBuffer()->WriteBack(c
); 
 116 wxString 
wxDataInputStream::ReadString() 
 123   string 
= new char[len
+1]; 
 134 // --------------------------------------------------------------------------- 
 135 // wxDataOutputStream 
 136 // --------------------------------------------------------------------------- 
 138 wxDataOutputStream::wxDataOutputStream(wxOutputStream
& s
) 
 139  : wxFilterOutputStream(s
) 
 143 wxDataOutputStream::~wxDataOutputStream() 
 147 void wxDataOutputStream::Write32(wxUint32 i
) 
 152   buf
[1] = (i 
>> 8) & 0xff; 
 153   buf
[2] = (i 
>> 16) & 0xff; 
 154   buf
[3] = (i 
>> 24) & 0xff; 
 158 void wxDataOutputStream::Write16(wxUint16 i
) 
 163   buf
[1] = (i 
>> 8) & 0xff; 
 167 void wxDataOutputStream::Write8(wxUint8 i
) 
 172 void wxDataOutputStream::WriteLine(const wxString
& line
) 
 175   wxString tmp_string 
= line 
+ _T("\r\n"); 
 177   wxString tmp_string 
= line 
+ _T('\n'); 
 180   Write((const wxChar 
*) tmp_string
, tmp_string
.Length()*sizeof(wxChar
)); 
 183 void wxDataOutputStream::WriteString(const wxString
& string
) 
 185   Write32(string
.Length()); 
 186   Write((const wxChar 
*) string
, string
.Length()*sizeof(wxChar
)); 
 189 // Must be at global scope for VC++ 5 
 190 extern "C" void ConvertToIeeeExtended(double num
, unsigned char *bytes
); 
 192 void wxDataOutputStream::WriteDouble(double d
) 
 197   ConvertToIeeeExtended(d
, (unsigned char *)buf
); 
 199 #  pragma warning "wxDataOutputStream::WriteDouble() not using IeeeExtended - will not work!"