• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDECore

  • kdecore
  • kernel
kcmdlineargs.h
Go to the documentation of this file.
1/* This file is part of the KDE project
2 Copyright (C) 1999 Waldo Bastian <bastian@kde.org>
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 <kdecore_export.h>
23#include <QtCore/QBool>
24
25#include <klocale.h>
26
27template <class T> class QList;
28class QString;
29class QStringList;
30class QByteArray;
31class QDataStream;
32class KUrl;
33
34class KCmdLineArgs;
35class KCmdLineArgsPrivate;
36class KCmdLineArgsStatic;
37class KCmdLineOptionsPrivate;
38
48class KDECORE_EXPORT KCmdLineOptions
49{
50 friend class KCmdLineArgs;
51 friend class KCmdLineArgsStatic;
52
53 public:
57 KCmdLineOptions ();
58
62 KCmdLineOptions (const KCmdLineOptions &options);
63
67 KCmdLineOptions& operator= (const KCmdLineOptions &options);
68
72 ~KCmdLineOptions ();
73
121 KCmdLineOptions &add (const QByteArray &name,
122 const KLocalizedString &description = KLocalizedString(),
123 const QByteArray &defaultValue = QByteArray());
124
130 KCmdLineOptions &add (const KCmdLineOptions &options);
131
132 private:
133
134 KCmdLineOptionsPrivate *d; //krazy:exclude=dpointer (for operator=)
135};
136
137class KCmdLineArgsList;
138class KApplication;
139class KAboutData;
140
281class KDECORE_EXPORT KCmdLineArgs
282{
283 friend class KApplication;
284 friend class KCmdLineArgsList;
285 friend class KCmdLineArgsStatic;
286public:
287 // Static functions:
288
289 enum StdCmdLineArg {
290 CmdLineArgQt = 0x01,
291 CmdLineArgKDE = 0x02,
292 CmdLineArgsMask=0x03,
293 CmdLineArgNone = 0x00,
294 Reserved = 0xff
295 };
296 Q_DECLARE_FLAGS(StdCmdLineArgs, StdCmdLineArg)
315 static void init(int argc, char **argv,
316 const QByteArray &appname,
317 const QByteArray &catalog,
318 const KLocalizedString &programName,
319 const QByteArray &version,
320 const KLocalizedString &description = KLocalizedString(),
321 StdCmdLineArgs stdargs=StdCmdLineArgs(CmdLineArgQt|CmdLineArgKDE));
322
335 static void init(int _argc,
336 char **_argv,
337 const KAboutData *about,
338 StdCmdLineArgs stdargs=StdCmdLineArgs(CmdLineArgQt|CmdLineArgKDE));
352 static void init(const KAboutData *about);
353
357 static void addStdCmdLineOptions(StdCmdLineArgs stdargs=StdCmdLineArgs(CmdLineArgQt|CmdLineArgKDE));
358
422 static void addCmdLineOptions(const KCmdLineOptions &options,
423 const KLocalizedString &name = KLocalizedString(),
424 const QByteArray &id = QByteArray(),
425 const QByteArray &afterId = QByteArray());
426
436 static KCmdLineArgs *parsedArgs(const QByteArray &id = QByteArray());
437
447 static QString cwd();
448
453 static QString appName();
454
462 static void usage(const QByteArray &id = QByteArray());
463
468 static void usageError(const QString &error);
469
476 static void enable_i18n();
477
478 // Member functions:
479
480
499 QString getOption(const QByteArray &option) const;
500
517 QStringList getOptionList(const QByteArray &option) const;
518
533 bool isSet(const QByteArray &option) const;
534
541 int count() const;
542
551 QString arg(int n) const;
552
566 KUrl url(int n) const;
567
574 static KUrl makeURL( const QByteArray &urlArg );
575
582 static void setCwd( const QByteArray &cwd );
583
587 void clear();
588
596 static void reset();
597
601 static void loadAppArgs( QDataStream &);
602
608 static void saveAppArgs( QDataStream &);
609
613 static void addTempFileOption();
614
615 // this avoids having to know the "id" used by addTempFileOption
616 // but this approach doesn't scale well, we can't have 50 standard options here...
620 static bool isTempFileSet();
621
627 static int &qtArgc();
628
637 static char **qtArgv();
638
643 static QStringList allArguments();
644
648 static const KAboutData *aboutData();
649
650protected:
655 KCmdLineArgs( const KCmdLineOptions &_options, const KLocalizedString &_name,
656 const QByteArray &_id);
657
665 ~KCmdLineArgs();
666
667private:
668
684 static void initIgnore(int _argc, char **_argv, const QByteArray &_appname);
685
686 KCmdLineArgsPrivate *const d;
687};
688
689Q_DECLARE_OPERATORS_FOR_FLAGS(KCmdLineArgs::StdCmdLineArgs)
690
691#endif
692
KAboutData
This class is used to store information about a program.
Definition: kaboutdata.h:193
KCmdLineArgs
A class for command-line argument handling.
Definition: kcmdlineargs.h:282
KCmdLineArgs::StdCmdLineArg
StdCmdLineArg
Definition: kcmdlineargs.h:289
KCmdLineOptions
Class that holds command line options.
Definition: kcmdlineargs.h:49
KLocalizedString
Class for producing and handling localized messages.
Definition: klocalizedstring.h:300
KUrl
Represents and parses a URL.
Definition: kurl.h:112
QList
Definition: kaboutdata.h:33
QStringList
QString
defaultValue
QString defaultValue(const QString &t)
Definition: kconfig_compiler.cpp:950
kdecore_export.h
klocale.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

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

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal