interest-filter.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
22 #ifndef NDN_INTEREST_FILTER_HPP
23 #define NDN_INTEREST_FILTER_HPP
24 
25 #include "name.hpp"
26 
27 namespace ndn {
28 
34 public:
40  InterestFilter(const Name& prefix)
41  : prefix_(prefix)
42  {
43  }
44 
50  InterestFilter(const std::string& prefixUri)
51  : prefix_(prefixUri)
52  {
53  }
54 
60  InterestFilter(const char* prefixUri)
61  : prefix_(prefixUri)
62  {
63  }
64 
73  InterestFilter(const Name& prefix, const std::string& regexFilter);
74 
83  InterestFilter(const Name& prefix, const char* regexFilter);
84 
93  InterestFilter(const std::string& prefixUri, const std::string& regexFilter);
94 
103  InterestFilter(const char* prefixUri, const std::string& regexFilter);
104 
113  InterestFilter(const std::string& prefixUri, const char* regexFilter);
114 
123  InterestFilter(const char* prefixUri, const char* regexFilter);
124 
146  bool
147  doesMatch(const Name& name) const;
148 
153  const Name&
154  getPrefix() const { return prefix_; }
155 
160  bool
161  hasRegexFilter() const { return regexFilter_.size() != 0; }
162 
167  const std::string&
168  getRegexFilter() const { return regexFilter_; }
169 
170 private:
177  static std::string
178  makePattern(const std::string& regexFilter);
179 
180  Name prefix_;
181  std::string regexFilter_;
182  std::string regexFilterPattern_;
183 };
184 
185 }
186 
187 #endif
const std::string & getRegexFilter() const
Get the regex filter.
Definition: interest-filter.hpp:168
Copyright (C) 2013-2016 Regents of the University of California.
Definition: common.hpp:35
const Name & getPrefix() const
Get the prefix given to the constructor.
Definition: interest-filter.hpp:154
InterestFilter(const Name &prefix)
Create an InterestFilter to match any Interest whose name starts with the given prefix.
Definition: interest-filter.hpp:40
InterestFilter(const char *prefixUri)
Create an InterestFilter to match any Interest whose name starts with the given prefix.
Definition: interest-filter.hpp:60
A Name holds an array of Name::Component and represents an NDN name.
Definition: name.hpp:40
InterestFilter(const std::string &prefixUri)
Create an InterestFilter to match any Interest whose name starts with the given prefix.
Definition: interest-filter.hpp:50
bool hasRegexFilter() const
Check if a regexFilter was supplied to the constructor.
Definition: interest-filter.hpp:161
An InterestFilter holds a Name prefix and optional regex match expression for use in Face::setInteres...
Definition: interest-filter.hpp:33
bool doesMatch(const Name &name) const
Check if the given name matches this filter.
Definition: interest-filter.cpp:73