]> git.saurik.com Git - wxWidgets.git/blame_incremental - docs/doxygen/overviews/stream.h
Add wxPreferencesEditor::ShownModally().
[wxWidgets.git] / docs / doxygen / overviews / stream.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: stream.h
3// Purpose: stream classes overview
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows licence
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10
11@page overview_stream Stream Classes Overview
12
13@tableofcontents
14
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).
22
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
31
32@section overview_stream_classes Stream Classes
33
34wxStream classes are divided in two main groups:
35
36@li The core: wxStreamBase, wxStreamBuffer, wxInputStream, wxOutputStream,
37 wxFilterInputStream, wxFilterOutputStream
38@li The "IO" classes: wxSocketInputStream, wxSocketOutputStream,
39 wxFileInputStream, wxFileOutputStream, ...
40@li Classes for reading text or binary data from a particular stream
41 such as wxTextInputStream, wxTextOutputStream, wxDataInputStream
42 and wxDataOutputStream
43
44wxStreamBase is the base definition of a stream. It defines, for example, the
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.
49
50wxStreamBuffer is a cache manager for wxStreamBase: it manages a stream buffer
51linked to a stream. One stream can have multiple stream buffers but one stream
52has always one autoinitialized stream buffer.
53
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.
57
58wxFilterInputStream and wxFileterOutputStream are the base class definitions for
59stream filtering.
60Stream filtering means a stream which does no syscall but filters data which
61are passed to it and then pass them to another stream.
62For example, wxZLibInputStream is an inline stream decompressor.
63
64The "IO" classes implements the specific parts of the stream. This could be
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(...)).
68
69
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) {
84 // Oh oh, something bad happens.
85 // For a complete list, look into the documentation at wxStreamBase.
86}
87
88// You can also inline all like this.
89if (in_stream.Read(data, nb_datas).LastError() != wxSTREAM_NOERROR) {
90 // Do something.
91}
92
93// You can also get the last number of bytes REALLY put into the buffer.
94size_t really_read = in_stream.LastRead();
95
96// Ok, moves to the beginning of the stream. SeekI returns the last position
97// in the stream counted from the beginning.
98off_t old_position = in_stream.SeekI(0, wxFromBeginning);
99
100// What is my current position ?
101off_t position = in_stream.TellI();
102
103// wxFileInputStream will close the file descriptor on destruction.
104@endcode
105
106*/