This commit is contained in:
parent
435d01dde7
commit
cae32e3215
|
@ -91,34 +91,32 @@ bool FloatOption::parse(const QList<QString> args, int start) {
|
||||||
return args_t == bindKey();
|
return args_t == bindKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace args_parse {
|
MatchMode::MatchMode(const QList<shared_ptr<IArgvPack>> mode, int mode_code)
|
||||||
class MatchMode {
|
|
||||||
private:
|
|
||||||
QList<shared_ptr<IArgvPack>> args_mode;
|
|
||||||
int code_store;
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit MatchMode(const QList<shared_ptr<IArgvPack>> mode, int mode_code)
|
|
||||||
:args_mode(mode), code_store(mode_code) { }
|
:args_mode(mode), code_store(mode_code) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 获取模式代码
|
* @brief 获取模式代码
|
||||||
* @return 模式代码
|
* @return 模式代码
|
||||||
*/
|
*/
|
||||||
int modeCode()const {
|
|
||||||
|
int MatchMode::modeCode() const {
|
||||||
return code_store;
|
return code_store;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 获取模式匹配结果
|
* @brief 获取模式匹配结果
|
||||||
* @return 模式匹配结果
|
* @return 模式匹配结果
|
||||||
*/
|
*/
|
||||||
QList<shared_ptr<IArgvPack>> result() const {
|
|
||||||
|
QList<shared_ptr<IArgvPack>> MatchMode::result() const {
|
||||||
return args_mode;
|
return args_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 解析匹配参数
|
* @brief 解析匹配参数
|
||||||
*/
|
*/
|
||||||
bool parse(const QList<QString>& args, int argv_index, int parse_index) {
|
|
||||||
|
bool MatchMode::parse(const QList<QString>& args, int argv_index, int parse_index) {
|
||||||
if (argv_index >= args.size())
|
if (argv_index >= args.size())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -157,8 +155,7 @@ namespace args_parse {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
}
|
|
||||||
void ArgsParser::loadMode(int mode_code, const QList<shared_ptr<IArgvPack>>& args_model) {
|
void ArgsParser::loadMode(int mode_code, const QList<shared_ptr<IArgvPack>>& args_model) {
|
||||||
this->match_modes.append(make_shared<MatchMode>(args_model, mode_code));
|
this->match_modes.append(make_shared<MatchMode>(args_model, mode_code));
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,6 +87,13 @@ namespace args_parse {
|
||||||
*/
|
*/
|
||||||
class ARGSPARSER_EXPORT FloatKeyValue : public __FloatArgvImpl {
|
class ARGSPARSER_EXPORT FloatKeyValue : public __FloatArgvImpl {
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* 浮动key-value解析单元.
|
||||||
|
*
|
||||||
|
* \param key 键名
|
||||||
|
* \param means 参数解释
|
||||||
|
* \param optional 是否可选
|
||||||
|
*/
|
||||||
explicit FloatKeyValue(const QString& key, const QString &means, bool optional = false);
|
explicit FloatKeyValue(const QString& key, const QString &means, bool optional = false);
|
||||||
virtual ~FloatKeyValue() = default;
|
virtual ~FloatKeyValue() = default;
|
||||||
|
|
||||||
|
@ -101,6 +108,13 @@ namespace args_parse {
|
||||||
*/
|
*/
|
||||||
class ARGSPARSER_EXPORT FloatOption : public __FloatArgvImpl {
|
class ARGSPARSER_EXPORT FloatOption : public __FloatArgvImpl {
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* 浮动option解析单元.
|
||||||
|
*
|
||||||
|
* \param key 键名
|
||||||
|
* \param means 参数解释
|
||||||
|
* \param optional 是否可选
|
||||||
|
*/
|
||||||
explicit FloatOption(const QString& key, const QString& means, bool optional = false);
|
explicit FloatOption(const QString& key, const QString& means, bool optional = false);
|
||||||
virtual ~FloatOption() = default;
|
virtual ~FloatOption() = default;
|
||||||
|
|
||||||
|
@ -126,7 +140,30 @@ namespace args_parse {
|
||||||
bool parse(const QList<QString> args, int start) override;
|
bool parse(const QList<QString> args, int start) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MatchMode;
|
class ARGSPARSER_EXPORT MatchMode {
|
||||||
|
private:
|
||||||
|
QList<shared_ptr<IArgvPack>> args_mode;
|
||||||
|
int code_store;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit MatchMode(const QList<shared_ptr<IArgvPack>> mode, int mode_code);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 获取模式代码
|
||||||
|
* @return 模式代码
|
||||||
|
*/
|
||||||
|
int modeCode()const;
|
||||||
|
/**
|
||||||
|
* @brief 获取模式匹配结果
|
||||||
|
* @return 模式匹配结果
|
||||||
|
*/
|
||||||
|
QList<shared_ptr<IArgvPack>> result() const;
|
||||||
|
/**
|
||||||
|
* @brief 解析匹配参数
|
||||||
|
*/
|
||||||
|
bool parse(const QList<QString>& args, int argv_index, int parse_index);
|
||||||
|
};
|
||||||
|
|
||||||
class ARGSPARSER_EXPORT ArgsParser {
|
class ARGSPARSER_EXPORT ArgsParser {
|
||||||
private:
|
private:
|
||||||
QList<std::shared_ptr<MatchMode>> match_modes;
|
QList<std::shared_ptr<MatchMode>> match_modes;
|
||||||
|
|
Loading…
Reference in New Issue