00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
#ifndef _KCMDLINEARGS_H_
00020
#define _KCMDLINEARGS_H_
00021
00022
#include "kdelibs_export.h"
00023
#include <kurl.h>
00024
00025
#include <qptrlist.h>
00026
#include <qstring.h>
00027
#include <qvaluelist.h>
00028
00029
typedef QValueList<QCString> QCStringList;
00030
00040 struct KDECORE_EXPORT KCmdLineOptions
00041 {
00055 const char *name;
00060 const char *description;
00065 const char *def;
00066 };
00067
00068
#define KCmdLineLastOption { 0, 0, 0 }
00069
00070
class KCmdLineArgsList;
00071
class KApplication;
00072
class KUniqueApplication;
00073
class KCmdLineParsedOptions;
00074
class KCmdLineParsedArgs;
00075
class KAboutData;
00076
class KCmdLineArgsPrivate;
00077
00222 class KDECORE_EXPORT KCmdLineArgs
00223 {
00224
friend class KApplication;
00225
friend class KUniqueApplication;
00226
friend class QPtrList<KCmdLineArgs>;
00227
public:
00228
00229
00249
static void init(
int _argc,
char **_argv,
const char *_appname,
00250
const char* programName,
const char *_description,
00251
const char *_version,
bool noKApp =
false);
00258
static void init(
int _argc,
char **_argv,
00259
const char *_appname,
const char *_description,
00260
const char *_version,
bool noKApp =
false) KDE_DEPRECATED;
00261
00275
static void init(
int _argc,
char **_argv,
00276
const KAboutData *about,
bool noKApp =
false);
00277
00291
static void init(
const KAboutData *about);
00292
00357
static void addCmdLineOptions(
const KCmdLineOptions *options,
00358
const char *name=0,
const char *
id = 0,
00359
const char *afterId=0);
00360
00370
static KCmdLineArgs *parsedArgs(
const char *
id=0);
00371
00381
static QString cwd();
00382
00387
static const char *appName();
00388
00396
static void usage(
const char *
id = 0);
00397
00402
static void usage(
const QString &error);
00403
00410
static void enable_i18n();
00411
00412
00413
00414
00433
QCString getOption(
const char *option)
const;
00434
00451 QCStringList getOptionList(
const char *option)
const;
00452
00467
bool isSet(
const char *option)
const;
00468
00475
int count()
const;
00476
00485
const char *arg(
int n)
const;
00486
00500
KURL url(
int n)
const;
00501
00508
static KURL makeURL(
const char * urlArg );
00509
00516 static void setCwd(
char * cwd ) { mCwd = cwd; }
00517
00521
void clear();
00522
00530
static void reset();
00531
00535
static void loadAppArgs(
QDataStream &);
00536
00541
static void addTempFileOption();
00542
00543
00544
00549
static bool isTempFileSet();
00550
00551
protected:
00556 KCmdLineArgs(
const KCmdLineOptions *_options,
const char *_name,
00557
const char *_id);
00558
00566 ~KCmdLineArgs();
00567
00568
private:
00574
static void findOption(
const char *_opt,
QCString opt,
int &i,
bool enabled,
bool &moreOptions);
00575
00582
static void parseAllArgs();
00583
00589
static int *qt_argc();
00590
00597
static char ***qt_argv();
00598
00606
static void removeArgs(
const char *
id);
00607
00613
static void saveAppArgs(
QDataStream &);
00614
00620
void setOption(
const QCString &option,
bool enabled);
00621
00627
void setOption(
const QCString &option,
const char *value);
00628
00634
void addArgument(
const char *argument);
00635
00641
void save(
QDataStream &) const;
00642
00648
void load(
QDataStream &);
00649
00665 static
void initIgnore(
int _argc,
char **_argv, const
char *_appname);
00666
00667 static
void printQ(const
QString &msg);
00668
00669 const KCmdLineOptions *options;
00670 const
char *name;
00671 const
char *
id;
00672 KCmdLineParsedOptions *parsedOptionList;
00673 KCmdLineParsedArgs *parsedArgList;
00674
bool isQt;
00675
00676 static KCmdLineArgsList *argsList;
00677 static const
KAboutData *about;
00678
00679 static
int argc;
00680 static
char **argv;
00681 static
bool parsed;
00682 static
bool ignoreUnknown;
00683 static
char *mCwd;
00684 static
bool parseArgs;
00685
00686 KCmdLineArgsPrivate *d;
00687 };
00688
00689 #endif
00690