]> git.saurik.com Git - wxWidgets.git/blame_incremental - docs/doxygen/overviews/stream.h
Make @genericAppearance Doxygen macro consistent with @appearance.
[wxWidgets.git] / docs / doxygen / overviews / stream.h
... / ...
CommitLineData
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
14wxWidgets provides its own set of stream classes in order to support platforms
15not providing standard C++ streams implementation and also to make it possible
16to provide binary versions of wxWidgets application not depending on any
17particular standard library version. The wxWidgets stream classes also provide
18some functionality not available in the standard library such as support for
19several compression formats and possibility to work with sockets or text
20controls (for output only in the latter case).
21
22Nevertheless wxWidgets programs can also use standard stream classes and are
23encouraged to do so if the above considerations don't apply. Moreover,
24wxStdInputStream and wxStdOutputStream classes are provided to provide a degree
25of interoperability between the two and make it possible to use any wxWidgets
26stream as a standard stream (the converse possibility to use a standard stream
27as a wxWidgets stream is planned for a future release).
28
29
30
31@section overview_stream_classes Stream Classes
32
33wxStream 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
43wxStreamBase is the base definition of a stream. It defines, for example, the
44API of OnSysRead(), OnSysWrite(), OnSysSeek() and OnSysTell(). These functions are
45really implemented by the "IO" classes.
46wxInputStream and wxOutputStream classes inherit from wxStreamBase and provide
47specialized methods for input and output.
48
49wxStreamBuffer is a cache manager for wxStreamBase: it manages a stream buffer
50linked to a stream. One stream can have multiple stream buffers but one stream
51has always one autoinitialized stream buffer.
52
53wxInputStream is the base class for read-only streams. It implements Read(),
54SeekI() (I for Input), and all read or IO generic related functions.
55wxOutputStream does the same thing for write-only streams.
56
57wxFilterInputStream and wxFileterOutputStream are the base class definitions for
58stream filtering.
59Stream filtering means a stream which does no syscall but filters data which
60are passed to it and then pass them to another stream.
61For example, wxZLibInputStream is an inline stream decompressor.
62
63The "IO" classes implements the specific parts of the stream. This could be
64nothing in the case of wxMemoryInputStream and wxMemoryOutputStream which base
65themselves on wxStreamBuffer.
66This could also be a simple link to the true syscall (for example read(...), write(...)).
67
68
69@section overview_stream_example Example
70
71Usage is simple. We can take the example of wxFileInputStream and here is some
72sample 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.
78wxFileInputStream in_stream("the_file_to_be_read");
79
80// Ok, read some bytes ... nb_datas is expressed in bytes.
81in_stream.Read(data, nb_datas);
82if (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.
88if (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.
93size_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.
97off_t old_position = in_stream.SeekI(0, wxFromBeginning);
98
99// What is my current position ?
100off_t position = in_stream.TellI();
101
102// wxFileInputStream will close the file descriptor on destruction.
103@endcode
104
105*/