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(); |
| 33 | |
| 34 | private: |
| 35 | int m_refNum; |
| 36 | }; |
| 37 | |
Alexander Afanasyev | 36b84cf | 2014-02-17 19:34:18 -0800 | [diff] [blame] | 38 | } // namespace ndn |
Yingdi Yu | 5e97420 | 2014-01-29 16:59:06 -0800 | [diff] [blame] | 39 | |
Alexander Afanasyev | 36b84cf | 2014-02-17 19:34:18 -0800 | [diff] [blame] | 40 | #include "regex-pattern-list-matcher.hpp" |
| 41 | |
| 42 | namespace ndn { |
| 43 | |
| 44 | inline RegexBackrefMatcher::RegexBackrefMatcher(const std::string& expr, shared_ptr<RegexBackrefManager> backRefManager) |
| 45 | : RegexMatcher (expr, EXPR_BACKREF, backRefManager) |
| 46 | { |
| 47 | // compile(); |
| 48 | } |
| 49 | |
| 50 | inline void |
| 51 | RegexBackrefMatcher::compile() |
| 52 | { |
| 53 | int lastIndex = m_expr.size() - 1; |
| 54 | if('(' == m_expr[0] && ')' == m_expr[lastIndex]){ |
| 55 | // m_backRefManager->pushRef(this); |
| 56 | |
| 57 | shared_ptr<RegexMatcher> matcher(new RegexPatternListMatcher(m_expr.substr(1, lastIndex - 1), m_backrefManager)); |
| 58 | m_matcherList.push_back(matcher); |
| 59 | } |
| 60 | else |
| 61 | throw RegexMatcher::Error(std::string("Error: RegexBackrefMatcher.Compile(): ") |
| 62 | + " Unrecognoized format " + m_expr); |
| 63 | } |
| 64 | |
| 65 | |
| 66 | } // namespace ndn |
| 67 | |
| 68 | #endif // NDN_UTIL_REGEX_REGEX_BACKREF_MATCHER_HPP |
Yingdi Yu | 5e97420 | 2014-01-29 16:59:06 -0800 | [diff] [blame] | 69 | |
| 70 | |