options.h
author insilmaril
Mon, 22 Oct 2007 09:50:09 +0000
changeset 610 ff98aee6fb99
parent 475 0f8879937035
permissions -rw-r--r--
Various patches: Better windows support, branch sorting, Freedesktop support
     1 #ifndef OPTIONS_H
     2 #define OPTIONS_H
     3 
     4 #include <QStringList>
     5 
     6 /*! \brief A single option which is listed in Options */
     7 class Option
     8 {
     9 public:
    10 	/*! Types of options */
    11 	enum Type  {
    12 		Switch,	//!< No paramater
    13 		String	//!< Parameter is a string
    14 	};
    15 
    16 	Option();
    17 	Option(const QString &, const Type &, const QString &, const QString &);
    18 	void set (const QString &, const Type &, const QString &, const QString &);
    19 	QString getName();
    20 	QString getShort();
    21 	QString getLong();
    22 	Type getType();
    23 	void setArg(const QString &);
    24 	QString getArg();
    25 	void setActive();
    26 	bool isActive();
    27 private:
    28 	QString name;
    29 	Type type;
    30 	QString sName;
    31 	QString lName;
    32 	QString sarg;
    33 	bool active;
    34 };
    35 
    36 
    37 /*! \brief Simple class to deal with command line options */
    38 
    39 class Options
    40 {
    41 public:
    42 	Options();
    43 	int parse();
    44 	void add (Option );
    45 	void add (const QString &,const Option::Type &, const QString &, const QString&);
    46 	void setHelpText(const QString&);
    47 	QString getHelpText();
    48 	QString getProgramName();
    49 	QStringList getFileList();
    50 	bool isOn (const QString &);
    51 	QString getArg (const QString &);
    52 
    53 private:
    54 	QString progname;
    55 	QString helptext;
    56 	QStringList filelist;
    57     QList <Option> optlist;
    58 };
    59 
    60 #endif