]>
git.saurik.com Git - wxWidgets.git/blob - src/common/stream.cpp
99baaa56343eb51cbd539a6b46e4154c2fa5f8d2
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/stream.cpp
3 // Purpose: wxStream base classes
4 // Author: Guilhem Lavaux
5 // Modified by: VZ (23.11.00) to fix realloc()ing new[]ed memory,
9 // Copyright: (c) Guilhem Lavaux
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
13 // ============================================================================
15 // ============================================================================
17 // ----------------------------------------------------------------------------
19 // ----------------------------------------------------------------------------
22 #pragma implementation "stream.h"
25 // For compilers that support precompilation, includes "wx.h".
26 #include "wx/wxprec.h"
39 #include "wx/stream.h"
40 #include "wx/datstrm.h"
41 #include "wx/objstrm.h"
43 // ----------------------------------------------------------------------------
45 // ----------------------------------------------------------------------------
47 // the temporary buffer size used when copying from stream to stream
48 #define BUF_TEMP_SIZE 10000
50 // ============================================================================
52 // ============================================================================
54 // ----------------------------------------------------------------------------
56 // ----------------------------------------------------------------------------
58 void wxStreamBuffer::SetError(wxStreamError err
)
60 if ( m_stream
->m_lasterror
== wxStream_NOERROR
)
61 m_stream
->m_lasterror
= err
;
64 void wxStreamBuffer::InitBuffer()
71 // there is nothing to destroy anyhow
75 void wxStreamBuffer::Init()
82 wxStreamBuffer::wxStreamBuffer(wxStreamBase
& stream
, BufMode mode
)
88 m_destroystream
= FALSE
;
91 wxStreamBuffer::wxStreamBuffer(BufMode mode
)
93 m_stream
= new wxStreamBase
;
97 m_destroystream
= TRUE
;
100 wxStreamBuffer::wxStreamBuffer(const wxStreamBuffer
& buffer
)
102 // doing this has big chances to lead to a crashwhen the source buffer is
103 // destroyed (otherwise assume the caller knows what he does)
104 wxASSERT_MSG( !buffer
.m_destroybuf
&& !buffer
.m_destroystream
,
105 _T("it's a bad idea to copy this buffer") );
107 m_buffer_start
= buffer
.m_buffer_start
;
108 m_buffer_end
= buffer
.m_buffer_end
;
109 m_buffer_pos
= buffer
.m_buffer_pos
;
110 m_buffer_size
= buffer
.m_buffer_size
;
111 m_fixed
= buffer
.m_fixed
;
112 m_flushable
= buffer
.m_flushable
;
113 m_stream
= buffer
.m_stream
;
114 m_mode
= buffer
.m_mode
;
115 m_destroybuf
= FALSE
;
116 m_destroystream
= FALSE
;
119 void wxStreamBuffer::FreeBuffer()
122 free(m_buffer_start
);
125 wxStreamBuffer::~wxStreamBuffer()
129 if ( m_destroystream
)
133 wxInputStream
*wxStreamBuffer::GetInputStream() const
135 return m_mode
== write
? NULL
: (wxInputStream
*)m_stream
;
138 wxOutputStream
*wxStreamBuffer::GetOutputStream() const
140 return m_mode
== read
? NULL
: (wxOutputStream
*)m_stream
;
143 void wxStreamBuffer::SetBufferIO(void *buffer_start
,
147 SetBufferIO(buffer_start
, (char *)buffer_end
- (char *)buffer_start
,
151 void wxStreamBuffer::SetBufferIO(void *start
,
155 // start by freeing the old buffer
158 m_buffer_start
= (char *)start
;
159 m_buffer_end
= m_buffer_start
+ len
;
163 // if we own it, we free it
164 m_destroybuf
= !takeOwnership
;
169 void wxStreamBuffer::SetBufferIO(size_t bufsize
)
171 // start by freeing the old buffer
176 SetBufferIO(malloc(bufsize
), bufsize
, TRUE
/* take ownership */);
178 else // no buffer size => no buffer
184 void wxStreamBuffer::ResetBuffer()
186 wxCHECK_RET( m_stream
, _T("should have a stream in wxStreamBuffer") );
188 m_stream
->m_lasterror
= wxStream_NOERROR
;
189 m_stream
->m_lastcount
= 0;
190 if (m_mode
== read
&& m_flushable
)
191 m_buffer_pos
= m_buffer_end
;
193 m_buffer_pos
= m_buffer_start
;
196 // fill the buffer with as much data as possible (only for read buffers)
197 bool wxStreamBuffer::FillBuffer()
199 wxInputStream
*inStream
= GetInputStream();
201 wxCHECK_MSG( inStream
, FALSE
, _T("should have a stream in wxStreamBuffer") );
203 size_t count
= inStream
->OnSysRead(m_buffer_start
, m_buffer_size
);
207 m_buffer_end
= m_buffer_start
+ count
;
208 m_buffer_pos
= m_buffer_start
;
213 // write the buffer contents to the stream (only for write buffers)
214 bool wxStreamBuffer::FlushBuffer()
216 wxCHECK_MSG( m_flushable
, FALSE
, _T("can't flush this buffer") );
218 // FIXME: what is this check for? (VZ)
219 if ( m_buffer_pos
== m_buffer_start
)
222 wxOutputStream
*outStream
= GetOutputStream();
224 wxCHECK_MSG( outStream
, FALSE
, _T("should have a stream in wxStreamBuffer") );
226 size_t current
= m_buffer_pos
- m_buffer_start
;
227 size_t count
= outStream
->OnSysWrite(m_buffer_start
, current
);
228 if ( count
!= current
)
231 m_buffer_pos
= m_buffer_start
;
236 size_t wxStreamBuffer::GetDataLeft()
238 /* Why is this done? RR. */
239 if ( m_buffer_pos
== m_buffer_end
&& m_flushable
)
242 return GetBytesLeft();
245 // copy up to size bytes from our buffer into the provided one
246 void wxStreamBuffer::GetFromBuffer(void *buffer
, size_t size
)
248 // don't get more bytes than left in the buffer
249 size_t left
= GetBytesLeft();
254 memcpy(buffer
, m_buffer_pos
, size
);
255 m_buffer_pos
+= size
;
258 // copy the contents of the provided buffer into this one
259 void wxStreamBuffer::PutToBuffer(const void *buffer
, size_t size
)
261 size_t left
= GetBytesLeft();
266 // we can't realloc the buffer, so just copy what we can
271 // realloc the buffer to have enough space for the data
272 size_t delta
= m_buffer_pos
- m_buffer_start
;
274 char *startOld
= m_buffer_start
;
275 m_buffer_size
+= size
;
276 m_buffer_start
= (char *)realloc(m_buffer_start
, m_buffer_size
);
277 if ( !m_buffer_start
)
279 // don't leak memory if realloc() failed
280 m_buffer_start
= startOld
;
281 m_buffer_size
-= size
;
283 // what else can we do?
287 // adjust the pointers invalidated by realloc()
288 m_buffer_pos
= m_buffer_start
+ delta
;
289 m_buffer_end
= m_buffer_start
+ m_buffer_size
;
293 memcpy(m_buffer_pos
, buffer
, size
);
294 m_buffer_pos
+= size
;
297 void wxStreamBuffer::PutChar(char c
)
299 wxOutputStream
*outStream
= GetOutputStream();
301 wxCHECK_RET( outStream
, _T("should have a stream in wxStreamBuffer") );
303 // if we don't have buffer at all, just forward this call to the stream,
306 outStream
->OnSysWrite(&c
, 1);
310 // otherwise check we have enough space left
311 if ( !GetDataLeft() && !FlushBuffer() )
314 SetError(wxStream_WRITE_ERR
);
319 m_stream
->m_lastcount
= 1;
324 char wxStreamBuffer::Peek()
326 wxCHECK_MSG( m_stream
&& HasBuffer(), 0,
327 _T("should have the stream and the buffer in wxStreamBuffer") );
329 if ( !GetDataLeft() )
331 SetError(wxStream_READ_ERR
);
336 GetFromBuffer(&c
, 1);
342 char wxStreamBuffer::GetChar()
344 wxInputStream
*inStream
= GetInputStream();
346 wxCHECK_MSG( inStream
, 0, _T("should have a stream in wxStreamBuffer") );
351 inStream
->OnSysRead(&c
, 1);
355 if ( !GetDataLeft() )
357 SetError(wxStream_READ_ERR
);
362 GetFromBuffer(&c
, 1);
363 m_stream
->m_lastcount
= 1;
370 size_t wxStreamBuffer::Read(void *buffer
, size_t size
)
372 wxInputStream
*inStream
= GetInputStream();
374 wxCHECK_MSG( inStream
, 0, _T("should have a stream in wxStreamBuffer") );
376 // lasterror is reset before all new IO calls
377 m_stream
->m_lasterror
= wxStream_NOERROR
;
381 m_stream
->m_lastcount
= inStream
->OnSysRead(buffer
, size
);
383 else // we have a buffer, use it
385 size_t orig_size
= size
;
389 size_t left
= GetDataLeft();
391 // if the requested number of bytes if greater than the buffer
392 // size, read data in chunks
395 GetFromBuffer(buffer
, left
);
397 buffer
= (char *)buffer
+ left
;
401 SetError(wxStream_EOF
);
405 else // otherwise just do it in one gulp
407 GetFromBuffer(buffer
, size
);
412 m_stream
->m_lastcount
= orig_size
- size
;
415 return m_stream
->m_lastcount
;
418 // this should really be called "Copy()"
419 size_t wxStreamBuffer::Read(wxStreamBuffer
*dbuf
)
421 wxCHECK_MSG( m_mode
!= write
, 0, _T("can't read from this buffer") );
423 char buf
[BUF_TEMP_SIZE
];
429 nRead
= Read(dbuf
, WXSIZEOF(buf
));
432 nRead
= dbuf
->Write(buf
, nRead
);
441 size_t wxStreamBuffer::Write(const void *buffer
, size_t size
)
443 wxOutputStream
*outStream
= GetOutputStream();
445 wxCHECK_MSG( outStream
, 0, _T("should have a stream in wxStreamBuffer") );
447 // lasterror is reset before all new IO calls
448 m_stream
->m_lasterror
= wxStream_NOERROR
;
450 if ( !HasBuffer() && m_fixed
)
452 // no buffer, just forward the call to the stream
453 m_stream
->m_lastcount
= outStream
->OnSysWrite(buffer
, size
);
455 else // we [may] have a buffer, use it
457 size_t orig_size
= size
;
461 size_t left
= GetBytesLeft();
463 // if the buffer is too large to fit in the stream buffer, split
464 // it in smaller parts
466 // NB: If stream buffer isn't fixed (as for wxMemoryOutputStream),
467 // we always go to the second case.
469 // FIXME: fine, but if it fails we should (re)try writing it by
470 // chunks as this will (hopefully) always work (VZ)
471 if ( size
> left
&& m_fixed
)
473 PutToBuffer(buffer
, left
);
475 buffer
= (char *)buffer
+ left
;
477 if ( !FlushBuffer() )
479 SetError(wxStream_WRITE_ERR
);
484 m_buffer_pos
= m_buffer_start
;
486 else // we can do it in one gulp
488 PutToBuffer(buffer
, size
);
493 m_stream
->m_lastcount
= orig_size
- size
;
496 return m_stream
->m_lastcount
;
499 size_t wxStreamBuffer::Write(wxStreamBuffer
*sbuf
)
501 wxCHECK_MSG( m_mode
!= read
, 0, _T("can't write to this buffer") );
502 wxCHECK_MSG( sbuf
->m_mode
!= write
, 0, _T("can't read from that buffer") );
504 char buf
[BUF_TEMP_SIZE
];
510 size_t nRead
= sbuf
->Read(buf
, WXSIZEOF(buf
));
513 nWrite
= Write(buf
, nRead
);
514 if ( nWrite
< nRead
)
516 // put back data we couldn't copy
517 wxInputStream
*in_stream
= (wxInputStream
*)sbuf
->GetStream();
519 in_stream
->Ungetch(buf
+ nWrite
, nRead
- nWrite
);
529 while ( nWrite
== WXSIZEOF(buf
) );
534 off_t
wxStreamBuffer::Seek(off_t pos
, wxSeekMode mode
)
538 off_t last_access
= GetLastAccess();
549 diff
= pos
+ GetIntPosition();
553 diff
= pos
+ last_access
;
557 wxFAIL_MSG( _T("invalid seek mode") );
559 return wxInvalidOffset
;
561 if (diff
< 0 || diff
> last_access
)
562 return wxInvalidOffset
;
563 SetIntPosition(diff
);
570 // We'll try to compute an internal position later ...
571 ret_off
= m_stream
->OnSysSeek(pos
, wxFromStart
);
576 diff
= pos
+ GetIntPosition();
578 if ( (diff
> last_access
) || (diff
< 0) )
580 // We must take into account the fact that we have read
581 // something previously.
582 ret_off
= m_stream
->OnSysSeek(diff
-last_access
, wxFromCurrent
);
588 SetIntPosition(diff
);
593 // Hard to compute: always seek to the requested position.
594 ret_off
= m_stream
->OnSysSeek(pos
, wxFromEnd
);
599 return wxInvalidOffset
;
602 off_t
wxStreamBuffer::Tell() const
604 off_t pos
= m_stream
->OnSysTell();
605 if ( pos
== wxInvalidOffset
)
606 return wxInvalidOffset
;
608 pos
+= GetIntPosition();
610 if ( m_mode
== read
&& m_flushable
)
611 pos
-= GetLastAccess();
616 // ----------------------------------------------------------------------------
618 // ----------------------------------------------------------------------------
620 wxStreamBase::wxStreamBase()
622 m_lasterror
= wxStream_NOERROR
;
626 wxStreamBase::~wxStreamBase()
630 // ----------------------------------------------------------------------------
632 // ----------------------------------------------------------------------------
634 wxInputStream::wxInputStream()
641 wxInputStream::~wxInputStream()
646 size_t wxInputStream::OnSysRead(void * WXUNUSED(buffer
),
647 size_t WXUNUSED(bufsize
))
652 bool wxInputStream::Eof() const
654 wxInputStream
*self
= wxConstCast(this, wxInputStream
);
658 if ( GetLastError() == wxSTREAM_EOF
)
668 char *wxInputStream::AllocSpaceWBack(size_t needed_size
)
670 // get number of bytes left from previous wback buffer
671 size_t toget
= m_wbacksize
- m_wbackcur
;
673 // allocate a buffer large enough to hold prev + new data
674 char *temp_b
= (char *)malloc(needed_size
+ toget
);
679 /* copy previous data (and free old buffer) if needed */
682 memmove(temp_b
+ needed_size
, m_wback
+ m_wbackcur
, toget
);
689 m_wbacksize
= needed_size
+ toget
;
694 size_t wxInputStream::GetWBack(void *buf
, size_t bsize
)
696 size_t toget
= m_wbacksize
-m_wbackcur
;
704 memcpy(buf
, (m_wback
+m_wbackcur
), toget
);
707 if (m_wbackcur
== m_wbacksize
)
718 size_t wxInputStream::Ungetch(const void *buf
, size_t bufsize
)
720 char *ptrback
= AllocSpaceWBack(bufsize
);
724 memcpy(ptrback
, buf
, bufsize
);
728 bool wxInputStream::Ungetch(char c
)
730 void *ptrback
= AllocSpaceWBack(1);
734 *(char *)ptrback
= c
;
738 char wxInputStream::GetC()
745 wxInputStream
& wxInputStream::Read(void *buf
, size_t size
)
747 size_t retsize
= GetWBack(buf
, size
);
751 m_lasterror
= wxStream_NOERROR
;
755 buf
= (char *)buf
+ retsize
;
757 m_lastcount
= OnSysRead(buf
, size
) + retsize
;
761 char wxInputStream::Peek()
765 if (m_lasterror
== wxStream_NOERROR
)
774 wxInputStream
& wxInputStream::Read(wxOutputStream
& stream_out
)
776 char buf
[BUF_TEMP_SIZE
];
777 size_t bytes_read
= BUF_TEMP_SIZE
;
779 while (bytes_read
== BUF_TEMP_SIZE
)
781 bytes_read
= Read(buf
, bytes_read
).LastRead();
782 bytes_read
= stream_out
.Write(buf
, bytes_read
).LastWrite();
787 off_t
wxInputStream::SeekI(off_t pos
, wxSeekMode mode
)
789 /* Should be check and improve, just to remove a slight bug !
790 I don't know whether it should be put as well in wxFileInputStream::OnSysSeek ? */
791 if (m_lasterror
==wxSTREAM_EOF
)
792 m_lasterror
=wxSTREAM_NOERROR
;
794 /* A call to SeekI() will automatically invalidate any previous call
795 to Ungetch(), otherwise it would be possible to SeekI() to one
796 one position, unread some bytes there, SeekI() to another position
797 and the data would be corrupted.
799 GRG: Could add code here to try to navigate within the wback
800 buffer if possible, but is it really needed? It would only work
801 when seeking in wxFromCurrent mode, else it would invalidate
812 return OnSysSeek(pos
, mode
);
815 off_t
wxInputStream::TellI() const
817 /* GRG: Changed to make it compatible with the wback buffer */
818 off_t pos
= OnSysTell();
820 if (pos
!= wxInvalidOffset
)
821 pos
-= (m_wbacksize
- m_wbackcur
);
826 // --------------------
827 // Overloaded operators
828 // --------------------
831 wxInputStream
& wxInputStream::operator>>(wxObject
*& obj
)
833 wxObjectInputStream
obj_s(*this);
834 obj
= obj_s
.LoadObject();
837 #endif // wxUSE_SERIAL
840 // ----------------------------------------------------------------------------
842 // ----------------------------------------------------------------------------
844 wxOutputStream::wxOutputStream()
848 wxOutputStream::~wxOutputStream()
852 size_t wxOutputStream::OnSysWrite(const void * WXUNUSED(buffer
),
853 size_t WXUNUSED(bufsize
))
858 void wxOutputStream::PutC(char c
)
863 wxOutputStream
& wxOutputStream::Write(const void *buffer
, size_t size
)
865 m_lastcount
= OnSysWrite(buffer
, size
);
869 wxOutputStream
& wxOutputStream::Write(wxInputStream
& stream_in
)
871 stream_in
.Read(*this);
875 off_t
wxOutputStream::TellO() const
880 off_t
wxOutputStream::SeekO(off_t pos
, wxSeekMode mode
)
882 return OnSysSeek(pos
, mode
);
885 void wxOutputStream::Sync()
890 wxOutputStream
& wxOutputStream::operator<<(wxObject
& obj
)
892 wxObjectOutputStream
obj_s(*this);
893 obj_s
.SaveObject(obj
);
896 #endif // wxUSE_SERIAL
898 // ----------------------------------------------------------------------------
899 // wxCountingOutputStream
900 // ----------------------------------------------------------------------------
902 wxCountingOutputStream::wxCountingOutputStream ()
907 size_t wxCountingOutputStream::GetSize() const
912 size_t wxCountingOutputStream::OnSysWrite(const void *WXUNUSED(buffer
),
915 m_currentPos
+= size
;
916 if (m_currentPos
> m_lastcount
)
917 m_lastcount
= m_currentPos
;
922 off_t
wxCountingOutputStream::OnSysSeek(off_t pos
, wxSeekMode mode
)
931 m_currentPos
= m_lastcount
+ pos
;
939 wxFAIL_MSG( _T("invalid seek mode") );
940 return wxInvalidOffset
;
943 if (m_currentPos
> m_lastcount
)
944 m_lastcount
= m_currentPos
;
949 off_t
wxCountingOutputStream::OnSysTell() const
954 // ----------------------------------------------------------------------------
955 // wxFilterInputStream
956 // ----------------------------------------------------------------------------
958 wxFilterInputStream::wxFilterInputStream()
960 m_parent_i_stream
= NULL
;
963 wxFilterInputStream::wxFilterInputStream(wxInputStream
& stream
)
965 m_parent_i_stream
= &stream
;
968 wxFilterInputStream::~wxFilterInputStream()
972 // ----------------------------------------------------------------------------
973 // wxFilterOutputStream
974 // ----------------------------------------------------------------------------
976 wxFilterOutputStream::wxFilterOutputStream()
978 m_parent_o_stream
= NULL
;
981 wxFilterOutputStream::wxFilterOutputStream(wxOutputStream
& stream
)
983 m_parent_o_stream
= &stream
;
986 wxFilterOutputStream::~wxFilterOutputStream()
990 // ----------------------------------------------------------------------------
991 // wxBufferedInputStream
992 // ----------------------------------------------------------------------------
994 wxBufferedInputStream::wxBufferedInputStream(wxInputStream
& s
,
995 wxStreamBuffer
*buffer
)
996 : wxFilterInputStream(s
)
1000 // use the buffer provided by the user
1001 m_i_streambuf
= buffer
;
1003 else // create a default buffer
1005 m_i_streambuf
= new wxStreamBuffer(*this, wxStreamBuffer::read
);
1007 m_i_streambuf
->SetBufferIO(1024);
1011 wxBufferedInputStream::~wxBufferedInputStream()
1013 m_parent_i_stream
->SeekI(-m_i_streambuf
->GetBytesLeft(), wxFromCurrent
);
1015 delete m_i_streambuf
;
1018 char wxBufferedInputStream::Peek()
1020 return m_i_streambuf
->Peek();
1023 wxInputStream
& wxBufferedInputStream::Read(void *buf
, size_t size
)
1027 retsize
= GetWBack(buf
, size
);
1028 m_lastcount
= retsize
;
1029 if ( retsize
== size
)
1031 m_lasterror
= wxStream_NOERROR
;
1035 buf
= (char *)buf
+ retsize
;
1037 m_i_streambuf
->Read(buf
, size
);
1042 off_t
wxBufferedInputStream::SeekI(off_t pos
, wxSeekMode mode
)
1044 return m_i_streambuf
->Seek(pos
, mode
);
1047 off_t
wxBufferedInputStream::TellI() const
1049 return m_i_streambuf
->Tell();
1052 size_t wxBufferedInputStream::OnSysRead(void *buffer
, size_t bufsize
)
1054 return m_parent_i_stream
->Read(buffer
, bufsize
).LastRead();
1057 off_t
wxBufferedInputStream::OnSysSeek(off_t seek
, wxSeekMode mode
)
1059 return m_parent_i_stream
->SeekI(seek
, mode
);
1062 off_t
wxBufferedInputStream::OnSysTell() const
1064 return m_parent_i_stream
->TellI();
1067 void wxBufferedInputStream::SetInputStreamBuffer(wxStreamBuffer
*buffer
)
1069 wxCHECK_RET( buffer
, _T("wxBufferedInputStream needs buffer") );
1071 delete m_i_streambuf
;
1072 m_i_streambuf
= buffer
;
1075 // ----------------------------------------------------------------------------
1076 // wxBufferedOutputStream
1077 // ----------------------------------------------------------------------------
1079 wxBufferedOutputStream::wxBufferedOutputStream(wxOutputStream
& s
,
1080 wxStreamBuffer
*buffer
)
1081 : wxFilterOutputStream(s
)
1085 m_o_streambuf
= buffer
;
1087 else // create a default one
1089 m_o_streambuf
= new wxStreamBuffer(*this, wxStreamBuffer::write
);
1091 m_o_streambuf
->SetBufferIO(1024);
1095 wxBufferedOutputStream::~wxBufferedOutputStream()
1098 delete m_o_streambuf
;
1101 wxOutputStream
& wxBufferedOutputStream::Write(const void *buffer
, size_t size
)
1104 m_o_streambuf
->Write(buffer
, size
);
1108 off_t
wxBufferedOutputStream::SeekO(off_t pos
, wxSeekMode mode
)
1111 return m_o_streambuf
->Seek(pos
, mode
);
1114 off_t
wxBufferedOutputStream::TellO() const
1116 return m_o_streambuf
->Tell();
1119 void wxBufferedOutputStream::Sync()
1121 m_o_streambuf
->FlushBuffer();
1122 m_parent_o_stream
->Sync();
1125 size_t wxBufferedOutputStream::OnSysWrite(const void *buffer
, size_t bufsize
)
1127 return m_parent_o_stream
->Write(buffer
, bufsize
).LastWrite();
1130 off_t
wxBufferedOutputStream::OnSysSeek(off_t seek
, wxSeekMode mode
)
1132 return m_parent_o_stream
->SeekO(seek
, mode
);
1135 off_t
wxBufferedOutputStream::OnSysTell() const
1137 return m_parent_o_stream
->TellO();
1140 size_t wxBufferedOutputStream::GetSize() const
1142 return m_parent_o_stream
->GetSize() + m_o_streambuf
->GetIntPosition();
1145 void wxBufferedOutputStream::SetOutputStreamBuffer(wxStreamBuffer
*buffer
)
1147 wxCHECK_RET( buffer
, _T("wxBufferedOutputStream needs buffer") );
1149 delete m_o_streambuf
;
1150 m_o_streambuf
= buffer
;
1153 // ----------------------------------------------------------------------------
1154 // Some IOManip function
1155 // ----------------------------------------------------------------------------
1157 wxOutputStream
& wxEndL(wxOutputStream
& stream
)
1160 return stream
.Write("\r\n", 2);
1163 return stream
.Write("\r", 1);
1165 return stream
.Write("\n", 1);