\section{KCmd\-Line\-Args Class Reference}
\label{classKCmdLineArgs}\index{KCmdLineArgs@{KCmdLineArgs}}
Simple access to the command-line arguments. 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=150pt]{classKCmdLineArgs__coll__graph}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf QCString} {\bf get\-Option} (const  char $\ast$option) const 
\begin{CompactList}\small\item\em Read out a string option. \item\end{CompactList}\item 
{\bf QCString\-List} {\bf get\-Option\-List} (const  char $\ast$option) const 
\begin{CompactList}\small\item\em Read out all occurences of a string option. \item\end{CompactList}\item 
bool {\bf is\-Set} (const  char $\ast$option) const 
\begin{CompactList}\small\item\em Read out a boolean option or check for the presence of string option. \item\end{CompactList}\item 
int {\bf count} () const 
\begin{CompactList}\small\item\em Read the number of arguments that aren't options (but, for example, filenames). \item\end{CompactList}\item 
const  char $\ast$ {\bf arg} (int n) const 
\begin{CompactList}\small\item\em Read out an argument. \item\end{CompactList}\item 
{\bf KURL} {\bf url} (int n) const 
\begin{CompactList}\small\item\em Read out an argument representing a URL. \item\end{CompactList}\item 
void {\bf clear} ()
\begin{CompactList}\small\item\em Clear all options and arguments. \item\end{CompactList}\end{CompactItemize}
\subsection*{Static Public Member Functions}
\begin{CompactItemize}
\item 
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)
\begin{CompactList}\small\item\em Initialize class. \item\end{CompactList}\item 
void {\bf init} (int \_\-argc, char $\ast$$\ast$\_\-argv, const  {\bf KAbout\-Data} $\ast$about, bool no\-KApp=false)
\begin{CompactList}\small\item\em Initialize class. \item\end{CompactList}\item 
void {\bf init} (const  {\bf KAbout\-Data} $\ast$about)
\begin{CompactList}\small\item\em Initialize Class. \item\end{CompactList}\item 
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)
\begin{CompactList}\small\item\em Add options to your application. \item\end{CompactList}\item 
{\bf KCmd\-Line\-Args} $\ast$ {\bf parsed\-Args} (const  char $\ast$id=0)
\begin{CompactList}\small\item\em Access parsed arguments. \item\end{CompactList}\item 
{\bf QString} {\bf cwd} ()
\begin{CompactList}\small\item\em Get the CWD (Current Working Directory) associated with the current command line arguments. \item\end{CompactList}\item 
const  char $\ast$ {\bf app\-Name} ()
\begin{CompactList}\small\item\em Get the appname according to argv[0]. \item\end{CompactList}\item 
void {\bf usage} (const  char $\ast$id=0)
\begin{CompactList}\small\item\em Print the usage help to stdout and exit. \item\end{CompactList}\item 
void {\bf usage} (const  {\bf QString} \&error)
\begin{CompactList}\small\item\em Print an error to stderr and the usage help to stdout and exit. \item\end{CompactList}\item 
void {\bf enable\_\-i18n} ()
\begin{CompactList}\small\item\em Enable i18n to be able to print a translated error message. \item\end{CompactList}\item 
{\bf KURL} {\bf make\-URL} (const  char $\ast$url\-Arg)
\begin{CompactList}\small\item\em Used by {\bf url}{\rm (p.\,\pageref{classKCmdLineArgs_a5})}(). \item\end{CompactList}\item 
void {\bf set\-Cwd} (char $\ast$cwd)
\begin{CompactList}\small\item\em Made public for apps that don't use KCmd\-Line\-Args To be done before {\bf make\-URL}{\rm (p.\,\pageref{classKCmdLineArgs_e10})}, to set the current working directory in case {\bf make\-URL}{\rm (p.\,\pageref{classKCmdLineArgs_e10})} needs it. \item\end{CompactList}\end{CompactItemize}
\subsection*{Protected Member Functions}
\begin{CompactItemize}
\item 
{\bf KCmd\-Line\-Args} (const  {\bf KCmd\-Line\-Options} $\ast$\_\-options, const  char $\ast$\_\-id, const  char $\ast$\_\-name)
\begin{CompactList}\small\item\em Constructor. \item\end{CompactList}\item 
{\bf $\sim$KCmd\-Line\-Args} ()
\begin{CompactList}\small\item\em Destructor. \item\end{CompactList}\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}
Simple access to the command-line arguments. A class for command-line argument handling. 

It takes into account Qt-specific options, KDE-specific options and application specific options.

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

A typical {\bf KDE}{\rm (p.\,\pageref{namespaceKDE})} application should look like this:



\footnotesize\begin{verbatim}  int main(int argc, char *argv[])
  {
     // Initialize command line args
     KCmdLineArgs::init(argc, argv, appName, 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/argments
     // A KApplication will usually do this in main but this is not
     // necassery.
     // 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


options are defined as follow

{\tt  static {\bf KCmd\-Line\-Options}{\rm (p.\,\pageref{structKCmdLineOptions})} options[] = \{ \{ \char`\"{}a\char`\"{}, I18N\_\-NOOP(\char`\"{}A short binary option.\char`\"{}), 0 \}, \{ \char`\"{}b $<$file$>$\char`\"{}, I18N\_\-NOOP(\char`\"{}A short option which takes an argument.\char`\"{}), 0 \}, \{ \char`\"{}c $<$speed$>$\char`\"{}, I18N\_\-NOOP(\char`\"{}As above but with a default value.\char`\"{}), \char`\"{}9600\char`\"{} \}, \{ \char`\"{}option1\char`\"{}, I18N\_\-NOOP(\char`\"{}A long binary option, off by default.\char`\"{}), 0 \}, \{ \char`\"{}nooption2\char`\"{}, I18N\_\-NOOP(\char`\"{}A long binary option, on by default.\char`\"{}), 0 \}, \{ \char`\"{}option3 $<$file$>$\char`\"{}, I18N\_\-NOOP(\char`\"{}A long option which takes an argument.\char`\"{}), 0 \}, \{ \char`\"{}option3 $<$speed$>$\char`\"{}, I18N\_\-NOOP(\char`\"{}As above with 9600 as default.\char`\"{}), \char`\"{}9600\char`\"{} \}, \{ \char`\"{}d\char`\"{}, 0, 0 \}, \{ \char`\"{}option4\char`\"{}, I18N\_\-NOOP(\char`\"{}A long option which has a short option as alias.\char`\"{}), 0 \}, \{ \char`\"{}e\char`\"{}, 0, 0 \}, \{ \char`\"{}nooption5\char`\"{}, I18N\_\-NOOP(\char`\"{}Another long option with an alias.\char`\"{}), 0 \}, \{ \char`\"{}f\char`\"{}, 0, 0 \}, \{ \char`\"{}option6 $<$speed$>$\char`\"{}, I18N\_\-NOOP(\char`\"{}'--option6 speed' is same a '-f speed'\char`\"{}), 0 \}, \{ \char`\"{}!option7 $<$cmd$>$\char`\"{}, I18N\_\-NOOP(\char`\"{}All options following this one will be treated as arguments\char`\"{}, 0 \}, \{ \char`\"{}+file\char`\"{}, I18N\_\-NOOP(\char`\"{}A required argument 'file'.), 0 \}, \{ \char`\"{}+[arg1]\char`\"{}, I18N\_\-NOOP(\char`\"{}An optional argument 'arg1'.\char`\"{}), 0 \}, \{ \char`\"{}!+command\char`\"{}, I18N\_\-NOOP(\char`\"{}A required argument 'command', that can contain multiple words, even starting with '-'.), 0 \}, \{ 0, 0, 0 \} // End of options. \}; }

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 alias. A program should only check for the long option.

With the above options a command line could look like: \small\begin{alltt}
     myapp -a -c 4800 --display localhost:0.0 --nooption5 -d /tmp/file
  \end{alltt}\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: \small\begin{alltt}
     myapp --nooption4 --option4 --nooption4
  \end{alltt}\normalsize 
 is the same as: \small\begin{alltt}
     myapp --nooption4
  \end{alltt}\normalsize 


Normally if an option value is provided multiple times only the last value is used: \small\begin{alltt}
     myapp -c 1200 -c 2400 -c 4800
  \end{alltt}\normalsize 
 is usually the same as: \small\begin{alltt}
     myapp -c 4800
  \end{alltt}\normalsize 


However, an application can choose to use all values specified as well. E.g. to specify a number of directories to use: \small\begin{alltt}
     myapp -I /usr/include -I /opt/kde/include -I /usr/X11/include
  \end{alltt}\normalsize 
 When an application does this it should mention this in the description of the option. {\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 190 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 913 of file kcmdlineargs.cpp.

References KStd\-Action::name().

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 925 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 \_\-description}, const char $\ast$ {\em \_\-version}, bool {\em no\-KApp} = 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 description}]A short description of what your application is about. \item[{\em version}]A version. \item[{\em no\-KApp}]Don't add commandline options for {\bf QApplication}/{\bf KApplication}{\rm (p.\,\pageref{classKApplication})} \end{description}
\end{Desc}


Definition at line 122 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 {\bf KAbout\-Data} $\ast$ {\em about}, bool {\em no\-KApp} = false)\hspace{0.3cm}{\tt  [static]}}\label{classKCmdLineArgs_e1}


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 about}]A {\bf KAbout\-Data}{\rm (p.\,\pageref{classKAboutData})} object describing your program. \item[{\em no\-KApp}]Don't add commandline options for {\bf QApplication} / {\bf KApplication}{\rm (p.\,\pageref{classKApplication})} \end{description}
\end{Desc}


