+ buf_input.Read( buf, 500 );
+
+ textCtrl.WriteText( "wxBufferedInputStream.LastError() returns: " );
+ switch (buf_input.LastError())
+ {
+ case wxSTREAM_NOERROR: textCtrl.WriteText( "wxSTREAM_NOERROR\n" ); break;
+ case wxSTREAM_EOF: textCtrl.WriteText( "wxSTREAM_EOF\n" ); break;
+ case wxSTREAM_READ_ERROR: textCtrl.WriteText( "wxSTREAM_READ_ERROR\n" ); break;
+ case wxSTREAM_WRITE_ERROR: textCtrl.WriteText( "wxSTREAM_WRITE_ERROR\n" ); break;
+ default: textCtrl.WriteText( "Huh?\n" ); break;
+ }
+ msg.Printf( "wxBufferedInputStream.LastRead() returns: %d\n", (int)buf_input.LastRead() );
+ textCtrl.WriteText( msg );
+ msg.Printf( "wxBufferedInputStream.TellI() returns: %d\n", (int)buf_input.TellI() );
+ textCtrl.WriteText( msg );
+ textCtrl.WriteText( "\n\n" );
+
+ textCtrl.WriteText( "Reading another 500 bytes:\n\n" );
+
+ buf_input.Read( buf, 500 );
+
+ textCtrl.WriteText( "wxBufferedInputStream.LastError() returns: " );
+ switch (buf_input.LastError())
+ {
+ case wxSTREAM_NOERROR: textCtrl.WriteText( "wxSTREAM_NOERROR\n" ); break;
+ case wxSTREAM_EOF: textCtrl.WriteText( "wxSTREAM_EOF\n" ); break;
+ case wxSTREAM_READ_ERROR: textCtrl.WriteText( "wxSTREAM_READ_ERROR\n" ); break;
+ case wxSTREAM_WRITE_ERROR: textCtrl.WriteText( "wxSTREAM_WRITE_ERROR\n" ); break;
+ default: textCtrl.WriteText( "Huh?\n" ); break;
+ }
+ msg.Printf( "wxBufferedInputStream.LastRead() returns: %d\n", (int)buf_input.LastRead() );
+ textCtrl.WriteText( msg );
+ msg.Printf( "wxBufferedInputStream.TellI() returns: %d\n", (int)buf_input.TellI() );
+ textCtrl.WriteText( msg );
+ textCtrl.WriteText( "\n\n" );
+
+ textCtrl.WriteText( "Reading another 500 bytes:\n\n" );
+
+ buf_input.Read( buf, 500 );
+
+ textCtrl.WriteText( "wxBufferedInputStream.LastError() returns: " );
+ switch (buf_input.LastError())
+ {
+ case wxSTREAM_NOERROR: textCtrl.WriteText( "wxSTREAM_NOERROR\n" ); break;
+ case wxSTREAM_EOF: textCtrl.WriteText( "wxSTREAM_EOF\n" ); break;
+ case wxSTREAM_READ_ERROR: textCtrl.WriteText( "wxSTREAM_READ_ERROR\n" ); break;
+ case wxSTREAM_WRITE_ERROR: textCtrl.WriteText( "wxSTREAM_WRITE_ERROR\n" ); break;
+ default: textCtrl.WriteText( "Huh?\n" ); break;
+ }
+ msg.Printf( "wxBufferedInputStream.LastRead() returns: %d\n", (int)buf_input.LastRead() );
+ textCtrl.WriteText( msg );
+ msg.Printf( "wxBufferedInputStream.TellI() returns: %d\n", (int)buf_input.TellI() );
+ textCtrl.WriteText( msg );
+ textCtrl.WriteText( "\n\n" );
+}
+
+void MyApp::DoStreamDemo5(wxCommandEvent& WXUNUSED(event))
+{
+ wxTextCtrl& textCtrl = * GetTextCtrl();
+
+ textCtrl.Clear();
+ textCtrl << "\nTesting wxFileInputStream's Peek():\n\n";
+
+ char ch;
+ wxString str;
+
+ textCtrl.WriteText( "Writing number 0 to 9 to wxFileOutputStream:\n\n" );
+
+ wxFileOutputStream file_output( wxString("test_wx.dat") );
+ for (ch = 0; ch < 10; ch++)
+ file_output.Write( &ch, 1 );
+
+ file_output.Sync();
+
+ wxFileInputStream file_input( wxString("test_wx.dat") );
+
+ ch = file_input.Peek();
+ str.Printf( "First char peeked: %d\n", (int) ch );
+ textCtrl.WriteText( str );
+
+ ch = file_input.GetC();
+ str.Printf( "First char read: %d\n", (int) ch );
+ textCtrl.WriteText( str );
+
+ ch = file_input.Peek();
+ str.Printf( "Second char peeked: %d\n", (int) ch );
+ textCtrl.WriteText( str );
+
+ ch = file_input.GetC();
+ str.Printf( "Second char read: %d\n", (int) ch );
+ textCtrl.WriteText( str );
+
+ ch = file_input.Peek();
+ str.Printf( "Third char peeked: %d\n", (int) ch );
+ textCtrl.WriteText( str );
+
+ ch = file_input.GetC();
+ str.Printf( "Third char read: %d\n", (int) ch );
+ textCtrl.WriteText( str );
+
+
+ textCtrl << "\n\n\nTesting wxMemoryInputStream's Peek():\n\n";
+
+ char buf[] = { 0,1,2,3,4,5,6,7,8,9,10 };
+ wxMemoryInputStream input( buf, 10 );
+
+ ch = input.Peek();
+ str.Printf( "First char peeked: %d\n", (int) ch );
+ textCtrl.WriteText( str );
+
+ ch = input.GetC();
+ str.Printf( "First char read: %d\n", (int) ch );
+ textCtrl.WriteText( str );
+
+ ch = input.Peek();
+ str.Printf( "Second char peeked: %d\n", (int) ch );
+ textCtrl.WriteText( str );
+
+ ch = input.GetC();
+ str.Printf( "Second char read: %d\n", (int) ch );
+ textCtrl.WriteText( str );
+
+ ch = input.Peek();
+ str.Printf( "Third char peeked: %d\n", (int) ch );
+ textCtrl.WriteText( str );
+
+ ch = input.GetC();
+ str.Printf( "Third char read: %d\n", (int) ch );
+ textCtrl.WriteText( str );