1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG definitions of the wxFileSystem family of classes
5 // Author: Joerg Baumann and Robin Dunn
7 // Created: 25-Sept-2000
9 // Copyright: (c) 2000 by Joerg Baumann
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
17 #include "pyistream.h"
18 #include <wx/stream.h>
22 //----------------------------------------------------------------------
25 %include my_typemaps.i
27 // Import some definitions of other classes, etc.
30 %pragma(python) code = "import wx"
31 %pragma(python) code = "import string"
33 //----------------------------------------------------------------------
34 // typemaps for wxInputStream
37 %typemap(python,in) wxInputStream * (wxPyInputStream* temp, bool created) {
38 if (SWIG_GetPtrObj($source, (void **) &temp, "_wxPyInputStream_p") == 0) {
39 $target = temp->m_wxis;
42 $target = wxPyCBInputStream::create($source, FALSE);
43 if ($target == NULL) {
44 PyErr_SetString(PyExc_TypeError,"Expected _wxInputStream_p or Python file-like object.");
51 %typemap(python, freearg) wxInputStream * {
57 // typemaps for wxInputStream
58 %typemap(python,out) wxInputStream* {
59 wxPyInputStream * _ptr = NULL;
62 _ptr = new wxPyInputStream($source);
64 $target = wxPyConstructObject(_ptr, "wxInputStream", TRUE);
67 //----------------------------------------------------------------------
70 // wxStringPtrList* to python list of strings typemap
71 %typemap(python, out) wxStringPtrList* {
73 $target = PyList_New($source->GetCount());
74 wxStringPtrList::Node *node = $source->GetFirst();
75 for (int i=0; node; i++) {
76 wxString *s = node->GetData();
77 PyList_SetItem($target, i, PyString_FromStringAndSize(s->c_str(), s->Len()));
78 node = node->GetNext();
90 %name(wxInputStream) class wxPyInputStream {
93 wxPyInputStream(PyObject* p) {
94 wxInputStream* wxis = wxPyCBInputStream::create(p);
96 return new wxPyInputStream(wxis);
104 wxString* read(int size=-1);
105 wxString* readline(int size=-1);
106 wxStringPtrList* readlines(int sizehint=-1);
107 void seek(int offset, int whence=0);
113 void truncate(int size=-1);
114 void write(wxString data);
115 void writelines(wxStringPtrList);
121 // TODO: make a more fully implemented file interface...
122 class wxOutputStream {
127 wxString* read(int size=-1);
128 wxString* readline(int size=-1);
129 wxStringPtrList* readlines(int sizehint=-1);
130 void seek(int offset, int whence=0);
134 void truncate(int size=-1);
135 void write(wxString data);
136 void writelines(wxStringPtrList);
140 void write(const wxString& str) {
141 self->Write(str.c_str(), str.Length());
147 // restore except and typemaps
148 %typemap(python,out) wxStringPtrList*;
149 %typemap(python,out) wxPyInputStream*;
152 //----------------------------------------------------------------------
155 wxPyPtrTypeMap_Add("wxInputStream", "wxPyInputStream");
158 //----------------------------------------------------------------------