ndn::InterestFilter Class Reference

Declares the set of Interests a producer can serve. More...

#include <ndn-cxx/interest-filter.hpp>

Classes

class  Error
 

Public Member Functions

 InterestFilter (const char *prefixUri)
 Construct an InterestFilter to match Interests by prefix. More...
 
 InterestFilter (const Name &prefix)
 Construct an InterestFilter to match Interests by prefix. More...
 
 InterestFilter (const Name &prefix, const std::string &regexFilter)
 Construct an InterestFilter to match Interests by prefix and regular expression. More...
 
 InterestFilter (const std::string &prefixUri)
 Construct an InterestFilter to match Interests by prefix. More...
 
InterestFilterallowLoopback (bool wantLoopback) noexcept
 Set whether Interest loopback is allowed. More...
 
bool allowsLoopback () const noexcept
 Get whether Interest loopback is allowed. More...
 
bool doesMatch (const Name &name) const
 Check if specified Interest name matches the filter. More...
 
const NamegetPrefix () const
 
const RegexPatternListMatchergetRegexFilter () const
 
bool hasRegexFilter () const
 
 operator const Name & () const
 Implicit conversion to Name. More...
 

Detailed Description

Declares the set of Interests a producer can serve.

A filter starts with a name prefix, followed by an optional NDN regular expression.

Definition at line 36 of file interest-filter.hpp.

Constructor & Destructor Documentation

◆ InterestFilter() [1/4]

ndn::InterestFilter::InterestFilter ( const Name prefix)

Construct an InterestFilter to match Interests by prefix.

This filter matches Interests whose name start with the given prefix.

Note
InterestFilter is implicitly convertible from Name.

Definition at line 27 of file interest-filter.cpp.

◆ InterestFilter() [2/4]

ndn::InterestFilter::InterestFilter ( const char *  prefixUri)

Construct an InterestFilter to match Interests by prefix.

This filter matches Interests whose name start with the given prefix.

Parameters
prefixUriname prefix, interpreted as ndn URI
Note
InterestFilter is implicitly convertible from null-terminated byte string.

Definition at line 32 of file interest-filter.cpp.

◆ InterestFilter() [3/4]

ndn::InterestFilter::InterestFilter ( const std::string &  prefixUri)

Construct an InterestFilter to match Interests by prefix.

This filter matches Interests whose name start with the given prefix.

Parameters
prefixUriname prefix, interpreted as ndn URI
Note
InterestFilter is implicitly convertible from std::string.

Definition at line 37 of file interest-filter.cpp.

◆ InterestFilter() [4/4]

ndn::InterestFilter::InterestFilter ( const Name prefix,
const std::string &  regexFilter 
)

Construct an InterestFilter to match Interests by prefix and regular expression.

This filter matches Interests whose name start with the given prefix and the remaining components match the given regular expression. For example, the following InterestFilter:

InterestFilter("/hello", "<world><>+")

matches Interests whose name has prefix /hello followed by component world and has at least one more component after it, such as:

/hello/world/%21 /hello/world/x/y/z

Note that regular expression will need to match all components (e.g., there are implicit heading ^ and trailing $ symbols in the regular expression).

Definition at line 42 of file interest-filter.cpp.

Member Function Documentation

◆ allowLoopback()

InterestFilter& ndn::InterestFilter::allowLoopback ( bool  wantLoopback)
inlinenoexcept

Set whether Interest loopback is allowed.

Parameters
wantLoopbackIf true, this InterestFilter may receive Interests that are expressed locally on the same Face; if false, this InterestFilter can only receive Interests received from the forwarder. The default is true.

Definition at line 141 of file interest-filter.hpp.

◆ allowsLoopback()

bool ndn::InterestFilter::allowsLoopback ( ) const
inlinenoexcept

Get whether Interest loopback is allowed.

Definition at line 129 of file interest-filter.hpp.

◆ doesMatch()

bool ndn::InterestFilter::doesMatch ( const Name name) const

Check if specified Interest name matches the filter.

Definition at line 58 of file interest-filter.cpp.

◆ getPrefix()

const Name& ndn::InterestFilter::getPrefix ( ) const
inline

Definition at line 108 of file interest-filter.hpp.

◆ getRegexFilter()

const RegexPatternListMatcher& ndn::InterestFilter::getRegexFilter ( ) const
inline

Definition at line 120 of file interest-filter.hpp.

◆ hasRegexFilter()

bool ndn::InterestFilter::hasRegexFilter ( ) const
inline

Definition at line 114 of file interest-filter.hpp.

◆ operator const Name &()

ndn::InterestFilter::operator const Name & ( ) const

Implicit conversion to Name.

Note
This allows InterestCallback to be declared with Name rather than InterestFilter, but this does not work if InterestFilter has regular expression.

Definition at line 48 of file interest-filter.cpp.