kcmdlineargs.h
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 <kurl.h>
00023
00024 #include <qptrlist.h>
00025 #include <qstring.h>
00026 #include <qvaluelist.h>
00027
00028 typedef QValueList<QCString> QCStringList;
00029
00033 struct KCmdLineOptions
00034 {
00035 const char *name;
00036 const char *description;
00037 const char *def;
00038 };
00039
00040 #define KCmdLineLastOption { 0, 0, 0 }
00041
00042 class KCmdLineArgsList;
00043 class KApplication;
00044 class KUniqueApplication;
00045 class KCmdLineParsedOptions;
00046 class KCmdLineParsedArgs;
00047 class KAboutData;
00048 class KCmdLineArgsPrivate;
00049
00190 class KCmdLineArgs
00191 {
00192 friend class KApplication;
00193 friend class KUniqueApplication;
00194 friend class QPtrList<KCmdLineArgs>;
00195 public:
00196
00197
00211 static void init(int _argc, char **_argv,
00212 const char *_appname, const char *_description,
00213 const char *_version, bool noKApp = false);
00214
00225 static void init(int _argc, char **_argv,
00226 const KAboutData *about, bool noKApp = false);
00227
00238 static void init(const KAboutData *about);
00239
00292 static void addCmdLineOptions( const KCmdLineOptions *options,
00293 const char *name=0, const char *id = 0,
00294 const char *afterId=0);
00295
00305 static KCmdLineArgs *parsedArgs(const char *id=0);
00306
00316 static QString cwd();
00317
00322 static const char *appName();
00323
00331 static void usage(const char *id = 0);
00332
00337 static void usage(const QString &error);
00338
00345 static void enable_i18n();
00346
00347
00348
00349
00366 QCString getOption(const char *option) const;
00367
00382 QCStringList getOptionList(const char *option) const;
00383
00400 bool isSet(const char *option) const;
00401
00408 int count() const;
00409
00418 const char *arg(int n) const;
00419
00433 KURL url(int n) const;
00434
00441 static KURL makeURL( const char * urlArg );
00442
00449 static void setCwd( char * cwd ) { mCwd = cwd; }
00450
00454 void clear();
00455
00456
00457 protected:
00462 KCmdLineArgs( const KCmdLineOptions *_options, const char *_id,
00463 const char *_name);
00464
00472 ~KCmdLineArgs();
00473
00474 private:
00480 static void findOption(const char *_opt, QCString opt, int &i, bool enabled, bool &moreOptions);
00481
00488 static void parseAllArgs();
00489
00495 static int *qt_argc();
00496
00503 static char ***qt_argv();
00504
00512 static void removeArgs(const char *id);
00513
00514
00520 static void saveAppArgs( QDataStream &);
00521
00527 static void loadAppArgs( QDataStream &);
00528
00534 void setOption(const QCString &option, bool enabled);
00535
00541 void setOption(const QCString &option, const char *value);
00542
00548 void addArgument(const char *argument);
00549
00555 void save( QDataStream &) const;
00556
00562 void load( QDataStream &);
00563
00579 static void initIgnore(int _argc, char **_argv, const char *_appname);
00580
00581 static void printQ(const QString &msg);
00582
00583 const KCmdLineOptions *options;
00584 const char *name;
00585 const char *id;
00586 KCmdLineParsedOptions *parsedOptionList;
00587 KCmdLineParsedArgs *parsedArgList;
00588 bool isQt;
00589
00590 static KCmdLineArgsList *argsList;
00591 static const KAboutData *about;
00592
00593 static int argc;
00594 static char **argv;
00595 static bool parsed;
00596 static bool ignoreUnknown;
00597 static char *mCwd;
00598
00599 KCmdLineArgsPrivate *d;
00600 };
00601
00602 #endif
00603
This file is part of the documentation for kdelibs Version 3.1.0.