You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
265 lines
7.0 KiB
265 lines
7.0 KiB
13 years ago
|
//
|
||
|
// Copyright 2006 Jim Bublitz <jbublitz@nwinternet.com>
|
||
|
// Earlier copyrights 1998 - 2005 Jim Bublitz and/or Phil Thompson
|
||
|
// may also apply
|
||
|
|
||
|
|
||
|
// Generated by preSip
|
||
13 years ago
|
// module tdecore version KDE 3.5.3
|
||
13 years ago
|
|
||
|
|
||
|
// 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.
|
||
|
|
||
|
|
||
12 years ago
|
class TDECmdLineOptions
|
||
13 years ago
|
{
|
||
|
%TypeHeaderCode
|
||
12 years ago
|
#include <tdecmdlineargs.h>
|
||
13 years ago
|
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
|
||
|
|
||
|
|
||
12 years ago
|
}; // class TDECmdLineOptions
|
||
13 years ago
|
|
||
|
|
||
12 years ago
|
class TDECmdLineArgs
|
||
13 years ago
|
{
|
||
|
%TypeHeaderCode
|
||
12 years ago
|
#include <tdecmdlineargs.h>
|
||
13 years ago
|
#include <tqapplication.h>
|
||
13 years ago
|
%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
|
||
12 years ago
|
TDECmdLineArgs::init (nargc,argv, a1, a2, a3, a4, a5);
|
||
13 years ago
|
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
|
||
12 years ago
|
TDECmdLineArgs::init (nargc,argv, a1, a2, a3, a4);
|
||
13 years ago
|
Py_END_ALLOW_THREADS
|
||
|
|
||
|
// Now modify the original list.
|
||
|
|
||
|
updatePyArgv (a0, argc, argv);
|
||
|
%End
|
||
|
|
||
12 years ago
|
static void init (SIP_PYLIST, const TDEAboutData*, bool = 0) [void (int, char**, const TDEAboutData*, bool = 0)];
|
||
13 years ago
|
%MethodCode
|
||
12 years ago
|
//takes _argv | (a Python list of strings which may be modified) | about | (TDEAboutData) | noKApp | (bool = 0)
|
||
13 years ago
|
|
||
|
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
|
||
12 years ago
|
TDECmdLineArgs::init (nargc, argv, a1, a2);
|
||
13 years ago
|
Py_END_ALLOW_THREADS
|
||
|
|
||
|
// Now modify the original list.
|
||
|
|
||
|
updatePyArgv (a0, argc, argv);
|
||
|
%End
|
||
|
|
||
12 years ago
|
static void init (const TDEAboutData*);
|
||
12 years ago
|
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)];
|
||
13 years ago
|
%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
|
||
12 years ago
|
// instead of a TDECmdLineOptions object (TDECmdLineOptions is not used);
|
||
13 years ago
|
// NULL (or None) parameters to mark the end of the list are not required
|
||
13 years ago
|
//end
|
||
|
|
||
|
int n;
|
||
|
|
||
|
if ((n = PyList_Size (a0)) == 0)
|
||
|
return NULL;
|
||
|
|
||
|
// opts is persistent
|
||
12 years ago
|
TDECmdLineOptions *opts;
|
||
13 years ago
|
|
||
|
Py_BEGIN_ALLOW_THREADS
|
||
12 years ago
|
opts = new TDECmdLineOptions [n + 1];
|
||
13 years ago
|
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
|
||
12 years ago
|
TDECmdLineArgs::addCmdLineOptions (opts, a1, a2, a3);
|
||
13 years ago
|
Py_END_ALLOW_THREADS
|
||
|
|
||
|
Py_INCREF (Py_None);
|
||
|
return Py_None;
|
||
|
|
||
|
errorExit:
|
||
|
delete opts;
|
||
|
return NULL;
|
||
|
%End
|
||
|
|
||
12 years ago
|
static TDECmdLineArgs* parsedArgs (const char* = 0);
|
||
13 years ago
|
static TQString cwd ();
|
||
13 years ago
|
static const char* appName ();
|
||
|
static void usage (const char* = 0);
|
||
13 years ago
|
static void usage (const TQString&);
|
||
13 years ago
|
static void enable_i18n ();
|
||
13 years ago
|
TQCString getOption (const char*);
|
||
13 years ago
|
|
||
|
%If ( KDE_3_1_4 - )
|
||
13 years ago
|
QCStringList getOptionList (const char*) const;
|
||
13 years ago
|
%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 ();
|
||
13 years ago
|
static void loadAppArgs (TQDataStream&);
|
||
13 years ago
|
|
||
|
%If ( KDE_3_4_0 - )
|
||
|
static void addTempFileOption ();
|
||
|
static bool isTempFileSet ();
|
||
|
%End
|
||
|
|
||
|
%End
|
||
|
|
||
|
|
||
|
protected:
|
||
12 years ago
|
TDECmdLineArgs (const TDECmdLineOptions*, const char*, const char*);
|
||
12 years ago
|
~TDECmdLineArgs ();
|
||
13 years ago
|
|
||
|
public:
|
||
|
|
||
|
%If ( - KDE_3_1_3 )
|
||
13 years ago
|
TQValueList<TQCString> getOptionList (const char*);
|
||
13 years ago
|
%End
|
||
|
|
||
|
|
||
12 years ago
|
}; // class TDECmdLineArgs
|
||
13 years ago
|
|