diff options
Diffstat (limited to 'src/adblock/adblockrule.cpp')
-rw-r--r-- | src/adblock/adblockrule.cpp | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/src/adblock/adblockrule.cpp b/src/adblock/adblockrule.cpp index 1cb6773a..7fdb3e10 100644 --- a/src/adblock/adblockrule.cpp +++ b/src/adblock/adblockrule.cpp @@ -55,13 +55,39 @@ // Self Includes #include "adblockrule.h" +// Local Includes #include "adblockrulefallbackimpl.h" +#include "adblockrulenullimpl.h" #include "adblockruletextmatchimpl.h" + AdBlockRule::AdBlockRule(const QString &filter) { - if (AdBlockRuleTextMatchImpl::isTextMatchFilter(filter)) + switch( AdBlockRule::ruleType(filter) ) + { + case TextRule: m_implementation = QSharedPointer<AdBlockRuleImpl>(new AdBlockRuleTextMatchImpl(filter)); - else + break; + + case FallbackRule: m_implementation = QSharedPointer<AdBlockRuleImpl>(new AdBlockRuleFallbackImpl(filter)); + break; + + case NullRule: + default: + m_implementation = QSharedPointer<AdBlockRuleImpl>(new AdBlockRuleNullImpl(filter)); + break; + } +} + + +RuleTypes AdBlockRule::ruleType(const QString &filter) +{ + if( AdBlockRuleTextMatchImpl::isTextMatchFilter(filter) ) + return TextRule; + + if( AdBlockRuleNullImpl::isNullFilter(filter) ) + return NullRule; + + return FallbackRule; } |