]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/common/mstream.cpp
Attempt to implement a bunch of wx string.h equivalents.
[wxWidgets.git] / src / common / mstream.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: mstream.cpp
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__
13#pragma implementation "mstream.h"
14#endif
15
16// For compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
18
19#ifdef __BORLANDC__
20 #pragma hdrstop
21#endif
22
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
33// ----------------------------------------------------------------------------
34// wxMemoryInputStream
35// ----------------------------------------------------------------------------
36
37wxMemoryInputStream::wxMemoryInputStream(const char *data, size_t len)
38 : wxInputStream()
39{
40 m_i_streambuf->SetBufferIO((char*) data, (char*) (data+len));
41 m_i_streambuf->SetIntPosition(0); // seek to start pos
42 m_i_streambuf->Fixed(TRUE);
43 m_length = len;
44}
45
46wxMemoryInputStream::~wxMemoryInputStream()
47{
48}
49
50char wxMemoryInputStream::Peek()
51{
52 return m_i_streambuf->GetBufferStart()[m_i_streambuf->GetIntPosition()];
53}
54
55// ----------------------------------------------------------------------------
56// wxMemoryOutputStream
57// ----------------------------------------------------------------------------
58
59wxMemoryOutputStream::wxMemoryOutputStream(char *data, size_t len)
60 : wxOutputStream()
61{
62 if (data)
63 m_o_streambuf->SetBufferIO(data, data+len);
64 m_o_streambuf->Fixed(TRUE);
65}
66
67wxMemoryOutputStream::~wxMemoryOutputStream()
68{
69}
70
71#endif