All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
regex-top-matcher.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
8 #ifndef NDN_UTIL_REGEX_REGEX_TOP_MATCHER_HPP
9 #define NDN_UTIL_REGEX_REGEX_TOP_MATCHER_HPP
10 
11 #include "../../common.hpp"
12 
13 #include "regex-matcher.hpp"
14 
15 namespace ndn {
16 
17 class RegexPatternListMatcher;
18 class RegexBackrefManager;
19 
21 {
22 public:
23  RegexTopMatcher(const std::string& expr, const std::string& expand = "");
24 
25  virtual
27 
28  bool
29  match(const Name& name);
30 
31  virtual bool
32  match(const Name& name, const int& offset, const int& length);
33 
34  virtual Name
35  expand(const std::string& expand = "");
36 
37  static shared_ptr<RegexTopMatcher>
38  fromName(const Name& name, bool hasAnchor=false);
39 
40 protected:
41  virtual void
42  compile();
43 
44 private:
45  std::string
46  getItemFromExpand(const std::string& expand, size_t& offset);
47 
48  static std::string
49  convertSpecialChar(const std::string& str);
50 
51 private:
52  const std::string m_expand;
53  shared_ptr<RegexPatternListMatcher> m_primaryMatcher;
54  shared_ptr<RegexPatternListMatcher> m_secondaryMatcher;
55  shared_ptr<RegexBackrefManager> m_primaryBackRefManager;
56  shared_ptr<RegexBackrefManager> m_secondaryBackRefManager;
57  bool m_secondaryUsed;
58 };
59 
60 } // namespace ndn
61 
62 #endif // NDN_UTIL_REGEX_REGEX_TOP_MATCHER_HPP
static shared_ptr< RegexTopMatcher > fromName(const Name &name, bool hasAnchor=false)
virtual void compile()
Compile the regular expression to generate the more matchers when necessary.
A Name holds an array of Name::Component and represents an NDN name.
Definition: name.hpp:26
virtual Name expand(const std::string &expand="")
bool match(const Name &name)
RegexTopMatcher(const std::string &expr, const std::string &expand="")