• Skip to content
  • Skip to link menu
KDE 4.0 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 
00258 class KDECORE_EXPORT KCmdLineArgs
00259 {
00260   friend class KApplication;
00261   friend class KUniqueApplication;
00262   friend class KCmdLineArgsList;
00263   friend class KCmdLineArgsStatic;
00264 public:
00265   // Static functions:
00266 
00267   enum StdCmdLineArg {
00268     CmdLineArgQt = 0x01,
00269     CmdLineArgKDE = 0x02,
00270     CmdLineArgsMask=0x03,
00271     CmdLineArgNone = 0x00,
00272     Reserved = 0xff
00273   };
00274   Q_DECLARE_FLAGS(StdCmdLineArgs, StdCmdLineArg)
00293    static void init(int argc, char **argv,
00294                     const QByteArray &appname,
00295                     const QByteArray &catalog,
00296                     const KLocalizedString &programName,
00297                     const QByteArray &version,
00298                     const KLocalizedString &description = KLocalizedString(),
00299                     StdCmdLineArgs stdargs=StdCmdLineArgs(CmdLineArgQt|CmdLineArgKDE));
00300 
00313   static void init(int _argc,
00314                    char **_argv,
00315                    const KAboutData *about,
00316                    StdCmdLineArgs stdargs=StdCmdLineArgs(CmdLineArgQt|CmdLineArgKDE));
00330   static void init(const KAboutData *about);
00331 
00335   static void addStdCmdLineOptions(StdCmdLineArgs stdargs=StdCmdLineArgs(CmdLineArgQt|CmdLineArgKDE));
00336 
00400   static void addCmdLineOptions(const KCmdLineOptions &options,
00401                                 const KLocalizedString &name = KLocalizedString(),
00402                                 const QByteArray &id = QByteArray(),
00403                                 const QByteArray &afterId = QByteArray());
00404 
00414   static KCmdLineArgs *parsedArgs(const QByteArray &id = QByteArray());
00415 
00425   static QString cwd();
00426 
00431   static QString appName();
00432 
00440   static void usage(const QByteArray &id = QByteArray());
00441 
00446   static void usageError(const QString &error);
00447 
00454   static void enable_i18n();
00455 
00456   // Member functions:
00457 
00458 
00477   QString getOption(const QByteArray &option) const;
00478 
00495   QStringList getOptionList(const QByteArray &option) const;
00496 
00511   bool isSet(const QByteArray &option) const;
00512 
00519   int count() const;
00520 
00529   QString arg(int n) const;
00530 
00544   KUrl url(int n) const;
00545 
00552   static KUrl makeURL( const QByteArray &urlArg );
00553 
00560   static void setCwd( const QByteArray &cwd );
00561 
00565   void clear();
00566 
00574   static void reset();
00575 
00579   static void loadAppArgs( QDataStream &);
00580 
00584   static void addTempFileOption();
00585 
00586   // this avoids having to know the "id" used by addTempFileOption
00587   // but this approach doesn't scale well, we can't have 50 standard options here...
00591   static bool isTempFileSet();
00592 
00598   static int &qtArgc();
00599 
00608   static char **qtArgv();
00609 
00613   static const KAboutData *aboutData();
00614 
00615 protected:
00620   KCmdLineArgs( const KCmdLineOptions &_options, const KLocalizedString &_name,
00621                 const QByteArray &_id);
00622 
00630   ~KCmdLineArgs();
00631 
00632 private:
00633 
00639   static void saveAppArgs( QDataStream &);
00640 
00656   static void initIgnore(int _argc, char **_argv, const QByteArray &_appname);
00657 
00658   KCmdLineArgsPrivate *const d;
00659 };
00660 
00661 Q_DECLARE_OPERATORS_FOR_FLAGS(KCmdLineArgs::StdCmdLineArgs)
00662 
00663 #endif
00664 

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
  •   WTF
  • KJSEmbed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  •   core
  • Phonon
  •   Backend
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
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