]>
Commit | Line | Data |
---|---|---|
3d4c6a21 | 1 | ///////////////////////////////////////////////////////////////////////////// |
32fc4afb | 2 | // Name: mstream.cpp |
3d4c6a21 GL |
3 | // Purpose: "Memory stream" classes |
4 | // Author: Guilhem Lavaux | |
5 | // Modified by: | |
6 | // Created: 04/01/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Guilhem Lavaux | |
9 | // Licence: wxWindows license | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifdef __GNUG__ | |
32fc4afb | 13 | #pragma implementation "mstream.h" |
3d4c6a21 GL |
14 | #endif |
15 | ||
79c3e0e1 GL |
16 | // For compilers that support precompilation, includes "wx.h". |
17 | #include "wx/wxprec.h" | |
79c3e0e1 GL |
18 | |
19 | #ifdef __BORLANDC__ | |
ce4169a4 | 20 | #pragma hdrstop |
79c3e0e1 | 21 | #endif |
3d4c6a21 | 22 | |
ce4169a4 RR |
23 | #ifndef WX_PRECOMP |
24 | #include "wx/defs.h" | |
25 | #endif | |
26 | ||
27 | #if wxUSE_STREAMS | |
28 | ||
29 | #include <stdlib.h> | |
30 | #include <wx/stream.h> | |
31 | #include <wx/mstream.h> | |
32 | ||
79c3e0e1 GL |
33 | // ---------------------------------------------------------------------------- |
34 | // wxMemoryInputStream | |
35 | // ---------------------------------------------------------------------------- | |
36 | ||
37 | wxMemoryInputStream::wxMemoryInputStream(const char *data, size_t len) | |
75ed1d15 | 38 | : wxInputStream() |
79c3e0e1 | 39 | { |
2d0a075d | 40 | m_i_streambuf->SetBufferIO((char*) data, (char*) (data+len)); |
18c07b73 | 41 | m_i_streambuf->SetIntPosition(0); // seek to start pos |
75ed1d15 | 42 | m_i_streambuf->Fixed(TRUE); |
18c07b73 | 43 | m_length = len; |
3d4c6a21 GL |
44 | } |
45 | ||
0cd9bfe8 GL |
46 | wxMemoryInputStream::~wxMemoryInputStream() |
47 | { | |
48 | } | |
49 | ||
32a4b1d5 GL |
50 | char wxMemoryInputStream::Peek() |
51 | { | |
75ed1d15 | 52 | return m_i_streambuf->GetBufferStart()[m_i_streambuf->GetIntPosition()]; |
3d4c6a21 GL |
53 | } |
54 | ||
79c3e0e1 GL |
55 | // ---------------------------------------------------------------------------- |
56 | // wxMemoryOutputStream | |
57 | // ---------------------------------------------------------------------------- | |
58 | ||
59 | wxMemoryOutputStream::wxMemoryOutputStream(char *data, size_t len) | |
75ed1d15 | 60 | : wxOutputStream() |
79c3e0e1 | 61 | { |
75ed1d15 GL |
62 | if (data) |
63 | m_o_streambuf->SetBufferIO(data, data+len); | |
64 | m_o_streambuf->Fixed(TRUE); | |
79c3e0e1 GL |
65 | } |
66 | ||
0cd9bfe8 | 67 | wxMemoryOutputStream::~wxMemoryOutputStream() |
79c3e0e1 | 68 | { |
3d4c6a21 | 69 | } |
ce4169a4 RR |
70 | |
71 | #endif |