]>
git.saurik.com Git - wxWidgets.git/blob - src/common/stream.cpp
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 off_t
wxStreamBase::OnSysSeek(off_t
WXUNUSED(seek
), wxSeekMode
WXUNUSED(mode
))
632 return wxInvalidOffset
;
635 off_t
wxStreamBase::OnSysTell() const
637 return wxInvalidOffset
;
640 // ----------------------------------------------------------------------------
642 // ----------------------------------------------------------------------------
644 wxInputStream::wxInputStream()
651 wxInputStream::~wxInputStream()
656 size_t wxInputStream::OnSysRead(void * WXUNUSED(buffer
),
657 size_t WXUNUSED(bufsize
))
662 bool wxInputStream::Eof() const
664 wxInputStream
*self
= wxConstCast(this, wxInputStream
);
668 if ( GetLastError() == wxSTREAM_EOF
)
678 char *wxInputStream::AllocSpaceWBack(size_t needed_size
)
680 // get number of bytes left from previous wback buffer
681 size_t toget
= m_wbacksize
- m_wbackcur
;
683 // allocate a buffer large enough to hold prev + new data
684 char *temp_b
= (char *)malloc(needed_size
+ toget
);
689 /* copy previous data (and free old buffer) if needed */
692 memmove(temp_b
+ needed_size
, m_wback
+ m_wbackcur
, toget
);
699 m_wbacksize
= needed_size
+ toget
;
704 size_t wxInputStream::GetWBack(void *buf
, size_t bsize
)
706 size_t toget
= m_wbacksize
-m_wbackcur
;
714 memcpy(buf
, (m_wback
+m_wbackcur
), toget
);
717 if (m_wbackcur
== m_wbacksize
)
728 size_t wxInputStream::Ungetch(const void *buf
, size_t bufsize
)
730 char *ptrback
= AllocSpaceWBack(bufsize
);
734 memcpy(ptrback
, buf
, bufsize
);
738 bool wxInputStream::Ungetch(char c
)
740 void *ptrback
= AllocSpaceWBack(1);
744 *(char *)ptrback
= c
;
748 char wxInputStream::GetC()
755 wxInputStream
& wxInputStream::Read(void *buf
, size_t size
)
757 size_t retsize
= GetWBack(buf
, size
);
761 m_lasterror
= wxStream_NOERROR
;
765 buf
= (char *)buf
+ retsize
;
767 m_lastcount
= OnSysRead(buf
, size
) + retsize
;
771 char wxInputStream::Peek()
775 if (m_lasterror
== wxStream_NOERROR
)
784 wxInputStream
& wxInputStream::Read(wxOutputStream
& stream_out
)
786 char buf
[BUF_TEMP_SIZE
];
787 size_t bytes_read
= BUF_TEMP_SIZE
;
789 while (bytes_read
== BUF_TEMP_SIZE
)
791 bytes_read
= Read(buf
, bytes_read
).LastRead();
792 bytes_read
= stream_out
.Write(buf
, bytes_read
).LastWrite();
797 off_t
wxInputStream::SeekI(off_t pos
, wxSeekMode mode
)
799 /* Should be check and improve, just to remove a slight bug !
800 I don't know whether it should be put as well in wxFileInputStream::OnSysSeek ? */
801 if (m_lasterror
==wxSTREAM_EOF
)
802 m_lasterror
=wxSTREAM_NOERROR
;
804 /* A call to SeekI() will automatically invalidate any previous call
805 to Ungetch(), otherwise it would be possible to SeekI() to one
806 one position, unread some bytes there, SeekI() to another position
807 and the data would be corrupted.
809 GRG: Could add code here to try to navigate within the wback
810 buffer if possible, but is it really needed? It would only work
811 when seeking in wxFromCurrent mode, else it would invalidate
822 return OnSysSeek(pos
, mode
);
825 off_t
wxInputStream::TellI() const
827 /* GRG: Changed to make it compatible with the wback buffer */
828 off_t pos
= OnSysTell();
830 if (pos
!= wxInvalidOffset
)
831 pos
-= (m_wbacksize
- m_wbackcur
);
836 // --------------------
837 // Overloaded operators
838 // --------------------
841 wxInputStream
& wxInputStream::operator>>(wxObject
*& obj
)
843 wxObjectInputStream
obj_s(*this);
844 obj
= obj_s
.LoadObject();
847 #endif // wxUSE_SERIAL
850 // ----------------------------------------------------------------------------
852 // ----------------------------------------------------------------------------
854 wxOutputStream::wxOutputStream()
858 wxOutputStream::~wxOutputStream()
862 size_t wxOutputStream::OnSysWrite(const void * WXUNUSED(buffer
),
863 size_t WXUNUSED(bufsize
))
868 void wxOutputStream::PutC(char c
)
873 wxOutputStream
& wxOutputStream::Write(const void *buffer
, size_t size
)
875 m_lastcount
= OnSysWrite(buffer
, size
);
879 wxOutputStream
& wxOutputStream::Write(wxInputStream
& stream_in
)
881 stream_in
.Read(*this);
885 off_t
wxOutputStream::TellO() const
890 off_t
wxOutputStream::SeekO(off_t pos
, wxSeekMode mode
)
892 return OnSysSeek(pos
, mode
);
895 void wxOutputStream::Sync()
900 wxOutputStream
& wxOutputStream::operator<<(wxObject
& obj
)
902 wxObjectOutputStream
obj_s(*this);
903 obj_s
.SaveObject(obj
);
906 #endif // wxUSE_SERIAL
908 // ----------------------------------------------------------------------------
909 // wxCountingOutputStream
910 // ----------------------------------------------------------------------------
912 wxCountingOutputStream::wxCountingOutputStream ()
917 size_t wxCountingOutputStream::GetSize() const
922 size_t wxCountingOutputStream::OnSysWrite(const void *WXUNUSED(buffer
),
925 m_currentPos
+= size
;
926 if (m_currentPos
> m_lastcount
)
927 m_lastcount
= m_currentPos
;
932 off_t
wxCountingOutputStream::OnSysSeek(off_t pos
, wxSeekMode mode
)
941 m_currentPos
= m_lastcount
+ pos
;
949 wxFAIL_MSG( _T("invalid seek mode") );
950 return wxInvalidOffset
;
953 if (m_currentPos
> m_lastcount
)
954 m_lastcount
= m_currentPos
;
959 off_t
wxCountingOutputStream::OnSysTell() const
964 // ----------------------------------------------------------------------------
965 // wxFilterInputStream
966 // ----------------------------------------------------------------------------
968 wxFilterInputStream::wxFilterInputStream()
970 m_parent_i_stream
= NULL
;
973 wxFilterInputStream::wxFilterInputStream(wxInputStream
& stream
)
975 m_parent_i_stream
= &stream
;
978 wxFilterInputStream::~wxFilterInputStream()
982 // ----------------------------------------------------------------------------
983 // wxFilterOutputStream
984 // ----------------------------------------------------------------------------
986 wxFilterOutputStream::wxFilterOutputStream()
988 m_parent_o_stream
= NULL
;
991 wxFilterOutputStream::wxFilterOutputStream(wxOutputStream
& stream
)
993 m_parent_o_stream
= &stream
;
996 wxFilterOutputStream::~wxFilterOutputStream()
1000 // ----------------------------------------------------------------------------
1001 // wxBufferedInputStream
1002 // ----------------------------------------------------------------------------
1004 wxBufferedInputStream::wxBufferedInputStream(wxInputStream
& s
,
1005 wxStreamBuffer
*buffer
)
1006 : wxFilterInputStream(s
)
1010 // use the buffer provided by the user
1011 m_i_streambuf
= buffer
;
1013 else // create a default buffer
1015 m_i_streambuf
= new wxStreamBuffer(*this, wxStreamBuffer::read
);
1017 m_i_streambuf
->SetBufferIO(1024);
1021 wxBufferedInputStream::~wxBufferedInputStream()
1023 m_parent_i_stream
->SeekI(-m_i_streambuf
->GetBytesLeft(), wxFromCurrent
);
1025 delete m_i_streambuf
;
1028 char wxBufferedInputStream::Peek()
1030 return m_i_streambuf
->Peek();
1033 wxInputStream
& wxBufferedInputStream::Read(void *buf
, size_t size
)
1037 retsize
= GetWBack(buf
, size
);
1038 m_lastcount
= retsize
;
1039 if ( retsize
== size
)
1041 m_lasterror
= wxStream_NOERROR
;
1045 buf
= (char *)buf
+ retsize
;
1047 m_i_streambuf
->Read(buf
, size
);
1052 off_t
wxBufferedInputStream::SeekI(off_t pos
, wxSeekMode mode
)
1054 return m_i_streambuf
->Seek(pos
, mode
);
1057 off_t
wxBufferedInputStream::TellI() const
1059 return m_i_streambuf
->Tell();
1062 size_t wxBufferedInputStream::OnSysRead(void *buffer
, size_t bufsize
)
1064 return m_parent_i_stream
->Read(buffer
, bufsize
).LastRead();
1067 off_t
wxBufferedInputStream::OnSysSeek(off_t seek
, wxSeekMode mode
)
1069 return m_parent_i_stream
->SeekI(seek
, mode
);
1072 off_t
wxBufferedInputStream::OnSysTell() const
1074 return m_parent_i_stream
->TellI();
1077 void wxBufferedInputStream::SetInputStreamBuffer(wxStreamBuffer
*buffer
)
1079 wxCHECK_RET( buffer
, _T("wxBufferedInputStream needs buffer") );
1081 delete m_i_streambuf
;
1082 m_i_streambuf
= buffer
;
1085 // ----------------------------------------------------------------------------
1086 // wxBufferedOutputStream
1087 // ----------------------------------------------------------------------------
1089 wxBufferedOutputStream::wxBufferedOutputStream(wxOutputStream
& s
,
1090 wxStreamBuffer
*buffer
)
1091 : wxFilterOutputStream(s
)
1095 m_o_streambuf
= buffer
;
1097 else // create a default one
1099 m_o_streambuf
= new wxStreamBuffer(*this, wxStreamBuffer::write
);
1101 m_o_streambuf
->SetBufferIO(1024);
1105 wxBufferedOutputStream::~wxBufferedOutputStream()
1108 delete m_o_streambuf
;
1111 wxOutputStream
& wxBufferedOutputStream::Write(const void *buffer
, size_t size
)
1114 m_o_streambuf
->Write(buffer
, size
);
1118 off_t
wxBufferedOutputStream::SeekO(off_t pos
, wxSeekMode mode
)
1121 return m_o_streambuf
->Seek(pos
, mode
);
1124 off_t
wxBufferedOutputStream::TellO() const
1126 return m_o_streambuf
->Tell();
1129 void wxBufferedOutputStream::Sync()
1131 m_o_streambuf
->FlushBuffer();
1132 m_parent_o_stream
->Sync();
1135 size_t wxBufferedOutputStream::OnSysWrite(const void *buffer
, size_t bufsize
)
1137 return m_parent_o_stream
->Write(buffer
, bufsize
).LastWrite();
1140 off_t
wxBufferedOutputStream::OnSysSeek(off_t seek
, wxSeekMode mode
)
1142 return m_parent_o_stream
->SeekO(seek
, mode
);
1145 off_t
wxBufferedOutputStream::OnSysTell() const
1147 return m_parent_o_stream
->TellO();
1150 size_t wxBufferedOutputStream::GetSize() const
1152 return m_parent_o_stream
->GetSize() + m_o_streambuf
->GetIntPosition();
1155 void wxBufferedOutputStream::SetOutputStreamBuffer(wxStreamBuffer
*buffer
)
1157 wxCHECK_RET( buffer
, _T("wxBufferedOutputStream needs buffer") );
1159 delete m_o_streambuf
;
1160 m_o_streambuf
= buffer
;
1163 // ----------------------------------------------------------------------------
1164 // Some IOManip function
1165 // ----------------------------------------------------------------------------
1167 wxOutputStream
& wxEndL(wxOutputStream
& stream
)
1170 return stream
.Write("\r\n", 2);
1173 return stream
.Write("\r", 1);
1175 return stream
.Write("\n", 1);