All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
regex-backref-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_BACKREF_MATCHER_HPP
9 #define NDN_UTIL_REGEX_REGEX_BACKREF_MATCHER_HPP
10 
11 #include "../../common.hpp"
12 
13 #include "regex-matcher.hpp"
14 
15 namespace ndn {
16 
18 {
19 public:
20  RegexBackrefMatcher(const std::string& expr, shared_ptr<RegexBackrefManager> backRefManager);
21 
23 
24  void
26  {
27  compile();
28  }
29 
30 protected:
31  virtual void
32  compile();
33 };
34 
35 } // namespace ndn
36 
38 
39 namespace ndn {
40 
41 inline RegexBackrefMatcher::RegexBackrefMatcher(const std::string& expr, shared_ptr<RegexBackrefManager> backRefManager)
42  : RegexMatcher (expr, EXPR_BACKREF, backRefManager)
43 {
44  // compile();
45 }
46 
47 inline void
49 {
50  int lastIndex = m_expr.size() - 1;
51  if ('(' == m_expr[0] && ')' == m_expr[lastIndex]){
52  // m_backRefManager->pushRef(this);
53 
54  shared_ptr<RegexMatcher> matcher(new RegexPatternListMatcher(m_expr.substr(1, lastIndex - 1), m_backrefManager));
55  m_matcherList.push_back(matcher);
56  }
57  else
58  throw RegexMatcher::Error(std::string("Error: RegexBackrefMatcher.Compile(): ")
59  + " Unrecognoized format " + m_expr);
60 }
61 
62 
63 } // namespace ndn
64 
65 #endif // NDN_UTIL_REGEX_REGEX_BACKREF_MATCHER_HPP
shared_ptr< RegexBackrefManager > m_backrefManager
RegexBackrefMatcher(const std::string &expr, shared_ptr< RegexBackrefManager > backRefManager)
const std::string m_expr
std::vector< shared_ptr< RegexMatcher > > m_matcherList
virtual void compile()
Compile the regular expression to generate the more matchers when necessary.