Yingdi Yu | 5e97420 | 2014-01-29 16:59:06 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2013 Regents of the University of California. |
| 4 | * @author: Yingdi Yu <yingdi@cs.ucla.edu> |
| 5 | * See COPYING for copyright and distribution information. |
| 6 | */ |
| 7 | |
Alexander Afanasyev | 36b84cf | 2014-02-17 19:34:18 -0800 | [diff] [blame] | 8 | #ifndef NDN_UTIL_REGEX_REGEX_BACKREF_MATCHER_HPP |
| 9 | #define NDN_UTIL_REGEX_REGEX_BACKREF_MATCHER_HPP |
| 10 | |
| 11 | #include "../../common.hpp" |
Yingdi Yu | 5e97420 | 2014-01-29 16:59:06 -0800 | [diff] [blame] | 12 | |
| 13 | #include "regex-matcher.hpp" |
| 14 | |
Alexander Afanasyev | 36b84cf | 2014-02-17 19:34:18 -0800 | [diff] [blame] | 15 | namespace ndn { |
Yingdi Yu | 5e97420 | 2014-01-29 16:59:06 -0800 | [diff] [blame] | 16 | |
| 17 | class RegexBackrefMatcher : public RegexMatcher |
| 18 | { |
| 19 | public: |
Alexander Afanasyev | 36b84cf | 2014-02-17 19:34:18 -0800 | [diff] [blame] | 20 | RegexBackrefMatcher(const std::string& expr, shared_ptr<RegexBackrefManager> backRefManager); |
Yingdi Yu | 5e97420 | 2014-01-29 16:59:06 -0800 | [diff] [blame] | 21 | |
| 22 | virtual ~RegexBackrefMatcher(){} |
| 23 | |
| 24 | void |
| 25 | lateCompile() |
| 26 | { |
| 27 | compile(); |
| 28 | } |
| 29 | |
| 30 | protected: |
| 31 | virtual void |
| 32 | compile(); |
Yingdi Yu | 5e97420 | 2014-01-29 16:59:06 -0800 | [diff] [blame] | 33 | }; |
| 34 | |
Alexander Afanasyev | 36b84cf | 2014-02-17 19:34:18 -0800 | [diff] [blame] | 35 | } // namespace ndn |
Yingdi Yu | 5e97420 | 2014-01-29 16:59:06 -0800 | [diff] [blame] | 36 | |
Alexander Afanasyev | 36b84cf | 2014-02-17 19:34:18 -0800 | [diff] [blame] | 37 | #include "regex-pattern-list-matcher.hpp" |
| 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 |
| 48 | RegexBackrefMatcher::compile() |
| 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 |
Yingdi Yu | 5e97420 | 2014-01-29 16:59:06 -0800 | [diff] [blame] | 66 | |
| 67 | |