]> git.saurik.com Git - wxWidgets.git/blame - docs/doxygen/overviews/stream.h
fixing sdk compilo
[wxWidgets.git] / docs / doxygen / overviews / stream.h
CommitLineData
15b6757b 1/////////////////////////////////////////////////////////////////////////////
23114fe1 2// Name: stream.h
72a7c559 3// Purpose: stream classes overview
15b6757b
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
526954c5 6// Licence: wxWindows licence
15b6757b
FM
7/////////////////////////////////////////////////////////////////////////////
8
880efa2a 9/**
36c9828f 10
831e1028 11@page overview_stream Stream Classes Overview
23114fe1 12
831e1028 13@tableofcontents
23114fe1 14
72a7c559
VZ
15wxWidgets provides its own set of stream classes in order to support platforms
16not providing standard C++ streams implementation and also to make it possible
17to provide binary versions of wxWidgets application not depending on any
18particular standard library version. The wxWidgets stream classes also provide
19some functionality not available in the standard library such as support for
20several compression formats and possibility to work with sockets or text
21controls (for output only in the latter case).
eb63011d 22
72a7c559
VZ
23Nevertheless wxWidgets programs can also use standard stream classes and are
24encouraged to do so if the above considerations don't apply. Moreover,
25wxStdInputStream and wxStdOutputStream classes are provided to provide a degree
26of interoperability between the two and make it possible to use any wxWidgets
27stream as a standard stream (the converse possibility to use a standard stream
28as a wxWidgets stream is planned for a future release).
29
30
831e1028
BP
31
32@section overview_stream_classes Stream Classes
23114fe1 33
eb63011d 34wxStream classes are divided in two main groups:
23114fe1
BP
35
36@li The core: wxStreamBase, wxStreamBuffer, wxInputStream, wxOutputStream,
eb63011d
FM
37 wxFilterInputStream, wxFilterOutputStream
38@li The "IO" classes: wxSocketInputStream, wxSocketOutputStream,
39 wxFileInputStream, wxFileOutputStream, ...
673453e2
RR
40@li Classes for reading text or binary data from a particular stream
41 such as wxTextInputStream, wxTextOutputStream, wxDataInputStream
42 and wxDataOutputStream
23114fe1
BP
43
44wxStreamBase is the base definition of a stream. It defines, for example, the
eb63011d
FM
45API of OnSysRead(), OnSysWrite(), OnSysSeek() and OnSysTell(). These functions are
46really implemented by the "IO" classes.
47wxInputStream and wxOutputStream classes inherit from wxStreamBase and provide
48specialized methods for input and output.
23114fe1
BP
49
50wxStreamBuffer is a cache manager for wxStreamBase: it manages a stream buffer
eb63011d
FM
51linked to a stream. One stream can have multiple stream buffers but one stream
52has always one autoinitialized stream buffer.
23114fe1 53
eb63011d
FM
54wxInputStream is the base class for read-only streams. It implements Read(),
55SeekI() (I for Input), and all read or IO generic related functions.
56wxOutputStream does the same thing for write-only streams.
23114fe1 57
eb63011d
FM
58wxFilterInputStream and wxFileterOutputStream are the base class definitions for
59stream filtering.
23114fe1 60Stream filtering means a stream which does no syscall but filters data which
eb63011d
FM
61are passed to it and then pass them to another stream.
62For example, wxZLibInputStream is an inline stream decompressor.
23114fe1
BP
63
64The "IO" classes implements the specific parts of the stream. This could be
eb63011d
FM
65nothing in the case of wxMemoryInputStream and wxMemoryOutputStream which base
66themselves on wxStreamBuffer.
67This could also be a simple link to the true syscall (for example read(...), write(...)).
23114fe1 68
30738aae 69
23114fe1
BP
70@section overview_stream_example Example
71
72Usage is simple. We can take the example of wxFileInputStream and here is some
73sample code:
74
75@code
76...
77// The constructor initializes the stream buffer and open the file descriptor
78// associated to the name of the file.
79wxFileInputStream in_stream("the_file_to_be_read");
80
81// Ok, read some bytes ... nb_datas is expressed in bytes.
82in_stream.Read(data, nb_datas);
83if (in_stream.LastError() != wxSTREAM_NOERROR) {
15b6757b
FM
84 // Oh oh, something bad happens.
85 // For a complete list, look into the documentation at wxStreamBase.
23114fe1 86}
36c9828f 87
23114fe1
BP
88// You can also inline all like this.
89if (in_stream.Read(data, nb_datas).LastError() != wxSTREAM_NOERROR) {
15b6757b 90 // Do something.
23114fe1 91}
36c9828f 92
23114fe1
BP
93// You can also get the last number of bytes REALLY put into the buffer.
94size_t really_read = in_stream.LastRead();
36c9828f 95
3c4f71cc 96// Ok, moves to the beginning of the stream. SeekI returns the last position
23114fe1
BP
97// in the stream counted from the beginning.
98off_t old_position = in_stream.SeekI(0, wxFromBeginning);
36c9828f 99
23114fe1
BP
100// What is my current position ?
101off_t position = in_stream.TellI();
36c9828f 102
23114fe1
BP
103// wxFileInputStream will close the file descriptor on destruction.
104@endcode
36c9828f 105
23114fe1 106*/