添加Delegate校验机制
This commit is contained in:
parent
66c957d7e5
commit
9171ae8786
|
@ -77,13 +77,23 @@ QHash<QString, std::shared_ptr<ExtractImpl>> TranslateBasic::totalExtractors() c
|
||||||
|
|
||||||
void TranslateBasic::addDelegate(std::shared_ptr<ExtractImpl> inst)
|
void TranslateBasic::addDelegate(std::shared_ptr<ExtractImpl> inst)
|
||||||
{
|
{
|
||||||
auto exist = std::count_if(
|
auto repeat_name_count = std::count_if(
|
||||||
this->_custom_rule_types.begin(), this->_custom_rule_types.end(),
|
this->_custom_rule_types.begin(), this->_custom_rule_types.end(),
|
||||||
[=](std::shared_ptr<ExtractImpl> v) {
|
[=](std::shared_ptr<ExtractImpl> v) {
|
||||||
return v->aliasName() == inst->aliasName();
|
return v->aliasName() == inst->aliasName();
|
||||||
});
|
});
|
||||||
|
|
||||||
assert("RuleName不能重复" && !exist);
|
if(repeat_name_count)
|
||||||
|
throw new BaseException(u8"RuleName不能重复");
|
||||||
|
|
||||||
|
switch (inst->outType()) {
|
||||||
|
case DataType::LIST_COLLECTION:
|
||||||
|
case DataType::UNION_COMBINATE:
|
||||||
|
throw new BaseException(u8"不能接受的委托类型!");
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
this->_custom_rule_types << inst;
|
this->_custom_rule_types << inst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue