Commandline arguments utility functions. More...
#include "args.h"#include <qmap.h>#include <qstring.h>#include "qtcompat.h"#include "util.h"#include "version.h"#include <assert.h>#include <iostream>#include <qobject.h>#include <QLIST>#include <qstringlist.h>#include <stdlib.h>Typedefs | |
| typedef QMap< QString, optHandler > | OptionMap |
| typedef QMap< QString, optHandlerParam > | OptionMapParam |
| typedef QMap< QString, QString > | OptionHelp |
Functions | |
| int | handleOption (const QString ¶m) |
| const QString | nextParam (const QString ¶m) |
| void | printHeader () |
| void | printHeaderErr () |
| void | handleHelpOptions () |
| void | handleStopOpt () |
| void | optionHandler (const QString ¶m, optHandler h, const QString &help) |
| void | optionHandlerParam (const QString ¶m, const QString ¶mName, optHandlerParam h, const QString &help) |
| void | setArgv0 (const QString &name) |
| QStringList | handleParams (int _argc, char **_argv) |
Variables | |
| bool | stopOpt = false |
| QString | binName |
| OptionHelp | optHelp |
| OptionHelp | optParamName |
| OptionMap | optMap |
| OptionMapParam | optMapParam |
| int | argIndex |
| int | argc |
| char ** | argv |
| int | maxParamNameLen = 1 |
Commandline arguments utility functions.
Utility functions to work with commandline arguments
| typedef QMap<QString, QString> OptionHelp |
Option help map
| typedef QMap<QString, optHandler> OptionMap |
Option handler map
| typedef QMap<QString, optHandlerParam> OptionMapParam |
Option handler map (with parameter)
| void handleHelpOptions | ( | ) |
Standard handler to handle --help parameter Prints all registered commandline options along with their helptext to STDOUT and exits
References util::CON, util::convertFromUnicode(), maxParamNameLen, gui::opt, optHelp, and optParamName.
Referenced by handleHelp().
| int handleOption | ( | const QString & | param | ) |
Calls option handler on given option
| param | Commandline option to check |
References nextParam(), optMap, and optMapParam.
Referenced by handleParams().
| QStringList handleParams | ( | int | _argc, | |
| char ** | _argv | |||
| ) |
Function to handle commandline parameters using installed callbacks Will terminate program with error message if unknown or invalid commandline options are found
| _argc | count of parameters (standard argc) | |
| _argv | parameters (standard argv) |
References argc, argIndex, argv, binName, util::fatalError(), handleOption(), printHeaderErr(), setArgv0(), and stopOpt.
Referenced by main().
| void handleStopOpt | ( | ) |
| const QString nextParam | ( | const QString & | param | ) |
Get next parameter from commandline
| param | name of currently processed parameter |
References argc, argIndex, argv, binName, util::fatalError(), and printHeaderErr().
Referenced by handleOption().
| void optionHandler | ( | const QString & | param, | |
| optHandler | h, | |||
| const QString & | help | |||
| ) |
Register function to handle option without parameter
| param | Name of option (case sensitive) | |
| h | Function to handle this option | |
| help | Brief one-line help about this option |
References maxParamNameLen, optHelp, and optMap.
Referenced by main().
| void optionHandlerParam | ( | const QString & | param, | |
| const QString & | paramName, | |||
| optHandlerParam | h, | |||
| const QString & | help | |||
| ) |
Register function to handle option with parameter Parameters can be accepted as: -opt[n], -opt [n]
| param | Name of option (case sensitive) | |
| paramName | Name of parameter (only shown in help) | |
| h | Function to handle this option | |
| help | Brief one-line help about this option |
References maxParamNameLen, optHelp, optMapParam, and optParamName.
Referenced by main().
| void printHeader | ( | ) |
Print out application header (name and version) to stdout
References APP_NAME, and PDFEDIT_VERSION.
Referenced by handleHelp().
| void printHeaderErr | ( | ) |
Print out application header (name and version) to stderr
References APP_NAME, and PDFEDIT_VERSION.
Referenced by handleParams(), main(), and nextParam().
| void setArgv0 | ( | const QString & | name | ) |
Sets name of binary to show in help, etc ... (parameter should be argv[0])
| name | name of binary |
References binName.
Referenced by handleParams().
| int argc |
Standard argc
Referenced by handleParams(), and nextParam().
| int argIndex |
Argument index currently processed
Referenced by handleParams(), and nextParam().
| char** argv |
Standard argv
Referenced by handleParams(), and nextParam().
| QString binName |
Name of the program (argv[0])
Referenced by handleHelp(), handleParams(), nextParam(), and setArgv0().
| int maxParamNameLen = 1 |
Length of longest parameter name (including name of its argument)
Referenced by handleHelpOptions(), optionHandler(), and optionHandlerParam().
Option help texts
Referenced by handleHelpOptions(), optionHandler(), and optionHandlerParam().
Option handlers (without parameters)
Referenced by handleOption(), and optionHandler().
Option handlers (with parameters)
Referenced by handleOption(), and optionHandlerParam().
Option parameter names
Referenced by handleHelpOptions(), and optionHandlerParam().
| bool stopOpt = false |
Stop processing options from commandline?
Referenced by handleParams(), and handleStopOpt().