KDELibs4Support

kcmdlineargs.h
1 /* This file is part of the KDE project
2  Copyright (C) 1999 Waldo Bastian <[email protected]>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 */
18 
19 #ifndef KCMDLINEARGS_H
20 #define KCMDLINEARGS_H
21 
22 #include <kdelibs4support_export.h>
23 
24 #ifdef KDELIBS4SUPPORT_NO_DEPRECATED_NOISE
25 #warning "This file is deprecated."
26 #endif
27 
28 #include <klocalizedstring.h>
29 
30 template <class T> class QList;
31 class QString;
32 class QStringList;
33 class QByteArray;
34 class QDataStream;
35 class QUrl;
36 
37 class KCmdLineArgs;
38 class KCmdLineArgsPrivate;
39 class KCmdLineArgsStatic;
40 class KCmdLineOptionsPrivate;
41 
53 class KDELIBS4SUPPORT_DEPRECATED_EXPORT_NOISE KCmdLineOptions
54 {
55  friend class KCmdLineArgs;
56  friend class KCmdLineArgsStatic;
57 
58 public:
63 
67  KCmdLineOptions(const KCmdLineOptions &options);
68 
72  KCmdLineOptions &operator= (const KCmdLineOptions &options);
73 
77  ~KCmdLineOptions();
78 
126  KCmdLineOptions &add(const QByteArray &name,
127  const KLocalizedString &description = KLocalizedString(),
128  const QByteArray &defaultValue = QByteArray());
129 
135  KCmdLineOptions &add(const KCmdLineOptions &options);
136 
137 private:
138 
139  KCmdLineOptionsPrivate *d; //krazy:exclude=dpointer (for operator=)
140 };
141 
142 class KCmdLineArgsList;
143 class KApplication;
144 class K4AboutData;
145 
286 class KDELIBS4SUPPORT_DEPRECATED_EXPORT KCmdLineArgs
287 {
288  friend class KApplication;
289  friend class KCmdLineArgsList;
290  friend class KCmdLineArgsStatic;
291 public:
292  // Static functions:
293 
294  enum StdCmdLineArg {
295  CmdLineArgQt = 0x01,
296  CmdLineArgKDE = 0x02,
297  CmdLineArgsMask = 0x03,
298  CmdLineArgNone = 0x00,
299  Reserved = 0xff
300  };
301  Q_DECLARE_FLAGS(StdCmdLineArgs, StdCmdLineArg)
320  static void init(int argc, char **argv,
321  const QByteArray &appname,
322  const QByteArray &catalog,
323  const KLocalizedString &programName,
324  const QByteArray &version,
325  const KLocalizedString &description = KLocalizedString(),
326  StdCmdLineArgs stdargs = StdCmdLineArgs(CmdLineArgQt | CmdLineArgKDE));
327 
340  static void init(int _argc,
341  char **_argv,
342  const K4AboutData *about,
343  StdCmdLineArgs stdargs = StdCmdLineArgs(CmdLineArgQt | CmdLineArgKDE));
357  static void init(const K4AboutData *about);
358 
362  static void addStdCmdLineOptions(StdCmdLineArgs stdargs = StdCmdLineArgs(CmdLineArgQt | CmdLineArgKDE));
363 
427  static void addCmdLineOptions(const KCmdLineOptions &options,
428  const KLocalizedString &name = KLocalizedString(),
429  const QByteArray &id = QByteArray(),
430  const QByteArray &afterId = QByteArray());
431 
441  static KCmdLineArgs *parsedArgs(const QByteArray &id = QByteArray());
442 
452  static QString cwd();
453 
458  static QString appName();
459 
467  static void usage(const QByteArray &id = QByteArray());
468 
473  static void usageError(const QString &error);
474 
481  static void enable_i18n();
482 
483  // Member functions:
484 
503  QString getOption(const QByteArray &option) const;
504 
521  QStringList getOptionList(const QByteArray &option) const;
522 
537  bool isSet(const QByteArray &option) const;
538 
545  int count() const;
546 
555  QString arg(int n) const;
556 
570  QUrl url(int n) const;
571 
578  static QUrl makeURL(const QByteArray &urlArg);
579 
586  static void setCwd(const QByteArray &cwd);
587 
591  void clear();
592 
600  static void reset();
601 
605  static void loadAppArgs(QDataStream &);
606 
612  static void saveAppArgs(QDataStream &);
613 
617  static void addTempFileOption();
618 
619  // this avoids having to know the "id" used by addTempFileOption
620  // but this approach doesn't scale well, we can't have 50 standard options here...
624  static bool isTempFileSet();
625 
631  static int &qtArgc();
632 
641  static char **qtArgv();
642 
647  static QStringList allArguments();
648 
652  static const K4AboutData *aboutData();
653 
654 protected:
659  KCmdLineArgs(const KCmdLineOptions &_options, const KLocalizedString &_name,
660  const QByteArray &_id);
661 
669  ~KCmdLineArgs();
670 
671 private:
672 
688  static void initIgnore(int _argc, char **_argv, const QByteArray &_appname);
689 
690  KCmdLineArgsPrivate *const d;
691 };
692 
693 Q_DECLARE_OPERATORS_FOR_FLAGS(KCmdLineArgs::StdCmdLineArgs)
694 
695 #endif
696 
Controls and provides information to all KDE applications.
Definition: kapplication.h:76
A class for command-line argument handling.
Definition: kcmdlineargs.h:286
This class is used to store information about a program.
Definition: k4aboutdata.h:199
QCA_EXPORT void init()
unsigned int version()
Returns the encoded number of KDE&#39;s version, see the KDE_VERSION macro.
Definition: kdeversion.cpp:24
Class that holds command line options.
Definition: kcmdlineargs.h:53
QCA_EXPORT QString appName()
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Aug 13 2020 22:58:29 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.