]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/stdstream.h
Remove never implemented wxDateTime::IsGregorianDate().
[wxWidgets.git] / interface / wx / stdstream.h
CommitLineData
72a7c559
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: stdstream.h
3// Purpose: interface of wxStdInputStream, wxStdInputStreamBuffer,
4// wxStdOutputStream, wxStdOutputStreamBuffer
5// Author: Jonathan Liu <net147@gmail.com>
72a7c559
VZ
6// Copyright: (c) 2009 Jonathan Liu
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
10/**
11 @class wxStdInputStreamBuffer
12
13 wxStdInputStreamBuffer is a std::streambuf derived stream buffer which
14 reads from a wxInputStream.
15
16 Example:
17 @code
18 wxFFileInputStream file("input.txt.gz");
19 wxZlibInputStream gzipInput(file, wxZLIB_GZIP);
20 wxStdInputStreamBuffer gzipStreamBuffer(gzipInput);
21
22 // redirect std::cin to read from compressed file
23 std::streambuf* streamBufferOld = std::cin.rdbuf(&gzipStreamBuffer);
24
25 // prompt for integer
26 int number;
27 std::cout << "Enter an integer: " << std::flush;
28 std::cin >> number;
29 std::cout << std::endl;
30 std::cout << "You entered the integer " << number << "." << std::endl;
31
32 // restore std::cin
33 std::cin.rdbuf(streamBufferOld);
34 @endcode
35
36 @library{wxbase}
37 @category{streams}
38
39 @see wxInputStream, wxStdInputStream
40*/
41class wxStdInputStreamBuffer : public std::streambuf
42{
43public:
44 /**
45 Creates a std::steambuf derived stream buffer which reads from a
46 wxInputStream.
47
48 @param stream
49 Stream to read from.
50 */
51 wxStdInputStreamBuffer(wxInputStream& stream);
52
53 /**
54 Destructor.
55 */
56 virtual ~wxStdInputStreamBuffer() { }
57};
58
59/**
60 @class wxStdInputStream
61
3d3ecbbc 62 wxStdInputStream is a std::istream derived stream which reads from
72a7c559
VZ
63 a wxInputStream.
64
65 Example:
66 @code
67 wxFFileInputStream file("words.txt");
68 wxStdInputStream in(file);
69 std::vector<std::string> words;
70
e4eef50b 71 // read words from words.txt
72a7c559
VZ
72 std::copy(std::istream_iterator<std::string>(in),
73 std::istream_iterator<std::string>(),
74 std::back_inserter(words));
75
76 // sort and remove duplicates
77 std::sort(words.begin(), words.end());
78 words.resize(std::unique(words.begin(), words.end()) - words.begin());
79
80 // print words
81 std::copy(words.begin(), words.end(),
82 std::ostream_iterator<std::string>(std::cout, "\n"));
83 @endcode
84
85 @library{wxbase}
86 @category{streams}
87
88 @see wxInputStream, wxStdInputStreamBuffer
89*/
90class wxStdInputStream : public std::istream
91{
92public:
93 /**
94 Creates a std::istream derived stream which reads from a
95 wxInputStream.
96
97 @param stream
98 Stream to read from.
99 */
100 wxStdInputStream(wxInputStream& stream);
101
102 /**
103 Destructor.
104 */
105 virtual ~wxStdInputStream() { }
106};
107
108/**
109 @class wxStdOutputStreamBuffer
110
111 wxStdOutputStreamBuffer is a std::streambuf derived stream buffer which
112 writes to a wxOutputStream.
113
114 Example:
115 @code
116 wxFFileOutputStream file("cout.txt.gz");
117 wxZlibOutputStream gzipOutput(file, -1, wxZLIB_GZIP);
118 wxStdOutputStreamBuffer gzipStreamBuffer(gzipOutput);
119
120 // redirect std::cout to cout.txt.gz using GZIP compression
121 std::streambuf* streamBufferOld = std::cout.rdbuf(&gzipStreamBuffer);
122
123 // write to std::cout
124 std::cout << "Hello world!" << std::endl;
125
126 // restore std::cout
127 std::cout.rdbuf(streamBufferOld);
128 @endcode
129
130 @library{wxbase}
131 @category{streams}
132
133 @see wxOutputStream, wxStdOutputStream
134*/
135class wxStdOutputStreamBuffer : public std::streambuf
136{
137public:
138 /**
139 Creates a std::steambuf derived stream buffer which writes to a
140 wxOutputStream.
141
142 @param stream
143 Stream to write to.
144 */
145 wxStdOutputStreamBuffer(wxOutputStream& stream);
146
147 /**
148 Destructor.
149 */
150 virtual ~wxStdOutputStreamBuffer() { }
151};
152
153/**
154 @class wxStdOutputStream
155
156 wxStdOutputStream is a std::ostream derived stream which writes to a
157 wxOutputStream.
158
159 Example:
160 @code
161 wxFFileOutputStream file("out.txt.gz");
162 wxZlibOutputStream gzipOutput(file, -1, wxZLIB_GZIP);
163 wxStdOutputStream out(gzipOutput);
164
165 out << "Hello world!" << std::endl;
166 @endcode
167
168 @library{wxbase}
169 @category{streams}
170
171 @see wxOutputStream, wxStdOutputStreamBuffer
172*/
173class wxStdOutputStream : public std::ostream
174{
175public:
176 /**
177 Creates a std::ostream derived stream which writes to a
178 wxOutputStream.
179
180 @param stream
181 Stream to write to.
182 */
183 wxStdOutputStream(wxOutputStream& stream);
184
185 /**
186 Destructor.
187 */
188 virtual ~wxStdOutputStream() { }
189};