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 "kdemacros.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 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 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
00537
protected:
00542
KCmdLineArgs(
const KCmdLineOptions *_options,
const char *_name,
00543
const char *_id);
00544
00552
~KCmdLineArgs();
00553
00554
private:
00560
static void findOption(
const char *_opt,
QCString opt,
int &i,
bool enabled,
bool &moreOptions);
00561
00568
static void parseAllArgs();
00569
00575
static int *qt_argc();
00576
00583
static char ***qt_argv();
00584
00592
static void removeArgs(
const char *
id);
00593
00599
static void saveAppArgs(
QDataStream &);
00600
00606
void setOption(
const QCString &option,
bool enabled);
00607
00613
void setOption(
const QCString &option,
const char *value);
00614
00620
void addArgument(
const char *argument);
00621
00627
void save(
QDataStream &) const;
00628
00634
void load(
QDataStream &);
00635
00651 static
void initIgnore(
int _argc,
char **_argv, const
char *_appname);
00652
00653 static
void printQ(const
QString &msg);
00654
00655 const
KCmdLineOptions *options;
00656 const
char *name;
00657 const
char *
id;
00658 KCmdLineParsedOptions *parsedOptionList;
00659 KCmdLineParsedArgs *parsedArgList;
00660
bool isQt;
00661
00662 static KCmdLineArgsList *argsList;
00663 static const
KAboutData *about;
00664
00665 static
int argc;
00666 static
char **argv;
00667 static
bool parsed;
00668 static
bool ignoreUnknown;
00669 static
char *mCwd;
00670 static
bool parseArgs;
00671
00672 KCmdLineArgsPrivate *d;
00673 };
00674
00675 #endif
00676
This file is part of the documentation for kdecore Library Version 3.3.1.