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