\section{KCmd\-Line\-Args Class Reference}
\label{classKCmdLineArgs}\index{KCmdLineArgs@{KCmdLineArgs}}
A class for command-line argument handling.  


{\tt \#include $<$kcmdlineargs.h$>$}

Collaboration diagram for KCmd\-Line\-Args:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=133pt]{classKCmdLineArgs__coll__graph}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf QCString} {\bf get\-Option} (const char $\ast$option) const 
\item 
{\bf QCString\-List} {\bf get\-Option\-List} (const char $\ast$option) const 
\item 
bool {\bf is\-Set} (const char $\ast$option) const 
\item 
int {\bf count} () const 
\item 
const char $\ast$ {\bf arg} (int n) const 
\item 
{\bf KURL} {\bf url} (int n) const 
\item 
void {\bf clear} ()
\end{CompactItemize}
\subsection*{Static Public Member Functions}
\begin{CompactItemize}
\item 
static void {\bf init} (int \_\-argc, char $\ast$$\ast$\_\-argv, const char $\ast$\_\-appname, const char $\ast$program\-Name, const char $\ast$\_\-description, const char $\ast$\_\-version, bool no\-KApp=false)
\item 
static void {\bf init} (int \_\-argc, char $\ast$$\ast$\_\-argv, const char $\ast$\_\-appname, const char $\ast$\_\-description, const char $\ast$\_\-version, bool no\-KApp=false) KDE\_\-DEPRECATED
\item 
static void {\bf init} (int \_\-argc, char $\ast$$\ast$\_\-argv, const {\bf KAbout\-Data} $\ast$about, bool no\-KApp=false)
\item 
static void {\bf init} (const {\bf KAbout\-Data} $\ast$about)
\item 
static void {\bf add\-Cmd\-Line\-Options} (const {\bf KCmd\-Line\-Options} $\ast$options, const char $\ast$name=0, const char $\ast$id=0, const char $\ast$after\-Id=0)
\item 
static {\bf KCmd\-Line\-Args} $\ast$ {\bf parsed\-Args} (const char $\ast$id=0)
\item 
static {\bf QString} {\bf cwd} ()
\item 
static const char $\ast$ {\bf app\-Name} ()
\item 
static void {\bf usage} (const char $\ast$id=0)
\item 
static void {\bf usage} (const {\bf QString} \&error)
\item 
static void {\bf enable\_\-i18n} ()
\item 
static {\bf KURL} {\bf make\-URL} (const char $\ast$url\-Arg)
\item 
static void {\bf set\-Cwd} (char $\ast$cwd)
\item 
static void {\bf reset} ()
\item 
static void {\bf load\-App\-Args} ({\bf QData\-Stream} \&)
\item 
static void {\bf add\-Temp\-File\-Option} ()
\item 
static bool {\bf is\-Temp\-File\-Set} ()
\end{CompactItemize}
\subsection*{Protected Member Functions}
\begin{CompactItemize}
\item 
{\bf KCmd\-Line\-Args} (const {\bf KCmd\-Line\-Options} $\ast$\_\-options, const char $\ast$\_\-name, const char $\ast$\_\-id)
\item 
{\bf $\sim$KCmd\-Line\-Args} ()
\end{CompactItemize}
\subsection*{Friends}
\begin{CompactItemize}
\item 
class {\bf KApplication}\label{classKCmdLineArgs_n0}

\item 
class {\bf KUnique\-Application}\label{classKCmdLineArgs_n1}

\item 
class {\bf QPtr\-List$<$KCmd\-Line\-Args$>$}\label{classKCmdLineArgs_n2}

\end{CompactItemize}


\subsection{Detailed Description}
A class for command-line argument handling. 

KCmd\-Line\-Args provides simple access to the command-line arguments for an application. It takes into account Qt-specific options, KDE-specific options and application specific options.

This class is used in main() via the static method {\bf init()}{\rm (p.\,\pageref{classKCmdLineArgs_e0})}.

A typical KDE application using KCmd\-Line\-Args should look like this:



\footnotesize\begin{verbatim}  int main(int argc, char *argv[])
  {
     // Initialize command line args
     KCmdLineArgs::init(argc, argv, appName, programName, description, version);

     // Tell which options are supported
     KCmdLineArgs::addCmdLineOptions( options );

     // Add options from other components
     KUniqueApplication::addCmdLineOptions();

     ....

     // Create application object without passing 'argc' and 'argv' again.
     KUniqueApplication app;

     ....

     // Handle our own options/arguments
     // A KApplication will usually do this in main but this is not
     // necessary.
     // A KUniqueApplication might want to handle it in newInstance().

     KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

     // A binary option (on / off)
     if (args->isSet("some-option"))
        ....

     // An option which takes an additional argument
     QCString anotherOptionArg = args->getOption("another-option");

     // Arguments (e.g. files to open)
     for(int i = 0; i < args->count(); i++) // Counting start at 0!
     {
        // don't forget to convert to Unicode!
        openFile( QFile::decodeName( args->arg(i)));
        // Or more convenient:
        // openURL( args->url(i));

     }

     args->clear(); // Free up some memory.
     ....
  }
\end{verbatim}
\normalsize


The options that an application supports are configured using the {\bf KCmd\-Line\-Options}{\rm (p.\,\pageref{structKCmdLineOptions})} class. An example is shown below:



\footnotesize\begin{verbatim}  static const KCmdLineOptions options[] =
  {
     { "a", I18N_NOOP("A short binary option"), 0 },
     { "b \<file>", I18N_NOOP("A short option which takes an argument"), 0 },
     { "c \<speed>", I18N_NOOP("As above but with a default value"), "9600" },
     { "option1", I18N_NOOP("A long binary option, off by default"), 0 },
     { "nooption2", I18N_NOOP("A long binary option, on by default"), 0 },
     { ":", I18N_NOOP("Extra options:"), 0 },
     { "option3 \<file>", I18N_NOOP("A long option which takes an argument"), 0 },
     { "option4 \<speed>", I18N_NOOP("A long option which takes an argument, defaulting to 9600"), "9600" },
     { "d", 0, 0 },
     { "option5", I18N_NOOP("A long option which has a short option as alias"), 0 },
     { "e", 0, 0 },
     { "nooption6", I18N_NOOP("Another long option with an alias"), 0 },
     { "f", 0, 0 },
     { "option7 \<speed>", I18N_NOOP("'--option7 speed' is the same as '-f speed'"), 0 },
     { "!option8 \<cmd>", I18N_NOOP("All options following this one will be treated as arguments"), 0 },
     { "+file", I18N_NOOP("A required argument 'file'"), 0 },
     { "+[arg1]", I18N_NOOP("An optional argument 'arg1'"), 0 },
     { "!+command", I18N_NOOP("A required argument 'command', that can contain multiple words, even starting with '-'"), 0 },
     { "", I18N_NOOP("Additional help text not associated with any particular option") 0 },
     KCmdLineLastOption // End of options.
  };
\end{verbatim}
\normalsize


The I18N\_\-NOOP macro is used to indicate that these strings should be marked for translation. The actual translation is done by KCmd\-Line\-Args. You can't use i18n() here because we are setting up a static data structure and can't do translations at compile time.

Note that a program should define the options before any arguments.

When a long option has a short option as an alias, a program should only test for the long option.

With the above options a command line could look like: 

\footnotesize\begin{verbatim}     myapp -a -c 4800 --display localhost:0.0 --nooption5 -d /tmp/file
\end{verbatim}
\normalsize


Long binary options can be in the form 'option' and 'nooption'. A command line may contain the same binary option multiple times, the last option determines the outcome: 

\footnotesize\begin{verbatim}     myapp --nooption4 --option4 --nooption4
\end{verbatim}
\normalsize
 is the same as: 

\footnotesize\begin{verbatim}     myapp --nooption4
\end{verbatim}
\normalsize


If an option value is provided multiple times, normally only the last value is used: 

\footnotesize\begin{verbatim}     myapp -c 1200 -c 2400 -c 4800
\end{verbatim}
\normalsize
 is usually the same as: 

\footnotesize\begin{verbatim}     myapp -c 4800
\end{verbatim}
\normalsize


However, an application can choose to use all values specified as well. As an example of this, consider that you may wish to specify a number of directories to use: 

\footnotesize\begin{verbatim}     myapp -I /usr/include -I /opt/kde/include -I /usr/X11/include
\end{verbatim}
\normalsize
 When an application does this it should mention this in the description of the option. To access these options, use {\bf get\-Option\-List()}{\rm (p.\,\pageref{classKCmdLineArgs_a1})}

Tips for end-users:

\begin{itemize}
\item Single char options like \char`\"{}-a -b -c\char`\"{} may be combined into \char`\"{}-abc\char`\"{} \item The option \char`\"{}--foo bar\char`\"{} may also be written \char`\"{}--foo=bar\char`\"{} \item The option \char`\"{}-P lp1\char`\"{} may also be written \char`\"{}-P=lp1\char`\"{} or \char`\"{}-Plp1\char`\"{} \item The option \char`\"{}--foo bar\char`\"{} may also be written \char`\"{}-foo bar\char`\"{}\end{itemize}
\begin{Desc}
\item[Author:]Waldo Bastian \end{Desc}
\begin{Desc}
\item[Version:]0.0.4 \end{Desc}




Definition at line 222 of file kcmdlineargs.h.

\subsection{Constructor \& Destructor Documentation}
\index{KCmdLineArgs@{KCmd\-Line\-Args}!KCmdLineArgs@{KCmdLineArgs}}
\index{KCmdLineArgs@{KCmdLineArgs}!KCmdLineArgs@{KCmd\-Line\-Args}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KCmd\-Line\-Args::KCmd\-Line\-Args (const {\bf KCmd\-Line\-Options} $\ast$ {\em \_\-options}, const char $\ast$ {\em \_\-name}, const char $\ast$ {\em \_\-id})\hspace{0.3cm}{\tt  [protected]}}\label{classKCmdLineArgs_b0}


Constructor. 

The given arguments are assumed to be constants. 

Definition at line 974 of file kcmdlineargs.cpp.

Referenced by add\-Cmd\-Line\-Options().\index{KCmdLineArgs@{KCmd\-Line\-Args}!~KCmdLineArgs@{$\sim$KCmdLineArgs}}
\index{~KCmdLineArgs@{$\sim$KCmdLineArgs}!KCmdLineArgs@{KCmd\-Line\-Args}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KCmd\-Line\-Args::$\sim${\bf KCmd\-Line\-Args} ()\hspace{0.3cm}{\tt  [protected]}}\label{classKCmdLineArgs_b1}


Destructor. 



Definition at line 986 of file kcmdlineargs.cpp.

\subsection{Member Function Documentation}
\index{KCmdLineArgs@{KCmd\-Line\-Args}!init@{init}}
\index{init@{init}!KCmdLineArgs@{KCmd\-Line\-Args}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCmd\-Line\-Args::init (int {\em \_\-argc}, char $\ast$$\ast$ {\em \_\-argv}, const char $\ast$ {\em \_\-appname}, const char $\ast$ {\em program\-Name}, const char $\ast$ {\em \_\-description}, const char $\ast$ {\em \_\-version}, bool {\em no\-KApp} = {\tt false})\hspace{0.3cm}{\tt  [static]}}\label{classKCmdLineArgs_e0}


Initialize class. 

