X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fcliparser.h;h=761eb0d4d3b9ad63e1ffb72c9a939d3ed31c0915;hp=0cdfcaf1a106cc9eb20b8849ef74479ba572d6f9;hb=abd7bd3611e560e0ede1b05d617c775614b6c808;hpb=5c6804f291a63f978e328aeddcc8448e3443b45e diff --git a/src/common/cliparser.h b/src/common/cliparser.h index 0cdfcaf1..761eb0d4 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-09 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -21,48 +21,22 @@ #ifndef CLIPARSER_H #define CLIPARSER_H -#include -#include -#include +#include -class CliParser{ +#include "abstractcliparser.h" + +//! Quassel's own parser for command line arguments +class CliParser : public AbstractCliParser { public: - inline CliParser() {}; + CliParser(); + + bool init(const QStringList &arguments = QStringList()); - bool parse(const QStringList &arguments); QString value(const QString &longName); bool isSet(const QString &longName); - inline void addSwitch(const QString &longName, const char shortName = 0, const QString &help = QString()) { - addArgument(longName, CliParserArg(CliParserArg::CliArgSwitch, shortName, help)); - } - inline void addOption(const QString &longName, const char shortName = 0, const QString &help = QString(), const QString &def = QString()) { - addArgument(longName, CliParserArg(CliParserArg::CliArgOption, shortName, help, def)); - } void usage(); private: - struct CliParserArg { - enum CliArgType { - CliArgInvalid, - CliArgSwitch, - CliArgOption - }; - CliParserArg(const CliArgType _type = CliArgInvalid, const char _shortName = 0, const QString _help = QString(), const QString _def = QString()) - : type(_type), - shortName(_shortName), - help(_help), - def(_def), - value(QString()), - boolValue(false) {}; - - CliArgType type; - char shortName; - QString help; - QString def; - QString value; - bool boolValue; - }; - 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()); @@ -70,7 +44,7 @@ private: QString lnameOfShortArg(const char arg); QStringList argsRaw; - QHash argsHash; + QMap argsMap; }; #endif