X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fcliparser.h;h=d659cec00776b9259fa135058be1c51ab3bf2181;hp=6872f773a8ef472e0afd8a1e79d75b945467257e;hb=921e54680da16fcf2adb7a90506875aceb6633a4;hpb=81c2e2cf2c12eb6839994f95f47698e5252fc91c diff --git a/src/common/cliparser.h b/src/common/cliparser.h index 6872f773..d659cec0 100644 --- a/src/common/cliparser.h +++ b/src/common/cliparser.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-08 by the Quassel IRC Team * + * Copyright (C) 2005-2015 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -15,47 +15,38 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef CLIPARSER_H #define CLIPARSER_H -#include -#include -#include -#include +#include -class CliParserArg; +#include "abstractcliparser.h" -class CliParser{ +//! Quassel's own parser for command line arguments +class CliParser : public AbstractCliParser +{ public: - inline CliParser() {}; - CliParser(int argc, char *argv[]); + CliParser(); + + bool init(const QStringList &arguments = QStringList()); + + QString value(const QString &longName); + bool isSet(const QString &longName); + void usage(); - ~CliParser(); - bool parse(); - QVariant value(QString key); - void addArgument(QString longName, char shortName, QVariant def); private: - QStringList argsRaw; - QHash savedValues; - QHash argsHash; - QHash::iterator> shortHash; -}; + void addArgument(const QString &longName, const CliParserArg &arg); + bool addLongArg(const CliParserArg::CliArgType type, const QString &name, const QString &value = QString()); + bool addShortArg(const CliParserArg::CliArgType type, const char shortName, const QString &value = QString()); + QString escapedValue(const QString &value); + QString lnameOfShortArg(const char arg); -class CliParserArg { -public: - inline CliParserArg() {}; - CliParserArg(const CliParserArg &other); - CliParserArg(QString longName, char shortName, QVariant _def); - CliParserArg &operator=(const CliParserArg &other); -// private: - QString lname; - char sname; - QVariant def; - QVariant value; + QStringList argsRaw; + QMap argsMap; }; -Q_DECLARE_METATYPE(CliParserArg); + #endif