• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDECore

kcmdlineargs.h

Go to the documentation of this file.
00001 /* This file is part of the KDE project
00002    Copyright (C) 1999 Waldo Bastian <bastian@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License version 2 as published by the Free Software Foundation.
00007 
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012 
00013    You should have received a copy of the GNU Library General Public License
00014    along with this library; see the file COPYING.LIB.  If not, write to
00015    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016    Boston, MA 02110-1301, USA.
00017 */
00018 
00019 #ifndef KCMDLINEARGS_H
00020 #define KCMDLINEARGS_H
00021 
00022 #include <kdecore_export.h>
00023 #include <QtCore/QBool>
00024 
00025 #include <klocale.h>
00026 
00027 template <class T> class QList;
00028 class QString;
00029 class QStringList;
00030 class QByteArray;
00031 class QDataStream;
00032 class KUrl;
00033 
00034 class KCmdLineArgs;
00035 class KCmdLineArgsPrivate;
00036 class KCmdLineArgsStatic;
00037 class KCmdLineOptionsPrivate;
00038 
00048 class KDECORE_EXPORT KCmdLineOptions
00049 {
00050     friend class KCmdLineArgs;
00051     friend class KCmdLineArgsStatic;
00052 
00053     public:
00057     KCmdLineOptions ();
00058 
00062     KCmdLineOptions (const KCmdLineOptions &options);
00063 
00067     KCmdLineOptions& operator= (const KCmdLineOptions &options);
00068 
00072     ~KCmdLineOptions ();
00073 
00094     KCmdLineOptions &add (const QByteArray &name,
00095                           const KLocalizedString &description = KLocalizedString(),
00096                           const QByteArray &defaultValue = QByteArray());
00097 
00103     KCmdLineOptions &add (const KCmdLineOptions &options);
00104 
00105     private:
00106 
00107     KCmdLineOptionsPrivate *d; //krazy:exclude=dpointer (for operator=)
00108 };
00109 
00110 class KCmdLineArgsList;
00111 class KApplication;
00112 class KUniqueApplication;
00113 class KAboutData;
00114 
00255 class KDECORE_EXPORT KCmdLineArgs
00256 {
00257   friend class KApplication;
00258   friend class KUniqueApplication;
00259   friend class KCmdLineArgsList;
00260   friend class KCmdLineArgsStatic;
00261 public:
00262   // Static functions:
00263 
00264   enum StdCmdLineArg {
00265     CmdLineArgQt = 0x01,
00266     CmdLineArgKDE = 0x02,
00267     CmdLineArgsMask=0x03,
00268     CmdLineArgNone = 0x00,
00269     Reserved = 0xff
00270   };
00271   Q_DECLARE_FLAGS(StdCmdLineArgs, StdCmdLineArg)
00290    static void init(int argc, char **argv,
00291                     const QByteArray &appname,
00292                     const QByteArray &catalog,
00293                     const KLocalizedString &programName,
00294                     const QByteArray &version,
00295                     const KLocalizedString &description = KLocalizedString(),
00296                     StdCmdLineArgs stdargs=StdCmdLineArgs(CmdLineArgQt|CmdLineArgKDE));
00297 
00310   static void init(int _argc,
00311                    char **_argv,
00312                    const KAboutData *about,
00313                    StdCmdLineArgs stdargs=StdCmdLineArgs(CmdLineArgQt|CmdLineArgKDE));
00327   static void init(const KAboutData *about);
00328 
00332   static void addStdCmdLineOptions(StdCmdLineArgs stdargs=StdCmdLineArgs(CmdLineArgQt|CmdLineArgKDE));
00333 
00397   static void addCmdLineOptions(const KCmdLineOptions &options,
00398                                 const KLocalizedString &name = KLocalizedString(),
00399                                 const QByteArray &id = QByteArray(),
00400                                 const QByteArray &afterId = QByteArray());
00401 
00411   static KCmdLineArgs *parsedArgs(const QByteArray &id = QByteArray());
00412 
00422   static QString cwd();
00423 
00428   static QString appName();
00429 
00437   static void usage(const QByteArray &id = QByteArray());
00438 
00443   static void usageError(const QString &error);
00444 
00451   static void enable_i18n();
00452 
00453   // Member functions:
00454 
00455 
00474   QString getOption(const QByteArray &option) const;
00475 
00492   QStringList getOptionList(const QByteArray &option) const;
00493 
00508   bool isSet(const QByteArray &option) const;
00509 
00516   int count() const;
00517 
00526   QString arg(int n) const;
00527 
00541   KUrl url(int n) const;
00542 
00549   static KUrl makeURL( const QByteArray &urlArg );
00550 
00557   static void setCwd( const QByteArray &cwd );
00558 
00562   void clear();
00563 
00571   static void reset();
00572 
00576   static void loadAppArgs( QDataStream &);
00577 
00583   static void saveAppArgs( QDataStream &);
00584 
00588   static void addTempFileOption();
00589 
00590   // this avoids having to know the "id" used by addTempFileOption
00591   // but this approach doesn't scale well, we can't have 50 standard options here...
00595   static bool isTempFileSet();
00596 
00602   static int &qtArgc();
00603 
00612   static char **qtArgv();
00613 
00617   static const KAboutData *aboutData();
00618 
00619 protected:
00624   KCmdLineArgs( const KCmdLineOptions &_options, const KLocalizedString &_name,
00625                 const QByteArray &_id);
00626 
00634   ~KCmdLineArgs();
00635 
00636 private:
00637 
00653   static void initIgnore(int _argc, char **_argv, const QByteArray &_appname);
00654 
00655   KCmdLineArgsPrivate *const d;
00656 };
00657 
00658 Q_DECLARE_OPERATORS_FOR_FLAGS(KCmdLineArgs::StdCmdLineArgs)
00659 
00660 #endif
00661 

KDECore

Skip menu "KDECore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal