1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
|
//
// Copyright 2006 Jim Bublitz <[email protected]>
// Earlier copyrights 1998 - 2005 Jim Bublitz and/or Phil Thompson
// may also apply
// Generated by preSip
// module tdecore version KDE 3.5.3
// This software is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of
// the License, or (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this library; see the file COPYING.
// If not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class TDECmdLineOptions
{
%TypeHeaderCode
#include <kcmdlineargs.h>
extern char **pyArgvToC(PyObject *argvlist,int *argcp);
extern void updatePyArgv(PyObject *argvlist,int argc,char **argv);
%End
public:
const char* name;
const char* description;
%If ( KDE_3_5_3 - )
// def is a Python keyword - use /PyName=/
//pykwd const char* def;
%End
}; // class TDECmdLineOptions
class TDECmdLineArgs
{
%TypeHeaderCode
#include <kcmdlineargs.h>
#include <tqapplication.h>
%End
public:
%If ( KDE_3_2_0 - )
static void init (SIP_PYLIST, const char*, const char*, const char*, const char*, bool = 0) [void (int, char**, const char*, const char*, const char*, const char*, bool = 0)];
%MethodCode
//takes _argc | (int) | _argv | (char) | _appname | (char) | programName | (char) | _description | (char) | _version | (char) | noKApp | (bool = 0)
int argc, nargc;
char **argv;
// Convert the list.
if ((argv = pyArgvToC(a0, &argc)) == NULL)
return NULL;
// Create it now the arguments are right.
nargc = argc;
Py_BEGIN_ALLOW_THREADS
TDECmdLineArgs::init (nargc,argv, a1, a2, a3, a4, a5);
Py_END_ALLOW_THREADS
// Now modify the original list.
updatePyArgv (a0, argc, argv);
%End
%End
static void init (SIP_PYLIST, const char*, const char*, const char*, bool = 0) [void (int, char**, const char*, const char*, const char*, bool = 0)];
%MethodCode
//takes _argv | (a Python list of strings which may be modified) | _appname | (char) | _description | (char) | _version | (char) | noKApp | (bool = False)
int argc, nargc;
char **argv;
// Convert the list.
if ((argv = pyArgvToC(a0, &argc)) == NULL)
return NULL;
// Create it now the arguments are right.
nargc = argc;
Py_BEGIN_ALLOW_THREADS
TDECmdLineArgs::init (nargc,argv, a1, a2, a3, a4);
Py_END_ALLOW_THREADS
// Now modify the original list.
updatePyArgv (a0, argc, argv);
%End
static void init (SIP_PYLIST, const TDEAboutData*, bool = 0) [void (int, char**, const TDEAboutData*, bool = 0)];
%MethodCode
//takes _argv | (a Python list of strings which may be modified) | about | (TDEAboutData) | noKApp | (bool = 0)
int argc, nargc; //, iserr = 0;
char **argv;
// Convert the list.
if ((argv = pyArgvToC (a0, &argc)) == NULL)
return NULL;
// Create it now the arguments are right.
nargc = argc;
Py_BEGIN_ALLOW_THREADS
TDECmdLineArgs::init (nargc, argv, a1, a2);
Py_END_ALLOW_THREADS
// Now modify the original list.
updatePyArgv (a0, argc, argv);
%End
static void init (const TDEAboutData*);
static void addCmdLineOptions (SIP_PYLIST, const char* = 0, const char* = 0, const char* = 0) [void (const TDECmdLineOptions*, const char* = 0, const char* = 0, const char* = 0)];
%MethodCode
//takes options | (a Python list of tuples) | name | (char = 0) | id | (char = 0) | afterId | (char = 0)
//doc
// A Pytbon list of tuples (name, description, default) is the first parameter
// instead of a TDECmdLineOptions object (TDECmdLineOptions is not used);
// NULL (or None) parameters to mark the end of the list are not required
//end
int n;
if ((n = PyList_Size (a0)) == 0)
return NULL;
// opts is persistent
TDECmdLineOptions *opts;
Py_BEGIN_ALLOW_THREADS
opts = new TDECmdLineOptions [n + 1];
Py_END_ALLOW_THREADS
int i, tsz;
for (i = 0; i < n; i++)
{
PyObject *tuple;
if ((tuple = PyList_GetItem (a0, i)) != NULL)
{
tsz = PyTuple_Size (tuple);
PyObject *member;
if (tsz == 0)
goto errorExit;
member = PyTuple_GET_ITEM (tuple, 0);
if (PyString_Check (member))
opts [i].name = PyString_AS_STRING (member);
else
goto errorExit;
if (tsz > 1)
{
member = PyTuple_GET_ITEM (tuple, 1);
if PyString_Check (member)
opts [i].description = PyString_AS_STRING (member);
else
goto errorExit;
}
else
opts [i].description = NULL;
if (tsz > 2)
{
member = PyTuple_GET_ITEM (tuple, 2);
if PyString_Check (member)
opts [i].def = PyString_AS_STRING (member);
else
goto errorExit;
}
else
opts [i].def = NULL;
}
else
goto errorExit;
}
// mark the end of the list
opts [n].name = NULL;
opts [n].description = NULL;
opts [n].def = NULL;
Py_BEGIN_ALLOW_THREADS
TDECmdLineArgs::addCmdLineOptions (opts, a1, a2, a3);
Py_END_ALLOW_THREADS
Py_INCREF (Py_None);
return Py_None;
errorExit:
delete opts;
return NULL;
%End
static TDECmdLineArgs* parsedArgs (const char* = 0);
static TQString cwd ();
static const char* appName ();
static void usage (const char* = 0);
static void usage (const TQString&);
static void enable_i18n ();
TQCString getOption (const char*);
%If ( KDE_3_1_4 - )
QCStringList getOptionList (const char*) const;
%End
bool isSet (const char*);
int count ();
const char* arg (int);
KURL url (int);
static KURL makeURL (const char*);
static void setCwd (char*);
void clear ();
%If ( KDE_3_2_0 - )
static void reset ();
static void loadAppArgs (TQDataStream&);
%If ( KDE_3_4_0 - )
static void addTempFileOption ();
static bool isTempFileSet ();
%End
%End
protected:
TDECmdLineArgs (const TDECmdLineOptions*, const char*, const char*);
~TDECmdLineArgs ();
public:
%If ( - KDE_3_1_3 )
TQValueList<TQCString> getOptionList (const char*);
%End
}; // class TDECmdLineArgs
|