update
This commit is contained in:
parent
b11f556b9a
commit
0f7d7a44bf
|
@ -6,7 +6,7 @@ using namespace size_provider;
|
|||
TranslateBasic::TranslateBasic()
|
||||
{
|
||||
// extractor type-list
|
||||
std::shared_ptr<ExtractImpl> u_ptr = std::make_shared<AsInteger>();
|
||||
std::shared_ptr<ExtractDelegate> u_ptr = std::make_shared<AsInteger>();
|
||||
_basic_extractor_types[u_ptr->unitType()] = u_ptr;
|
||||
|
||||
u_ptr = std::make_shared<AsUnsigned>();
|
||||
|
@ -46,12 +46,12 @@ TranslateBasic::TranslateBasic()
|
|||
_size_provider_types[sz_ptr->name()] = sz_ptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<ExtractImpl> TranslateBasic::defaultExtractUnit() const
|
||||
std::shared_ptr<ExtractDelegate> TranslateBasic::defaultExtractUnit() const
|
||||
{
|
||||
return _default_translate_rule;
|
||||
}
|
||||
|
||||
QHash<QString, std::shared_ptr<ExtractImpl>> TranslateBasic::basicExtractors() const
|
||||
QHash<QString, std::shared_ptr<ExtractDelegate>> TranslateBasic::basicExtractors() const
|
||||
{
|
||||
return _basic_extractor_types;
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ std::shared_ptr<RuleMatch> TranslateBasic::defaultRuleMatch() const
|
|||
return _default_rule_match;
|
||||
}
|
||||
|
||||
QHash<QString, std::shared_ptr<ExtractImpl>> TranslateBasic::totalExtractors() const
|
||||
QHash<QString, std::shared_ptr<ExtractDelegate>> TranslateBasic::totalExtractors() const
|
||||
{
|
||||
decltype(_basic_extractor_types) ntypes;
|
||||
for(auto key : _complex_extractor_types.keys())
|
||||
|
@ -75,11 +75,11 @@ QHash<QString, std::shared_ptr<ExtractImpl>> TranslateBasic::totalExtractors() c
|
|||
return ntypes;
|
||||
}
|
||||
|
||||
void TranslateBasic::addDelegate(std::shared_ptr<ExtractImpl> inst)
|
||||
void TranslateBasic::addDelegate(std::shared_ptr<ExtractDelegate> inst)
|
||||
{
|
||||
auto repeat_name_count = std::count_if(
|
||||
this->_custom_rule_types.begin(), this->_custom_rule_types.end(),
|
||||
[=](std::shared_ptr<ExtractImpl> v) {
|
||||
[=](std::shared_ptr<ExtractDelegate> v) {
|
||||
return v->aliasName() == inst->aliasName();
|
||||
});
|
||||
|
||||
|
@ -114,13 +114,13 @@ QList<QString> TranslateBasic::delegateAlias() const
|
|||
{
|
||||
QList<QString> values;
|
||||
std::transform(_custom_rule_types.begin(), _custom_rule_types.end(),
|
||||
std::back_inserter(values), [](std::shared_ptr<ExtractImpl> impl){
|
||||
std::back_inserter(values), [](std::shared_ptr<ExtractDelegate> impl){
|
||||
return impl->aliasName();
|
||||
});
|
||||
return values;
|
||||
}
|
||||
|
||||
std::shared_ptr<ExtractImpl> TranslateBasic::operator[](const QString& name) const
|
||||
std::shared_ptr<ExtractDelegate> TranslateBasic::operator[](const QString& name) const
|
||||
{
|
||||
for(auto ins : _custom_rule_types)
|
||||
if(ins->aliasName() == name)
|
||||
|
@ -129,7 +129,7 @@ std::shared_ptr<ExtractImpl> TranslateBasic::operator[](const QString& name) con
|
|||
assert("Ö¸¶¨Name²»´æÔÚ" && 0);
|
||||
}
|
||||
|
||||
void TranslateBasic::replaceDelegate(const QString& name, std::shared_ptr<ExtractImpl> inst)
|
||||
void TranslateBasic::replaceDelegate(const QString& name, std::shared_ptr<ExtractDelegate> inst)
|
||||
{
|
||||
for (auto idx = 0; _custom_rule_types.size(); ++idx) {
|
||||
auto rule_inst = _custom_rule_types.at(idx);
|
||||
|
|
|
@ -109,9 +109,9 @@ public:
|
|||
/// </summary>
|
||||
class TranslateBasic {
|
||||
private:
|
||||
QHash<QString, std::shared_ptr<ExtractImpl>> _basic_extractor_types;
|
||||
QHash<QString, std::shared_ptr<ExtractImpl>> _complex_extractor_types;
|
||||
std::shared_ptr<ExtractImpl> _default_translate_rule = nullptr;
|
||||
QHash<QString, std::shared_ptr<ExtractDelegate>> _basic_extractor_types;
|
||||
QHash<QString, std::shared_ptr<ExtractDelegate>> _complex_extractor_types;
|
||||
std::shared_ptr<ExtractDelegate> _default_translate_rule = nullptr;
|
||||
|
||||
QHash<QString, std::shared_ptr<SizeProvider>> _size_provider_types;
|
||||
std::shared_ptr<SizeProvider> _default_size_provider = nullptr;
|
||||
|
@ -119,7 +119,7 @@ private:
|
|||
QHash<QString, std::shared_ptr<RuleMatch>> _rule_match_types;
|
||||
std::shared_ptr<RuleMatch> _default_rule_match = nullptr;
|
||||
|
||||
QList<std::shared_ptr<ExtractImpl>> _custom_rule_types;
|
||||
QList<std::shared_ptr<ExtractDelegate>> _custom_rule_types;
|
||||
|
||||
public:
|
||||
TranslateBasic();
|
||||
|
@ -129,15 +129,15 @@ public:
|
|||
std::shared_ptr<RuleMatch> defaultRuleMatch() const;
|
||||
QHash<QString, std::shared_ptr<RuleMatch>> ruleMatchList() const;
|
||||
|
||||
std::shared_ptr<ExtractImpl> defaultExtractUnit() const;
|
||||
QHash<QString, std::shared_ptr<ExtractImpl>> basicExtractors() const;
|
||||
QHash<QString, std::shared_ptr<ExtractImpl>> totalExtractors() const;
|
||||
std::shared_ptr<ExtractDelegate> defaultExtractUnit() const;
|
||||
QHash<QString, std::shared_ptr<ExtractDelegate>> basicExtractors() const;
|
||||
QHash<QString, std::shared_ptr<ExtractDelegate>> totalExtractors() const;
|
||||
|
||||
void addDelegate(std::shared_ptr<ExtractImpl> inst);
|
||||
void addDelegate(std::shared_ptr<ExtractDelegate> inst);
|
||||
void removeDelegate(const QString& alias);
|
||||
void replaceDelegate(const QString &name, std::shared_ptr<ExtractImpl> inst);
|
||||
void replaceDelegate(const QString &name, std::shared_ptr<ExtractDelegate> inst);
|
||||
QList<QString> delegateAlias() const;
|
||||
std::shared_ptr<ExtractImpl> operator[](const QString &name) const;
|
||||
std::shared_ptr<ExtractDelegate> operator[](const QString &name) const;
|
||||
};
|
||||
|
||||
namespace size_provider {
|
||||
|
|
|
@ -128,7 +128,7 @@ void WrapConfigs::aliasAppend()
|
|||
name += "#";
|
||||
|
||||
auto ins = _bind_base->defaultExtractUnit()->newDefault();
|
||||
auto nins = std::dynamic_pointer_cast<ExtractImpl>(ins);
|
||||
auto nins = std::dynamic_pointer_cast<ExtractDelegate>(ins);
|
||||
nins->setAlias(name);
|
||||
|
||||
_bind_base->addDelegate(nins);
|
||||
|
@ -172,7 +172,7 @@ void WrapConfigs::dataChanged(QStandardItem* cell)
|
|||
|
||||
auto new_type = cell->text();
|
||||
auto new_ins = _bind_base->basicExtractors()[new_type]->newDefault();
|
||||
auto new_delegate = std::dynamic_pointer_cast<ExtractImpl>(new_ins);
|
||||
auto new_delegate = std::dynamic_pointer_cast<ExtractDelegate>(new_ins);
|
||||
new_delegate->setAlias(origin_key);
|
||||
_bind_base->replaceDelegate(origin_key, new_delegate);
|
||||
}break;
|
||||
|
@ -248,7 +248,7 @@ CountWithinConfiguration::CountWithinConfiguration(QWidget* p /*= nullptr*/)
|
|||
});
|
||||
}
|
||||
|
||||
void CountWithinConfiguration::currentRuleAccept(std::shared_ptr<ExtractImpl> u, const QModelIndex& i)
|
||||
void CountWithinConfiguration::currentRuleAccept(std::shared_ptr<ExtractDelegate> u, const QModelIndex& i)
|
||||
{
|
||||
this->_bind_u = u;
|
||||
this->_bind_index = i;
|
||||
|
@ -295,7 +295,7 @@ EncodingConfiguration::EncodingConfiguration(QWidget* p /*= nullptr*/)
|
|||
});
|
||||
}
|
||||
|
||||
void EncodingConfiguration::currentRuleAccept(std::shared_ptr<ExtractImpl> u, const QModelIndex& i)
|
||||
void EncodingConfiguration::currentRuleAccept(std::shared_ptr<ExtractDelegate> u, const QModelIndex& i)
|
||||
{
|
||||
this->_bind_u = u;
|
||||
this->_bind_index = i;
|
||||
|
@ -368,7 +368,7 @@ BitCombineConfiguration::BitCombineConfiguration(QWidget* p /*= nullptr*/)
|
|||
});
|
||||
}
|
||||
|
||||
void BitCombineConfiguration::currentRuleAccept(std::shared_ptr<ExtractImpl> u, const QModelIndex& i)
|
||||
void BitCombineConfiguration::currentRuleAccept(std::shared_ptr<ExtractDelegate> u, const QModelIndex& i)
|
||||
{
|
||||
this->_bind_u = std::dynamic_pointer_cast<extract::AsBitCombine>(u);;
|
||||
this->_bind_index = i;
|
||||
|
|
|
@ -59,14 +59,14 @@ namespace configurations {
|
|||
class CountWithinConfiguration : public QWidget {
|
||||
Q_OBJECT
|
||||
private:
|
||||
std::shared_ptr<ExtractImpl> _bind_u;
|
||||
std::shared_ptr<ExtractDelegate> _bind_u;
|
||||
QModelIndex _bind_index;
|
||||
QSpinBox* const _count_input;
|
||||
|
||||
public:
|
||||
CountWithinConfiguration(QWidget* p = nullptr);
|
||||
|
||||
void currentRuleAccept(std::shared_ptr<ExtractImpl> u, const QModelIndex& i);
|
||||
void currentRuleAccept(std::shared_ptr<ExtractDelegate> u, const QModelIndex& i);
|
||||
|
||||
signals:
|
||||
void currentRuleChanged(const QModelIndex& idx);
|
||||
|
@ -78,7 +78,7 @@ namespace configurations {
|
|||
class EncodingConfiguration : public QWidget {
|
||||
Q_OBJECT
|
||||
private:
|
||||
std::shared_ptr<ExtractImpl> _bind_u;
|
||||
std::shared_ptr<ExtractDelegate> _bind_u;
|
||||
QModelIndex _bind_index;
|
||||
QSpinBox* const _count_input;
|
||||
QComboBox* const _encoding_set;
|
||||
|
@ -86,7 +86,7 @@ namespace configurations {
|
|||
public:
|
||||
EncodingConfiguration(QWidget* p = nullptr);
|
||||
|
||||
void currentRuleAccept(std::shared_ptr<ExtractImpl> u, const QModelIndex& i);
|
||||
void currentRuleAccept(std::shared_ptr<ExtractDelegate> u, const QModelIndex& i);
|
||||
|
||||
signals:
|
||||
void currentRuleChanged(const QModelIndex& idx);
|
||||
|
@ -110,7 +110,7 @@ namespace configurations {
|
|||
public:
|
||||
BitCombineConfiguration(QWidget* p = nullptr);
|
||||
|
||||
void currentRuleAccept(std::shared_ptr<ExtractImpl> u, const QModelIndex& i);
|
||||
void currentRuleAccept(std::shared_ptr<ExtractDelegate> u, const QModelIndex& i);
|
||||
void reloadContent(std::shared_ptr<extract::AsBitCombine> u);
|
||||
|
||||
signals:
|
||||
|
|
|
@ -729,12 +729,12 @@ int ExtractProcess::offsetSpan() const
|
|||
return _inst._bytes_offset;
|
||||
}
|
||||
|
||||
std::shared_ptr<ExtractImpl> ExtractProcess::delegateInst() const
|
||||
std::shared_ptr<ExtractDelegate> ExtractProcess::delegateInst() const
|
||||
{
|
||||
return _inst._delegate_inst;
|
||||
}
|
||||
|
||||
void ExtractProcess::setDelegate(std::shared_ptr<ExtractImpl> inst)
|
||||
void ExtractProcess::setDelegate(std::shared_ptr<ExtractDelegate> inst)
|
||||
{
|
||||
_inst._delegate_inst = inst;
|
||||
}
|
||||
|
@ -766,7 +766,7 @@ void ExtractProcess::loadFrom(std::shared_ptr<TranslateBasic> core, const QJsonO
|
|||
QString delegate_alias;
|
||||
STRING_PEAK(delegate_alias, obj);
|
||||
auto vcopy = core->operator[](delegate_alias)->newDefault();
|
||||
_inst._delegate_inst = std::dynamic_pointer_cast<ExtractImpl>(vcopy);
|
||||
_inst._delegate_inst = std::dynamic_pointer_cast<ExtractDelegate>(vcopy);
|
||||
|
||||
QJsonObject data_obj;
|
||||
OBJECT_PEAK(data_obj, field_obj);
|
||||
|
|
|
@ -34,7 +34,7 @@ public:
|
|||
/// <summary>
|
||||
/// 翻译单元抽象接口
|
||||
/// </summary>
|
||||
class ExtractImpl : public ExtractStruct {
|
||||
class ExtractDelegate : public ExtractStruct {
|
||||
public:
|
||||
/// <summary>
|
||||
/// 基础类型
|
||||
|
@ -87,19 +87,19 @@ public:
|
|||
/// 委托实例
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
virtual std::shared_ptr<ExtractImpl> delegateInst() const = 0;
|
||||
virtual std::shared_ptr<ExtractDelegate> delegateInst() const = 0;
|
||||
/// <summary>
|
||||
/// 设置委托实例
|
||||
/// </summary>
|
||||
/// <param typeAlias="inst"></param>
|
||||
virtual void setDelegate(std::shared_ptr<ExtractImpl> inst) = 0;
|
||||
virtual void setDelegate(std::shared_ptr<ExtractDelegate> inst) = 0;
|
||||
};
|
||||
|
||||
|
||||
class SizeProvider;
|
||||
class RuleMatch;
|
||||
namespace extract {
|
||||
class AbstractExtractor : public ExtractImpl {
|
||||
class AbstractExtractor : public ExtractDelegate {
|
||||
private:
|
||||
struct __Private {
|
||||
QString typename_store = "";
|
||||
|
@ -112,7 +112,7 @@ namespace extract {
|
|||
AbstractExtractor(const QString& name, DataType data);
|
||||
virtual bool setCountWithin(int bytes);
|
||||
|
||||
// ExtractImpl ===========================
|
||||
// ExtractDelegate ===========================
|
||||
QString unitType() const override;
|
||||
virtual DataType outType() const;
|
||||
int countWithin() const override;
|
||||
|
@ -156,7 +156,7 @@ namespace extract {
|
|||
QHash<int, QString> switchOptions() const;
|
||||
virtual void clearOptions();
|
||||
|
||||
// ExtractImpl ============================
|
||||
// ExtractDelegate ============================
|
||||
void parse(const QByteArray& bytes, std::shared_ptr<DataContext> out) const override;
|
||||
|
||||
// Serializable ==============================
|
||||
|
@ -173,7 +173,7 @@ namespace extract {
|
|||
static QString topic();
|
||||
AsInteger();
|
||||
|
||||
// ExtractImpl ============================
|
||||
// ExtractDelegate ============================
|
||||
bool setCountWithin(int bytes) override;
|
||||
void parse(const QByteArray& bytes, std::shared_ptr<DataContext> out) const override;
|
||||
|
||||
|
@ -189,7 +189,7 @@ namespace extract {
|
|||
static QString topic();
|
||||
AsUnsigned();
|
||||
|
||||
// ExtractImpl ============================
|
||||
// ExtractDelegate ============================
|
||||
bool setCountWithin(int bytes) override;
|
||||
void parse(const QByteArray& bytes, std::shared_ptr<DataContext> out) const override;
|
||||
|
||||
|
@ -213,7 +213,7 @@ namespace extract {
|
|||
void setStrCodec(QTextCodec* ins);
|
||||
QString codecName() const;
|
||||
|
||||
// ExtractImpl ============================
|
||||
// ExtractDelegate ============================
|
||||
void parse(const QByteArray& bytes, std::shared_ptr<DataContext> out) const override;
|
||||
|
||||
// Serializable ==============================
|
||||
|
@ -241,7 +241,7 @@ namespace extract {
|
|||
};
|
||||
|
||||
|
||||
class AsList : public ExtractImpl {
|
||||
class AsList : public ExtractDelegate {
|
||||
private:
|
||||
struct __Private {
|
||||
QString _alias_name = "";
|
||||
|
@ -274,7 +274,7 @@ namespace extract {
|
|||
|
||||
};
|
||||
|
||||
class AsUnion : public ExtractImpl {
|
||||
class AsUnion : public ExtractDelegate {
|
||||
private:
|
||||
struct __Private {
|
||||
int byte_count = 1;
|
||||
|
@ -308,7 +308,7 @@ namespace extract {
|
|||
};
|
||||
|
||||
|
||||
class AsRuleSet : public ExtractImpl {
|
||||
class AsRuleSet : public ExtractDelegate {
|
||||
private:
|
||||
struct __Private {
|
||||
QString alias_name = "";
|
||||
|
@ -350,7 +350,7 @@ namespace extract {
|
|||
struct __Private {
|
||||
QString _field_name = "";
|
||||
int _bytes_offset = 0;
|
||||
std::shared_ptr<ExtractImpl> _delegate_inst = nullptr;
|
||||
std::shared_ptr<ExtractDelegate> _delegate_inst = nullptr;
|
||||
} _inst;
|
||||
|
||||
public:
|
||||
|
@ -362,8 +362,8 @@ namespace extract {
|
|||
|
||||
virtual int countWithin() const;
|
||||
|
||||
std::shared_ptr<ExtractImpl> delegateInst() const override;
|
||||
void setDelegate(std::shared_ptr<ExtractImpl> inst) override;
|
||||
std::shared_ptr<ExtractDelegate> delegateInst() const override;
|
||||
void setDelegate(std::shared_ptr<ExtractDelegate> inst) override;
|
||||
|
||||
void registSubField(std::shared_ptr<ScopeFieldsSetter> inst) override;
|
||||
void parse(const QByteArray& bytes, std::shared_ptr<DataContext> out) const override;
|
||||
|
|
Loading…
Reference in New Issue