This function should be called as the very first thing in your application. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-argc}]As passed to {\tt main}(...). \item[{\em \_\-argv}]As passed to {\tt main}(...). \item[{\em \_\-appname}]The untranslated name of your application. This should match with {\tt argv}[0]. \item[{\em program\-Name}]A program name string to be used for display purposes. This string should be marked for translation. Example: I18N\_\-NOOP(\char`\"{}KEdit\char`\"{}) \item[{\em \_\-description}]A short description of what your application is about. \item[{\em \_\-version}]A version. \item[{\em no\-KApp}]Set this true to not add commandline options for {\bf QApplication} / {\bf KApplication}{\rm (p.\,\pageref{classKApplication})}\end{description}
\end{Desc}
\begin{Desc}
\item[Since:]3.2 \end{Desc}


Definition at line 127 of file kcmdlineargs.cpp.

Referenced by init().\index{KCmdLineArgs@{KCmd\-Line\-Args}!init@{init}}
\index{init@{init}!KCmdLineArgs@{KCmd\-Line\-Args}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCmd\-Line\-Args::init (int {\em \_\-argc}, char $\ast$$\ast$ {\em \_\-argv}, const char $\ast$ {\em \_\-appname}, const char $\ast$ {\em \_\-description}, const char $\ast$ {\em \_\-version}, bool {\em no\-KApp} = {\tt false})\hspace{0.3cm}{\tt  [static]}}\label{classKCmdLineArgs_e1}


\begin{Desc}
\item[{\bf Deprecated}]You should convert any calls to this method to use the one above, by adding in the program name to be used for display purposes. Do not forget to mark it for translation using I18N\_\-NOOP. \end{Desc}


Definition at line 136 of file kcmdlineargs.cpp.

References init().\index{KCmdLineArgs@{KCmd\-Line\-Args}!init@{init}}
\index{init@{init}!KCmdLineArgs@{KCmd\-Line\-Args}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCmd\-Line\-Args::init (int {\em \_\-argc}, char $\ast$$\ast$ {\em \_\-argv}, const {\bf KAbout\-Data} $\ast$ {\em about}, bool {\em no\-KApp} = {\tt false})\hspace{0.3cm}{\tt  [static]}}\label{classKCmdLineArgs_e2}


Initialize class. 

This function should be called as the very first thing in your application. It uses {\bf KAbout\-Data}{\rm (p.\,\pageref{classKAboutData})} to replace some of the arguments that would otherwise be required.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-argc}]As passed to {\tt main}(...). \item[{\em \_\-argv}]As passed to {\tt main}(...). \item[{\em about}]A {\bf KAbout\-Data}{\rm (p.\,\pageref{classKAboutData})} object describing your program. \item[{\em no\-KApp}]Set this true to not add commandline options for {\bf QApplication} / {\bf KApplication}{\rm (p.\,\pageref{classKApplication})} \end{description}
\end{Desc}


Definition at line 162 of file kcmdlineargs.cpp.

References KApplication::add\-Cmd\-Line\-Options(), and KStatic\-Deleter$<$ type $>$::set\-Object().\index{KCmdLineArgs@{KCmd\-Line\-Args}!init@{init}}
\index{init@{init}!KCmdLineArgs@{KCmd\-Line\-Args}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCmd\-Line\-Args::init (const {\bf KAbout\-Data} $\ast$ {\em about})\hspace{0.3cm}{\tt  [static]}}\label{classKCmdLineArgs_e3}


Initialize Class. 

This function should be called as the very first thing in your application. This method will rarely be used, since it doesn't provide any argument parsing. It does provide access to the {\bf KAbout\-Data}{\rm (p.\,\pageref{classKAboutData})} information. This method is exactly the same as calling init(0,0, const KAbout\-Data $\ast$about, true).

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em about}]the about data. \end{description}
\end{Desc}
\begin{Desc}
\item[See also:]{\bf KAbout\-Data}{\rm (p.\,\pageref{classKAboutData})} \end{Desc}


Definition at line 153 of file kcmdlineargs.cpp.

References KAbout\-Data::app\-Name(), and init().\index{KCmdLineArgs@{KCmd\-Line\-Args}!addCmdLineOptions@{addCmdLineOptions}}
\index{addCmdLineOptions@{addCmdLineOptions}!KCmdLineArgs@{KCmd\-Line\-Args}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCmd\-Line\-Args::add\-Cmd\-Line\-Options (const {\bf KCmd\-Line\-Options} $\ast$ {\em options}, const char $\ast$ {\em name} = {\tt 0}, const char $\ast$ {\em id} = {\tt 0}, const char $\ast$ {\em after\-Id} = {\tt 0})\hspace{0.3cm}{\tt  [static]}}\label{classKCmdLineArgs_e4}


Add options to your application. 

You must make sure that all possible options have been added before any class uses the command line arguments.

The list of options should look like this:



\footnotesize\begin{verbatim} static KCmdLineOptions options[] =
 {
    { "option1 \<argument>", I18N_NOOP("Description 1"), "my_extra_arg" },
    { "o", 0, 0 },
    { "option2", I18N_NOOP("Description 2"), 0 },
    { "nooption3", I18N_NOOP("Description 3"), 0 },
    KCmdLineLastOption
 }
\end{verbatim}
\normalsize


