• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kdecore
 

kdecore

  • kdecore
kcmdlineargs.h
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 "kdelibs_export.h"
23 #include <kurl.h>
24 
25 #include <tqptrlist.h>
26 #include <tqstring.h>
27 #include <tqvaluelist.h>
28 
29 typedef TQValueList<TQCString> QCStringList;
30 
40 struct KDECORE_EXPORT KCmdLineOptions
41 {
55  const char *name;
60  const char *description;
65  const char *def; // Default
66 };
67 
68 #define KCmdLineLastOption { 0, 0, 0 }
69 
70 class KCmdLineArgsList;
71 class KApplication;
72 class KUniqueApplication;
73 class KCmdLineParsedOptions;
74 class KCmdLineParsedArgs;
75 class KAboutData;
76 class KCmdLineArgsPrivate;
77 
222 class KDECORE_EXPORT KCmdLineArgs
223 {
224  friend class KApplication;
225  friend class KUniqueApplication;
226  friend class TQPtrList<KCmdLineArgs>;
227 public:
228  // Static functions:
229 
249  static void init(int _argc, char **_argv, const char *_appname,
250  const char* programName, const char *_description,
251  const char *_version, bool noKApp = false);
258  static void init(int _argc, char **_argv,
259  const char *_appname, const char *_description,
260  const char *_version, bool noKApp = false) KDE_DEPRECATED;
261 
275  static void init(int _argc, char **_argv,
276  const KAboutData *about, bool noKApp = false);
277 
291  static void init(const KAboutData *about);
292 
357  static void addCmdLineOptions( const KCmdLineOptions *options,
358  const char *name=0, const char *id = 0,
359  const char *afterId=0);
360 
370  static KCmdLineArgs *parsedArgs(const char *id=0);
371 
381  static TQString cwd();
382 
387  static const char *appName();
388 
396  static void usage(const char *id = 0);
397 
402  static void usage(const TQString &error);
403 
410  static void enable_i18n();
411 
412  // Member functions:
413 
414 
433  TQCString getOption(const char *option) const;
434 
451  QCStringList getOptionList(const char *option) const;
452 
467  bool isSet(const char *option) const;
468 
475  int count() const;
476 
485  const char *arg(int n) const;
486 
500  KURL url(int n) const;
501 
508  static KURL makeURL( const char * urlArg );
509 
516  static void setCwd( char * cwd ) { mCwd = cwd; }
517 
521  void clear();
522 
530  static void reset();
531 
535  static void loadAppArgs( TQDataStream &);
536 
541  static void addTempFileOption();
542 
543  // this avoids having to know the "id" used by addTempFileOption
544  // but this approach doesn't scale well, we can't have 50 standard options here...
549  static bool isTempFileSet();
550 
551 protected:
556  KCmdLineArgs( const KCmdLineOptions *_options, const char *_name,
557  const char *_id);
558 
566  ~KCmdLineArgs();
567 
568 private:
574  static void findOption(const char *_opt, TQCString opt, int &i, bool enabled, bool &moreOptions);
575 
582  static void parseAllArgs();
583 
589  static int *qt_argc();
590 
597  static char ***qt_argv();
598 
606  static void removeArgs(const char *id);
607 
613  static void saveAppArgs( TQDataStream &);
614 
620  void setOption(const TQCString &option, bool enabled);
621 
627  void setOption(const TQCString &option, const char *value);
628 
634  void addArgument(const char *argument);
635 
641  void save( TQDataStream &) const;
642 
648  void load( TQDataStream &);
649 
665  static void initIgnore(int _argc, char **_argv, const char *_appname);
666 
667  static void printQ(const TQString &msg);
668 
669  const KCmdLineOptions *options;
670  const char *name;
671  const char *id;
672  KCmdLineParsedOptions *parsedOptionList;
673  KCmdLineParsedArgs *parsedArgList;
674  bool isQt;
675 
676  static KCmdLineArgsList *argsList; // All options.
677  static const KAboutData *about;
678 
679  static int argc; // The original argc
680  static char **argv; // The original argv
681  static bool parsed; // Whether we have parsed the arguments since calling init
682  static bool ignoreUnknown; // Ignore unknown options and arguments
683  static char *mCwd; // Current working directory. Important for KUnqiueApp!
684  static bool parseArgs;
685 
686  KCmdLineArgsPrivate *d;
687 };
688 
689 #endif
690 
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:96
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

kdecore

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

kdecore

Skip menu "kdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kdecore by doxygen 1.8.6
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |