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