1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG typemaps and wrappers for wxInputStream
7 // Created: 25-Sept-2000
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
16 //---------------------------------------------------------------------------
19 #include "wx/wxPython/pyistream.h"
22 //---------------------------------------------------------------------------
26 // typemaps for wxInputStream
27 %typemap(in) wxInputStream* (wxPyInputStream* temp, bool created) {
28 if (wxPyConvertSwigPtr($input, (void **)&temp, wxT("wxPyInputStream"))) {
32 PyErr_Clear(); // clear the failure of the wxPyConvert above
33 $1 = wxPyCBInputStream_create($input, false);
35 PyErr_SetString(PyExc_TypeError, "Expected wxInputStream or Python file-like object.");
41 %typemap(freearg) wxInputStream* {
47 %typemap(in) wxInputStream& = wxInputStream*;
48 %typemap(freearg) wxInputStream& = wxInputStream*;
51 %typemap(out) wxInputStream* {
52 wxPyInputStream * _ptr = NULL;
55 _ptr = new wxPyInputStream($1);
57 $result = wxPyConstructObject(_ptr, wxT("wxPyInputStream"), $owner);
61 //---------------------------------------------------------------------------
71 %rename(InputStream) wxPyInputStream;
76 wxPyInputStream(PyObject* p) {
77 wxInputStream* wxis = wxPyCBInputStream::create(p);
79 return new wxPyInputStream(wxis);
89 PyObject* read(int size=-1);
90 PyObject* readline(int size=-1);
91 PyObject* readlines(int sizehint=-1);
92 void seek(int offset, int whence=0);
98 void truncate(int size=-1);
99 void write(wxString data);
100 void writelines(wxStringPtrList);
108 bool Ungetch(char c);
110 long SeekI(long pos, wxSeekMode mode = wxFromStart);
116 // TODO: make a more fully implemented file interface...
117 class wxOutputStream {
122 wxString* read(int size=-1);
123 wxString* readline(int size=-1);
124 wxStringPtrList* readlines(int sizehint=-1);
125 void seek(int offset, int whence=0);
129 void truncate(int size=-1);
130 void write(wxString data);
131 void writelines(wxStringPtrList);
135 void write(PyObject* obj) {
136 // We use only strings for the streams, not unicode
137 PyObject* str = PyObject_Str(obj);
139 PyErr_SetString(PyExc_TypeError, "Unable to convert to string");
142 self->Write(PyString_AS_STRING(str),
143 PyString_GET_SIZE(str));
150 //---------------------------------------------------------------------------
152 wxPyPtrTypeMap_Add("wxInputStream", "wxPyInputStream");
154 //---------------------------------------------------------------------------