]> git.saurik.com Git - wxWidgets.git/blob - src/common/stream.cpp
Replaced ostream with FILE* in wxExpr.
[wxWidgets.git] / src / common / stream.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: stream.cpp
3 // Purpose: wxStream base classes
4 // Author: Guilhem Lavaux
5 // Modified by:
6 // Created: 11/07/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Guilhem Lavaux
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "stream.h"
14 #endif
15
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
18
19 #ifdef __BORLANDC__
20 #pragma hdrstop
21 #endif
22
23 #ifndef WX_PRECOMP
24 #include "wx/defs.h"
25 #endif
26
27 #if wxUSE_STREAMS
28
29 #include <ctype.h>
30 #include <wx/stream.h>
31 #include <wx/datstrm.h>
32 #include <wx/objstrm.h>
33
34 #define BUF_TEMP_SIZE 10000
35
36 // ----------------------------------------------------------------------------
37 // wxStreamBuffer
38 // ----------------------------------------------------------------------------
39
40 #define CHECK_ERROR(err) \
41 if (m_stream->m_lasterror == wxStream_NOERROR) \
42 m_stream->m_lasterror = err
43
44 wxStreamBuffer::wxStreamBuffer(wxStreamBase& stream, BufMode mode)
45 : m_buffer_start(NULL), m_buffer_end(NULL), m_buffer_pos(NULL),
46 m_buffer_size(0), m_wback(NULL), m_wbacksize(0), m_wbackcur(0),
47 m_fixed(TRUE), m_flushable(TRUE), m_stream(&stream),
48 m_mode(mode), m_destroybuf(FALSE), m_destroystream(FALSE)
49 {
50 }
51
52 wxStreamBuffer::wxStreamBuffer(BufMode mode)
53 : m_buffer_start(NULL), m_buffer_end(NULL), m_buffer_pos(NULL),
54 m_buffer_size(0), m_wback(NULL), m_wbacksize(0), m_wbackcur(0),
55 m_fixed(TRUE), m_flushable(FALSE), m_stream(NULL),
56 m_mode(mode), m_destroybuf(FALSE), m_destroystream(TRUE)
57 {
58 m_stream = new wxStreamBase();
59 }
60
61 wxStreamBuffer::wxStreamBuffer(const wxStreamBuffer& buffer)
62 {
63 m_buffer_start = buffer.m_buffer_start;
64 m_buffer_end = buffer.m_buffer_end;
65 m_buffer_pos = buffer.m_buffer_pos;
66 m_buffer_size = buffer.m_buffer_size;
67 m_fixed = buffer.m_fixed;
68 m_flushable = buffer.m_flushable;
69 m_stream = buffer.m_stream;
70 m_mode = buffer.m_mode;
71 m_destroybuf = FALSE;
72 m_destroystream = FALSE;
73 m_wback = NULL;
74 m_wbacksize = 0;
75 m_wbackcur = 0;
76 }
77
78 wxStreamBuffer::~wxStreamBuffer()
79 {
80 if (m_wback)
81 free(m_wback);
82 if (m_destroybuf)
83 wxDELETEA(m_buffer_start);
84 if (m_destroystream)
85 delete m_stream;
86 }
87
88 size_t wxStreamBuffer::WriteBack(const char *buf, size_t bufsize)
89 {
90 char *ptrback;
91
92 if (m_mode != read)
93 return 0;
94
95 ptrback = AllocSpaceWBack(bufsize);
96 if (!ptrback)
97 return 0;
98
99 memcpy(ptrback, buf, bufsize);
100 return bufsize;
101 }
102
103 bool wxStreamBuffer::WriteBack(char c)
104 {
105 char *ptrback;
106
107 ptrback = AllocSpaceWBack(1);
108 if (!ptrback)
109 return FALSE;
110
111 *ptrback = c;
112 return TRUE;
113 }
114
115 void wxStreamBuffer::SetBufferIO(char *buffer_start, char *buffer_end)
116 {
117 if (m_destroybuf)
118 wxDELETEA(m_buffer_start);
119 m_buffer_start = buffer_start;
120 m_buffer_end = buffer_end;
121
122 m_buffer_size = m_buffer_end-m_buffer_start;
123 m_destroybuf = FALSE;
124 ResetBuffer();
125 }
126
127 void wxStreamBuffer::SetBufferIO(size_t bufsize)
128 {
129 char *b_start;
130
131 if (m_destroybuf)
132 wxDELETEA(m_buffer_start);
133
134 if (!bufsize) {
135 m_buffer_start = NULL;
136 m_buffer_end = NULL;
137 m_buffer_pos = NULL;
138 m_buffer_size = 0;
139 return;
140 }
141
142 b_start = new char[bufsize];
143 SetBufferIO(b_start, b_start + bufsize);
144 m_destroybuf = TRUE;
145 }
146
147 void wxStreamBuffer::ResetBuffer()
148 {
149 m_stream->m_lasterror = wxStream_NOERROR;
150 m_stream->m_lastcount = 0;
151 if (m_mode == read)
152 m_buffer_pos = m_buffer_end;
153 else
154 m_buffer_pos = m_buffer_start;
155 }
156
157 char *wxStreamBuffer::AllocSpaceWBack(size_t needed_size)
158 {
159 char *temp_b;
160
161 m_wbacksize += needed_size;
162
163 if (!m_wback)
164 temp_b = (char *)malloc(m_wbacksize);
165 else
166 temp_b = (char *)realloc(m_wback, m_wbacksize);
167
168 if (!temp_b)
169 return NULL;
170 m_wback = temp_b;
171
172 return (char *)(m_wback+(m_wbacksize-needed_size));
173 }
174
175 size_t wxStreamBuffer::GetWBack(char *buf, size_t bsize)
176 {
177 size_t s_toget = m_wbacksize-m_wbackcur;
178
179 if (bsize < s_toget)
180 s_toget = bsize;
181
182 memcpy(buf, (m_wback+m_wbackcur), s_toget);
183
184 m_wbackcur += s_toget;
185 if (m_wbackcur == m_wbacksize) {
186 free(m_wback);
187 m_wback = (char *)NULL;
188 m_wbacksize = 0;
189 m_wbackcur = 0;
190 }
191
192 return s_toget;
193 }
194
195 bool wxStreamBuffer::FillBuffer()
196 {
197 size_t count;
198
199 count = m_stream->OnSysRead(m_buffer_start, m_buffer_size);
200 m_buffer_end = m_buffer_start+count;
201 m_buffer_pos = m_buffer_start;
202
203 if (count == 0)
204 return FALSE;
205 return TRUE;
206 }
207
208 bool wxStreamBuffer::FlushBuffer()
209 {
210 size_t count, current;
211
212 if (m_buffer_pos == m_buffer_start || !m_flushable)
213 return FALSE;
214
215 current = m_buffer_pos-m_buffer_start;
216 count = m_stream->OnSysWrite(m_buffer_start, current);
217 if (count != current)
218 return FALSE;
219 m_buffer_pos = m_buffer_start;
220
221 return TRUE;
222 }
223
224 void wxStreamBuffer::GetFromBuffer(void *buffer, size_t size)
225 {
226 size_t s_toget = m_buffer_end-m_buffer_pos;
227
228 if (size < s_toget)
229 s_toget = size;
230
231 memcpy(buffer, m_buffer_pos, s_toget);
232 m_buffer_pos += s_toget;
233 }
234
235 void wxStreamBuffer::PutToBuffer(const void *buffer, size_t size)
236 {
237 size_t s_toput = m_buffer_end-m_buffer_pos;
238
239 if (s_toput < size && !m_fixed) {
240 m_buffer_start = (char *)realloc(m_buffer_start, m_buffer_size+size);
241 // I round a bit
242 m_buffer_size += size;
243 m_buffer_end = m_buffer_start+m_buffer_size;
244 s_toput = size;
245 }
246 if (s_toput > size)
247 s_toput = size;
248 memcpy(m_buffer_pos, buffer, s_toput);
249 m_buffer_pos += s_toput;
250 }
251
252 void wxStreamBuffer::PutChar(char c)
253 {
254 wxASSERT(m_stream != NULL);
255
256 if (!m_buffer_size) {
257 m_stream->OnSysWrite(&c, 1);
258 return;
259 }
260
261 if (GetDataLeft() == 0 && !FlushBuffer()) {
262 CHECK_ERROR(wxStream_WRITE_ERR);
263 return;
264 }
265
266 PutToBuffer(&c, 1);
267 m_stream->m_lastcount = 1;
268 }
269
270 char wxStreamBuffer::GetChar()
271 {
272 char c;
273
274 wxASSERT(m_stream != NULL);
275
276 if (!m_buffer_size) {
277 m_stream->OnSysRead(&c, 1);
278 return c;
279 }
280
281 if (!GetDataLeft()) {
282 CHECK_ERROR(wxStream_READ_ERR);
283 return 0;
284 }
285
286 GetFromBuffer(&c, 1);
287
288 m_stream->m_lastcount = 1;
289 return c;
290 }
291
292 size_t wxStreamBuffer::Read(void *buffer, size_t size)
293 {
294 wxASSERT(m_stream != NULL);
295
296 if (m_mode == write)
297 return 0;
298
299 // ------------------
300 // Buffering disabled
301 // ------------------
302
303 m_stream->m_lasterror = wxStream_NOERROR;
304 m_stream->m_lastcount = GetWBack((char *)buffer, size);
305 size -= m_stream->m_lastcount;
306 if (size == 0)
307 return m_stream->m_lastcount;
308
309 buffer = (void *)((char *)buffer+m_stream->m_lastcount);
310
311 if (!m_buffer_size)
312 return (m_stream->m_lastcount += m_stream->OnSysRead(buffer, size));
313
314 // -----------------
315 // Buffering enabled
316 // -----------------
317 size_t buf_left, orig_size = size;
318
319 while (size > 0) {
320 buf_left = GetDataLeft();
321
322 // First case: the requested buffer is larger than the stream buffer,
323 // we split it.
324 if (size > buf_left) {
325 GetFromBuffer(buffer, buf_left);
326 size -= buf_left;
327 buffer = (char *)buffer + buf_left; // ANSI C++ violation.
328
329 if (!FillBuffer()) {
330 CHECK_ERROR(wxStream_READ_ERR);
331 return (m_stream->m_lastcount = orig_size-size);
332 }
333 } else {
334
335 // Second case: we just copy from the stream buffer.
336 GetFromBuffer(buffer, size);
337 break;
338 }
339 }
340 return (m_stream->m_lastcount += orig_size);
341 }
342
343 size_t wxStreamBuffer::Read(wxStreamBuffer *s_buf)
344 {
345 char buf[BUF_TEMP_SIZE];
346 size_t s = 0, bytes_read = BUF_TEMP_SIZE;
347
348 if (m_mode == write)
349 return 0;
350
351 while (bytes_read != 0) {
352 bytes_read = Read(buf, bytes_read);
353 bytes_read = s_buf->Write(buf, bytes_read);
354 s += bytes_read;
355 }
356 return s;
357 }
358
359 size_t wxStreamBuffer::Write(const void *buffer, size_t size)
360 {
361 wxASSERT(m_stream != NULL);
362
363 if (m_mode == read)
364 return 0;
365
366 // ------------------
367 // Buffering disabled
368 // ------------------
369
370 m_stream->m_lasterror = wxStream_NOERROR;
371 if (!m_buffer_size)
372 return (m_stream->m_lastcount = m_stream->OnSysWrite(buffer, size));
373
374 // ------------------
375 // Buffering enabled
376 // ------------------
377
378 size_t buf_left, orig_size = size;
379
380 while (size > 0) {
381 buf_left = m_buffer_end - m_buffer_pos;
382
383 // First case: the buffer to write is larger than the stream buffer,
384 // we split it
385 if (size > buf_left) {
386 PutToBuffer(buffer, buf_left);
387 size -= buf_left;
388 buffer = (char *)buffer + buf_left; // ANSI C++ violation.
389
390 if (!FlushBuffer()) {
391 CHECK_ERROR(wxStream_WRITE_ERR);
392 return (m_stream->m_lastcount = orig_size-size);
393 }
394
395 m_buffer_pos = m_buffer_start;
396
397 } else {
398
399 // Second case: just copy it in the stream buffer.
400 PutToBuffer(buffer, size);
401 break;
402 }
403 }
404 return (m_stream->m_lastcount = orig_size);
405 }
406
407 size_t wxStreamBuffer::Write(wxStreamBuffer *sbuf)
408 {
409 char buf[BUF_TEMP_SIZE];
410 size_t s = 0, bytes_count = BUF_TEMP_SIZE, b_count2;
411
412 if (m_mode == read)
413 return 0;
414
415 while (bytes_count == BUF_TEMP_SIZE) {
416 b_count2 = sbuf->Read(buf, bytes_count);
417 bytes_count = Write(buf, b_count2);
418 if (b_count2 > bytes_count)
419 sbuf->WriteBack(buf+bytes_count, b_count2-bytes_count);
420 s += bytes_count;
421 }
422 return s;
423 }
424
425 off_t wxStreamBuffer::Seek(off_t pos, wxSeekMode mode)
426 {
427 off_t ret_off, diff, last_access;
428
429 last_access = GetLastAccess();
430
431 if (!m_flushable) {
432 diff = pos + GetIntPosition();
433 if (diff < 0 || diff > last_access)
434 return wxInvalidOffset;
435 SetIntPosition(diff);
436 return diff;
437 }
438
439 switch (mode) {
440 case wxFromStart: {
441 // We'll try to compute an internal position later ...
442 ret_off = m_stream->OnSysSeek(pos, wxFromStart);
443 ResetBuffer();
444 return ret_off;
445 }
446 case wxFromCurrent: {
447 diff = pos + GetIntPosition();
448
449 if ( (diff > last_access) || (diff < 0) ) {
450 ret_off = m_stream->OnSysSeek(pos, wxFromCurrent);
451 ResetBuffer();
452 return ret_off;
453 } else {
454 SetIntPosition(diff);
455 return pos;
456 }
457 }
458 case wxFromEnd:
459 // Hard to compute: always seek to the requested position.
460 ret_off = m_stream->OnSysSeek(pos, wxFromEnd);
461 ResetBuffer();
462 return ret_off;
463 }
464 return wxInvalidOffset;
465 }
466
467 off_t wxStreamBuffer::Tell() const
468 {
469 off_t pos;
470
471 if (m_flushable) {
472 pos = m_stream->OnSysTell();
473 if (pos == wxInvalidOffset)
474 return wxInvalidOffset;
475 return pos - GetLastAccess() + GetIntPosition();
476 } else
477 return GetIntPosition();
478 }
479
480 size_t wxStreamBuffer::GetDataLeft()
481 {
482 if (m_buffer_end == m_buffer_pos && m_flushable)
483 FillBuffer();
484 return m_buffer_end-m_buffer_pos;
485 }
486
487 // ----------------------------------------------------------------------------
488 // wxStreamBase
489 // ----------------------------------------------------------------------------
490
491 wxStreamBase::wxStreamBase()
492 {
493 m_lasterror = wxStream_NOERROR;
494 m_lastcount = 0;
495 }
496
497 wxStreamBase::~wxStreamBase()
498 {
499 }
500
501 size_t wxStreamBase::OnSysRead(void *WXUNUSED(buffer), size_t WXUNUSED(size))
502 {
503 return 0;
504 }
505
506 size_t wxStreamBase::OnSysWrite(const void *WXUNUSED(buffer), size_t WXUNUSED(bufsize))
507 {
508 return 0;
509 }
510
511 off_t wxStreamBase::OnSysSeek(off_t WXUNUSED(seek), wxSeekMode WXUNUSED(mode))
512 {
513 return wxInvalidOffset;
514 }
515
516 off_t wxStreamBase::OnSysTell() const
517 {
518 return wxInvalidOffset;
519 }
520
521 // ----------------------------------------------------------------------------
522 // wxInputStream
523 // ----------------------------------------------------------------------------
524
525 wxInputStream::wxInputStream()
526 : wxStreamBase()
527 {
528 m_i_destroybuf = TRUE;
529 m_i_streambuf = new wxStreamBuffer(*this, wxStreamBuffer::read);
530 }
531
532 wxInputStream::wxInputStream(wxStreamBuffer *buffer)
533 : wxStreamBase()
534 {
535 m_i_destroybuf = FALSE;
536 m_i_streambuf = buffer;
537 }
538
539 wxInputStream::~wxInputStream()
540 {
541 if (m_i_destroybuf)
542 delete m_i_streambuf;
543 }
544
545 char wxInputStream::GetC()
546 {
547 char c;
548 m_i_streambuf->Read(&c, 1);
549 return c;
550 }
551
552 wxInputStream& wxInputStream::Read(void *buffer, size_t size)
553 {
554 m_i_streambuf->Read(buffer, size);
555 // wxStreamBuffer sets all variables for us
556 return *this;
557 }
558
559 char wxInputStream::Peek()
560 {
561 m_i_streambuf->GetDataLeft();
562
563 return *(m_i_streambuf->GetBufferPos());
564 }
565
566
567 wxInputStream& wxInputStream::Read(wxOutputStream& stream_out)
568 {
569 char buf[BUF_TEMP_SIZE];
570 size_t bytes_read = BUF_TEMP_SIZE;
571
572 while (bytes_read == BUF_TEMP_SIZE) {
573 bytes_read = Read(buf, bytes_read).LastRead();
574 bytes_read = stream_out.Write(buf, bytes_read).LastWrite();
575 }
576 return *this;
577 }
578
579 off_t wxInputStream::SeekI(off_t pos, wxSeekMode mode)
580 {
581 return m_i_streambuf->Seek(pos, mode);
582 }
583
584 off_t wxInputStream::TellI() const
585 {
586 return m_i_streambuf->Tell();
587 }
588
589 // --------------------
590 // Overloaded operators
591 // --------------------
592
593 wxInputStream& wxInputStream::operator>>(wxString& line)
594 {
595 wxDataInputStream s(*this);
596
597 line = s.ReadLine();
598 return *this;
599 }
600
601 wxInputStream& wxInputStream::operator>>(char& c)
602 {
603 c = GetC();
604 return *this;
605 }
606
607 wxInputStream& wxInputStream::operator>>(signed short& i)
608 {
609 signed long l;
610
611 *this >> l;
612 i = (signed short)l;
613 return *this;
614 }
615
616 wxInputStream& wxInputStream::operator>>(signed int& i)
617 {
618 signed long l;
619
620 *this >> l;
621 i = (signed int)l;
622 return *this;
623 }
624
625 wxInputStream& wxInputStream::operator>>(signed long& i)
626 {
627 /* I only implemented a simple integer parser */
628 int c;
629 int sign;
630
631 while (isspace( c = GetC() ) )
632 /* Do nothing */ ;
633
634 i = 0;
635 if (! (c == '-' || isdigit(c)) ) {
636 InputStreamBuffer()->WriteBack(c);
637 return *this;
638 }
639
640 if (c == '-') {
641 sign = -1;
642 c = GetC();
643 } else if (c == '+') {
644 sign = 1;
645 c = GetC();
646 } else {
647 sign = 1;
648 }
649
650 while (isdigit(c)) {
651 i = i*10 + c;
652 c = GetC();
653 }
654
655 i *= sign;
656
657 return *this;
658 }
659
660 wxInputStream& wxInputStream::operator>>(unsigned short& i)
661 {
662 unsigned long l;
663
664 *this >> l;
665 i = (unsigned short)l;
666 return *this;
667 }
668
669 wxInputStream& wxInputStream::operator>>(unsigned int& i)
670 {
671 unsigned long l;
672
673 *this >> l;
674 i = (unsigned int)l;
675 return *this;
676 }
677
678 wxInputStream& wxInputStream::operator>>(unsigned long& i)
679 {
680 /* I only implemented a simple integer parser */
681 int c;
682
683 while (isspace( c = GetC() ) )
684 /* Do nothing */ ;
685
686 i = 0;
687 if (!isdigit(c)) {
688 InputStreamBuffer()->WriteBack(c);
689 return *this;
690 }
691
692 while (isdigit(c)) {
693 i = i*10 + c;
694 c = GetC();
695 }
696
697 return *this;
698 }
699
700 wxInputStream& wxInputStream::operator>>(double& f)
701 {
702 /* I only implemented a simple float parser */
703 int c, sign;
704
705 while (isspace( c = GetC() ) )
706 /* Do nothing */ ;
707
708 f = 0.0;
709 if (! (c == '-' || isdigit(c)) ) {
710 InputStreamBuffer()->WriteBack(c);
711 return *this;
712 }
713
714 if (c == '-') {
715 sign = -1;
716 c = GetC();
717 } else if (c == '+') {
718 sign = 1;
719 c = GetC();
720 } else {
721 sign = 1;
722 }
723
724 while (isdigit(c)) {
725 f = f*10 + (c - '0');
726 c = GetC();
727 }
728
729 if (c == '.') {
730 double f_multiplicator = (double) 0.1;
731 c = GetC();
732
733 while (isdigit(c)) {
734 f += (c-'0')*f_multiplicator;
735 f_multiplicator /= 10;
736 c = GetC();
737 }
738 }
739
740 f *= sign;
741
742 return *this;
743 }
744
745 #if wxUSE_SERIAL
746 wxInputStream& wxInputStream::operator>>(wxObject *& obj)
747 {
748 wxObjectInputStream obj_s(*this);
749 obj = obj_s.LoadObject();
750 return *this;
751 }
752 #endif
753
754
755 // ----------------------------------------------------------------------------
756 // wxOutputStream
757 // ----------------------------------------------------------------------------
758 wxOutputStream::wxOutputStream()
759 : wxStreamBase()
760 {
761 m_o_destroybuf = TRUE;
762 m_o_streambuf = new wxStreamBuffer(*this, wxStreamBuffer::write);
763 }
764
765 wxOutputStream::wxOutputStream(wxStreamBuffer *buffer)
766 : wxStreamBase()
767 {
768 m_o_destroybuf = FALSE;
769 m_o_streambuf = buffer;
770 }
771
772 wxOutputStream::~wxOutputStream()
773 {
774 if (m_o_destroybuf)
775 delete m_o_streambuf;
776 }
777
778 wxOutputStream& wxOutputStream::Write(const void *buffer, size_t size)
779 {
780 m_o_streambuf->Write(buffer, size);
781 return *this;
782 }
783
784 wxOutputStream& wxOutputStream::Write(wxInputStream& stream_in)
785 {
786 stream_in.Read(*this);
787 return *this;
788 }
789
790 off_t wxOutputStream::TellO() const
791 {
792 return m_o_streambuf->Tell();
793 }
794
795 off_t wxOutputStream::SeekO(off_t pos, wxSeekMode mode)
796 {
797 return m_o_streambuf->Seek(pos, mode);
798 }
799
800 void wxOutputStream::Sync()
801 {
802 m_o_streambuf->FlushBuffer();
803 }
804
805 wxOutputStream& wxOutputStream::operator<<(const char *string)
806 {
807 return Write(string, strlen(string));
808 }
809
810 wxOutputStream& wxOutputStream::operator<<(wxString& string)
811 {
812 #if wxUSE_UNICODE
813 const wxWX2MBbuf buf = string.mb_str();
814 return *this << buf;
815 #else
816 return Write(string, string.Len());
817 #endif
818 }
819
820 wxOutputStream& wxOutputStream::operator<<(char c)
821 {
822 return Write(&c, 1);
823 }
824
825 wxOutputStream& wxOutputStream::operator<<(signed short i)
826 {
827 signed long l = (signed long)i;
828 return *this << l;
829 }
830
831 wxOutputStream& wxOutputStream::operator<<(signed int i)
832 {
833 signed long l = (signed long)i;
834 return *this << l;
835 }
836
837 wxOutputStream& wxOutputStream::operator<<(signed long i)
838 {
839 wxString strlong;
840 strlong.Printf(_T("%ld"), i);
841 return *this << strlong;
842 }
843
844 wxOutputStream& wxOutputStream::operator<<(unsigned short i)
845 {
846 unsigned long l = (unsigned long)i;
847 return *this << l;
848 }
849
850 wxOutputStream& wxOutputStream::operator<<(unsigned int i)
851 {
852 unsigned long l = (unsigned long)i;
853 return *this << l;
854 }
855
856 wxOutputStream& wxOutputStream::operator<<(unsigned long i)
857 {
858 wxString strlong;
859 strlong.Printf(_T("%lu"), i);
860 return *this << strlong;
861 }
862
863 wxOutputStream& wxOutputStream::operator<<(double f)
864 {
865 wxString strfloat;
866
867 strfloat.Printf(_T("%f"), f);
868 return *this << strfloat;
869 }
870
871 #if wxUSE_SERIAL
872 wxOutputStream& wxOutputStream::operator<<(wxObject& obj)
873 {
874 wxObjectOutputStream obj_s(*this);
875 obj_s.SaveObject(obj);
876 return *this;
877 }
878 #endif
879
880 // ----------------------------------------------------------------------------
881 // wxFilterInputStream
882 // ----------------------------------------------------------------------------
883 wxFilterInputStream::wxFilterInputStream()
884 : wxInputStream(NULL)
885 {
886 // WARNING streambuf set to NULL !
887 }
888
889 wxFilterInputStream::wxFilterInputStream(wxInputStream& stream)
890 : wxInputStream(stream.InputStreamBuffer())
891 {
892 m_parent_i_stream = &stream;
893 }
894
895 wxFilterInputStream::~wxFilterInputStream()
896 {
897 }
898
899 // ----------------------------------------------------------------------------
900 // wxFilterOutputStream
901 // ----------------------------------------------------------------------------
902 wxFilterOutputStream::wxFilterOutputStream()
903 : wxOutputStream(NULL)
904 {
905 }
906
907 wxFilterOutputStream::wxFilterOutputStream(wxOutputStream& stream)
908 : wxOutputStream(stream.OutputStreamBuffer())
909 {
910 m_parent_o_stream = &stream;
911 }
912
913 wxFilterOutputStream::~wxFilterOutputStream()
914 {
915 }
916
917 // ----------------------------------------------------------------------------
918 // Some IOManip function
919 // ----------------------------------------------------------------------------
920
921 wxOutputStream& wxEndL(wxOutputStream& stream)
922 {
923 #ifdef __MSW__
924 return stream.Write("\r\n", 2);
925 #else
926 return stream.Write("\n", 1);
927 #endif
928 }
929
930 #endif
931 // wxUSE_STREAMS