\begin{itemize}
\item \char`\"{}option1\char`\"{} is an option that requires an additional argument, but if one is not provided, it uses \char`\"{}my\_\-extra\_\-arg\char`\"{}. \item \char`\"{}option2\char`\"{} is an option that can be turned on. The default is off. \item \char`\"{}option3\char`\"{} is an option that can be turned off. The default is on. \item \char`\"{}o\char`\"{} does not have a description. It is an alias for the option that follows. In this case \char`\"{}option2\char`\"{}. \item \char`\"{}+file\char`\"{} specifies an argument. The '+' is removed. If your program doesn't specify that it can use arguments your program will abort when an argument is passed to it. Note that the reverse is not true. If required, you must check yourself the number of arguments specified by the user: 

\footnotesize\begin{verbatim}       KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
       if (args->count() == 0) KCmdLineArgs::usage(i18n("No file specified!"));
\end{verbatim}
\normalsize
\end{itemize}
In BNF: 

\footnotesize\begin{verbatim} cmd = myapp [options] file
 options = (option)*
 option = --option1 \<argument> |
          (-o | --option2 | --nooption2) |
          ( --option3 | --nooption3 )
\end{verbatim}
\normalsize


Instead of \char`\"{}--option3\char`\"{} one may also use \char`\"{}-option3\char`\"{}

Usage examples:

\begin{itemize}
\item \char`\"{}myapp --option1 test\char`\"{} \item \char`\"{}myapp\char`\"{} (same as \char`\"{}myapp --option1 my\_\-extra\_\-arg\char`\"{}) \item \char`\"{}myapp --option2\char`\"{} \item \char`\"{}myapp --nooption2\char`\"{} (same as \char`\"{}myapp\char`\"{}, since it is off by default) \item \char`\"{}myapp -o\char`\"{} (same as \char`\"{}myapp --option2\char`\"{}) \item \char`\"{}myapp --nooption3\char`\"{} \item \char`\"{}myapp --option3 (same as \char`\"{}myapp\char`\"{}, since it is on by default) \item \char`\"{}myapp --option2 --nooption2\char`\"{} (same as \char`\"{}myapp\char`\"{}, because it option2 is off by default, and the last usage applies) \item \char`\"{}myapp /tmp/file\char`\"{}\end{itemize}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em options}]A list of options that your code supplies. \item[{\em name}]the name of the option, can be 0. \item[{\em id}]A name with which these options can be identified, can be 0. \item[{\em after\-Id}]The options are inserted after this set of options, can be 0. \end{description}
\end{Desc}


Definition at line 206 of file kcmdlineargs.cpp.

References id, and KCmd\-Line\-Args().

Referenced by KUnique\-Application::add\-Cmd\-Line\-Options(), KApplication::add\-Cmd\-Line\-Options(), and add\-Temp\-File\-Option().\index{KCmdLineArgs@{KCmd\-Line\-Args}!parsedArgs@{parsedArgs}}
\index{parsedArgs@{parsedArgs}!KCmdLineArgs@{KCmd\-Line\-Args}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf KCmd\-Line\-Args} $\ast$ KCmd\-Line\-Args::parsed\-Args (const char $\ast$ {\em id} = {\tt 0})\hspace{0.3cm}{\tt  [static]}}\label{classKCmdLineArgs_e5}


Access parsed arguments. 

This function returns all command line arguments that your code handles. If unknown command-line arguments are encountered the program is aborted and usage information is shown.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em id}]The name of the options you are interested in, can be 0. \end{description}
\end{Desc}


Definition at line 308 of file kcmdlineargs.cpp.

References id.

Referenced by KApplication::dcop\-Client(), is\-Temp\-File\-Set(), and KUnique\-Application::start().\index{KCmdLineArgs@{KCmd\-Line\-Args}!cwd@{cwd}}
\index{cwd@{cwd}!KCmdLineArgs@{KCmd\-Line\-Args}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QString} KCmd\-Line\-Args::cwd ()\hspace{0.3cm}{\tt  [static]}}\label{classKCmdLineArgs_e6}


Get the CWD (Current Working Directory) associated with the current command line arguments. 

Typically this is needed in {\bf KUnique\-Application::new\-Instance()}{\rm (p.\,\pageref{classKUniqueApplication_a4})} since the CWD of the process may be different from the CWD where the user started a second instance. \begin{Desc}
\item[Returns:]the current working directory \end{Desc}


Definition at line 194 of file kcmdlineargs.cpp.

References QFile::decode\-Name().

