+// ----------------------------------------------------------------------------
+// wxBufferedInputStream
+// ----------------------------------------------------------------------------
+
+namespace
+{
+
+// helper function used for initializing the buffer used by
+// wxBufferedInput/OutputStream: it simply returns the provided buffer if it's
+// not NULL or creates a buffer of the given size otherwise
+template <typename T>
+wxStreamBuffer *
+CreateBufferIfNeeded(T& stream, wxStreamBuffer *buffer, size_t bufsize = 1024)
+{
+ return buffer ? buffer : new wxStreamBuffer(bufsize, stream);
+}
+
+} // anonymous namespace
+
+wxBufferedInputStream::wxBufferedInputStream(wxInputStream& stream,
+ wxStreamBuffer *buffer)
+ : wxFilterInputStream(stream)
+{
+ m_i_streambuf = CreateBufferIfNeeded(*this, buffer);
+}
+
+wxBufferedInputStream::wxBufferedInputStream(wxInputStream& stream,
+ size_t bufsize)
+ : wxFilterInputStream(stream)
+{
+ m_i_streambuf = CreateBufferIfNeeded(*this, NULL, bufsize);
+}
+