30 #include <boost/algorithm/string/predicate.hpp> 35 namespace validator_config {
38 Filter::match(uint32_t pktType,
const Name& pktName,
const shared_ptr<ValidationState>& state)
63 return matchName(pktName);
69 , m_relation(relation)
74 RelationNameFilter::matchName(
const Name&
name)
85 RegexNameFilter::matchName(
const Name& name)
87 return m_regex.
match(name);
93 auto propertyIt = configSection.begin();
95 if (propertyIt == configSection.end() || !boost::iequals(propertyIt->first,
"type")) {
99 std::string type = propertyIt->second.data();
100 if (boost::iequals(type,
"name"))
101 return createNameFilter(configSection, configFilename);
107 Filter::createNameFilter(
const ConfigSection& configSection,
const std::string& configFilename)
109 auto propertyIt = configSection.begin();
112 if (propertyIt == configSection.end())
115 if (boost::iequals(propertyIt->first,
"name")) {
119 name =
Name(propertyIt->second.data());
128 if (propertyIt == configSection.end() || !boost::iequals(propertyIt->first,
"relation")) {
135 if (propertyIt != configSection.end())
138 return make_unique<RelationNameFilter>(name, relation);
140 else if (boost::iequals(propertyIt->first,
"regex")) {
141 std::string regexString = propertyIt->second.data();
144 if (propertyIt != configSection.end())
148 return make_unique<RegexNameFilter>(
Regex(regexString));
155 NDN_THROW(
Error(
"Unrecognized <filter> property: " + propertyIt->first));
#define NDN_THROW_NESTED(e)
bool match(uint32_t pktType, const Name &pktName, const shared_ptr< ValidationState > &state)
Sign Interest using Packet Specification v0.3 semantics.
PartialName getPrefix(ssize_t nComponents) const
Returns a prefix of the name.
Copyright (c) 2011-2015 Regents of the University of California.
const size_t MIN_SIZE
minimal number of components for Signed Interest
provides a tag type for simple types
bool checkNameRelation(NameRelation relation, const Name &name1, const Name &name2)
check whether name1 and name2 satisfies relation
NameRelation getNameRelationFromString(const std::string &relationString)
convert relationString to NameRelation
RelationNameFilter(const Name &name, NameRelation relation)
RegexNameFilter(const Regex ®ex)
Represents an absolute name.
static unique_ptr< Filter > create(const ConfigSection &configSection, const std::string &configFilename)
Create a filter from the configuration section.
size_t size() const
Returns the number of components.
boost::property_tree::ptree ConfigSection
bool match(const Name &name)