diff options
author | Andrew <forkk@forkk.net> | 2013-03-28 11:37:12 -0500 |
---|---|---|
committer | Andrew <forkk@forkk.net> | 2013-03-28 11:37:12 -0500 |
commit | ebb2c54975e3f0b7b891532e8e72d2ef760f96c4 (patch) | |
tree | 973de7066457a1faddffd3834eb0c260d5191ec2 /libutil | |
parent | 168ed3e8e58a8e5065ffa720f8d45f4cee0f2069 (diff) | |
parent | 1f13f0c665001a1a79f00cdad1e63e6c9802e55f (diff) | |
download | MultiMC-ebb2c54975e3f0b7b891532e8e72d2ef760f96c4.tar MultiMC-ebb2c54975e3f0b7b891532e8e72d2ef760f96c4.tar.gz MultiMC-ebb2c54975e3f0b7b891532e8e72d2ef760f96c4.tar.lz MultiMC-ebb2c54975e3f0b7b891532e8e72d2ef760f96c4.tar.xz MultiMC-ebb2c54975e3f0b7b891532e8e72d2ef760f96c4.zip |
Merge branch 'master' of git://github.com/peterix/MultiMC5
Conflicts:
CMakeLists.txt
gui/mainwindow.cpp
Diffstat (limited to 'libutil')
-rw-r--r-- | libutil/CMakeLists.txt | 3 | ||||
-rw-r--r-- | libutil/include/cmdutils.h | 17 | ||||
-rw-r--r-- | libutil/src/cmdutils.cpp | 16 |
3 files changed, 15 insertions, 21 deletions
diff --git a/libutil/CMakeLists.txt b/libutil/CMakeLists.txt index 5b2c3837..11b21426 100644 --- a/libutil/CMakeLists.txt +++ b/libutil/CMakeLists.txt @@ -31,9 +31,6 @@ include/pathutils.h include/osutils.h include/userutils.h include/cmdutils.h - -include/siglist.h -include/siglist_impl.h ) SET(LIBUTIL_SOURCES diff --git a/libutil/include/cmdutils.h b/libutil/include/cmdutils.h index 32261dd7..83397e73 100644 --- a/libutil/include/cmdutils.h +++ b/libutil/include/cmdutils.h @@ -73,15 +73,6 @@ enum LIBUTIL_EXPORT Enum }; } -namespace OptionType -{ -enum LIBUTIL_EXPORT Enum -{ - Switch, - Option -}; -} - /** * @brief The ParsingError class */ @@ -210,6 +201,12 @@ public: private: FlagStyle::Enum m_flagStyle; ArgumentStyle::Enum m_argStyle; + + enum OptionType + { + otSwitch, + otOption + }; // Important: the common part MUST BE COMMON ON ALL THREE structs struct CommonDef { @@ -226,7 +223,7 @@ private: QString metavar; QVariant def; // option - OptionType::Enum type; + OptionType type; QChar flag; }; diff --git a/libutil/src/cmdutils.cpp b/libutil/src/cmdutils.cpp index 3bf4e872..13db503d 100644 --- a/libutil/src/cmdutils.cpp +++ b/libutil/src/cmdutils.cpp @@ -56,7 +56,7 @@ void Parser::addSwitch(QString name, bool def) throw "Name not unique"; OptionDef *param = new OptionDef; - param->type = OptionType::Switch; + param->type = otSwitch; param->name = name; param->metavar = QString("<%1>").arg(name); param->def = def; @@ -72,7 +72,7 @@ void Parser::addOption(QString name, QVariant def) throw "Name not unique"; OptionDef *param = new OptionDef; - param->type = OptionType::Option; + param->type = otOption; param->name = name; param->metavar = QString("<%1>").arg(name); param->def = def; @@ -161,7 +161,7 @@ QString Parser::compileHelp(QString progName, int helpIndent, bool useFlags) help << flagPrefix << option->flag << ", "; } help << optPrefix << option->name; - if (option->type == OptionType::Option) + if (option->type == otOption) { QString arg = QString("%1%2").arg(((m_argStyle == ArgumentStyle::Equals) ? "=" : " "), option->metavar); nameLength += arg.length(); @@ -193,7 +193,7 @@ QString Parser::compileUsage(QString progName, bool useFlags) usage << flagPrefix << option->flag; else usage << optPrefix << option->name; - if (option->type == OptionType::Option) + if (option->type == otOption) usage << ((m_argStyle == ArgumentStyle::Equals) ? "=" : " ") << option->metavar; usage << "]"; } @@ -265,9 +265,9 @@ QHash<QString, QVariant> Parser::parse(QStringList argv) throw ParsingError(QString("Option %2%1 was given multiple times").arg(name, optionPrefix)); OptionDef *option = m_options[name]; - if (option->type == OptionType::Switch) + if (option->type == otSwitch) map[name] = true; - else //if (option->type == OptionType::Option) + else //if (option->type == otOption) { if (m_argStyle == ArgumentStyle::Space) expecting.append(name); @@ -312,9 +312,9 @@ QHash<QString, QVariant> Parser::parse(QStringList argv) if (map.contains(option->name)) throw ParsingError(QString("Option %2%1 was given multiple times").arg(option->name, optionPrefix)); - if (option->type == OptionType::Switch) + if (option->type == otSwitch) map[option->name] = true; - else //if (option->type == OptionType::Option) + else //if (option->type == otOption) { if (m_argStyle == ArgumentStyle::Space) expecting.append(option->name); |