]>
git.saurik.com Git - wxWidgets.git/blob - src/common/stream.cpp
0a6991a42ff3c89bd954b23deeb557f463057881
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
;
92 wxStreamBuffer::wxStreamBuffer(BufMode mode
)
94 m_stream
= new wxStreamBase
;
98 m_destroystream
= TRUE
;
102 wxStreamBuffer::wxStreamBuffer(const wxStreamBuffer
& buffer
)
104 // doing this has big chances to lead to a crashwhen the source buffer is
105 // destroyed (otherwise assume the caller knows what he does)
106 wxASSERT_MSG( !buffer
.m_destroybuf
&& !buffer
.m_destroystream
,
107 _T("it's a bad idea to copy this buffer") );
109 m_buffer_start
= buffer
.m_buffer_start
;
110 m_buffer_end
= buffer
.m_buffer_end
;
111 m_buffer_pos
= buffer
.m_buffer_pos
;
112 m_buffer_size
= buffer
.m_buffer_size
;
113 m_fixed
= buffer
.m_fixed
;
114 m_flushable
= buffer
.m_flushable
;
115 m_stream
= buffer
.m_stream
;
116 m_mode
= buffer
.m_mode
;
117 m_destroybuf
= FALSE
;
118 m_destroystream
= FALSE
;
121 void wxStreamBuffer::FreeBuffer()
124 free(m_buffer_start
);
127 wxStreamBuffer::~wxStreamBuffer()
131 if ( m_destroystream
)
135 wxInputStream
*wxStreamBuffer::GetInputStream() const
137 return m_mode
== write
? NULL
: (wxInputStream
*)m_stream
;
140 wxOutputStream
*wxStreamBuffer::GetOutputStream() const
142 return m_mode
== read
? NULL
: (wxOutputStream
*)m_stream
;
145 void wxStreamBuffer::SetBufferIO(void *buffer_start
,
149 SetBufferIO(buffer_start
, (char *)buffer_end
- (char *)buffer_start
,
153 void wxStreamBuffer::SetBufferIO(void *start
,
157 // start by freeing the old buffer
160 m_buffer_start
= (char *)start
;
161 m_buffer_end
= m_buffer_start
+ len
;
165 // if we own it, we free it
166 m_destroybuf
= !takeOwnership
;
171 void wxStreamBuffer::SetBufferIO(size_t bufsize
)
173 // start by freeing the old buffer
178 SetBufferIO(malloc(bufsize
), bufsize
, TRUE
/* take ownership */);
180 else // no buffer size => no buffer
186 void wxStreamBuffer::ResetBuffer()
188 wxCHECK_RET( m_stream
, _T("should have a stream in wxStreamBuffer") );
190 m_stream
->m_lasterror
= wxStream_NOERROR
;
191 m_stream
->m_lastcount
= 0;
192 if (m_mode
== read
&& m_flushable
)
193 m_buffer_pos
= m_buffer_end
;
195 m_buffer_pos
= m_buffer_start
;
198 // fill the buffer with as much data as possible (only for read buffers)
199 bool wxStreamBuffer::FillBuffer()
201 wxInputStream
*inStream
= GetInputStream();
203 wxCHECK_MSG( inStream
, FALSE
, _T("should have a stream in wxStreamBuffer") );
205 size_t count
= inStream
->OnSysRead(m_buffer_start
, m_buffer_size
);
209 m_buffer_end
= m_buffer_start
+ count
;
210 m_buffer_pos
= m_buffer_start
;
215 // write the buffer contents to the stream (only for write buffers)
216 bool wxStreamBuffer::FlushBuffer()
218 wxCHECK_MSG( m_flushable
, FALSE
, _T("can't flush this buffer") );
220 // FIXME: what is this check for? (VZ)
221 if ( m_buffer_pos
== m_buffer_start
)
224 wxOutputStream
*outStream
= GetOutputStream();
226 wxCHECK_MSG( outStream
, FALSE
, _T("should have a stream in wxStreamBuffer") );
228 size_t current
= m_buffer_pos
- m_buffer_start
;
229 size_t count
= outStream
->OnSysWrite(m_buffer_start
, current
);
230 if ( count
!= current
)
233 m_buffer_pos
= m_buffer_start
;
238 size_t wxStreamBuffer::GetDataLeft()
240 /* Why is this done? RR. */
241 if ( m_buffer_pos
== m_buffer_end
&& m_flushable
)
244 return GetBytesLeft();
247 // copy up to size bytes from our buffer into the provided one
248 void wxStreamBuffer::GetFromBuffer(void *buffer
, size_t size
)
250 // don't get more bytes than left in the buffer
251 size_t left
= GetBytesLeft();
256 memcpy(buffer
, m_buffer_pos
, size
);
257 m_buffer_pos
+= size
;
260 // copy the contents of the provided buffer into this one
261 void wxStreamBuffer::PutToBuffer(const void *buffer
, size_t size
)
263 size_t left
= GetBytesLeft();
268 // we can't realloc the buffer, so just copy what we can
273 // realloc the buffer to have enough space for the data
274 size_t delta
= m_buffer_pos
- m_buffer_start
;
276 char *startOld
= m_buffer_start
;
277 m_buffer_size
+= size
;
278 m_buffer_start
= (char *)realloc(m_buffer_start
, m_buffer_size
);
279 if ( !m_buffer_start
)
281 // don't leak memory if realloc() failed
282 m_buffer_start
= startOld
;
283 m_buffer_size
-= size
;
285 // what else can we do?
289 // adjust the pointers invalidated by realloc()
290 m_buffer_pos
= m_buffer_start
+ delta
;
291 m_buffer_end
= m_buffer_start
+ m_buffer_size
;
295 memcpy(m_buffer_pos
, buffer
, size
);
296 m_buffer_pos
+= size
;
299 void wxStreamBuffer::PutChar(char c
)
301 wxOutputStream
*outStream
= GetOutputStream();
303 wxCHECK_RET( outStream
, _T("should have a stream in wxStreamBuffer") );
305 // if we don't have buffer at all, just forward this call to the stream,
308 outStream
->OnSysWrite(&c
, 1);
312 // otherwise check we have enough space left
313 if ( !GetDataLeft() && !FlushBuffer() )
316 SetError(wxStream_WRITE_ERR
);
321 m_stream
->m_lastcount
= 1;
326 char wxStreamBuffer::Peek()
328 wxCHECK_MSG( m_stream
&& HasBuffer(), 0,
329 _T("should have the stream and the buffer in wxStreamBuffer") );
331 if ( !GetDataLeft() )
333 SetError(wxStream_READ_ERR
);
338 GetFromBuffer(&c
, 1);
344 char wxStreamBuffer::GetChar()
346 wxInputStream
*inStream
= GetInputStream();
348 wxCHECK_MSG( inStream
, 0, _T("should have a stream in wxStreamBuffer") );
353 inStream
->OnSysRead(&c
, 1);
357 if ( !GetDataLeft() )
359 SetError(wxStream_READ_ERR
);
364 GetFromBuffer(&c
, 1);
365 m_stream
->m_lastcount
= 1;
372 size_t wxStreamBuffer::Read(void *buffer
, size_t size
)
374 wxInputStream
*inStream
= GetInputStream();
376 wxCHECK_MSG( inStream
, 0, _T("should have a stream in wxStreamBuffer") );
378 // lasterror is reset before all new IO calls
379 m_stream
->m_lasterror
= wxStream_NOERROR
;
383 m_stream
->m_lastcount
= inStream
->OnSysRead(buffer
, size
);
385 else // we have a buffer, use it
387 size_t orig_size
= size
;
391 size_t left
= GetDataLeft();
393 // if the requested number of bytes if greater than the buffer
394 // size, read data in chunks
397 GetFromBuffer(buffer
, left
);
399 buffer
= (char *)buffer
+ left
;
403 SetError(wxStream_EOF
);
407 else // otherwise just do it in one gulp
409 GetFromBuffer(buffer
, size
);
414 m_stream
->m_lastcount
= orig_size
- size
;
417 return m_stream
->m_lastcount
;
420 // this should really be called "Copy()"
421 size_t wxStreamBuffer::Read(wxStreamBuffer
*dbuf
)
423 wxCHECK_MSG( m_mode
!= write
, 0, _T("can't read from this buffer") );
425 char buf
[BUF_TEMP_SIZE
];
431 nRead
= Read(dbuf
, WXSIZEOF(buf
));
434 nRead
= dbuf
->Write(buf
, nRead
);
443 size_t wxStreamBuffer::Write(const void *buffer
, size_t size
)
445 wxOutputStream
*outStream
= GetOutputStream();
447 wxCHECK_MSG( outStream
, 0, _T("should have a stream in wxStreamBuffer") );
449 // lasterror is reset before all new IO calls
450 m_stream
->m_lasterror
= wxStream_NOERROR
;
452 if ( !HasBuffer() && m_fixed
)
454 // no buffer, just forward the call to the stream
455 m_stream
->m_lastcount
= outStream
->OnSysWrite(buffer
, size
);
457 else // we [may] have a buffer, use it
459 size_t orig_size
= size
;
463 size_t left
= GetBytesLeft();
465 // if the buffer is too large to fit in the stream buffer, split
466 // it in smaller parts
468 // NB: If stream buffer isn't fixed (as for wxMemoryOutputStream),
469 // we always go to the second case.
471 // FIXME: fine, but if it fails we should (re)try writing it by
472 // chunks as this will (hopefully) always work (VZ)
473 if ( size
> left
&& m_fixed
)
475 PutToBuffer(buffer
, left
);
477 buffer
= (char *)buffer
+ left
;
479 if ( !FlushBuffer() )
481 SetError(wxStream_WRITE_ERR
);
486 m_buffer_pos
= m_buffer_start
;
488 else // we can do it in one gulp
490 PutToBuffer(buffer
, size
);
495 m_stream
->m_lastcount
= orig_size
- size
;
498 return m_stream
->m_lastcount
;
501 size_t wxStreamBuffer::Write(wxStreamBuffer
*sbuf
)
503 wxCHECK_MSG( m_mode
!= read
, 0, _T("can't write to this buffer") );
504 wxCHECK_MSG( sbuf
->m_mode
!= write
, 0, _T("can't read from that buffer") );
506 char buf
[BUF_TEMP_SIZE
];
512 size_t nRead
= sbuf
->Read(buf
, WXSIZEOF(buf
));
515 nWrite
= Write(buf
, nRead
);
516 if ( nWrite
< nRead
)
518 // put back data we couldn't copy
519 wxInputStream
*in_stream
= (wxInputStream
*)sbuf
->GetStream();
521 in_stream
->Ungetch(buf
+ nWrite
, nRead
- nWrite
);
531 while ( nWrite
== WXSIZEOF(buf
) );
536 off_t
wxStreamBuffer::Seek(off_t pos
, wxSeekMode mode
)
540 off_t last_access
= GetLastAccess();
551 diff
= pos
+ GetIntPosition();
555 diff
= pos
+ last_access
;
559 wxFAIL_MSG( _T("invalid seek mode") );
561 return wxInvalidOffset
;
563 if (diff
< 0 || diff
> last_access
)
564 return wxInvalidOffset
;
565 SetIntPosition(diff
);
572 // We'll try to compute an internal position later ...
573 ret_off
= m_stream
->OnSysSeek(pos
, wxFromStart
);
578 diff
= pos
+ GetIntPosition();
580 if ( (diff
> last_access
) || (diff
< 0) )
582 // We must take into account the fact that we have read
583 // something previously.
584 ret_off
= m_stream
->OnSysSeek(diff
-last_access
, wxFromCurrent
);
590 SetIntPosition(diff
);
595 // Hard to compute: always seek to the requested position.
596 ret_off
= m_stream
->OnSysSeek(pos
, wxFromEnd
);
601 return wxInvalidOffset
;
604 off_t
wxStreamBuffer::Tell() const
606 off_t pos
= m_stream
->OnSysTell();
607 if ( pos
== wxInvalidOffset
)
608 return wxInvalidOffset
;
610 pos
+= GetIntPosition();
612 if ( m_mode
== read
&& m_flushable
)
613 pos
-= GetLastAccess();
618 // ----------------------------------------------------------------------------
620 // ----------------------------------------------------------------------------
622 wxStreamBase::wxStreamBase()
624 m_lasterror
= wxStream_NOERROR
;
628 wxStreamBase::~wxStreamBase()
632 off_t
wxStreamBase::OnSysSeek(off_t
WXUNUSED(seek
), wxSeekMode
WXUNUSED(mode
))
634 return wxInvalidOffset
;
637 off_t
wxStreamBase::OnSysTell() const
639 return wxInvalidOffset
;
642 // ----------------------------------------------------------------------------
644 // ----------------------------------------------------------------------------
646 wxInputStream::wxInputStream()
653 wxInputStream::~wxInputStream()
658 size_t wxInputStream::OnSysRead(void * WXUNUSED(buffer
),
659 size_t WXUNUSED(bufsize
))
664 bool wxInputStream::Eof() const
666 wxInputStream
*self
= wxConstCast(this, wxInputStream
);
670 if ( GetLastError() == wxSTREAM_EOF
)
680 char *wxInputStream::AllocSpaceWBack(size_t needed_size
)
682 // get number of bytes left from previous wback buffer
683 size_t toget
= m_wbacksize
- m_wbackcur
;
685 // allocate a buffer large enough to hold prev + new data
686 char *temp_b
= (char *)malloc(needed_size
+ toget
);
691 /* copy previous data (and free old buffer) if needed */
694 memmove(temp_b
+ needed_size
, m_wback
+ m_wbackcur
, toget
);
701 m_wbacksize
= needed_size
+ toget
;
706 size_t wxInputStream::GetWBack(void *buf
, size_t bsize
)
708 size_t toget
= m_wbacksize
-m_wbackcur
;
716 memcpy(buf
, (m_wback
+m_wbackcur
), toget
);
719 if (m_wbackcur
== m_wbacksize
)
730 size_t wxInputStream::Ungetch(const void *buf
, size_t bufsize
)
732 char *ptrback
= AllocSpaceWBack(bufsize
);
736 memcpy(ptrback
, buf
, bufsize
);
740 bool wxInputStream::Ungetch(char c
)
742 void *ptrback
= AllocSpaceWBack(1);
746 *(char *)ptrback
= c
;
750 char wxInputStream::GetC()
757 wxInputStream
& wxInputStream::Read(void *buf
, size_t size
)
759 size_t retsize
= GetWBack(buf
, size
);
763 m_lasterror
= wxStream_NOERROR
;
767 buf
= (char *)buf
+ retsize
;
769 m_lastcount
= OnSysRead(buf
, size
) + retsize
;
773 char wxInputStream::Peek()
777 if (m_lasterror
== wxStream_NOERROR
)
786 wxInputStream
& wxInputStream::Read(wxOutputStream
& stream_out
)
788 char buf
[BUF_TEMP_SIZE
];
789 size_t bytes_read
= BUF_TEMP_SIZE
;
791 while (bytes_read
== BUF_TEMP_SIZE
)
793 bytes_read
= Read(buf
, bytes_read
).LastRead();
794 bytes_read
= stream_out
.Write(buf
, bytes_read
).LastWrite();
799 off_t
wxInputStream::SeekI(off_t pos
, wxSeekMode mode
)
801 /* Should be check and improve, just to remove a slight bug !
802 I don't know whether it should be put as well in wxFileInputStream::OnSysSeek ? */
803 if (m_lasterror
==wxSTREAM_EOF
)
804 m_lasterror
=wxSTREAM_NOERROR
;
806 /* A call to SeekI() will automatically invalidate any previous call
807 to Ungetch(), otherwise it would be possible to SeekI() to one
808 one position, unread some bytes there, SeekI() to another position
809 and the data would be corrupted.
811 GRG: Could add code here to try to navigate within the wback
812 buffer if possible, but is it really needed? It would only work
813 when seeking in wxFromCurrent mode, else it would invalidate
824 return OnSysSeek(pos
, mode
);
827 off_t
wxInputStream::TellI() const
829 /* GRG: Changed to make it compatible with the wback buffer */
830 off_t pos
= OnSysTell();
832 if (pos
!= wxInvalidOffset
)
833 pos
-= (m_wbacksize
- m_wbackcur
);
838 // --------------------
839 // Overloaded operators
840 // --------------------
843 wxInputStream
& wxInputStream::operator>>(wxObject
*& obj
)
845 wxObjectInputStream
obj_s(*this);
846 obj
= obj_s
.LoadObject();
849 #endif // wxUSE_SERIAL
852 // ----------------------------------------------------------------------------
854 // ----------------------------------------------------------------------------
856 wxOutputStream::wxOutputStream()
860 wxOutputStream::~wxOutputStream()
864 size_t wxOutputStream::OnSysWrite(const void * WXUNUSED(buffer
),
865 size_t WXUNUSED(bufsize
))
870 void wxOutputStream::PutC(char c
)
875 wxOutputStream
& wxOutputStream::Write(const void *buffer
, size_t size
)
877 m_lastcount
= OnSysWrite(buffer
, size
);
881 wxOutputStream
& wxOutputStream::Write(wxInputStream
& stream_in
)
883 stream_in
.Read(*this);
887 off_t
wxOutputStream::TellO() const
892 off_t
wxOutputStream::SeekO(off_t pos
, wxSeekMode mode
)
894 return OnSysSeek(pos
, mode
);
897 void wxOutputStream::Sync()
902 wxOutputStream
& wxOutputStream::operator<<(wxObject
& obj
)
904 wxObjectOutputStream
obj_s(*this);
905 obj_s
.SaveObject(obj
);
908 #endif // wxUSE_SERIAL
910 // ----------------------------------------------------------------------------
911 // wxCountingOutputStream
912 // ----------------------------------------------------------------------------
914 wxCountingOutputStream::wxCountingOutputStream ()
919 size_t wxCountingOutputStream::GetSize() const
924 size_t wxCountingOutputStream::OnSysWrite(const void *WXUNUSED(buffer
),
927 m_currentPos
+= size
;
928 if (m_currentPos
> m_lastcount
)
929 m_lastcount
= m_currentPos
;
934 off_t
wxCountingOutputStream::OnSysSeek(off_t pos
, wxSeekMode mode
)
943 m_currentPos
= m_lastcount
+ pos
;
951 wxFAIL_MSG( _T("invalid seek mode") );
952 return wxInvalidOffset
;
955 if (m_currentPos
> m_lastcount
)
956 m_lastcount
= m_currentPos
;
961 off_t
wxCountingOutputStream::OnSysTell() const
966 // ----------------------------------------------------------------------------
967 // wxFilterInputStream
968 // ----------------------------------------------------------------------------
970 wxFilterInputStream::wxFilterInputStream()
972 m_parent_i_stream
= NULL
;
975 wxFilterInputStream::wxFilterInputStream(wxInputStream
& stream
)
977 m_parent_i_stream
= &stream
;
980 wxFilterInputStream::~wxFilterInputStream()
984 // ----------------------------------------------------------------------------
985 // wxFilterOutputStream
986 // ----------------------------------------------------------------------------
988 wxFilterOutputStream::wxFilterOutputStream()
990 m_parent_o_stream
= NULL
;
993 wxFilterOutputStream::wxFilterOutputStream(wxOutputStream
& stream
)
995 m_parent_o_stream
= &stream
;
998 wxFilterOutputStream::~wxFilterOutputStream()
1002 // ----------------------------------------------------------------------------
1003 // wxBufferedInputStream
1004 // ----------------------------------------------------------------------------
1006 wxBufferedInputStream::wxBufferedInputStream(wxInputStream
& s
,
1007 wxStreamBuffer
*buffer
)
1008 : wxFilterInputStream(s
)
1012 // use the buffer provided by the user
1013 m_i_streambuf
= buffer
;
1015 else // create a default buffer
1017 m_i_streambuf
= new wxStreamBuffer(*this, wxStreamBuffer::read
);
1019 m_i_streambuf
->SetBufferIO(1024);
1023 wxBufferedInputStream::~wxBufferedInputStream()
1025 m_parent_i_stream
->SeekI(-m_i_streambuf
->GetBytesLeft(), wxFromCurrent
);
1027 delete m_i_streambuf
;
1030 char wxBufferedInputStream::Peek()
1032 return m_i_streambuf
->Peek();
1035 wxInputStream
& wxBufferedInputStream::Read(void *buf
, size_t size
)
1039 retsize
= GetWBack(buf
, size
);
1040 m_lastcount
= retsize
;
1041 if ( retsize
== size
)
1043 m_lasterror
= wxStream_NOERROR
;
1047 buf
= (char *)buf
+ retsize
;
1049 m_i_streambuf
->Read(buf
, size
);
1054 off_t
wxBufferedInputStream::SeekI(off_t pos
, wxSeekMode mode
)
1056 return m_i_streambuf
->Seek(pos
, mode
);
1059 off_t
wxBufferedInputStream::TellI() const
1061 return m_i_streambuf
->Tell();
1064 size_t wxBufferedInputStream::OnSysRead(void *buffer
, size_t bufsize
)
1066 return m_parent_i_stream
->Read(buffer
, bufsize
).LastRead();
1069 off_t
wxBufferedInputStream::OnSysSeek(off_t seek
, wxSeekMode mode
)
1071 return m_parent_i_stream
->SeekI(seek
, mode
);
1074 off_t
wxBufferedInputStream::OnSysTell() const
1076 return m_parent_i_stream
->TellI();
1079 void wxBufferedInputStream::SetInputStreamBuffer(wxStreamBuffer
*buffer
)
1081 wxCHECK_RET( buffer
, _T("wxBufferedInputStream needs buffer") );
1083 delete m_i_streambuf
;
1084 m_i_streambuf
= buffer
;
1087 // ----------------------------------------------------------------------------
1088 // wxBufferedOutputStream
1089 // ----------------------------------------------------------------------------
1091 wxBufferedOutputStream::wxBufferedOutputStream(wxOutputStream
& s
,
1092 wxStreamBuffer
*buffer
)
1093 : wxFilterOutputStream(s
)
1097 m_o_streambuf
= buffer
;
1099 else // create a default one
1101 m_o_streambuf
= new wxStreamBuffer(*this, wxStreamBuffer::write
);
1103 m_o_streambuf
->SetBufferIO(1024);
1107 wxBufferedOutputStream::~wxBufferedOutputStream()
1110 delete m_o_streambuf
;
1113 wxOutputStream
& wxBufferedOutputStream::Write(const void *buffer
, size_t size
)
1116 m_o_streambuf
->Write(buffer
, size
);
1120 off_t
wxBufferedOutputStream::SeekO(off_t pos
, wxSeekMode mode
)
1123 return m_o_streambuf
->Seek(pos
, mode
);
1126 off_t
wxBufferedOutputStream::TellO() const
1128 return m_o_streambuf
->Tell();
1131 void wxBufferedOutputStream::Sync()
1133 m_o_streambuf
->FlushBuffer();
1134 m_parent_o_stream
->Sync();
1137 size_t wxBufferedOutputStream::OnSysWrite(const void *buffer
, size_t bufsize
)
1139 return m_parent_o_stream
->Write(buffer
, bufsize
).LastWrite();
1142 off_t
wxBufferedOutputStream::OnSysSeek(off_t seek
, wxSeekMode mode
)
1144 return m_parent_o_stream
->SeekO(seek
, mode
);
1147 off_t
wxBufferedOutputStream::OnSysTell() const
1149 return m_parent_o_stream
->TellO();
1152 size_t wxBufferedOutputStream::GetSize() const
1154 return m_parent_o_stream
->GetSize() + m_o_streambuf
->GetIntPosition();
1157 void wxBufferedOutputStream::SetOutputStreamBuffer(wxStreamBuffer
*buffer
)
1159 wxCHECK_RET( buffer
, _T("wxBufferedOutputStream needs buffer") );
1161 delete m_o_streambuf
;
1162 m_o_streambuf
= buffer
;
1165 // ----------------------------------------------------------------------------
1166 // Some IOManip function
1167 // ----------------------------------------------------------------------------
1169 wxOutputStream
& wxEndL(wxOutputStream
& stream
)
1172 return stream
.Write("\r\n", 2);
1175 return stream
.Write("\r", 1);
1177 return stream
.Write("\n", 1);