]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_streams.i
wxSystemSettings::GetMetric returns -1 if the metric is not supported
[wxWidgets.git] / wxPython / src / _streams.i
CommitLineData
c368d904 1/////////////////////////////////////////////////////////////////////////////
d14a1e28
RD
2// Name: _streams.i
3// Purpose: SWIG typemaps and wrappers for wxInputStream
c368d904 4//
d14a1e28 5// Author: Robin Dunn
c368d904
RD
6//
7// Created: 25-Sept-2000
8// RCS-ID: $Id$
d14a1e28 9// Copyright: (c) 2003 by Total Control Software
c368d904
RD
10// Licence: wxWindows license
11/////////////////////////////////////////////////////////////////////////////
12
d14a1e28 13// Not a %module
c368d904 14
c368d904 15
d14a1e28 16//---------------------------------------------------------------------------
c368d904 17
d14a1e28
RD
18%{
19#include "wx/wxPython/pyistream.h"
20%}
c368d904 21
d14a1e28
RD
22//---------------------------------------------------------------------------
23%newgroup
c368d904 24
c368d904 25
c368d904 26// typemaps for wxInputStream
d14a1e28
RD
27%typemap(in) wxInputStream* (wxPyInputStream* temp, bool created) {
28 if (wxPyConvertSwigPtr($input, (void **)&temp, wxT("wxPyInputStream"))) {
29 $1 = temp->m_wxis;
a72f4631 30 created = false;
f74ff5ef 31 } else {
d14a1e28 32 PyErr_Clear(); // clear the failure of the wxPyConvert above
a72f4631 33 $1 = wxPyCBInputStream_create($input, false);
d14a1e28
RD
34 if ($1 == NULL) {
35 PyErr_SetString(PyExc_TypeError, "Expected wxInputStream or Python file-like object.");
36 SWIG_fail;
c368d904 37 }
a72f4631 38 created = true;
c368d904
RD
39 }
40}
d14a1e28
RD
41%typemap(freearg) wxInputStream* {
42 if (created$argnum)
43 delete $1;
f74ff5ef
RD
44}
45
c368d904 46
d14a1e28
RD
47%typemap(in) wxInputStream& = wxInputStream*;
48%typemap(freearg) wxInputStream& = wxInputStream*;
49
50
51%typemap(out) wxInputStream* {
c368d904
RD
52 wxPyInputStream * _ptr = NULL;
53
d14a1e28
RD
54 if ($1) {
55 _ptr = new wxPyInputStream($1);
c368d904 56 }
a72f4631 57 $result = wxPyConstructObject(_ptr, wxT("wxPyInputStream"), true);
c368d904
RD
58}
59
d14a1e28
RD
60
61//---------------------------------------------------------------------------
c368d904 62
1e4a197e
RD
63enum wxSeekMode
64{
65 wxFromStart,
66 wxFromCurrent,
67 wxFromEnd
68};
c368d904 69
c368d904 70
d14a1e28 71%name(InputStream) class wxPyInputStream {
c368d904 72public:
d14a1e28 73 %extend {
c368d904 74 wxPyInputStream(PyObject* p) {
f74ff5ef
RD
75 wxInputStream* wxis = wxPyCBInputStream::create(p);
76 if (wxis)
77 return new wxPyInputStream(wxis);
c368d904
RD
78 else
79 return NULL;
80 }
81 }
d14a1e28 82
c368d904
RD
83 void close();
84 void flush();
85 bool eof();
a541c325
RD
86 PyObject* read(int size=-1);
87 PyObject* readline(int size=-1);
88 PyObject* readlines(int sizehint=-1);
c368d904
RD
89 void seek(int offset, int whence=0);
90 int tell();
f74ff5ef 91
c368d904
RD
92 /*
93 bool isatty();
94 int fileno();
95 void truncate(int size=-1);
96 void write(wxString data);
97 void writelines(wxStringPtrList);
98 */
1e4a197e
RD
99
100 char Peek();
101 char GetC();
102 size_t LastRead();
103 bool CanRead();
104 bool Eof();
105 bool Ungetch(char c);
106
107 long SeekI(long pos, wxSeekMode mode = wxFromStart);
108 long TellI();
d14a1e28 109};
c368d904
RD
110
111
112
113// TODO: make a more fully implemented file interface...
114class wxOutputStream {
115public:
116 /*
117 void close();
118 void flush();
119 wxString* read(int size=-1);
120 wxString* readline(int size=-1);
121 wxStringPtrList* readlines(int sizehint=-1);
122 void seek(int offset, int whence=0);
123 int tell();
124 bool isatty();
125 int fileno();
126 void truncate(int size=-1);
127 void write(wxString data);
128 void writelines(wxStringPtrList);
129 */
130
d14a1e28 131 %extend {
a541c325
RD
132 void write(PyObject* obj) {
133 // We use only strings for the streams, not unicode
134 PyObject* str = PyObject_Str(obj);
135 if (! str) {
136 PyErr_SetString(PyExc_TypeError, "Unable to convert to string");
137 return;
138 }
139 self->Write(PyString_AS_STRING(str),
140 PyString_GET_SIZE(str));
141 Py_DECREF(str);
c368d904
RD
142 }
143 }
144};
145
146
d14a1e28 147//---------------------------------------------------------------------------
9416aa89
RD
148%init %{
149 wxPyPtrTypeMap_Add("wxInputStream", "wxPyInputStream");
150%}
d14a1e28 151//---------------------------------------------------------------------------