1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG definitions of the wxFileSystem family of classes
5 // Author: Joerg Baumann
7 // Created: 25-Sept-2000
9 // Copyright: (c) 2000 by Joerg Baumann
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
17 #include <wx/stream.h>
21 //----------------------------------------------------------------------
24 %include my_typemaps.i
26 // Import some definitions of other classes, etc.
29 %pragma(python) code = "import wx"
30 %pragma(python) code = "import string"
32 //----------------------------------------------------------------------
33 // typemaps for wxInputStream
36 %typemap(python,in) wxInputStream * (wxPyInputStream* temp, bool created) {
37 if (SWIG_GetPtrObj($source, (void **) &temp, "_wxPyInputStream_p") == 0) {
38 $target = temp->m_wxis;
41 $target = wxPyCBInputStream::create($source, FALSE);
42 if ($target == NULL) {
43 PyErr_SetString(PyExc_TypeError,"Expected _wxInputStream_p or Python file-like object.");
50 %typemap(python, freearg) wxInputStream * {
56 // typemaps for wxInputStream
57 %typemap(python,out) wxInputStream* {
58 wxPyInputStream * _ptr = NULL;
61 _ptr = new wxPyInputStream($source);
63 $target = wxPyConstructObject(_ptr, "wxInputStream", TRUE);
66 //----------------------------------------------------------------------
69 // wxStringPtrList* to python list of strings typemap
70 %typemap(python, out) wxStringPtrList* {
72 $target = PyList_New($source->GetCount());
73 wxStringPtrList::Node *node = $source->GetFirst();
74 for (int i=0; node; i++) {
75 wxString *s = node->GetData();
76 PyList_SetItem($target, i, PyString_FromStringAndSize(s->c_str(), s->Len()));
77 node = node->GetNext();
89 %name(wxInputStream) class wxPyInputStream {
92 wxPyInputStream(PyObject* p) {
93 wxInputStream* wxis = wxPyCBInputStream::create(p);
95 return new wxPyInputStream(wxis);
103 wxString* read(int size=-1);
104 wxString* readline(int size=-1);
105 wxStringPtrList* readlines(int sizehint=-1);
106 void seek(int offset, int whence=0);
112 void truncate(int size=-1);
113 void write(wxString data);
114 void writelines(wxStringPtrList);
120 // TODO: make a more fully implemented file interface...
121 class wxOutputStream {
126 wxString* read(int size=-1);
127 wxString* readline(int size=-1);
128 wxStringPtrList* readlines(int sizehint=-1);
129 void seek(int offset, int whence=0);
133 void truncate(int size=-1);
134 void write(wxString data);
135 void writelines(wxStringPtrList);
139 void write(const wxString& str) {
140 self->Write(str.c_str(), str.Length());
146 // restore except and typemaps
147 %typemap(python,out) wxStringPtrList*;
148 %typemap(python,out) wxPyInputStream*;
151 //----------------------------------------------------------------------
154 wxPyPtrTypeMap_Add("wxInputStream", "wxPyInputStream");
157 //----------------------------------------------------------------------