Referenced by make\-URL().\index{KCmdLineArgs@{KCmd\-Line\-Args}!appName@{appName}}
\index{appName@{appName}!KCmdLineArgs@{KCmd\-Line\-Args}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}const char $\ast$ KCmd\-Line\-Args::app\-Name ()\hspace{0.3cm}{\tt  [static]}}\label{classKCmdLineArgs_e7}


Get the appname according to argv[0]. 

\begin{Desc}
\item[Returns:]the name of the application \end{Desc}


Definition at line 199 of file kcmdlineargs.cpp.\index{KCmdLineArgs@{KCmd\-Line\-Args}!usage@{usage}}
\index{usage@{usage}!KCmdLineArgs@{KCmd\-Line\-Args}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCmd\-Line\-Args::usage (const char $\ast$ {\em id} = {\tt 0})\hspace{0.3cm}{\tt  [static]}}\label{classKCmdLineArgs_e8}


Print the usage help to stdout and exit. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em id}]if 0, print all options. If id is set, only print the option specified by id. The id is the value set by \#ref {\bf add\-Cmd\-Line\-Options()}{\rm (p.\,\pageref{classKCmdLineArgs_e4})}. \end{description}
\end{Desc}


Definition at line 757 of file kcmdlineargs.cpp.

References QString::append(), arg(), QString::arg(), KCmd\-Line\-Options::def, KCmd\-Line\-Options::description, enable\_\-i18n(), QString::ends\-With(), id, QCString::length(), QCString::mid(), name, KCmd\-Line\-Options::name, options, KAbout\-Data::short\-Description(), QString\-List::split(), and usage().

Referenced by usage().\index{KCmdLineArgs@{KCmd\-Line\-Args}!usage@{usage}}
\index{usage@{usage}!KCmdLineArgs@{KCmd\-Line\-Args}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCmd\-Line\-Args::usage (const {\bf QString} \& {\em error})\hspace{0.3cm}{\tt  [static]}}\label{classKCmdLineArgs_e9}


Print an error to stderr and the usage help to stdout and exit. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em error}]the error to print \end{description}
\end{Desc}


Definition at line 742 of file kcmdlineargs.cpp.

References QCString::left(), QCString::length(), and QString::local8Bit().\index{KCmdLineArgs@{KCmd\-Line\-Args}!enable_i18n@{enable\_\-i18n}}
\index{enable_i18n@{enable\_\-i18n}!KCmdLineArgs@{KCmd\-Line\-Args}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCmd\-Line\-Args::enable\_\-i18n ()\hspace{0.3cm}{\tt  [static]}}\label{classKCmdLineArgs_e10}


Enable i18n to be able to print a translated error message. 

N.B.: This function leaks memory, therefore you are expected to exit afterwards (e.g., by calling {\bf usage()}{\rm (p.\,\pageref{classKCmdLineArgs_e8})}). 

Definition at line 728 of file kcmdlineargs.cpp.

References KInstance::config().

Referenced by usage().\index{KCmdLineArgs@{KCmd\-Line\-Args}!getOption@{getOption}}
\index{getOption@{getOption}!KCmdLineArgs@{KCmd\-Line\-Args}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QCString} KCmd\-Line\-Args::get\-Option (const char $\ast$ {\em option}) const}\label{classKCmdLineArgs_a0}


Read out a string option. 

The option must have a corresponding {\bf KCmd\-Line\-Options}{\rm (p.\,\pageref{structKCmdLineOptions})} entry of the form: 

\footnotesize\begin{verbatim}    { "option \<argument>", I18N_NOOP("Description"), "default" }
\end{verbatim}
\normalsize
 You cannot test for the presence of an alias - you must always test for the full option.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em option}]The name of the option without '-'.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The value of the option. If the option was not present on the command line the default is returned. If the option was present more than the value of the last occurrence is used. \end{Desc}


Definition at line 1102 of file kcmdlineargs.cpp.

References QCString::find().

Referenced by KApplication::dcop\-Client().\index{KCmdLineArgs@{KCmd\-Line\-Args}!getOptionList@{getOptionList}}
\index{getOptionList@{getOptionList}!KCmdLineArgs@{KCmd\-Line\-Args}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QCString\-List} KCmd\-Line\-Args::get\-Option\-List (const char $\ast$ {\em option}) const}\label{classKCmdLineArgs_a1}


