All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
ndn-regex-top-matcher.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
23 #ifndef NDN_NDN_REGEX_TOP_MATCHER_HPP
24 #define NDN_NDN_REGEX_TOP_MATCHER_HPP
25 
26 #include "ndn-regex-matcher-base.hpp"
27 
28 // Only compile if we set NDN_CPP_HAVE_REGEX_LIB in ndn-regex-matcher-base.hpp.
29 #if NDN_CPP_HAVE_REGEX_LIB
30 
31 namespace ndn {
32 
33 class NdnRegexPatternListMatcher;
34 class NdnRegexBackrefManager;
35 
36 class NdnRegexTopMatcher: public NdnRegexMatcherBase {
37 public:
38  NdnRegexTopMatcher(const std::string& expr, const std::string& expand = "");
39 
40  virtual
41  ~NdnRegexTopMatcher();
42 
43  bool
44  match(const Name& name);
45 
46  virtual bool
47  match(const Name& name, size_t offset, size_t len);
48 
49  virtual Name
50  expand(const std::string& expand = "");
51 
52  static ptr_lib::shared_ptr<NdnRegexTopMatcher>
53  fromName(const Name& name, bool hasAnchor=false);
54 
55 protected:
56  virtual void
57  compile();
58 
59 private:
60  static std::string
61  getItemFromExpand(const std::string& expand, size_t& offset);
62 
63  static std::string
64  convertSpecialChar(const std::string& str);
65 
66 private:
67  const std::string expand_;
68  ptr_lib::shared_ptr<NdnRegexPatternListMatcher> primaryMatcher_;
69  ptr_lib::shared_ptr<NdnRegexPatternListMatcher> secondaryMatcher_;
70  ptr_lib::shared_ptr<NdnRegexBackrefManager> primaryBackrefManager_;
71  ptr_lib::shared_ptr<NdnRegexBackrefManager> secondaryBackrefManager_;
72  bool isSecondaryUsed_;
73 };
74 
75 }
76 
77 #endif // NDN_CPP_HAVE_REGEX_LIB
78 
79 #endif