kcmdlineargs.h
/* This file is part of the KDE project
Copyright (C) 1999 Waldo Bastian <bastian@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef _KCMDLINEARGS_H_
#define _KCMDLINEARGS_H_
#include "kdelibs_export.h"
#include <kurl.h>
#include <qptrlist.h>
#include <qstring.h>
#include <qvaluelist.h>
typedef QValueList<QCString> QCStringList;
struct KDECORE_EXPORT KCmdLineOptions
{
const char *name;
const char *description;
const char *def; // Default
};
#define KCmdLineLastOption { 0, 0, 0 }
class KCmdLineArgsList;
class KApplication;
class KUniqueApplication;
class KCmdLineParsedOptions;
class KCmdLineParsedArgs;
class KAboutData;
class KCmdLineArgsPrivate;
class KDECORE_EXPORT KCmdLineArgs
{
friend class KApplication;
friend class KUniqueApplication;
friend class QPtrList<KCmdLineArgs>;
public:
// Static functions:
static void init(int _argc, char **_argv, const char *_appname,
const char* programName, const char *_description,
const char *_version, bool noKApp = false);
static void init(int _argc, char **_argv,
const char *_appname, const char *_description,
const char *_version, bool noKApp = false) KDE_DEPRECATED;
static void init(int _argc, char **_argv,
const KAboutData *about, bool noKApp = false);
static void init(const KAboutData *about);
static void addCmdLineOptions( const KCmdLineOptions *options,
const char *name=0, const char *id = 0,
const char *afterId=0);
static KCmdLineArgs *parsedArgs(const char *id=0);
static QString cwd();
static const char *appName();
static void usage(const char *id = 0);
static void usage(const QString &error);
static void enable_i18n();
// Member functions:
QCString getOption(const char *option) const;
QCStringList getOptionList(const char *option) const;
bool isSet(const char *option) const;
int count() const;
const char *arg(int n) const;
KURL url(int n) const;
static KURL makeURL( const char * urlArg );
static void setCwd( char * cwd ) { mCwd = cwd; }
void clear();
static void reset();
static void loadAppArgs( QDataStream &);
static void addTempFileOption();
// this avoids having to know the "id" used by addTempFileOption
// but this approach doesn't scale well, we can't have 50 standard options here...
static bool isTempFileSet();
protected:
KCmdLineArgs( const KCmdLineOptions *_options, const char *_name,
const char *_id);
~KCmdLineArgs();
private:
static void findOption(const char *_opt, QCString opt, int &i, bool enabled, bool &moreOptions);
static void parseAllArgs();
static int *qt_argc();
static char ***qt_argv();
static void removeArgs(const char *id);
static void saveAppArgs( QDataStream &);
void setOption(const QCString &option, bool enabled);
void setOption(const QCString &option, const char *value);
void addArgument(const char *argument);
void save( QDataStream &) const;
void load( QDataStream &);
static void initIgnore(int _argc, char **_argv, const char *_appname);
static void printQ(const QString &msg);
const KCmdLineOptions *options;
const char *name;
const char *id;
KCmdLineParsedOptions *parsedOptionList;
KCmdLineParsedArgs *parsedArgList;
bool isQt;
static KCmdLineArgsList *argsList; // All options.
static const KAboutData *about;
static int argc; // The original argc
static char **argv; // The original argv
static bool parsed; // Whether we have parsed the arguments since calling init
static bool ignoreUnknown; // Ignore unknown options and arguments
static char *mCwd; // Current working directory. Important for KUnqiueApp!
static bool parseArgs;
KCmdLineArgsPrivate *d;
};
#endif
KURL
Represents and parses a URL.
Definition: kurl.h:127
KCmdLineOptions::def
const char * def
The default value for the option, if it is not specified on the command line.
Definition: kcmdlineargs.h:65
KApplication
Controls and provides information to all KDE applications.
Definition: kapplication.h:94
KCmdLineOptions::description
const char * description
The text description of the option as should appear in myapp –help.
Definition: kcmdlineargs.h:60
KCmdLineArgs
A class for command-line argument handling.
Definition: kcmdlineargs.h:222
KCmdLineArgs::setCwd
static void setCwd(char *cwd)
Made public for apps that don't use KCmdLineArgs To be done before makeURL, to set the current workin...
Definition: kcmdlineargs.h:516
KCmdLineOptions
Structure that holds command line options.
Definition: kcmdlineargs.h:40
KAboutData
This class is used to store information about a program.
Definition: kaboutdata.h:182
KUniqueApplication
Maintains only a single instance of a running application at a time.
Definition: kuniqueapplication.h:48
KCmdLineOptions::name
const char * name
The name of the argument as it should be called on the command line and appear in myapp –help...
Definition: kcmdlineargs.h:55

KDE Home | KDE Accessibility Home | Description of Access Keys