Read out all occurrences of a string option. 

The option must have a corresponding {\bf KCmd\-Line\-Options}{\rm (p.\,\pageref{structKCmdLineOptions})} entry of the form: 

\footnotesize\begin{verbatim}    { "option \<argument>", I18N_NOOP("Description"), "default" }
\end{verbatim}
\normalsize
 You cannot test for the presence of an alias - you must always test for the full option.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em option}]The name of the option, without '-' or '-no'.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]A list of all option values. If no option was present on the command line, an empty list is returned. \end{Desc}


Definition at line 1134 of file kcmdlineargs.cpp.

References QValue\-List::begin(), QValue\-List::end(), QCString::insert(), and QValue\-List::prepend().\index{KCmdLineArgs@{KCmd\-Line\-Args}!isSet@{isSet}}
\index{isSet@{isSet}!KCmdLineArgs@{KCmd\-Line\-Args}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KCmd\-Line\-Args::is\-Set (const char $\ast$ {\em option}) const}\label{classKCmdLineArgs_a2}


Read out a boolean option or check for the presence of string option. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em option}]The name of the option without '-' or '-no'.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The value of the option. It will be true if the option was specifically turned on in the command line, or if the option is turned on by default (in the {\bf KCmd\-Line\-Options}{\rm (p.\,\pageref{structKCmdLineOptions})} list) and was not specifically turned off in the command line. Equivalently, it will be false if the option was specifically turned off in the command line, or if the option is turned off by default (in the {\bf KCmd\-Line\-Options}{\rm (p.\,\pageref{structKCmdLineOptions})} list) and was not specifically turned on in the command line. \end{Desc}


Definition at line 1164 of file kcmdlineargs.cpp.

References QCString::find().

Referenced by KApplication::dcop\-Client(), is\-Temp\-File\-Set(), and KUnique\-Application::start().\index{KCmdLineArgs@{KCmd\-Line\-Args}!count@{count}}
\index{count@{count}!KCmdLineArgs@{KCmd\-Line\-Args}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int KCmd\-Line\-Args::count () const}\label{classKCmdLineArgs_a3}


Read the number of arguments that aren't options (but, for example, filenames). 

\begin{Desc}
\item[Returns:]The number of arguments that aren't options \end{Desc}


Definition at line 1207 of file kcmdlineargs.cpp.

Referenced by load\-App\-Args().\index{KCmdLineArgs@{KCmd\-Line\-Args}!arg@{arg}}
\index{arg@{arg}!KCmdLineArgs@{KCmd\-Line\-Args}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}const char $\ast$ KCmd\-Line\-Args::arg (int {\em n}) const}\label{classKCmdLineArgs_a4}


Read out an argument. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em n}]The argument to read. 0 is the first argument. {\bf count()}{\rm (p.\,\pageref{classKCmdLineArgs_a3})}-1 is the last argument.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]A {\tt const} {\tt char} {\tt $\ast$} pointer to the n'th argument. \end{Desc}


Definition at line 1215 of file kcmdlineargs.cpp.

Referenced by url(), and usage().\index{KCmdLineArgs@{KCmd\-Line\-Args}!url@{url}}
\index{url@{url}!KCmdLineArgs@{KCmd\-Line\-Args}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf KURL} KCmd\-Line\-Args::url (int {\em n}) const}\label{classKCmdLineArgs_a5}


Read out an argument representing a URL. 

The argument can be \begin{itemize}
\item an absolute filename \item a relative filename \item a URL\end{itemize}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em n}]The argument to read. 0 is the first argument. {\bf count()}{\rm (p.\,\pageref{classKCmdLineArgs_a3})}-1 is the last argument.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]a URL representing the n'th argument. \end{Desc}


Definition at line 1231 of file kcmdlineargs.cpp.

References arg(), and make\-URL().\index{KCmdLineArgs@{KCmd\-Line\-Args}!makeURL@{makeURL}}
\index{makeURL@{makeURL}!KCmdLineArgs@{KCmd\-Line\-Args}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf KURL} KCmd\-Line\-Args::make\-URL (const char $\ast$ {\em url\-Arg})\hspace{0.3cm}{\tt  [static]}}\label{classKCmdLineArgs_e11}