Definition at line 146 of file kcmdlineargs.cpp.

References KApplication::add\-Cmd\-Line\-Options().\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_e2}


Initialize Class. 

This function should be called as the very first thing in your application. This method is exactly the same as calling {\bf init}{\rm (p.\,\pageref{classKCmdLineArgs_e0})}(0,0, const {\bf KAbout\-Data}{\rm (p.\,\pageref{classKAboutData})} $\ast$about, true) This method will rarely be used \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em about}]the about data. \end{description}
\end{Desc}


Definition at line 139 of file kcmdlineargs.cpp.

References 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} = 0, const char $\ast$ {\em id} = 0, const char $\ast$ {\em after\-Id} = 0)\hspace{0.3cm}{\tt  [static]}}\label{classKCmdLineArgs_e3}


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:

static {\bf KCmd\-Line\-Options}{\rm (p.\,\pageref{structKCmdLineOptions})} options[] = \{ \{ \char`\"{}option1 $<$argument$>$\char`\"{}, I18N\_\-NOOP(\char`\"{}Description 1\char`\"{}), \char`\"{}default\char`\"{} \}, \{ \char`\"{}o\char`\"{}, 0, 0 \}, \{ \char`\"{}option2\char`\"{}, I18N\_\-NOOP(\char`\"{}Description 2\char`\"{}), 0 \}, \{ \char`\"{}nooption3\char`\"{}, I18N\_\-NOOP(\char`\"{}Description 3\char`\"{}), 0 \}, \{ 0, 0, 0\} \}

\begin{itemize}
\item \char`\"{}option1\char`\"{} is an option that requires an additional argument \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.\end{itemize}
In BNF: cmd = myapp [options] file options = (option)$\ast$ option = --option1  $|$ (-o $|$ --option2 $|$ --nooption2) $|$ ( --option3 $|$ --nooption3 )

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 default\char`\"{}) \item \char`\"{}myapp --option2\char`\"{} \item \char`\"{}myapp --nooption2\char`\"{} (same as \char`\"{}myapp\char`\"{}) \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`\"{}) \item \char`\"{}myapp --option2 --nooption2\char`\"{} (same as \char`\"{}myapp\char`\"{}) \item \char`\"{}myapp /tmp/file\char`\"{}\end{itemize}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em options}]A list of options thath 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 191 of file kcmdlineargs.cpp.

References id, KCmd\-Line\-Args(), and KStd\-Action::name().

Referenced by KUnique\-Application::add\-Cmd\-Line\-Options(), and KApplication::add\-Cmd\-Line\-Options().\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} = 0)\hspace{0.3cm}{\tt  [static]}}\label{classKCmdLineArgs_e4}


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 290 of file kcmdlineargs.cpp.

References id.

Referenced by KApplication::dcop\-Client(), 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_e5}


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_a3})} 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 179 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_e6}


Get the appname according to argv[0]. 

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


Definition at line 184 of file kcmdlineargs.cpp.

Referenced by KApplication::set\-Top\-Widget().\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} = 0)\hspace{0.3cm}{\tt  [static]}}\label{classKCmdLineArgs_e7}


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_e3})}. \end{description}
\end{Desc}


Definition at line 729 of file kcmdlineargs.cpp.

References arg(), QString::arg(), KCmd\-Line\-Options::def, KCmd\-Line\-Options::description, KStd\-Accel::description(), enable\_\-i18n(), QString::from\-Latin1(), id, KStd\-Action::name(), 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_e8}


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

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


Definition at line 714 of file kcmdlineargs.cpp.

References QCString::left(), QString::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_e9}


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_e7})}()). 

Definition at line 700 of file kcmdlineargs.cpp.

References KInstance::config(), and KNotify\-Client::instance().

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: \small\begin{alltt}
    \{ "option <argument>", I18N\_NOOP("Description"), "default" \}
  \end{alltt}\normalsize 


\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 occurence is used. \end{Desc}


Definition at line 1034 of file kcmdlineargs.cpp.

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 occurences of a string option. 

The option must have a corresponding {\bf KCmd\-Line\-Options}{\rm (p.\,\pageref{structKCmdLineOptions})} entry of the form: \small\begin{alltt}
    \{ "option <argument>", I18N\_NOOP("Description"), "default" \}
  \end{alltt}\normalsize 


\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em option}]The name of the option without '-'.\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 1066 of file kcmdlineargs.cpp.

References QValue\-List$<$ QCString $>$::begin(), QValue\-List$<$ QCString $>$::end(), and QValue\-List$<$ QCString $>$::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. If the option was not present on the command line the default is returned. If the option is listed as 'no' the default is true. If the option is listed as '' the default is false.\end{Desc}
If the option is listed as ' ' this function returns {\tt true} if the option was present and {\tt false} otherwise. 

Definition at line 1096 of file kcmdlineargs.cpp.

Referenced by KApplication::dcop\-Client(), 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 1139 of file kcmdlineargs.cpp.\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 1147 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 1163 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_e10}


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\-Args}]the argument \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]the url. \end{Desc}


Definition at line 1168 of file kcmdlineargs.cpp.

References KURL::clean\-Path(), cwd(), QFile::decode\-Name(), QString::from\-Local8Bit(), KURL::is\-Relative\-URL(), 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}void KCmd\-Line\-Args::set\-Cwd (char $\ast$ {\em cwd})\hspace{0.3cm}{\tt  [inline, static]}}\label{classKCmdLineArgs_e11}


Made public for apps that don't use KCmd\-Line\-Args To be done before {\bf make\-URL}{\rm (p.\,\pageref{classKCmdLineArgs_e10})}, to set the current working directory in case {\bf make\-URL}{\rm (p.\,\pageref{classKCmdLineArgs_e10})} needs it. 

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


Definition at line 449 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 941 of file kcmdlineargs.cpp.

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