30 #include <boost/algorithm/string/predicate.hpp>
35 Filter::match(uint32_t pktType,
const Name& pktName,
const shared_ptr<ValidationState>& state)
60 return matchName(pktName);
66 , m_relation(relation)
71 RelationNameFilter::matchName(
const Name& name)
82 RegexNameFilter::matchName(
const Name& name)
84 return m_regex.
match(name);
90 auto propertyIt = configSection.begin();
92 if (propertyIt == configSection.end() || !boost::iequals(propertyIt->first,
"type")) {
96 std::string type = propertyIt->second.data();
97 if (boost::iequals(type,
"name"))
98 return createNameFilter(configSection, configFilename);
104 Filter::createNameFilter(
const ConfigSection& configSection,
const std::string& configFilename)
106 auto propertyIt = configSection.begin();
109 if (propertyIt == configSection.end())
112 if (boost::iequals(propertyIt->first,
"name")) {
116 name =
Name(propertyIt->second.data());
119 NDN_THROW_NESTED(Error(
"Invalid <filter.name>: " + propertyIt->second.data()));
125 if (propertyIt == configSection.end() || !boost::iequals(propertyIt->first,
"relation")) {
126 NDN_THROW(Error(
"Expecting <filter.relation>"));
132 if (propertyIt != configSection.end())
133 NDN_THROW(Error(
"Expecting end of <filter>"));
135 return make_unique<RelationNameFilter>(name, relation);
137 else if (boost::iequals(propertyIt->first,
"regex")) {
138 std::string regexString = propertyIt->second.data();
141 if (propertyIt != configSection.end())
142 NDN_THROW(Error(
"Expecting end of <filter>"));
145 return make_unique<RegexNameFilter>(
Regex(regexString));
147 catch (
const Regex::Error&) {
152 NDN_THROW(Error(
"Unrecognized <filter> property: " + propertyIt->first));
Represents an absolute name.
PartialName getPrefix(ssize_t nComponents) const
Returns a prefix of the name.
size_t size() const noexcept
Returns the number of components.
bool match(const Name &name)
Provides a tag type for simple types.
static unique_ptr< Filter > create(const ConfigSection &configSection, const std::string &configFilename)
Create a filter from the configuration section.
bool match(uint32_t pktType, const Name &pktName, const shared_ptr< ValidationState > &state)
RegexNameFilter(const Regex ®ex)
RelationNameFilter(const Name &name, NameRelation relation)
#define NDN_THROW_NESTED(e)
NameRelation getNameRelationFromString(const std::string &relationString)
Convert relationString to NameRelation.
boost::property_tree::ptree ConfigSection
bool checkNameRelation(NameRelation relation, const Name &name1, const Name &name2)
Check whether name1 and name2 satisfies relation.
@ V03
Sign Interest using Packet Specification v0.3 semantics.
constexpr size_t MIN_SIZE
Minimum number of name components for an old-style Signed Interest.
@ ParametersSha256DigestComponent