Used by {\bf url()}{\rm (p.\,\pageref{classKCmdLineArgs_a5})}. 

Made public for apps that don't use KCmd\-Line\-Args \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em url\-Arg}]the argument \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]the url. \end{Desc}


Definition at line 1236 of file kcmdlineargs.cpp.

References KURL::clean\-Path(), cwd(), QFile::decode\-Name(), and KURL::set\-Path().

Referenced by url().\index{KCmdLineArgs@{KCmd\-Line\-Args}!setCwd@{setCwd}}
\index{setCwd@{setCwd}!KCmdLineArgs@{KCmd\-Line\-Args}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static void KCmd\-Line\-Args::set\-Cwd (char $\ast$ {\em cwd})\hspace{0.3cm}{\tt  [inline, static]}}\label{classKCmdLineArgs_e12}


Made public for apps that don't use KCmd\-Line\-Args To be done before make\-URL, to set the current working directory in case make\-URL needs it. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cwd}]the new working directory \end{description}
\end{Desc}


Definition at line 516 of file kcmdlineargs.h.\index{KCmdLineArgs@{KCmd\-Line\-Args}!clear@{clear}}
\index{clear@{clear}!KCmdLineArgs@{KCmd\-Line\-Args}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCmd\-Line\-Args::clear ()}\label{classKCmdLineArgs_a6}


Clear all options and arguments. 



Definition at line 995 of file kcmdlineargs.cpp.

Referenced by load\-App\-Args(), and reset().\index{KCmdLineArgs@{KCmd\-Line\-Args}!reset@{reset}}
\index{reset@{reset}!KCmdLineArgs@{KCmd\-Line\-Args}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCmd\-Line\-Args::reset ()\hspace{0.3cm}{\tt  [static]}}\label{classKCmdLineArgs_e13}


Reset all option definitions, i.e. 

cancel all add\-Cmd\-Line\-Options calls. Note that KApplication's options are removed too, you might want to call {\bf KApplication::add\-Cmd\-Line\-Options}{\rm (p.\,\pageref{classKApplication_e0})} if you want them back.

You usually don't want to call this method. 

Definition at line 1004 of file kcmdlineargs.cpp.

References clear().\index{KCmdLineArgs@{KCmd\-Line\-Args}!loadAppArgs@{loadAppArgs}}
\index{loadAppArgs@{loadAppArgs}!KCmdLineArgs@{KCmd\-Line\-Args}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCmd\-Line\-Args::load\-App\-Args ({\bf QData\-Stream} \&)\hspace{0.3cm}{\tt  [static]}}\label{classKCmdLineArgs_e14}


Load arguments from a stream. 



Definition at line 264 of file kcmdlineargs.cpp.

References clear(), count(), id, load(), and KStatic\-Deleter$<$ type $>$::set\-Object().\index{KCmdLineArgs@{KCmd\-Line\-Args}!addTempFileOption@{addTempFileOption}}
\index{addTempFileOption@{addTempFileOption}!KCmdLineArgs@{KCmd\-Line\-Args}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KCmd\-Line\-Args::add\-Temp\-File\-Option ()\hspace{0.3cm}{\tt  [static]}}\label{classKCmdLineArgs_e15}


Add standard option --tempfile \begin{Desc}
\item[Since:]3.4. \end{Desc}




Definition at line 1271 of file kcmdlineargs.cpp.

References add\-Cmd\-Line\-Options().\index{KCmdLineArgs@{KCmd\-Line\-Args}!isTempFileSet@{isTempFileSet}}
\index{isTempFileSet@{isTempFileSet}!KCmdLineArgs@{KCmd\-Line\-Args}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KCmd\-Line\-Args::is\-Temp\-File\-Set ()\hspace{0.3cm}{\tt  [static]}}\label{classKCmdLineArgs_e16}


\begin{Desc}
\item[Returns:]true if --tempfile was set \end{Desc}
\begin{Desc}
\item[Since:]3.4 \end{Desc}


Definition at line 1276 of file kcmdlineargs.cpp.

References is\-Set(), and parsed\-Args().

The documentation for this class was generated from the following files:\begin{CompactItemize}
\item 
kcmdlineargs.h\item 
kcmdlineargs.cpp\end{CompactItemize}
