regex-backref-matcher.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
24 #ifndef NDN_UTIL_REGEX_REGEX_BACKREF_MATCHER_HPP
25 #define NDN_UTIL_REGEX_REGEX_BACKREF_MATCHER_HPP
26 
27 #include "../../common.hpp"
28 
29 #include "regex-matcher.hpp"
30 
31 namespace ndn {
32 
34 {
35 public:
36  RegexBackrefMatcher(const std::string& expr, shared_ptr<RegexBackrefManager> backrefManager);
37 
38  virtual
40  {
41  }
42 
43  void
45  {
46  compile();
47  }
48 
49 protected:
50  virtual void
51  compile();
52 };
53 
54 } // namespace ndn
55 
57 
58 namespace ndn {
59 
60 inline
62  shared_ptr<RegexBackrefManager> backrefManager)
63  : RegexMatcher(expr, EXPR_BACKREF, backrefManager)
64 {
65  // compile();
66 }
67 
68 inline void
70 {
71  if (m_expr.size() < 2)
72  BOOST_THROW_EXCEPTION(RegexMatcher::Error("Unrecognized format: " + m_expr));
73 
74  size_t lastIndex = m_expr.size() - 1;
75  if ('(' == m_expr[0] && ')' == m_expr[lastIndex]) {
76  // m_backRefManager->pushRef(this);
77 
78  shared_ptr<RegexMatcher> matcher(new RegexPatternListMatcher(m_expr.substr(1, lastIndex - 1),
80  m_matchers.push_back(matcher);
81  }
82  else
83  BOOST_THROW_EXCEPTION(RegexMatcher::Error("Unrecognized format: " + m_expr));
84 }
85 
86 
87 } // namespace ndn
88 
89 #endif // NDN_UTIL_REGEX_REGEX_BACKREF_MATCHER_HPP
Copyright (c) 2013-2017 Regents of the University of California.
Definition: common.hpp:66
RegexBackrefMatcher(const std::string &expr, shared_ptr< RegexBackrefManager > backrefManager)
shared_ptr< RegexBackrefManager > m_backrefManager
std::vector< shared_ptr< RegexMatcher > > m_matchers
const std::string m_expr
virtual void compile()
Compile the regular expression to generate the more matchers when necessary.