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

tdecore

  • tdecore
tdecmdlineargs.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 _TDECMDLINEARGS_H_
20 #define _TDECMDLINEARGS_H_
21 
22 #include "tdelibs_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 TDECORE_EXPORT TDECmdLineOptions
41 {
55  const char *name;
60  const char *description;
65  const char *def; // Default
66 };
67 
68 #define TDECmdLineLastOption { 0, 0, 0 }
69 
70 class TDECmdLineArgsList;
71 class TDEApplication;
72 class TDEUniqueApplication;
73 class TDECmdLineParsedOptions;
74 class TDECmdLineParsedArgs;
75 class TDEAboutData;
76 class TDECmdLineArgsPrivate;
77 
222 class TDECORE_EXPORT TDECmdLineArgs
223 {
224  friend class TDEApplication;
225  friend class TDEUniqueApplication;
226  friend class TQPtrList<TDECmdLineArgs>;
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) TDE_DEPRECATED;
261 
275  static void init(int _argc, char **_argv,
276  const TDEAboutData *about, bool noKApp = false);
277 
291  static void init(const TDEAboutData *about);
292 
357  static void addCmdLineOptions( const TDECmdLineOptions *options,
358  const char *name=0, const char *id = 0,
359  const char *afterId=0);
360 
370  static TDECmdLineArgs *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  TDECmdLineArgs( const TDECmdLineOptions *_options, const char *_name,
557  const char *_id);
558 
566  ~TDECmdLineArgs();
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 *tqt_argc();
590 
597  static char ***tqt_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 TDECmdLineOptions *options;
670  const char *name;
671  const char *id;
672  TDECmdLineParsedOptions *parsedOptionList;
673  TDECmdLineParsedArgs *parsedArgList;
674  bool isQt;
675 
676  static TDECmdLineArgsList *argsList; // All options.
677  static const TDEAboutData *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  TDECmdLineArgsPrivate *d;
687 };
688 
689 #endif
690 
KURL
Represents and parses a URL.
Definition: kurl.h:128
TDEAboutData
This class is used to store information about a program.
Definition: tdeaboutdata.h:183
TDEApplication
Controls and provides information to all KDE applications.
Definition: tdeapplication.h:95
TDECmdLineArgs
A class for command-line argument handling.
Definition: tdecmdlineargs.h:223
TDECmdLineArgs::setCwd
static void setCwd(char *cwd)
Made public for apps that don't use TDECmdLineArgs To be done before makeURL, to set the current work...
Definition: tdecmdlineargs.h:516
TDEUniqueApplication
Maintains only a single instance of a running application at a time.
Definition: tdeuniqueapplication.h:49
TDECmdLineOptions
Structure that holds command line options.
Definition: tdecmdlineargs.h:41
TDECmdLineOptions::name
const char * name
The name of the argument as it should be called on the command line and appear in myapp –help.
Definition: tdecmdlineargs.h:55
TDECmdLineOptions::def
const char * def
The default value for the option, if it is not specified on the command line.
Definition: tdecmdlineargs.h:65
TDECmdLineOptions::description
const char * description
The text description of the option as should appear in myapp –help.
Definition: tdecmdlineargs.h:60

tdecore

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

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.9.1
This website is maintained by Timothy Pearson.